//
// GJBaseGameLayer::createBackground from 0x14020b820 to 0x14020bad4 (692 bytes)
//
// 7 xrefs:
// > GameManager::finishedLoadingBGAsync @ 0x140182990
// > GJBaseGameLayer::syncBGTextures @ 0x14023afc3
// > LevelEditorLayer::init @ 0x1402d2b9f
// > LevelSettingsLayer::selectArtClosed @ 0x140321f3d
// > PlayLayer::setupHasCompleted @ 0x1403a6a59
// > ArtTriggerGameObject::triggerObject @ 0x1404c2721
// > ??> @ 0x1406ccd08
//
// 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
//
// Hidden C++ exception states: #wind=1
void GJBaseGameLayer::createBackground(GJBaseGameLayer *a1, int a2)
{
int v2; // edi
cocos2d::CCSprite *m_background; // rcx
cocos2d::CCSprite *v5; // rcx
int v6; // ebp
char v7; // r14
GameManager *v8; // rcx
int v9; // ebx
cocos2d::CCString *v10; // rax
const char *CString; // rax
cocos2d::CCSprite *v12; // rax
GLuint v13; // eax
cocos2d::CCTexture2D *v14; // rax
float v15; // xmm0_4
cocos2d::CCSprite_vtbl *v16; // rbx
const cocos2d::CCPoint *v17; // rax
__int64 v18; // rdx
__int64 v19; // rcx
__int64 v20; // rcx
cocos2d::CCDirector *v21; // rax
float v22; // xmm0_4
__int16 v23; // [rsp+20h] [rbp-58h] BYREF
char v24; // [rsp+22h] [rbp-56h]
__int64 v25; // [rsp+28h] [rbp-50h]
cocos2d::CCRect v26; // [rsp+30h] [rbp-48h] BYREF
struct cocos2d::_ccTexParams v27; // [rsp+40h] [rbp-38h] BYREF
v2 = a2;
m_background = a1->m_background;
if ( !m_background || m_background->getTag(m_background) != a2 )
{
v5 = a1->m_background;
if ( v5 )
{
v5->removeFromParent(v5);
a1->m_background = nullptr;
}
v6 = 59;
if ( v2 > 59 )
v2 = 59;
v7 = 1;
switch ( v2 )
{
case 16:
case 35:
case 37:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
v7 = 0;
break;
default:
break;
}
v8 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v25 = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v8 = (GameManager *)qword_1406C2ED8;
}
if ( v2 < 59 )
v6 = v2;
v9 = 1;
if ( v6 > 1 )
v9 = v6;
GameManager::loadBackground(v8, v9);
v10 = cocos2d::CCString::createWithFormat("game_bg_%02d_001.png", v9);
CString = cocos2d::CCString::getCString(v10);
v12 = cocos2d::CCSprite::create(CString);
a1->m_background = v12;
v12->setTag(v12, v2);
v27.minFilter = 9729;
v27.magFilter = 9729;
v13 = 10497;
v27.wrapS = 10497;
if ( v7 )
v13 = 33648;
v27.wrapT = v13;
v14 = a1->m_background->getTexture(&a1->m_background->cocos2d::CCTextureProtocol);
cocos2d::CCTexture2D::setTexParameters(v14, &v27);
v15 = ((float (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, __int64))a1->m_objectParent->addChild_0)(
a1->m_objectParent,
a1->m_background,
4294967236LL);
v16 = a1->m_background->__vftable;
cocos2d::CCPoint::CCPoint(v15, 0.0);
v16->setAnchorPoint(a1->m_background, v17);
cocos2d::CCApplication::sharedApplication(v19, v18);
v21 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v20);
cocos2d::CCDirector::getScreenScaleFactorMax(v21);
((void (__fastcall *)(cocos2d::CCSprite *))a1->m_background->setScale_0)(a1->m_background);
v25 = 1;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))a1->m_background->setBlendFunc)(
&a1->m_background->cocos2d::CCTextureProtocol,
1);
v23 = 32040;
v24 = -1;
a1->m_background->setColor(&a1->m_background->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v23);
cocos2d::CCRect::CCRect(&v26, &a1->m_background->m_obRect);
v22 = a1->m_background->getScale(a1->m_background);
a1->m_gameState.m_unkFloat10 = v22 * v26.size.width;
}
}