//
// PlayLayer::prepareCreateObjectsFromSetup from 0x406878 to 0x406afa (642 bytes)
//
// 1 xrefs:
// > PlayLayer::init @ 0x40b348
//
// 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:47:28 +0000
//
int __fastcall PlayLayer::prepareCreateObjectsFromSetup(_DWORD *a1, unsigned __int8 *a2)
{
_BOOL4 v4; // r5
cocos2d::CCArray *Font; // r0
int v6; // r7
_DWORD *v7; // r8
int v8; // r3
unsigned __int8 *v9; // r2
unsigned __int8 *v10; // r3
unsigned __int8 *v11; // r1
unsigned __int8 *v12; // r5
int v13; // lr
int v14; // r5
int v15; // r7
unsigned int v16; // r11
int v17; // r3
int *v18; // r0
int v19; // r3
unsigned int v20; // r3
unsigned __int8 *v21; // r2
unsigned __int8 *v22; // r1
unsigned __int8 *v23; // r3
unsigned __int8 *v24; // r5
int v25; // r0
cocos2d::CCObject *v26; // r0
int v27; // r0
_BYTE *v28; // r3
char v29; // r5
char v30; // r1
char v31; // r2
GameManager *updated; // r0
GameManager *v33; // r0
cocos2d::CCObject *v34; // r0
int result; // r0
unsigned int v36; // r2
unsigned int v37; // r1
int v38; // [sp+14h] [bp-4h]
int v39[3]; // [sp+18h] [bp+0h] BYREF
int v40; // [sp+24h] [bp+Ch] BYREF
int v41; // [sp+28h] [bp+10h]
int v42; // [sp+2Ch] [bp+14h]
_DWORD v43[2]; // [sp+30h] [bp+18h] BYREF
int *v44; // [sp+38h] [bp+20h]
v4 = 0;
memset(v39, 0, sizeof(v39));
std::string::__init(v39, " ", 1u);
if ( !sub_3FF3AC(a2, (unsigned __int8 *)v39) )
{
v40 = 0;
v41 = 0;
v42 = 0;
std::string::__init(&v40, &unk_B6B226, 0);
v4 = !sub_3FF3AC(a2, (unsigned __int8 *)&v40);
std::string::~string((int)&v40);
}
Font = (cocos2d::CCArray *)std::string::~string((int)v39);
if ( !v4 )
goto LABEL_42;
v6 = *a2;
v7 = a1 + 2928;
if ( (v6 & 1) != 0 )
{
v8 = *((_DWORD *)a2 + 1);
v9 = *((unsigned __int8 **)a2 + 2);
if ( !v8 )
{
v14 = -1;
LABEL_17:
v15 = *((_DWORD *)a2 + 1);
goto LABEL_20;
}
}
else
{
v8 = v6 >> 1;
if ( !(v6 >> 1) )
{
v14 = -1;
goto LABEL_19;
}
v9 = a2 + 1;
}
v10 = &v9[v8];
v11 = v9;
while ( 1 )
{
v12 = v11;
if ( v11 == v10 )
break;
v13 = *v11++;
if ( v13 == 59 )
{
v14 = v12 - v9;
goto LABEL_14;
}
}
v14 = -1;
LABEL_14:
if ( (v6 & 1) != 0 )
goto LABEL_17;
LABEL_19:
v15 = v6 >> 1;
LABEL_20:
v16 = 0;
while ( 1 )
{
std::string::basic_string(&v40, a2, v16, v14 - v16);
if ( (v40 & 1) != 0 )
v17 = v41;
else
v17 = (int)(unsigned __int8)v40 >> 1;
if ( v17 || v16 != v15 )
{
v18 = (int *)a1[2929];
if ( v18 == (int *)a1[2930] )
{
v36 = -1431655765 * (((int)v18 - *v7) >> 2);
v37 = v36 + 1;
if ( v36 + 1 > 0x15555555 )
sub_3878B8();
if ( v36 > 0xAAAAAA9 )
{
v37 = 357913941;
}
else if ( v37 < 1431655766 * (((int)v18 - *v7) >> 2) )
{
v37 = 1431655766 * (((int)v18 - *v7) >> 2);
}
std::__split_buffer::__split_buffer(v43, v37, v36, (int)(a1 + 2930));
if ( v44 )
std::string::basic_string(v44, (int)&v40);
v44 += 3;
std::vector::__swap_out_circular_buffer(a1 + 2928, v43);
std::__split_buffer::~__split_buffer((int)v43);
}
else
{
if ( v18 )
std::string::basic_string(v18, (int)&v40);
a1[2929] += 12;
}
}
if ( v14 == -1 )
break;
v19 = *a2;
v16 = v14 + 1;
if ( (v19 & 1) != 0 )
{
v20 = *((_DWORD *)a2 + 1);
v21 = *((unsigned __int8 **)a2 + 2);
}
else
{
v20 = v19 >> 1;
v21 = a2 + 1;
}
if ( v16 < v20 )
{
v22 = &v21[v16];
v23 = &v21[v20];
while ( 1 )
{
v24 = v22;
if ( v22 == v23 )
break;
v25 = *v22++;
if ( v25 == 59 )
{
v14 = v24 - v21;
goto LABEL_40;
}
}
}
v14 = -1;
LABEL_40:
std::string::~string((int)&v40);
}
std::string::~string((int)&v40);
v26 = (cocos2d::CCObject *)LevelSettingsObject::objectFromString(*v7);
a1[521] = v26;
cocos2d::CCObject::retain(v26);
*(_DWORD *)(a1[521] + 320) = a1[352];
GJBaseGameLayer::loadLevelSettings((GJBaseGameLayer *)a1);
v27 = *(_DWORD *)(a1[521] + 264);
v28 = (_BYTE *)a1[519];
v29 = v28[2106];
BYTE1(v38) = v28[2107];
BYTE2(v38) = v28[2108];
v30 = v28[2110];
v31 = v28[2111];
LOBYTE(v28) = v28[2109];
LOBYTE(v38) = v29;
BYTE1(v43[0]) = v30;
LOBYTE(v43[0]) = (_BYTE)v28;
BYTE2(v43[0]) = v31;
updated = (GameManager *)GJEffectManager::updateColors(v27, v38, v43[0]);
v33 = (GameManager *)GameManager::sharedState(updated);
Font = (cocos2d::CCArray *)GameManager::loadFont(v33, *(_DWORD *)(a1[521] + 300));
LABEL_42:
v34 = (cocos2d::CCObject *)cocos2d::CCArray::create(Font);
a1[2931] = v34;
result = cocos2d::CCObject::retain(v34);
a1[2933] = 1;
if ( (*a2 & 1) != 0 )
{
**((_BYTE **)a2 + 2) = 0;
*((_DWORD *)a2 + 1) = 0;
}
else
{
a2[1] = 0;
*a2 = 0;
}
return result;
}