//
// GJMGLayer::init from 0x5468bc to 0x546ba6 (746 bytes)
//
// 1 xrefs:
// > GJMGLayer::create @ 0x546c5c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:52:23 +0000
//
int __fastcall GJMGLayer::init(GJMGLayer *this, GJMGLayer *a2)
{
int v4; // r8
cocos2d::CCDirector *v5; // r0
int v6; // r1
GameManager *v7; // r0
const char **v8; // r0
const char *MGTexture; // r0
const char *v10; // r9
size_t v11; // r0
size_t v12; // r5
std::logic_error *exception; // r4
cocos2d::CCSpriteBatchNode *v14; // r3
unsigned int v15; // r10
cocos2d::CCSpriteBatchNode *v16; // r0
char v17; // r3
int v18; // r0
int v19; // r3
int v20; // r0
float v21; // s14
float v22; // s15
cocos2d::CCSprite *v23; // r0
const cocos2d::CCRect *v24; // r2
int v25; // r0
int v26; // r9
void (__fastcall *v27)(int, _BYTE *); // r10
cocos2d::CCString *v28; // r0
cocos2d::CCSpriteBatchNode *CString; // r0
unsigned int v30; // r2
int v31; // r0
int v32; // r3
int v33; // r0
float v34; // s16
int v35; // r0
float v36; // s16
cocos2d::CCSprite *v37; // r0
const cocos2d::CCRect *v38; // r2
int v39; // r0
int v40; // r7
void (__fastcall *v41)(int, _BYTE *); // r10
int v42; // r7
void (__fastcall *v43)(int, _BYTE *); // r9
unsigned int v45; // [sp+4h] [bp-3Ch]
int v46; // [sp+Ch] [bp-34h] BYREF
float v47[2]; // [sp+10h] [bp-30h] BYREF
float v48[2]; // [sp+18h] [bp-28h] BYREF
_BYTE v49[4]; // [sp+20h] [bp-20h] BYREF
float v50; // [sp+24h] [bp-1Ch]
_BYTE v51[4]; // [sp+28h] [bp-18h] BYREF
float v52; // [sp+2Ch] [bp-14h]
int v53; // [sp+30h] [bp-10h] BYREF
size_t v54; // [sp+34h] [bp-Ch]
cocos2d::CCSpriteBatchNode *v55; // [sp+38h] [bp-8h]
v4 = cocos2d::CCLayer::init(this);
if ( !v4 )
return v4;
v5 = (cocos2d::CCDirector *)(*(int (__fastcall **)(GJMGLayer *, void *))(*(_DWORD *)this + 160))(this, &unk_D2C098);
cocos2d::CCDirector::sharedDirector(v5);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v47);
v7 = (GameManager *)GJMGLayer::defaultYOffsetForBG2(a2, v6);
*((_DWORD *)this + 91) = v7;
v8 = (const char **)GameManager::sharedState(v7);
MGTexture = (const char *)GameManager::getMGTexture(v8, (const char *)a2);
v53 = 0;
v54 = 0;
v55 = nullptr;
v10 = MGTexture;
v11 = strlen(MGTexture);
v12 = v11;
if ( v11 > 0xFFFFFFEF )
{
exception = (std::logic_error *)_cxa_allocate_exception(8u);
std::logic_error::logic_error(exception, "basic_string");
*(_DWORD *)exception = &off_D1546C;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::length_error,
(void (*)(void *))std::length_error::~length_error);
}
if ( v11 > 0xA )
{
v15 = (v11 + 16) & 0xFFFFFFF0;
v16 = (cocos2d::CCSpriteBatchNode *)operator new(v15);
v54 = v12;
v53 = v15 | 1;
v14 = v16;
v55 = v16;
LABEL_8:
v11 = (size_t)memcpy(v14, v10, v12);
v14 = (cocos2d::CCSpriteBatchNode *)v11;
goto LABEL_9;
}
LOBYTE(v53) = 2 * v11;
v14 = (cocos2d::CCSpriteBatchNode *)((char *)&v53 + 1);
if ( v11 )
goto LABEL_8;
LABEL_9:
*((_BYTE *)v14 + v12) = 0;
*(_WORD *)((char *)&v46 + 1) = -154;
v17 = v53;
*((_BYTE *)this + 332) = 0;
if ( (v17 & 1) == 0 )
v11 = (size_t)&v53 + 1;
LOBYTE(v46) = 0;
if ( (v17 & 1) != 0 )
v11 = (size_t)v55;
v18 = cocos2d::CCSpriteBatchNode::create((cocos2d::CCSpriteBatchNode *)v11, (const char *)&dword_1C + 1, 0);
v19 = *(_DWORD *)this;
*((_DWORD *)this + 88) = v18;
(*(void (__fastcall **)(GJMGLayer *, int, int))(v19 + 232))(this, v18, 2);
v20 = (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 88) + 448))(*((_DWORD *)this + 88));
(*(void (__fastcall **)(float *, int))(*(_DWORD *)v20 + 72))(v48, v20);
v21 = v47[0];
v22 = v48[0];
*((float *)this + 81) = v48[0];
v45 = (int)(float)(ceilf(v21 / v22) + 1.0);
v23 = (cocos2d::CCSprite *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 88) + 448))(*((_DWORD *)this + 88));
v25 = cocos2d::CCSprite::createWithTexture(v23, (cocos2d::CCTexture2D *)&unk_D2C0A0, v24);
*((_DWORD *)this + 79) = v25;
*(_BYTE *)(v25 + 471) = 1;
v26 = *((_DWORD *)this + 79);
v27 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v26 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v51, 0.0, 0.0);
v27(v26, v51);
(*(void (__fastcall **)(_DWORD, int *))(**((_DWORD **)this + 79) + 480))(*((_DWORD *)this + 79), &v46);
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 88) + 228))(
*((_DWORD *)this + 88),
*((_DWORD *)this + 79));
GJMGLayer::loadGroundSprites(this, v45, 1);
GJMGLayer::updateGroundColor((unsigned int)this, v46, 1);
v28 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"fg_%02d_2_001.png",
(const char *)a2);
CString = (cocos2d::CCSpriteBatchNode *)cocos2d::CCString::getCString(v28);
v31 = cocos2d::CCSpriteBatchNode::create(CString, (const char *)&dword_1C + 1, v30);
v32 = *(_DWORD *)this;
*((_DWORD *)this + 89) = v31;
(*(void (__fastcall **)(GJMGLayer *, int, int))(v32 + 232))(this, v31, 3);
v33 = (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 88) + 448))(*((_DWORD *)this + 88));
(*(void (__fastcall **)(_BYTE *, int))(*(_DWORD *)v33 + 72))(v49, v33);
v34 = v50;
v35 = (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 89) + 448))(*((_DWORD *)this + 89));
(*(void (__fastcall **)(_BYTE *, int))(*(_DWORD *)v35 + 72))(v51, v35);
v36 = v34 - v52;
v37 = (cocos2d::CCSprite *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 89) + 448))(*((_DWORD *)this + 89));
v39 = cocos2d::CCSprite::createWithTexture(v37, (cocos2d::CCTexture2D *)&unk_D2C0A0, v38);
*((_DWORD *)this + 80) = v39;
*(_BYTE *)(v39 + 471) = 1;
v40 = *((_DWORD *)this + 80);
v41 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v40 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v51, 0.0, 0.0);
v41(v40, v51);
(*(void (__fastcall **)(_DWORD, int *))(**((_DWORD **)this + 80) + 480))(*((_DWORD *)this + 80), &v46);
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 89) + 228))(
*((_DWORD *)this + 89),
*((_DWORD *)this + 80));
v42 = *((_DWORD *)this + 89);
v43 = *(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v42 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v51, 0.0, v36);
v43(v42, v51);
GJMGLayer::loadGroundSprites(this, v45, 0);
GJMGLayer::updateGroundColor((unsigned int)this, v46, 0);
if ( (v53 & 1) != 0 )
operator delete(v55);
return v4;
}