//
// LevelEditorLayer::updateObjectColors from 0x461514 to 0x4618c8 (948 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::manualUpdateObjectColors @ 0x4618e2
// > GJSmartBlockPreview::addPreview @ 0x66f674
//
// 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:48:53 +0000
//
unsigned int __fastcall LevelEditorLayer::updateObjectColors(LevelEditorLayer *this, cocos2d::CCArray *a2)
{
unsigned int v4; // r7
unsigned __int8 *v5; // r0
int v6; // r0
unsigned int result; // r0
int v8; // r4
int MainColor; // r0
GJEffectManager *v10; // r8
int v11; // r6
GJSpriteColor *MainColorMode; // r0
int SecondaryColor; // r0
GJEffectManager *v14; // r8
int v15; // r6
GJSpriteColor *SecondaryColorMode; // r0
GJSpriteColor *v17; // r0
int v18; // r6
int active; // r0
int v20; // r3
int v21; // r0
_DWORD *v22; // r2
int v23; // r0
signed int v24; // r12
int GroupID; // r0
int v26; // r0
float v27; // s16
signed int i; // r6
GJEffectManager *v29; // r8
int v30; // r0
GJSpriteColor *v31; // r0
int v32; // r6
int v33; // r0
int v34; // r0
int v35; // r0
_DWORD *v36; // r2
int v37; // r0
float v38; // s16
signed int j; // r6
GJEffectManager *v40; // r8
int v41; // r0
signed int v42; // r12
int v43; // r0
int v44; // r0
int v45; // [sp+8h] [bp-34h]
void *v46; // [sp+Ch] [bp-30h]
_DWORD *v47; // [sp+10h] [bp-2Ch]
signed int v48; // [sp+10h] [bp-2Ch]
_DWORD *v49; // [sp+10h] [bp-2Ch]
signed int v50; // [sp+10h] [bp-2Ch]
int v51; // [sp+14h] [bp-28h]
int v52; // [sp+14h] [bp-28h]
int v53; // [sp+14h] [bp-28h]
int v54; // [sp+14h] [bp-28h]
int v55; // [sp+18h] [bp-24h]
int v56; // [sp+1Ch] [bp-20h] BYREF
_DWORD v57[4]; // [sp+20h] [bp-1Ch] BYREF
int v58; // [sp+30h] [bp-Ch]
v4 = 0;
v5 = (unsigned __int8 *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 612) + 472))(*((_DWORD *)this + 612));
v6 = GameToolbox::transformColor(v5, 0.0, -0.3, 0.4);
v46 = &_stack_chk_guard;
LOWORD(v55) = v6;
BYTE2(v55) = BYTE2(v6);
while ( 1 )
{
result = cocos2d::CCArray::count(a2);
if ( v4 >= result )
break;
v8 = cocos2d::CCArray::objectAtIndex(a2, v4);
MainColor = GameObject::getMainColor((GameObject *)v8);
v10 = *((GJEffectManager **)this + 381);
v11 = MainColor;
MainColorMode = GameObject::getMainColorMode((GameObject *)v8);
*(_DWORD *)(v11 + 8) = GJEffectManager::activeOpacityForIndex(v10, (int)MainColorMode);
if ( GameObject::hasSecondaryColor((GameObject *)v8) )
{
SecondaryColor = GameObject::getSecondaryColor((GameObject *)v8);
v14 = *((GJEffectManager **)this + 381);
v15 = SecondaryColor;
SecondaryColorMode = GameObject::getSecondaryColorMode((GameObject *)v8);
*(_DWORD *)(v15 + 8) = GJEffectManager::activeOpacityForIndex(v14, (int)SecondaryColorMode);
}
v17 = GameObject::getMainColorMode((GameObject *)v8);
BYTE2(v56) = -1;
LOWORD(v56) = -1;
v18 = (int)v17;
active = GJEffectManager::activeColorForIndex(*((GJEffectManager **)this + 381), (int)v17);
v20 = *(__int16 *)(v8 + 1020);
LOWORD(v56) = active;
BYTE2(v56) = BYTE2(active);
if ( v20 > 0 )
{
v24 = 0;
while ( v24 < *(__int16 *)(v8 + 1020) )
{
v48 = v24;
v52 = *((_DWORD *)this + 381);
GroupID = GameObject::getGroupID((GameObject *)v8, v24);
v26 = GJEffectManager::colorForGroupID(v52, GroupID, &v56, *(unsigned __int8 *)(v8 + 902) ^ 1);
v24 = v48 + 1;
LOWORD(v56) = v26;
BYTE2(v56) = BYTE2(v26);
}
}
v47 = (_DWORD *)(*(_DWORD *)(v8 + 960) + 16);
v51 = *(_DWORD *)(v8 + 960);
v21 = sub_45F7AC((int)v47);
v22 = v47;
if ( !v21 )
{
v23 = GJEffectManager::colorForEffect(
*((_DWORD *)this + 381),
v56,
*v47,
v47[1],
*(_DWORD *)(v51 + 24),
*(_DWORD *)(v51 + 28),
v45,
v46,
v47);
LOWORD(v56) = v23;
BYTE2(v56) = BYTE2(v23);
}
(*(void (__fastcall **)(int, int *, _DWORD *))(*(_DWORD *)v8 + 792))(v8, &v56, v22);
if ( v18 <= 0 )
v27 = 1.0;
else
v27 = COERCE_FLOAT(GJEffectManager::activeOpacityForIndex(*((GJEffectManager **)this + 381), v18));
if ( *(__int16 *)(v8 + 1020) > 0 )
{
for ( i = 0; i < *(__int16 *)(v8 + 1020); ++i )
{
v29 = *((GJEffectManager **)this + 381);
v30 = GameObject::getGroupID((GameObject *)v8, i);
v27 = v27 * COERCE_FLOAT(GJEffectManager::opacityModForGroup(v29, v30));
}
}
*(float *)(*(_DWORD *)(v8 + 960) + 8) = v27;
if ( GameObject::hasSecondaryColor((GameObject *)v8) )
{
v31 = GameObject::getSecondaryColorMode((GameObject *)v8);
LOWORD(v57[0]) = -1;
BYTE2(v57[0]) = -1;
v32 = (int)v31;
if ( v31 == (GJSpriteColor *)&stru_3EC.st_size )
{
v57[1] = 0;
v57[2] = 1059481190;
v57[3] = 1041865114;
LOWORD(v58) = 256;
v33 = GJEffectManager::colorForEffect(
*((_DWORD *)this + 381),
v56,
0,
1059481190,
1041865114,
v58,
v45,
v46,
v47);
LOWORD(v57[0]) = v33;
BYTE2(v57[0]) = BYTE2(v33);
}
else
{
if ( (int)v31 > 0 )
{
v34 = GJEffectManager::activeColorForIndex(*((GJEffectManager **)this + 381), (int)v31);
LOWORD(v57[0]) = v34;
BYTE2(v57[0]) = BYTE2(v34);
}
if ( *(__int16 *)(v8 + 1020) > 0 )
{
v42 = 0;
while ( v42 < *(__int16 *)(v8 + 1020) )
{
v50 = v42;
v54 = *((_DWORD *)this + 381);
v43 = GameObject::getGroupID((GameObject *)v8, v42);
v44 = GJEffectManager::colorForGroupID(v54, v43, v57, 0);
v42 = v50 + 1;
LOWORD(v57[0]) = v44;
BYTE2(v57[0]) = BYTE2(v44);
}
}
}
v49 = (_DWORD *)(*(_DWORD *)(v8 + 964) + 16);
v53 = *(_DWORD *)(v8 + 964);
v35 = sub_45F7AC((int)v49);
v36 = v49;
if ( !v35 )
{
v37 = GJEffectManager::colorForEffect(
*((_DWORD *)this + 381),
v57[0],
*v49,
v49[1],
*(_DWORD *)(v53 + 24),
*(_DWORD *)(v53 + 28),
v45,
v46,
v49);
LOWORD(v57[0]) = v37;
BYTE2(v57[0]) = BYTE2(v37);
}
(*(void (__fastcall **)(int, _DWORD *, _DWORD *))(*(_DWORD *)v8 + 796))(v8, v57, v36);
if ( v32 <= 0 )
v38 = 1.0;
else
v38 = COERCE_FLOAT(GJEffectManager::activeOpacityForIndex(*((GJEffectManager **)this + 381), v32));
if ( *(__int16 *)(v8 + 1020) > 0 )
{
for ( j = 0; j < *(__int16 *)(v8 + 1020); ++j )
{
v40 = *((GJEffectManager **)this + 381);
v41 = GameObject::getGroupID((GameObject *)v8, j);
v38 = v38 * COERCE_FLOAT(GJEffectManager::opacityModForGroup(v40, v41));
}
}
*(float *)(*(_DWORD *)(v8 + 964) + 8) = v38;
}
if ( *(_BYTE *)(v8 + 755) )
AnimatedGameObject::updateChildSpriteColor(v8, v55);
++v4;
}
return result;
}