//
// LevelEditorLayer::resetUnusedColorChannels from 0x4738f0 to 0x473de0 (1264 bytes)
//
// 2 xrefs:
// > EditorUI::handleEditorAction @ 0x6f20e2
// > EditorCommandsPopup::onCommand @ 0x77a856
//
// 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:49:06 +0000
//
int __fastcall LevelEditorLayer::resetUnusedColorChannels(LevelEditorLayer *this)
{
int AllObjects; // r0
int v3; // r3
_DWORD *v4; // r3
GameObject **v5; // r6
GameObject *v6; // r4
GameObject *v7; // t1
_DWORD *v8; // r3
GameObject **v9; // r7
GameObject **v10; // r11
int v11; // r3
GameObject *v12; // r0
GameObject *v13; // t1
int v14; // r3
int v15; // r4
int v17; // r2
GJSpriteColor *SecondaryColorMode; // r0
unsigned int v19; // r10
unsigned int v20; // r4
unsigned int v21; // r11
unsigned int v22; // r5
_DWORD *v23; // r3
unsigned int v24; // r0
int v25; // r1
float v26; // s15
bool v27; // r5
unsigned int v28; // r5
unsigned int v29; // r1
_DWORD *v30; // r3
unsigned int v31; // r0
int v32; // r1
unsigned int v33; // r10
unsigned int v34; // r4
unsigned int v35; // r11
unsigned int v36; // r5
int **v37; // r3
int *v38; // r0
int v39; // r1
float v40; // s15
bool v41; // r5
unsigned int v42; // r5
unsigned int v43; // r1
_DWORD *v44; // r3
unsigned int v45; // r0
int v46; // r1
int ColorIndex; // r0
unsigned int v48; // r6
unsigned int v49; // r4
unsigned int v50; // r10
int v51; // r5
_DWORD *v52; // r3
unsigned int v53; // r0
int v54; // r1
float v55; // s15
bool v56; // r5
unsigned int v57; // r5
unsigned int v58; // r1
_DWORD *v59; // r3
unsigned int v60; // r0
int v61; // r1
GameObject **v62; // [sp+0h] [bp-54h]
unsigned int MainColorMode; // [sp+10h] [bp-44h] BYREF
void *v64; // [sp+14h] [bp-40h] BYREF
_DWORD v65[3]; // [sp+20h] [bp-34h] BYREF
void *v66[3]; // [sp+2Ch] [bp-28h] BYREF
int v67; // [sp+38h] [bp-1Ch] BYREF
unsigned int v68; // [sp+3Ch] [bp-18h]
void *v69; // [sp+40h] [bp-14h] BYREF
int v70; // [sp+44h] [bp-10h]
float v71; // [sp+48h] [bp-Ch]
v67 = 0;
v68 = 0;
v69 = nullptr;
v70 = 0;
v71 = 1.0;
AllObjects = LevelEditorLayer::getAllObjects(this);
if ( AllObjects )
{
v4 = *(_DWORD **)(AllObjects + 52);
if ( *v4 )
{
v5 = (GameObject **)v4[3];
v62 = &v5[*v4] + 0x3FFFFFFF;
while ( 1 )
{
LABEL_6:
if ( v5 > v62 )
goto LABEL_2;
v7 = *v5++;
v6 = v7;
if ( !v7 )
goto LABEL_2;
MainColorMode = (unsigned int)GameObject::getMainColorMode(v6);
SecondaryColorMode = GameObject::getSecondaryColorMode(v6);
v19 = MainColorMode;
v66[0] = SecondaryColorMode;
if ( (int)MainColorMode >= 1000 )
goto LABEL_58;
v20 = v68;
if ( v68 )
{
v21 = v68 - 1;
if ( ((v68 - 1) & v68) != 0 )
v22 = MainColorMode % v68;
else
v22 = v21 & MainColorMode;
v23 = *(_DWORD **)(v67 + 4 * v22);
if ( v23 )
{
while ( 1 )
{
v23 = (_DWORD *)*v23;
if ( !v23 )
break;
v24 = v23[1];
v25 = ((v68 - 1) & v68) != 0 ? v24 % v68 : v21 & v24;
if ( v25 != v22 )
break;
if ( v23[2] == MainColorMode )
goto LABEL_58;
}
}
}
else
{
v22 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)&v64,
(int)&v67,
MainColorMode,
&MainColorMode);
v26 = (float)(unsigned int)(v70 + 1);
if ( v26 > (float)((float)v20 * v71) )
break;
if ( !v20 )
{
v27 = 0;
LABEL_44:
v28 = 2 * v20 + !v27;
v29 = (unsigned int)ceilf(v26 / v71);
if ( v29 < v28 )
v29 = v28;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v67, v29);
v20 = v68;
if ( ((v68 - 1) & v68) != 0 )
v22 = v19 % v68;
else
v22 = (v68 - 1) & v19;
}
v30 = *(_DWORD **)(v67 + 4 * v22);
if ( v30 )
{
*(_DWORD *)v64 = *v30;
*v30 = v64;
}
else
{
*(_DWORD *)v64 = v69;
v69 = v64;
*(_DWORD *)(v67 + 4 * v22) = &v69;
if ( *(_DWORD *)v64 )
{
v31 = *(_DWORD *)(*(_DWORD *)v64 + 4);
if ( ((v20 - 1) & v20) != 0 )
v32 = v31 % v20;
else
v32 = (v20 - 1) & v31;
*(_DWORD *)(v67 + 4 * v32) = v64;
}
}
++v70;
LABEL_58:
v33 = (unsigned int)v66[0];
if ( (int)v66[0] < 1000 )
{
v34 = v68;
if ( v68 )
{
v35 = v68 - 1;
if ( ((v68 - 1) & v68) != 0 )
v36 = (unsigned int)v66[0] % v68;
else
v36 = v35 & (unsigned int)v66[0];
v37 = *(int ***)(v67 + 4 * v36);
if ( v37 )
{
while ( 1 )
{
v37 = (int **)*v37;
if ( !v37 )
break;
v38 = v37[1];
v39 = ((v68 - 1) & v68) != 0 ? (unsigned int)v38 % v68 : v35 & (unsigned int)v38;
if ( v39 != v36 )
break;
if ( v37[2] == v66[0] )
goto LABEL_6;
}
}
}
else
{
v36 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)v65,
(int)&v67,
(int)v66[0],
v66);
v40 = (float)(unsigned int)(v70 + 1);
if ( v40 > (float)((float)v34 * v71) )
{
v41 = v34 > 2 && ((v34 - 1) & v34) == 0;
}
else
{
if ( v34 )
goto LABEL_79;
v41 = 0;
}
v42 = 2 * v34 + !v41;
v43 = (unsigned int)ceilf(v40 / v71);
if ( v43 < v42 )
v43 = v42;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v67, v43);
v34 = v68;
if ( ((v68 - 1) & v68) != 0 )
v36 = v33 % v68;
else
v36 = (v68 - 1) & v33;
LABEL_79:
v44 = *(_DWORD **)(v67 + 4 * v36);
if ( v44 )
{
*(_DWORD *)v65[0] = *v44;
*v44 = v65[0];
}
else
{
*(_DWORD *)v65[0] = v69;
v69 = (void *)v65[0];
*(_DWORD *)(v67 + 4 * v36) = &v69;
if ( *(_DWORD *)v65[0] )
{
v45 = *(_DWORD *)(*(_DWORD *)v65[0] + 4);
if ( ((v34 - 1) & v34) != 0 )
v46 = v45 % v34;
else
v46 = (v34 - 1) & v45;
*(_DWORD *)(v67 + 4 * v46) = v65[0];
}
}
++v70;
}
}
v27 = v20 > 2 && ((v20 - 1) & v20) == 0;
goto LABEL_44;
}
}
LABEL_2:
v3 = *((_DWORD *)this + 2933);
if ( v3 )
{
v8 = *(_DWORD **)(v3 + 52);
if ( *v8 )
{
v9 = (GameObject **)v8[3];
v10 = &v9[*v8] + 0x3FFFFFFF;
while ( 1 )
{
do
{
LABEL_11:
if ( v9 > v10 )
goto LABEL_12;
v13 = *v9++;
v12 = v13;
if ( !v13 )
goto LABEL_12;
ColorIndex = GameObject::getColorIndex(v12);
v48 = ColorIndex;
v65[0] = ColorIndex;
}
while ( ColorIndex >= 1000 );
v49 = v68;
if ( v68 )
{
v50 = v68 - 1;
if ( ((v68 - 1) & v68) != 0 )
v51 = ColorIndex % v68;
else
v51 = ColorIndex & v50;
v52 = *(_DWORD **)(v67 + 4 * v51);
if ( v52 )
{
while ( 1 )
{
v52 = (_DWORD *)*v52;
if ( !v52 )
break;
v53 = v52[1];
v54 = ((v68 - 1) & v68) != 0 ? v53 % v68 : v50 & v53;
if ( v54 != v51 )
break;
if ( v52[2] == v48 )
goto LABEL_11;
}
}
}
else
{
v51 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)v66,
(int)&v67,
v48,
v65);
v55 = (float)(unsigned int)(v70 + 1);
if ( v55 > (float)((float)v49 * v71) )
{
v56 = v49 > 2 && ((v49 - 1) & v49) == 0;
}
else
{
if ( v49 )
goto LABEL_116;
v56 = 0;
}
v57 = 2 * v49 + !v56;
v58 = (unsigned int)ceilf(v55 / v71);
if ( v58 < v57 )
v58 = v57;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v67, v58);
v49 = v68;
if ( ((v68 - 1) & v68) != 0 )
v51 = v48 % v68;
else
v51 = (v68 - 1) & v48;
LABEL_116:
v59 = *(_DWORD **)(v67 + 4 * v51);
if ( v59 )
{
*(_DWORD *)v66[0] = *v59;
*v59 = v66[0];
}
else
{
*(_DWORD *)v66[0] = v69;
v69 = v66[0];
*(_DWORD *)(v67 + 4 * v51) = &v69;
if ( *(_DWORD *)v66[0] )
{
v60 = *(_DWORD *)(*(_DWORD *)v66[0] + 4);
if ( ((v49 - 1) & v49) != 0 )
v61 = v60 % v49;
else
v61 = (v49 - 1) & v60;
*(void **)(v67 + 4 * v61) = v66[0];
}
}
++v70;
}
}
}
LABEL_12:
v11 = *(_DWORD *)(*(_DWORD *)(*((_DWORD *)this + 521) + 264) + 268);
if ( v11 )
{
v14 = *(_DWORD *)(v11 + 52);
if ( v14 )
v15 = *(_DWORD *)(v14 + 272);
else
v15 = 0;
while ( v14 )
{
v66[0] = *(void **)(*(_DWORD *)(v14 + 260) + 88);
if ( (unsigned int)v66[0] - 1 <= 0x3E6
&& !std::__hash_table,std::equal_to,std::allocator>::find(
&v67,
(unsigned int *)v66) )
{
GJEffectManager::removeColorAction(*(GJEffectManager **)(*((_DWORD *)this + 521) + 264), (int)v66[0]);
}
if ( v15 )
v17 = *(_DWORD *)(v15 + 272);
else
v17 = 0;
v14 = v15;
v15 = v17;
}
}
return std::__hash_table,std::equal_to,std::allocator>::~__hash_table((int)&v67);
}