//
// GJBaseGameLayer::createBackground from 0x856fc8 to 0x85720c (580 bytes)
//
// 6 xrefs:
// > PlayLayer::setupHasCompleted @ 0x5dc410
// > LevelEditorLayer::init @ 0x67ca08
// > GJBaseGameLayer::asyncBGLoaded @ 0x858044
// > GJBaseGameLayer::syncBGTextures @ 0x866a10
// > LevelSettingsLayer::selectArtClosed @ 0xa345d0
// > ??> @ 0xb83f8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void GJBaseGameLayer::createBackground(GJBaseGameLayer *a1, int a2)
{
cocos2d::CCSprite *m_background; // x0
int v4; // w0
unsigned int v5; // w21
GameManager *v6; // x0
cocos2d::CCSprite *v7; // x0
const char *v8; // x1
cocos2d::CCSprite *v9; // x0
GLuint v10; // w0
cocos2d::CCSprite *v11; // x1
cocos2d::CCTexture2D *v12; // x0
cocos2d::CCSprite *v13; // x22
void (__fastcall *setAnchorPoint)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCSprite *v15; // x22
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // x23
AppDelegate *v17; // x0
float v18; // s0
cocos2d::CCSprite *v19; // x0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
float width; // s8
GameManager *v22; // x0
cocos2d::CCSprite *BGTexture; // x0
const char *v24; // x1
cocos2d::CCSprite *v25; // x0
int v26; // [xsp+48h] [xbp+48h]
cocos2d::ccTexParams v27; // [xsp+58h] [xbp+58h] BYREF
cocos2d::CCRect v28; // [xsp+68h] [xbp+68h] BYREF
m_background = a1->m_background;
if ( m_background )
{
v26 = a2;
v4 = m_background->getTag(m_background);
a2 = v26;
if ( v4 == v26 )
return;
if ( a1->m_background )
{
GJBaseGameLayer::removeBackground(a1);
a2 = v26;
}
}
if ( a2 > 59 )
v5 = 59;
else
v5 = a2;
switch ( v5 )
{
case 0x10u:
case 0x23u:
case 0x25u:
case 0x28u:
case 0x29u:
case 0x2Au:
case 0x2Bu:
case 0x2Cu:
case 0x2Du:
case 0x2Eu:
case 0x2Fu:
case 0x30u:
case 0x31u:
case 0x32u:
case 0x33u:
case 0x35u:
case 0x36u:
case 0x37u:
case 0x38u:
case 0x39u:
case 0x3Au:
case 0x3Bu:
v22 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v22, v5);
v25 = (cocos2d::CCSprite *)cocos2d::CCSprite::create(BGTexture, v24);
a1->m_background = v25;
v25->setTag(v25, v5);
v10 = 10497;
v27.minFilter = 9729;
v27.wrapS = 10497;
v27.magFilter = 9729;
break;
default:
v6 = GameManager::sharedState();
v7 = (cocos2d::CCSprite *)GameManager::getBGTexture(v6, v5);
v9 = (cocos2d::CCSprite *)cocos2d::CCSprite::create(v7, v8);
a1->m_background = v9;
v9->setTag(v9, v5);
v27.minFilter = 9729;
v27.magFilter = 9729;
v10 = 33648;
v27.wrapS = 10497;
break;
}
v11 = a1->m_background;
v27.wrapT = v10;
v12 = v11->getTexture(v11);
cocos2d::CCTexture2D::setTexParameters(v12, &v27);
a1->m_objectParent->addChild_0(a1->m_objectParent, a1->m_background, -60);
v13 = a1->m_background;
setAnchorPoint = v13->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v28.origin, 0.0, 0.0);
setAnchorPoint(v13, &v28.origin);
v15 = a1->m_background;
setScale = v15->setScale;
v17 = AppDelegate::get();
v18 = AppDelegate::bgScale(v17);
setScale(v15, v18);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_background->setBlendFunc)(a1->m_background, 1);
v19 = a1->m_background;
setColor = v19->setColor;
LOWORD(v28.origin.x) = 32040;
BYTE2(v28.origin.x) = -1;
setColor(v19, (const cocos2d::ccColor3B *)&v28);
cocos2d::CCRect::CCRect(&v28, &a1->m_background->m_obRect);
width = v28.size.width;
a1->m_gameState.m_unkFloat10 = width * a1->m_background->getScale(a1->m_background);
}