//
// PlayLayer::loadDefaultColors from 0x4091a4 to 0x409596 (1010 bytes)
//
// 2 xrefs:
// > PlayLayer::setupHasCompleted @ 0x40a68a
// > PlayLayer::resetLevel @ 0x4126bc
//
// 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:30 +0000
//
int __fastcall PlayLayer::loadDefaultColors(PlayLayer *this)
{
GJEffectManager *v2; // r0
cocos2d::CCArray *AllColorActions; // r10
unsigned int i; // r9
int v5; // r0
unsigned int v6; // r4
unsigned int v7; // r8
unsigned int v8; // r11
int v9; // r6
_DWORD *v10; // r3
unsigned int v11; // r0
int v12; // r1
_DWORD *v13; // r0
_DWORD *v14; // r7
float v15; // s15
bool v16; // r6
unsigned int v17; // r6
unsigned int v18; // r1
_DWORD *v19; // r3
unsigned int v20; // r0
int v21; // r1
unsigned int v22; // r4
cocos2d::CCArray *v23; // r6
int v24; // r0
unsigned int *v25; // r11
_DWORD *v26; // r9
unsigned int v27; // r0
int v28; // r0
int v29; // r7
int v30; // r4
unsigned int v31; // r8
unsigned int v32; // r4
unsigned int v33; // r7
int v34; // r6
_DWORD *v35; // r2
_DWORD *j; // r10
unsigned int v37; // r0
int v38; // r1
_DWORD *v39; // r0
_DWORD *v40; // r7
float v41; // s13
float v42; // s15
bool v43; // r6
unsigned int v44; // r6
unsigned int v45; // r1
int v46; // r6
_DWORD *v47; // r3
unsigned int v48; // r0
int v49; // r1
unsigned int v51; // [sp+20h] [bp-34h]
cocos2d::CCArray *v52; // [sp+24h] [bp-30h]
unsigned int v53; // [sp+34h] [bp-20h] BYREF
int v54; // [sp+38h] [bp-1Ch] BYREF
unsigned int v55; // [sp+3Ch] [bp-18h]
_DWORD *v56; // [sp+40h] [bp-14h] BYREF
int v57; // [sp+44h] [bp-10h]
float v58; // [sp+48h] [bp-Ch]
v2 = *((GJEffectManager **)this + 381);
v54 = 0;
v55 = 0;
v56 = nullptr;
v57 = 0;
v58 = 1.0;
AllColorActions = (cocos2d::CCArray *)GJEffectManager::getAllColorActions(v2);
for ( i = 0; i < cocos2d::CCArray::count(AllColorActions); ++i )
{
v5 = cocos2d::CCArray::objectAtIndex(AllColorActions, i);
if ( !*(_BYTE *)(v5 + 80) )
continue;
v6 = v55;
v7 = *(_DWORD *)(v5 + 88);
if ( v55 )
{
v8 = v55 - 1;
if ( ((v55 - 1) & v55) != 0 )
v9 = v7 % v55;
else
v9 = v7 & v8;
v10 = *(_DWORD **)(v54 + 4 * v9);
if ( v10 )
{
while ( 1 )
{
v10 = (_DWORD *)*v10;
if ( !v10 )
break;
v11 = v10[1];
v12 = ((v55 - 1) & v55) != 0 ? v11 % v55 : v8 & v11;
if ( v12 != v9 )
break;
if ( v10[2] == v7 )
goto LABEL_33;
}
}
}
else
{
v9 = 0;
}
v13 = (_DWORD *)operator new(0xCu);
v13[2] = v7;
v13[1] = v7;
*v13 = 0;
v14 = v13;
v15 = (float)(unsigned int)(v57 + 1);
if ( v15 > (float)((float)v6 * v58) )
{
v16 = v6 > 2 && ((v6 - 1) & v6) == 0;
goto LABEL_19;
}
if ( !v6 )
{
v16 = 0;
LABEL_19:
v17 = 2 * v6 + !v16;
v18 = (unsigned int)ceilf(v15 / v58);
if ( v18 < v17 )
v18 = v17;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v54, v18);
v6 = v55;
if ( ((v55 - 1) & v55) != 0 )
v9 = v7 % v55;
else
v9 = v7 & (v55 - 1);
}
v19 = *(_DWORD **)(v54 + 4 * v9);
if ( v19 )
{
*v14 = *v19;
*v19 = v14;
}
else
{
*v14 = v56;
v56 = v14;
*(_DWORD *)(v54 + 4 * v9) = &v56;
if ( *v14 )
{
v20 = *(_DWORD *)(*v14 + 4);
if ( ((v6 - 1) & v6) != 0 )
v21 = v20 % v6;
else
v21 = (v6 - 1) & v20;
*(_DWORD *)(v54 + 4 * v21) = v14;
}
}
++v57;
LABEL_33:
;
}
GJEffectManager::reset(*((GJEffectManager **)this + 381));
v22 = 0;
v23 = (cocos2d::CCArray *)GJEffectManager::getAllColorActions(*(GJEffectManager **)(*((_DWORD *)this + 521) + 264));
while ( v22 < cocos2d::CCArray::count(v23) )
{
v24 = cocos2d::CCArray::objectAtIndex(v23, v22);
(*(void (__fastcall **)(PlayLayer *, int, _DWORD, _DWORD, _DWORD, _DWORD, int, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)this + 616))(
this,
v24 + 68,
0,
*(_DWORD *)(v24 + 88),
*(unsigned __int8 *)(v24 + 80),
*(_DWORD *)(v24 + 92),
v24 + 100,
*(_DWORD *)(v24 + 116),
*(unsigned __int8 *)(v24 + 121),
0,
*(_DWORD *)(v24 + 124),
*(_DWORD *)(v24 + 128));
++v22;
}
v52 = (cocos2d::CCArray *)GJEffectManager::getAllColorActions(*((GJEffectManager **)this + 381));
v51 = 0;
v25 = (unsigned int *)((char *)this + 12068);
v26 = (_DWORD *)((char *)this + 12064);
v27 = cocos2d::CCArray::count(v52);
while ( 2 )
{
if ( v51 < v27 )
{
v28 = cocos2d::CCArray::objectAtIndex(v52, v51);
v29 = *(unsigned __int8 *)(v28 + 80);
v30 = v28;
v53 = *(_DWORD *)(v28 + 88);
if ( v29 == (std::__hash_table,std::equal_to,std::allocator>::find(&v54, &v53) != nullptr) )
{
LABEL_40:
++v51;
v27 = cocos2d::CCArray::count(v52);
continue;
}
v31 = *(_DWORD *)(v30 + 88);
v32 = *v25;
if ( *v25 )
{
v33 = v32 - 1;
if ( ((v32 - 1) & v32) != 0 )
v34 = v31 % v32;
else
v34 = v31 & v33;
v35 = *(_DWORD **)(*v26 + 4 * v34);
if ( v35 )
{
for ( j = (_DWORD *)*v35; j; j = (_DWORD *)*j )
{
v37 = j[1];
v38 = ((v32 - 1) & v32) != 0 ? v37 % v32 : v33 & v37;
if ( v38 != v34 )
break;
if ( j[2] == v31 )
goto LABEL_40;
}
}
}
else
{
v34 = 0;
}
v39 = (_DWORD *)operator new(0xCu);
v39[2] = v31;
v39[1] = v31;
*v39 = 0;
v40 = v39;
v41 = *((float *)this + 3020);
v42 = (float)(unsigned int)(*((_DWORD *)this + 3019) + 1);
if ( v42 > (float)((float)v32 * v41) )
{
v43 = v32 > 2 && ((v32 - 1) & v32) == 0;
LABEL_58:
v44 = 2 * v32 + !v43;
v45 = (unsigned int)ceilf(v42 / v41);
if ( v45 < v44 )
v45 = v44;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)this + 12064, v45);
v32 = *v25;
v46 = *v25 - 1;
if ( (v46 & *v25) != 0 )
v34 = v31 % v32;
else
v34 = v31 & v46;
}
else if ( !v32 )
{
v43 = 0;
goto LABEL_58;
}
v47 = *(_DWORD **)(*v26 + 4 * v34);
if ( v47 )
{
*v40 = *v47;
*v47 = v40;
}
else
{
*v40 = *((_DWORD *)this + 3018);
*((_DWORD *)this + 3018) = v40;
*(_DWORD *)(*v26 + 4 * v34) = (char *)this + 12072;
if ( *v40 )
{
v48 = *(_DWORD *)(*v40 + 4);
if ( ((v32 - 1) & v32) != 0 )
v49 = v48 % v32;
else
v49 = (v32 - 1) & v48;
*(_DWORD *)(*v26 + 4 * v49) = v40;
}
}
++*((_DWORD *)this + 3019);
goto LABEL_40;
}
break;
}
GJEffectManager::updateEffects(*((GJEffectManager **)this + 381), 0.0);
GJEffectManager::calculateBaseActiveColors(*((GJEffectManager **)this + 381));
GJEffectManager::processInheritedColors(*((GJEffectManager **)this + 381));
return std::__hash_table,std::equal_to,std::allocator>::~__hash_table((int)&v54);
}