//
// PlayLayer::processCreateObjectsFromSetup from 0x31c434 to 0x31c8aa (1142 bytes)
//
// 2 xrefs:
// > PlayLayer::init @ 0x31ce98
// > LevelInfoLayer::loadLevelStep @ 0x3b10b4
//
// 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 PlayLayer::processCreateObjectsFromSetup(PlayLayer *a1)
{
std::string *v2; // r5
std::string *v3; // r3
void **v4; // r6
void **v5; // r3
GJGameLevel *m_level; // r3
GJLevelType m_levelType; // r2
float v8; // s15
float v9; // r0
int v10; // s16
std::string *v11; // r11
int i; // r3
int v13; // r0
int v14; // r5
int v15; // r6
int v16; // r7
int v17; // r3
ParticleGameObject *v18; // r0
StartPosObject *v19; // r5
int m_objectID; // r3
float *p_m_loadingProgress; // r5
unsigned int v22; // r1
unsigned int v23; // r3
float v24; // s15
int m_mainColorKeyIndex; // r2
cocos2d::CCDictionary **p_m_colorKeyDict; // r7
int v27; // r9
int v28; // r3
cocos2d::CCObject *v29; // r8
int *p_m_nextColorKey; // r3
int m_detailColorKeyIndex; // r2
int m_objectsCreated; // [sp+4h] [bp-60h]
int v33; // [sp+Ch] [bp-58h]
int m_nextColorKey; // [sp+Ch] [bp-58h]
int v35; // [sp+14h] [bp-50h]
unsigned int v36; // [sp+18h] [bp-4Ch]
int v37; // [sp+1Ch] [bp-48h]
std::string *v38; // [sp+20h] [bp-44h]
int v39; // [sp+20h] [bp-44h]
int v40; // [sp+24h] [bp-40h]
GJLevelType v41; // [sp+28h] [bp-3Ch]
bool v42; // [sp+2Ch] [bp-38h]
cocos2d::CCDictionary *v43; // [sp+30h] [bp-34h]
char *v44; // [sp+38h] [bp-2Ch] BYREF
char v45[4]; // [sp+3Ch] [bp-28h] BYREF
std::string v46; // [sp+40h] [bp-24h] BYREF
std::vector p; // [sp+44h] [bp-20h] BYREF
std::vector v48; // [sp+50h] [bp-14h] BYREF
p.m_start = nullptr;
p.m_reserveEnd = nullptr;
v2 = (std::string *)operator new(0x964u);
v3 = v2;
do
{
if ( v3 )
v3->m_data.m_data = (stl::StringData::Internal *)&unk_ACDDA8;
++v3;
}
while ( v3 != &v2[601] );
std::_Destroy_aux::__destroy(0, 0);
if ( p.m_start )
operator delete(p.m_start);
p.m_start = v2;
p.m_finish = v2 + 601;
p.m_reserveEnd = v2 + 601;
memset(&v48, 0, sizeof(v48));
v4 = (void **)operator new(0x964u);
v5 = v4;
do
*v5++ = nullptr;
while ( v5 != v4 + 601 );
if ( v48.m_start )
operator delete(v48.m_start);
m_level = a1->m_level;
v48.m_start = v4;
v48.m_finish = v4 + 601;
m_levelType = m_level->m_levelType;
LOBYTE(m_level) = m_level->m_lowDetailModeToggled;
v48.m_reserveEnd = v4 + 601;
v41 = m_levelType;
v42 = (char)m_level;
v36 = a1->m_objectStrings.m_finish - a1->m_objectStrings.m_start;
v8 = COERCE_FLOAT(roundf()) + 10.0;
if ( v8 > 100.0 )
v8 = 100.0;
v9 = ceilf((float)v36 / v8);
m_objectsCreated = a1->m_objectsCreated;
v37 = m_objectsCreated;
v35 = 0;
v10 = (int)v9;
while ( m_objectsCreated < v36 && m_objectsCreated < a1->m_objectsCreated + v10 )
{
v11 = &a1->m_objectStrings.m_start[v37];
for ( i = 0; i != 601; ++i )
v48.m_start[i] = nullptr;
v13 = sub_774910(v11, 44, 0);
v33 = *((_DWORD *)v11->m_data.m_data - 3);
v14 = v13;
if ( v13 != -1 )
{
v15 = 0;
v16 = 1;
v17 = 0;
while ( 1 )
{
if ( v17 != v33 )
{
if ( v16 )
{
sub_776158(&v44, v11, v17, v14 - v17);
v35 = atoi(v44);
sub_774008(&v44);
}
else if ( (unsigned int)(v35 - 1) < 0x258 )
{
v38 = &p.m_start[v35];
sub_776158(v45, v11, v17, v14 - v17);
sub_774794(v38, v45);
sub_774008(v45);
v48.m_start[v35] = a1;
}
v16 ^= 1u;
}
if ( v15 )
break;
v39 = v14 + 1;
v14 = sub_774910(v11, 44, v14 + 1);
v17 = v39;
if ( v14 == -1 )
{
v14 = v33;
v15 = 1;
}
}
}
v18 = (ParticleGameObject *)GameObject::objectFromVector(&p, &v48, a1, v42);
v19 = (StartPosObject *)v18;
if ( v18 )
{
m_objectID = v18->m_objectID;
if ( m_objectID == 31 )
{
sub_775C20(&v46, v11);
StartPosObject::loadSettingsFromString(v19, (std::string)&v46);
sub_774008(&v46);
}
else if ( m_objectID == 2065 )
{
ParticleGameObject::updateParticleStruct(v18);
}
if ( v19->getType(v19) != SecretCoin || v41 == Main )
{
m_mainColorKeyIndex = v19->m_mainColorKeyIndex;
if ( m_mainColorKeyIndex > 0 )
{
p_m_nextColorKey = &a1->m_nextColorKey;
if ( m_mainColorKeyIndex > a1->m_nextColorKey )
*p_m_nextColorKey = m_mainColorKeyIndex;
m_detailColorKeyIndex = v19->m_detailColorKeyIndex;
if ( m_detailColorKeyIndex > *p_m_nextColorKey )
*p_m_nextColorKey = m_detailColorKeyIndex;
}
else
{
p_m_colorKeyDict = &a1->m_colorKeyDict;
v27 = 0;
if ( GameObject::hasSecondaryColor(v19) )
v28 = 2;
else
v28 = 1;
v40 = v28;
do
{
GameObject::getColorKey((GameObject *)&v46, (bool)v19, (v27 ^ 1) & 1);
if ( cocos2d::CCDictionary::objectForKey(*p_m_colorKeyDict, &v46) )
{
m_nextColorKey = *(_DWORD *)(cocos2d::CCDictionary::objectForKey(*p_m_colorKeyDict, &v46) + 52);
}
else
{
m_nextColorKey = a1->m_nextColorKey;
v43 = *p_m_colorKeyDict;
v29 = (cocos2d::CCObject *)operator new(0x38u);
cocos2d::CCObject::CCObject(v29);
v29->__vftable = (cocos2d::CCObject_vtbl *)&off_A45350;
v29[1].__vftable = (cocos2d::CCObject_vtbl *)m_nextColorKey;
cocos2d::CCObject::autorelease(v29);
cocos2d::CCDictionary::setObject((int)v43, v29);
++a1->m_nextColorKey;
}
if ( (((unsigned __int8)v27 ^ 1) & 1) != 0 )
v19->m_mainColorKeyIndex = m_nextColorKey;
else
v19->m_detailColorKeyIndex = m_nextColorKey;
++v27;
sub_774008(&v46);
}
while ( v27 != v40 );
}
if ( v19->getType(v19) == (Collectible|0x1) )
{
if ( cocos2d::CCArray::count(a1->m_coinArray) > 2u )
goto LABEL_30;
cocos2d::CCArray::addObject(a1->m_coinArray, v19);
}
PlayLayer::addObject(a1, v19);
}
}
LABEL_30:
sub_7751A8(v11);
++m_objectsCreated;
++v37;
}
p_m_loadingProgress = &a1->m_loadingProgress;
v22 = v10 + a1->m_objectsCreated;
a1->m_objectsCreated = v22;
v23 = a1->m_objectStrings.m_finish - a1->m_objectStrings.m_start;
v24 = (float)(int)(v22 - 1) / (float)v23;
if ( v24 > 1.0 )
v24 = 1.0;
*p_m_loadingProgress = v24;
if ( v22 >= v23 )
{
PlayLayer::createObjectsFromSetupFinished(a1);
*p_m_loadingProgress = 1.0;
PlayLayer::setupHasCompleted(a1);
}
if ( v48.m_start )
operator delete(v48.m_start);
std::vector::~vector((void **)&p.m_start);
}