//
// GJBaseGameLayer::createBackground from 0x46d068 to 0x46d1dc (372 bytes)
//
// 5 xrefs:
// > PlayLayer::setupHasCompleted @ 0x31bc8e
// > LevelEditorLayer::init @ 0x376b3c
// > GJBaseGameLayer::asyncBGLoaded @ 0x46dbec
// > GJBaseGameLayer::syncBGTextures @ 0x476f1c
// > LevelSettingsLayer::selectArtClosed @ 0x56f992
//
// 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)
{
int v3; // r5
cocos2d::CCSprite *m_background; // r0
int v5; // r7
GameManager *v6; // r0
cocos2d::CCSprite *BGTexture; // r0
const char *v8; // r1
cocos2d::CCSprite *v9; // r0
cocos2d::CCSprite_vtbl *v10; // r3
cocos2d::CCSprite *v11; // r0
GLuint v12; // r3
cocos2d::CCTexture2D *v13; // r0
cocos2d::CCSprite *v14; // r7
void (__fastcall *setAnchorPoint)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCSprite *v16; // r7
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // r8
AppDelegate *v18; // r0
float v19; // r0
cocos2d::CCSprite *v20; // r0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
float width; // s16
cocos2d::ccTexParams v23; // [sp+Ch] [bp-24h] BYREF
cocos2d::CCRect v24; // [sp+1Ch] [bp-14h] BYREF
v3 = a2;
m_background = a1->m_background;
if ( m_background && m_background->getTag(m_background) == a2 )
return;
if ( a1->m_background )
GJBaseGameLayer::removeBackground(a1);
if ( v3 >= 59 )
v3 = 59;
if ( v3 > 51 )
{
if ( (unsigned int)(v3 - 53) <= 6 )
{
LABEL_15:
v5 = 0;
goto LABEL_16;
}
}
else if ( v3 >= 40 || v3 == 35 || v3 == 37 || v3 == 16 )
{
goto LABEL_15;
}
v5 = 1;
LABEL_16:
v6 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v6, v3);
v9 = (cocos2d::CCSprite *)cocos2d::CCSprite::create(BGTexture, v8);
v10 = v9->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_background = v9;
v10->setTag(v9, v3);
memset(&v23, 0, sizeof(v23));
v11 = a1->m_background;
v23.minFilter = 9729;
v23.magFilter = 9729;
v12 = 10497;
v23.wrapS = 10497;
if ( v5 )
v12 = 33648;
v23.wrapT = v12;
v13 = v11->getTexture(v11);
cocos2d::CCTexture2D::setTexParameters(v13, &v23);
a1->m_objectParent->addChild_0(a1->m_objectParent, a1->m_background, -60);
v14 = a1->m_background;
setAnchorPoint = v14->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v24.origin, 0.0, 0.0);
setAnchorPoint(v14, &v24.origin);
v16 = a1->m_background;
setScale = v16->setScale;
v18 = AppDelegate::get();
v19 = AppDelegate::bgScale(v18);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))setScale)(v16, LODWORD(v19));
((void (__fastcall *)(cocos2d::CCSprite *, int, _DWORD))a1->m_background->setBlendFunc)(a1->m_background, 1, 0);
v20 = a1->m_background;
setColor = v20->setColor;
LOWORD(v24.origin.x) = 32040;
BYTE2(v24.origin.x) = -1;
setColor(v20, (const cocos2d::ccColor3B *)&v24);
cocos2d::CCRect::CCRect(&v24, &a1->m_background->m_obRect);
width = v24.size.width;
a1->m_gameState.m_unkFloat10 = width * a1->m_background->getScale(a1->m_background);
}