//
// PlayLayer::processCreateObjectsFromSetup from 0x1000ad2f0 to 0x1000adc9c (2476 bytes)
//
// 2 xrefs:
// > PlayLayer::init @ 0x1000acc05
// > LevelInfoLayer::loadLevelStep @ 0x1002c43ad
//
// 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 __fastcall PlayLayer::processCreateObjectsFromSetup(PlayLayer *a1)
{
PlayLayer *v1; // r13
void **v2; // rbx
unsigned __int64 v3; // rsi
float v4; // xmm1_4
__m128 v5; // xmm0
unsigned __int64 v6; // rdx
__m128 v7; // xmm2
int m_objectsCreated; // eax
__int64 v9; // rsi
GJGameLevel *m_level; // rax
__int64 v11; // rdx
std::__vector_base::pointer begin; // rbx
__int64 v13; // rax
__int64 v14; // r14
std::string *v15; // r15
std::string::size_type v16; // rax
unsigned int sizex2; // ecx
std::string::size_type size; // rcx
std::string::size_type v19; // r14
std::string::size_type v20; // r15
unsigned int v21; // r13d
std::string::size_type v22; // r13
std::string::pointer v23; // rbx
unsigned int v24; // ebx
std::string::size_type v25; // rbx
std::string::pointer v26; // r13
size_t v27; // r13
char *v28; // r12
__int64 v29; // rax
size_t v30; // r14
char *v31; // rbx
__int64 v32; // rax
size_t v33; // rbx
char *v34; // r12
size_t v35; // r14
__int64 v36; // rbx
std::string *v37; // r14
std::string::size_type v38; // rax
__int64 v39; // rcx
GameObject *v40; // rax
ParticleGameObject *v41; // r15
int m_objectID; // eax
int m_mainColorKeyIndex; // eax
int m_nextColorKey; // ecx
int m_detailColorKeyIndex; // eax
bool hasSecondaryColor; // r14
__int64 v47; // rax
__int64 v48; // rax
std::string *v49; // rcx
int v50; // r12d
cocos2d::CCDictionary *m_colorKeyDict; // rbx
cocos2d::CCObject *v52; // r13
int v53; // r14d
cocos2d::CCDictionary *v54; // rbx
cocos2d::CCObject *v55; // r13
int v56; // ecx
int v57; // eax
std::string *v58; // rbx
std::__vector_base::pointer end; // r14
std::__vector_base::pointer v60; // rdi
__int128 v61; // [rsp+0h] [rbp-100h] BYREF
void *__p; // [rsp+10h] [rbp-F0h]
std::string::size_type v63; // [rsp+18h] [rbp-E8h]
char *data; // [rsp+20h] [rbp-E0h]
__int64 v65; // [rsp+28h] [rbp-D8h]
__int64 v66; // [rsp+30h] [rbp-D0h]
__int64 (__fastcall **v67)(); // [rsp+38h] [rbp-C8h]
std::vector v68; // [rsp+40h] [rbp-C0h] BYREF
_BOOL4 m_lowDetailModeToggled; // [rsp+60h] [rbp-A0h]
GJLevelType m_levelType; // [rsp+64h] [rbp-9Ch]
std::string::size_type v71; // [rsp+68h] [rbp-98h]
__int64 v72; // [rsp+70h] [rbp-90h]
unsigned __int64 v73; // [rsp+78h] [rbp-88h]
std::vector v74; // [rsp+80h] [rbp-80h] BYREF
__int64 v75; // [rsp+A0h] [rbp-60h]
std::string *v76; // [rsp+A8h] [rbp-58h]
char __dst[16]; // [rsp+B0h] [rbp-50h] BYREF
char *v78; // [rsp+C0h] [rbp-40h]
PlayLayer *v79; // [rsp+C8h] [rbp-38h]
char v80; // [rsp+D7h] [rbp-29h]
v1 = a1;
memset(&v68, 0, sizeof(v68));
sub_1000CADA0(&v68, 601);
memset(&v74, 0, sizeof(v74));
v2 = (void **)operator new(0x12C8u);
__bzero(v2, 4808);
v74.__begin_ = v2;
v74.__end_ = v2 + 601;
v74.__end_cap_.__value_ = v2 + 601;
v3 = 0xAAAAAAAAAAAAAAABLL * (((char *)v1->m_objectStrings.__end_ - (char *)v1->m_objectStrings.__begin_) >> 3);
v4 = fminf(100.0, (float)(int)(v3 / 0x3E8) + 10.0);
if ( (v3 & 0x8000000000000000LL) != 0LL )
{
v6 = 0xAAAAAAAAAAAAAAABLL * (((char *)a1->m_objectStrings.__end_ - (char *)a1->m_objectStrings.__begin_) >> 3);
v5 = 0;
v5.f32[0] = (float)(int)((v3 >> 1) | v3 & 1) + (float)(int)((v3 >> 1) | v3 & 1);
}
else
{
v5 = 0;
v5.f32[0] = (float)(int)v3;
v6 = 0xAAAAAAAAAAAAAAABLL * (((char *)a1->m_objectStrings.__end_ - (char *)a1->m_objectStrings.__begin_) >> 3);
}
v7 = v5;
v7.f32[0] = v5.f32[0] / v4;
v66 = (unsigned int)(int)_mm_round_ss((__m128)0LL, v7, 10).f32[0];
m_objectsCreated = a1->m_objectsCreated;
v9 = m_objectsCreated;
v73 = v6;
if ( v6 <= m_objectsCreated )
goto LABEL_97;
m_level = a1->m_level;
m_levelType = m_level->m_levelType;
v72 = 0;
m_lowDetailModeToggled = m_level->m_lowDetailModeToggled;
v67 = off_1008B8348;
v79 = a1;
v11 = v9;
do
{
m_objectsCreated = v1->m_objectsCreated;
v65 = v11;
if ( v11 >= m_objectsCreated + (int)v66 )
goto LABEL_94;
begin = v1->m_objectStrings.__begin_;
v13 = 0;
*v74.__begin_ = nullptr;
do
{
v74.__begin_[v13 + 1] = nullptr;
v74.__begin_[v13 + 2] = nullptr;
v74.__begin_[v13 + 3] = nullptr;
v13 += 4;
v74.__begin_[v13] = nullptr;
}
while ( v13 != 600 );
v14 = v65;
v15 = (std::string *)&begin[v65];
v16 = std::string::find(v15, 44, 0);
sizex2 = begin[v14].m_data.m_short.sizex2;
v76 = v15;
if ( (sizex2 & 1) != 0 )
{
size = v15->__r_.__value_.__l.__size_;
if ( v16 == -1 )
goto LABEL_60;
LABEL_15:
v19 = v16;
v63 = (int)size;
data = v76->__r_.__value_.__s.__data_;
v80 = 1;
v75 = 0;
v20 = 0;
while ( 1 )
{
if ( v20 == v63 )
{
if ( (v75 & 1) != 0 )
goto LABEL_60;
goto LABEL_58;
}
if ( (v80 & 1) != 0 )
{
v21 = (unsigned int)v76->__r_.__value_.__l.0;
if ( (v21 & 1) != 0 )
{
v22 = v76->__r_.__value_.__l.__size_;
if ( v22 < v20 )
LABEL_111:
sub_1000547C0();
v23 = v76->__r_.__value_.__l.__data_;
}
else
{
v22 = v21 >> 1;
v23 = data;
if ( v20 > v22 )
goto LABEL_111;
}
v27 = v22 - v20;
if ( v27 >= v19 - v20 )
v27 = v19 - v20;
if ( v27 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v5.i64);
if ( v27 >= 0x17 )
{
v71 = v19;
v30 = 26;
if ( (v27 | 7) != 0x17 )
v30 = (v27 | 7) + 1;
v28 = (char *)operator new(v30);
v78 = v28;
*(_QWORD *)__dst = v30 | 1;
*(_QWORD *)&__dst[8] = v27;
v19 = v71;
}
else
{
__dst[0] = 2 * v27;
v28 = &__dst[1];
if ( !v27 )
{
__dst[1] = 0;
if ( (__dst[0] & 1) == 0 )
goto LABEL_35;
LABEL_40:
v31 = v78;
LODWORD(v32) = atoi(v78);
v72 = v32;
operator delete(v31);
goto LABEL_41;
}
}
memmove(v28, &v23[v20], v27);
v28[v27] = 0;
if ( (__dst[0] & 1) != 0 )
goto LABEL_40;
LABEL_35:
LODWORD(v29) = atoi(&__dst[1]);
v72 = v29;
LABEL_41:
v1 = v79;
goto LABEL_57;
}
if ( (unsigned int)(v72 - 1) > 0x257 )
goto LABEL_57;
v24 = (unsigned int)v76->__r_.__value_.__l.0;
if ( (v24 & 1) != 0 )
{
v25 = v76->__r_.__value_.__l.__size_;
if ( v25 < v20 )
LABEL_113:
sub_1000547C0();
v26 = v76->__r_.__value_.__l.__data_;
}
else
{
v25 = v24 >> 1;
v26 = data;
if ( v20 > v25 )
goto LABEL_113;
}
v33 = v25 - v20;
if ( v33 >= v19 - v20 )
v33 = v19 - v20;
if ( v33 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v5.i64);
v71 = v19;
if ( v33 >= 0x17 )
{
v35 = 26;
if ( (v33 | 7) != 0x17 )
v35 = (v33 | 7) + 1;
v34 = (char *)operator new(v35);
v78 = v34;
*(_QWORD *)__dst = v35 | 1;
*(_QWORD *)&__dst[8] = v33;
}
else
{
__dst[0] = 2 * v33;
v34 = &__dst[1];
if ( !v33 )
goto LABEL_54;
}
memmove(v34, &v26[v20], v33);
LABEL_54:
v34[v33] = 0;
v36 = (unsigned int)v72;
v37 = &v68.__begin_[(unsigned int)v72];
if ( (v37->m_data.m_short.sizex2 & 1) != 0 )
operator delete(v37->m_data.m_long.longStorage);
v37->m_data.m_long.longStorage = v78;
v5.i64[0] = *(_QWORD *)__dst;
*(_OWORD *)&v37->m_data.m_short.sizex2 = *(_OWORD *)__dst;
v1 = v79;
v74.__begin_[v36] = v79;
v19 = v71;
LABEL_57:
v80 ^= 1u;
if ( (v75 & 1) != 0 )
goto LABEL_60;
LABEL_58:
v20 = v19 + 1;
v38 = std::string::find(v76, 44, v19 + 1);
v19 = v63;
LOBYTE(v39) = v38 == -1;
v75 = v39;
if ( v38 != -1 )
v19 = v38;
}
}
LODWORD(size) = sizex2 >> 1;
if ( v16 != -1 )
goto LABEL_15;
LABEL_60:
v40 = GameObject::objectFromVector(&v68, &v74, v1, m_lowDetailModeToggled);
v41 = (ParticleGameObject *)v40;
if ( !v40 )
goto LABEL_87;
m_objectID = v40->m_objectID;
if ( m_objectID == 2065 )
{
ParticleGameObject::updateParticleStruct(v41);
}
else if ( m_objectID == 31 )
{
if ( (*(_BYTE *)&v76->__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v61, v76->__r_.__value_.__l.__data_, v76->__r_.__value_.__l.__size_, *(double *)v5.i64);
}
else
{
__p = v76->__r_.__value_.__l.__data_;
v5 = *(__m128 *)&v76->__r_.__value_.__l.0;
v61 = *(_OWORD *)&v76->__r_.__value_.__l.0;
}
StartPosObject::loadSettingsFromString(v41, &v61);
if ( (v61 & 1) != 0 )
operator delete(__p);
}
if ( ((unsigned int (__fastcall *)(ParticleGameObject *))v41->getType)(v41) == 22 && m_levelType != Main )
goto LABEL_87;
m_mainColorKeyIndex = v41->m_mainColorKeyIndex;
if ( m_mainColorKeyIndex > 0 )
{
m_nextColorKey = v1->m_nextColorKey;
if ( m_mainColorKeyIndex > m_nextColorKey )
{
v1->m_nextColorKey = m_mainColorKeyIndex;
m_nextColorKey = m_mainColorKeyIndex;
}
m_detailColorKeyIndex = v41->m_detailColorKeyIndex;
if ( m_detailColorKeyIndex > m_nextColorKey )
v1->m_nextColorKey = m_detailColorKeyIndex;
goto LABEL_83;
}
hasSecondaryColor = GameObject::hasSecondaryColor(v41);
GameObject::getColorKey(__dst, v41, 1, 0);
if ( cocos2d::CCDictionary::objectForKey_1(v1->m_colorKeyDict, __dst) )
{
v47 = cocos2d::CCDictionary::objectForKey_1(v79->m_colorKeyDict, __dst);
v1 = v79;
v41->m_mainColorKeyIndex = *(_DWORD *)(v47 + 56);
if ( (__dst[0] & 1) == 0 )
goto LABEL_79;
LABEL_78:
operator delete(v78);
goto LABEL_79;
}
v50 = v79->m_nextColorKey;
m_colorKeyDict = v79->m_colorKeyDict;
v52 = (cocos2d::CCObject *)operator new(0x40u);
cocos2d::CCObject::CCObject(v52);
v52->__vftable = (cocos2d::CCObject_vtbl *)v67;
LODWORD(v52[1].__vftable) = v50;
cocos2d::CCObject::autorelease(v52);
cocos2d::CCDictionary::setObject_1(m_colorKeyDict, v52, __dst);
v1 = v79;
++v79->m_nextColorKey;
v41->m_mainColorKeyIndex = v50;
if ( (__dst[0] & 1) != 0 )
goto LABEL_78;
LABEL_79:
if ( hasSecondaryColor )
{
GameObject::getColorKey(__dst, v41, 0, 0);
if ( !cocos2d::CCDictionary::objectForKey_1(v1->m_colorKeyDict, __dst) )
{
v53 = v79->m_nextColorKey;
v54 = v79->m_colorKeyDict;
v55 = (cocos2d::CCObject *)operator new(0x40u);
cocos2d::CCObject::CCObject(v55);
v55->__vftable = (cocos2d::CCObject_vtbl *)v67;
LODWORD(v55[1].__vftable) = v53;
cocos2d::CCObject::autorelease(v55);
cocos2d::CCDictionary::setObject_1(v54, v55, __dst);
v1 = v79;
++v79->m_nextColorKey;
v41->m_detailColorKeyIndex = v53;
if ( (__dst[0] & 1) == 0 )
goto LABEL_83;
LABEL_82:
operator delete(v78);
goto LABEL_83;
}
v48 = cocos2d::CCDictionary::objectForKey_1(v79->m_colorKeyDict, __dst);
v1 = v79;
v41->m_detailColorKeyIndex = *(_DWORD *)(v48 + 56);
if ( (__dst[0] & 1) != 0 )
goto LABEL_82;
}
LABEL_83:
if ( ((unsigned int (__fastcall *)(ParticleGameObject *))v41->getType)(v41) == 31 )
{
if ( (unsigned int)sub_100720070(v1->m_coinArray) > 2 )
goto LABEL_87;
sub_10071FCD0(v1->m_coinArray, v41);
}
PlayLayer::addObject(v1, v41);
LABEL_87:
v49 = v76;
if ( (*(_BYTE *)&v76->__r_.__value_.__s.0 & 1) != 0 )
{
*v76->__r_.__value_.__l.__data_ = 0;
v49->__r_.__value_.__l.__size_ = 0;
}
else
{
*(_WORD *)&v76->__r_.__value_.__l.0 = 0;
}
v11 = v65 + 1;
}
while ( v73 > v65 + 1 );
m_objectsCreated = v1->m_objectsCreated;
LABEL_94:
v73 = 0xAAAAAAAAAAAAAAABLL * (((char *)v1->m_objectStrings.__end_ - (char *)v1->m_objectStrings.__begin_) >> 3);
if ( (v73 & 0x8000000000000000LL) != 0LL )
v5.f32[0] = (float)(int)((v73 >> 1) | v73 & 1) + (float)(int)((v73 >> 1) | v73 & 1);
else
v5.f32[0] = (float)(int)v73;
LABEL_97:
v56 = m_objectsCreated + v66 - 1;
v57 = m_objectsCreated + v66;
v1->m_objectsCreated = v57;
v1->m_loadingProgress = fminf(1.0, (float)v56 / v5.f32[0]);
if ( v73 <= v57 )
{
PlayLayer::createObjectsFromSetupFinished(v1);
v1->m_loadingProgress = 1.0;
PlayLayer::setupHasCompleted(v1);
}
if ( v74.__begin_ )
{
v74.__end_ = v74.__begin_;
operator delete(v74.__begin_);
}
v58 = v68.__begin_;
if ( v68.__begin_ )
{
end = v68.__end_;
v60 = v68.__begin_;
if ( v68.__end_ != v68.__begin_ )
{
do
{
if ( (end[-1].m_data.m_short.sizex2 & 1) != 0 )
operator delete(end[-1].m_data.m_long.longStorage);
--end;
}
while ( end != v58 );
v60 = v68.__begin_;
}
v68.__end_ = v58;
operator delete(v60);
}
}