//
// PlayLayer::processCreateObjectsFromSetup from 0x1403ad0f0 to 0x1403ad8c1 (2001 bytes)
//
// 4 xrefs:
// > LevelInfoLayer::loadLevelStep @ 0x1402fd28e
// > PlayLayer::init @ 0x1403a6674
// > ??> @ 0x1406d6c80
// > ??> @ 0x1406d6c8c
//
// 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=3
void PlayLayer::processCreateObjectsFromSetup(PlayLayer *a1)
{
char *v2; // rdi
GJGameLevel *m_level; // rax
GJLevelType m_levelType; // r15d
unsigned __int64 v5; // rbx
float v6; // xmm6_4
float v7; // xmm8_4
float v8; // xmm7_4
float v9; // xmm0_4
float v10; // xmm1_4
float v11; // xmm0_4
float v12; // xmm0_4
int v13; // r8d
int v14; // r12d
__int64 v15; // rdx
const void **v16; // rsi
std::_Vector_val>::pointer Myfirst; // rax
__int64 v18; // rcx
const void **v19; // r14
char *v20; // rbx
_BYTE *v21; // rax
__int64 v22; // rcx
char *v23; // r15
bool v24; // r12
char *v25; // rax
size_t v26; // r8
size_t v27; // rbx
const void **v28; // rax
const char *v29; // rcx
char *v30; // rcx
size_t v31; // r8
size_t v32; // rbx
const void **v33; // rax
const void **v34; // r14
char *v35; // r15
GameObject *v36; // rax
__int64 v37; // rbx
int m_objectID; // eax
__int64 v39; // rax
int v40; // eax
int v41; // r15d
int v42; // edi
int v43; // r14d
struct cocos2d::CCInteger *v44; // rax
int m_nextColorKey; // ecx
int v46; // eax
int v47; // r8d
std::_Vector_val>::pointer v48; // r9
__int64 v49; // rcx
float v50; // xmm0_4
__int64 v51; // rax
float v52; // xmm1_4
std::_Vector_val>::pointer v53; // rcx
std::_Vector_val>::pointer m_capacity; // rbx
std::_Vector_val>::pointer Mylast; // rdi
std::_Vector_val>::pointer v56; // rax
unsigned __int8 v57; // [rsp+28h] [rbp-E0h]
bool m_lowDetailModeToggled; // [rsp+29h] [rbp-DFh]
int v59; // [rsp+2Ch] [rbp-DCh]
GJLevelType v60; // [rsp+30h] [rbp-D8h]
int m_objectsCreated; // [rsp+34h] [rbp-D4h]
char *v62; // [rsp+38h] [rbp-D0h]
int Block; // [rsp+40h] [rbp-C8h]
int Block_4; // [rsp+44h] [rbp-C4h]
std::vector Block_8; // [rsp+48h] [rbp-C0h] BYREF
__int64 v66; // [rsp+60h] [rbp-A8h]
std::vector v67; // [rsp+68h] [rbp-A0h] BYREF
unsigned __int64 v68; // [rsp+80h] [rbp-88h]
__int128 v69; // [rsp+88h] [rbp-80h] BYREF
__int64 v70; // [rsp+98h] [rbp-70h]
__int64 v71; // [rsp+A0h] [rbp-68h]
char *String[2]; // [rsp+A8h] [rbp-60h] BYREF
__int64 v73; // [rsp+B8h] [rbp-50h]
unsigned __int64 v74; // [rsp+C0h] [rbp-48h]
v2 = nullptr;
v59 = 0;
memset(&v67, 0, sizeof(v67));
sub_1402F2EC0((__int64 *)&v67);
memset(&Block_8, 0, sizeof(Block_8));
sub_1402F2990((__int64)&Block_8);
Block = 0;
m_level = a1->m_level;
m_levelType = m_level->m_levelType;
v60 = m_levelType;
m_lowDetailModeToggled = m_level->m_lowDetailModeToggled;
v5 = a1->m_objectStrings._Mypair._Myval2._Mylast - a1->m_objectStrings._Mypair._Myval2._Myfirst;
v68 = v5;
v6 = (float)(int)(v5 / 0x3E8);
v7 = v6 - 0.5;
v8 = v6 + 0.5;
if ( v6 < 0.0 )
v9 = ceilf(v7);
else
v9 = floorf(v8);
v10 = 100.0;
if ( (float)(v9 + 10.0) < 100.0 )
{
if ( v6 < 0.0 )
v11 = ceilf(v7);
else
v11 = floorf(v8);
v10 = v11 + 10.0;
}
if ( (v5 & 0x8000000000000000uLL) != 0LL )
v12 = (float)(int)(v5 & 1 | (v5 >> 1)) + (float)(int)(v5 & 1 | (v5 >> 1));
else
v12 = (float)(int)v5;
v13 = (int)ceilf(v12 / v10);
Block_4 = v13;
m_objectsCreated = a1->m_objectsCreated;
v14 = m_objectsCreated;
if ( m_objectsCreated < v5 )
{
v15 = 32LL * m_objectsCreated;
v66 = v15;
while ( v14 < v13 + a1->m_objectsCreated )
{
v16 = (const void **)((char *)&a1->m_objectStrings._Mypair._Myval2._Myfirst->m_data.m_bigStorage + v15);
Myfirst = Block_8._Mypair._Myval2._Myfirst;
v18 = 75;
do
{
*Myfirst = nullptr;
Myfirst[1] = nullptr;
Myfirst[2] = nullptr;
Myfirst += 8;
*(Myfirst - 5) = nullptr;
*(Myfirst - 4) = nullptr;
*(Myfirst - 3) = nullptr;
*(Myfirst - 2) = nullptr;
*(Myfirst - 1) = nullptr;
--v18;
}
while ( v18 );
*Myfirst = nullptr;
v19 = v16;
if ( (unsigned __int64)v16[3] > 0xF )
v19 = (const void **)*v16;
v20 = (char *)v16[2];
if ( v20 )
{
v21 = memchr(v19, 44, (size_t)v16[2]);
if ( v21 )
{
v23 = (char *)(v21 - (_BYTE *)v19);
v24 = 1;
LOBYTE(v22) = 0;
v57 = 0;
if ( v21 - (_BYTE *)v19 != -1 )
{
v25 = (char *)(int)v20;
v62 = (char *)(int)v20;
while ( 2 )
{
if ( v2 == v25 )
goto LABEL_46;
if ( v24 )
{
*(_OWORD *)String = 0;
v73 = 0;
v74 = 0;
if ( v20 < v2 )
sub_14003BCC0(v22);
v26 = v23 - v2;
v27 = v20 - v2;
if ( v27 < v23 - v2 )
v26 = v27;
v28 = v16;
if ( (unsigned __int64)v16[3] > 0xF )
v28 = (const void **)*v16;
sub_14003A930(String, &v2[(_QWORD)v28], v26);
v59 |= 1u;
v29 = (const char *)String;
if ( v74 > 0xF )
v29 = String[0];
Block = atoi(v29);
if ( v74 > 0xF )
{
v30 = String[0];
if ( v74 + 1 >= 0x1000 )
{
v30 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v30 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v30);
}
goto LABEL_44;
}
if ( Block > 0 && Block <= 600 )
{
v69 = 0;
v70 = 0;
v71 = 0;
if ( v20 < v2 )
sub_14003BCC0(v22);
v31 = v23 - v2;
v32 = v20 - v2;
if ( v32 < v23 - v2 )
v31 = v32;
v33 = v16;
if ( (unsigned __int64)v16[3] > 0xF )
v33 = (const void **)*v16;
sub_14003A930(&v69, &v2[(_QWORD)v33], v31);
v59 |= 2u;
sub_140051590((__int64)&v67._Mypair._Myval2._Myfirst[Block], (__int64)&v69);
sub_14003A830((__int64)&v69);
Block_8._Mypair._Myval2._Myfirst[Block] = a1;
LABEL_44:
v25 = v62;
v22 = v57;
}
v24 = !v24;
LABEL_46:
if ( (_BYTE)v22 )
break;
v2 = v23 + 1;
v34 = v16;
if ( (unsigned __int64)v16[3] > 0xF )
v34 = (const void **)*v16;
v20 = (char *)v16[2];
if ( v2 < v20
&& (v35 = (char *)memchr(&v2[(_QWORD)v34], 44, v20 - v2), v25 = v62, v35)
&& (v23 = (char *)(v35 - (char *)v34), v23 != (char *)-1LL) )
{
v22 = v57;
}
else
{
v23 = v25;
LOBYTE(v22) = 1;
v57 = 1;
}
continue;
}
}
v14 = m_objectsCreated;
}
m_levelType = v60;
}
v36 = GameObject::objectFromVector(&v67, &Block_8, a1, m_lowDetailModeToggled);
v37 = (__int64)v36;
if ( v36 )
{
m_objectID = v36->m_objectID;
if ( m_objectID == 31 )
{
v39 = sub_14003BDB0((__int64)&v69, (__int64)v16);
StartPosObject::loadSettingsFromString(v37, v39);
}
else if ( m_objectID == 2065 && *(_BYTE *)(v37 + 1496) )
{
*(_BYTE *)(v37 + 1496) = 0;
GameToolbox::particleStringToStruct((__int64 *)(v37 + 1464), v37 + 1504);
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v37 + 1632LL))(v37) != 22 || m_levelType == Main )
{
v40 = *(_DWORD *)(v37 + 1328);
if ( v40 > 0 )
{
m_nextColorKey = a1->m_nextColorKey;
if ( v40 > m_nextColorKey )
{
a1->m_nextColorKey = v40;
m_nextColorKey = v40;
}
v46 = *(_DWORD *)(v37 + 1332);
if ( v46 > m_nextColorKey )
a1->m_nextColorKey = v46;
}
else
{
v41 = (*(_QWORD *)(v37 + 896) != 0) + 1;
v42 = 0;
do
{
GameObject::getColorKey(v37, &v69, v42 == 0, 0);
if ( cocos2d::CCDictionary::objectForKey(a1->m_colorKeyDict, &v69) )
{
v43 = *(_DWORD *)(cocos2d::CCDictionary::objectForKey(a1->m_colorKeyDict, &v69) + 56);
}
else
{
v43 = a1->m_nextColorKey;
v44 = cocos2d::CCInteger::create(v43);
cocos2d::CCDictionary::setObject(a1->m_colorKeyDict, v44, &v69);
++a1->m_nextColorKey;
}
if ( v42 )
*(_DWORD *)(v37 + 1332) = v43;
else
*(_DWORD *)(v37 + 1328) = v43;
sub_14003A830((__int64)&v69);
++v42;
}
while ( v42 < v41 );
}
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v37 + 1632LL))(v37) == 31 )
{
if ( cocos2d::CCArray::count(a1->m_coinArray) >= 3 )
goto LABEL_82;
cocos2d::CCArray::addObject(a1->m_coinArray, (struct cocos2d::CCObject *)v37);
}
PlayLayer::addObject(a1, (GameObject *)v37);
}
}
LABEL_82:
v2 = nullptr;
v16[2] = nullptr;
if ( (unsigned __int64)v16[3] > 0xF )
v16 = (const void **)*v16;
*(_BYTE *)v16 = 0;
m_objectsCreated = ++v14;
v15 = v66 + 32;
v66 += 32;
v13 = Block_4;
if ( v14 >= v68 )
break;
m_levelType = v60;
}
}
v47 = a1->m_objectsCreated + v13;
a1->m_objectsCreated = v47;
v48 = a1->m_objectStrings._Mypair._Myval2._Myfirst;
v49 = a1->m_objectStrings._Mypair._Myval2._Mylast - v48;
if ( v49 < 0 )
{
v51 = (a1->m_objectStrings._Mypair._Myval2._Mylast - v48) & 1 | ((unsigned __int64)v49 >> 1);
v50 = (float)(int)v51 + (float)(int)v51;
}
else
{
v50 = (float)(int)v49;
}
v52 = (float)(v47 - 1) / v50;
if ( v52 >= 1.0 )
v52 = 1.0;
a1->m_loadingProgress = v52;
if ( v47 >= (unsigned __int64)(a1->m_objectStrings._Mypair._Myval2._Mylast - v48) )
{
PlayLayer::createObjectsFromSetupFinished(a1);
a1->m_loadingProgress = 1.0;
PlayLayer::setupHasCompleted(a1);
}
v53 = Block_8._Mypair._Myval2._Myfirst;
if ( Block_8._Mypair._Myval2._Myfirst )
{
if ( (unsigned __int64)(8 * (Block_8._Mypair._Myval2._Myend - Block_8._Mypair._Myval2._Myfirst)) >= 0x1000 )
{
v53 = *((std::_Vector_val>::pointer *)Block_8._Mypair._Myval2._Myfirst - 1);
if ( (unsigned __int64)((char *)Block_8._Mypair._Myval2._Myfirst - (char *)v53 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v53);
memset(&Block_8, 0, sizeof(Block_8));
}
m_capacity = v67._Mypair._Myval2._Myfirst;
if ( v67._Mypair._Myval2._Myfirst )
{
Mylast = v67._Mypair._Myval2._Mylast;
if ( v67._Mypair._Myval2._Myfirst != v67._Mypair._Myval2._Mylast )
{
do
sub_14003A830((__int64)m_capacity++);
while ( m_capacity != Mylast );
m_capacity = v67._Mypair._Myval2._Myfirst;
}
v56 = m_capacity;
if ( (((char *)v67._Mypair._Myval2._Myend - (char *)m_capacity) & 0xFFFFFFFFFFFFFFE0uLL) >= 0x1000 )
{
m_capacity = (std::_Vector_val>::pointer)m_capacity[-1].m_data.m_capacity;
if ( (unsigned __int64)((char *)v56 - (char *)m_capacity - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(m_capacity);
}
}