//
// GJBaseGameLayer::createBackground from 0x1001ddbf8 to 0x1001ddda0 (424 bytes)
//
// 6 xrefs:
// > PlayLayer::setupHasCompleted @ 0x100116a54
// > LevelSettingsLayer::selectArtClosed @ 0x10017c1d8
// > GJBaseGameLayer::swapBackground @ 0x1001dde1c
// > GJBaseGameLayer::asyncBGLoaded @ 0x1001dde54
// > GJBaseGameLayer::syncBGTextures @ 0x100202184
// > LevelEditorLayer::init @ 0x1003575ac
//
// 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 __fastcall GJBaseGameLayer::createBackground(GJBaseGameLayer *a1, int a2)
{
__int64 v2; // x20
cocos2d::CCSprite *m_background; // x0
cocos2d::CCSprite *v5; // x0
GLuint v6; // w21
GameManager *v7; // x0
const char *BGTexture; // x0
cocos2d::CCSprite *v9; // x0
cocos2d::CCTexture2D *v10; // x0
__n128 v11; // q0
cocos2d::CCSprite *v12; // x20
__n128 v13; // q1
cocos2d::CCSprite *v14; // x20
AppDelegate *v15; // x0
float v16; // s0
cocos2d::CCSprite *v17; // x0
double v18; // d0
float v19; // s8
__int64 v20; // [xsp+0h] [xbp-50h] BYREF
float v21; // [xsp+8h] [xbp-48h]
cocos2d::ccTexParams v22; // [xsp+10h] [xbp-40h] BYREF
LODWORD(v2) = a2;
m_background = a1->m_background;
if ( m_background )
{
if ( ((unsigned int (__fastcall *)(cocos2d::CCSprite *))m_background->getTag)(m_background) == a2 )
return;
v5 = a1->m_background;
if ( v5 )
{
((void (__fastcall *)(cocos2d::CCSprite *))v5->removeFromParent)(v5);
a1->m_background = nullptr;
}
}
if ( (int)v2 >= 59 )
v2 = 59;
else
v2 = (unsigned int)v2;
if ( (unsigned int)(v2 - 16) > 0x2B )
v6 = 33648;
else
v6 = dword_10063A320[(unsigned int)(v2 - 16)];
v7 = GameManager::sharedState();
BGTexture = GameManager::getBGTexture(v7, v2);
v9 = cocos2d::CCSprite::create(BGTexture);
a1->m_background = v9;
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v9->setTag)(v9, v2);
*(int32x2_t *)&v22.minFilter = vdup_n_s32(0x2601u);
v22.wrapS = 10497;
v22.wrapT = v6;
v10 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getTexture)(a1->m_background);
cocos2d::CCTexture2D::setTexParameters(v10, &v22);
v11 = ((__n128 (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, __int64))a1->m_objectParent->addChild_0)(
a1->m_objectParent,
a1->m_background,
4294967236LL);
v12 = a1->m_background;
v11.n128_u32[0] = 0;
v13.n128_u32[0] = 0;
sub_100022980(v11, v13, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v12->setAnchorPoint)(v12, &v20);
v14 = a1->m_background;
v15 = AppDelegate::get();
v16 = AppDelegate::bgScale(v15);
((void (__fastcall *)(cocos2d::CCSprite *, float))v14->setScale)(v14, v16);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_background->setBlendFunc)(a1->m_background, 1);
v17 = a1->m_background;
BYTE2(v20) = -1;
LOWORD(v20) = 32040;
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v17->setColor)(v17, &v20);
v18 = sub_100022B98(&v20, (__int64)&a1->m_background->m_obRect);
v19 = v21;
a1->m_gameState.m_unkFloat10 = v19
* ((float (__fastcall *)(cocos2d::CCSprite *, double))a1->m_background->getScale)(
a1->m_background,
v18);
}