//
// CharacterColorPage::updateColorMode from 0xb51530 to 0xb518ac (892 bytes)
//
// 3 xrefs:
// > CharacterColorPage::onMode @ 0xb51e2c
// > CharacterColorPage::init @ 0xb52ba0
// > ??> @ 0xb54f8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:01:59 +0000
//
__int64 __fastcall CharacterColorPage::updateColorMode(CharacterColorPage *this, int a2)
{
__int64 v3; // x0
__int64 v4; // x0
__int64 i; // x22
__int64 v6; // x28
__int64 v7; // x0
unsigned int v8; // w20
cocos2d::CCNode *v9; // x24
cocos2d::CCNode *v10; // x26
__int64 v11; // x0
const cocos2d::CCPoint *v12; // x0
unsigned __int64 v13; // x0
__int64 v14; // x0
unsigned int v15; // w2
int isColorUnlocked; // w24
__int64 v17; // x28
GameStatsManager *v18; // x0
void (__fastcall *v19)(__int64, __int64 *); // x2
__int64 v20; // x0
unsigned int v21; // w2
void (__fastcall *v22)(__int64, __int64 *); // x2
unsigned int j; // w20
__int64 v24; // x22
ButtonSprite *v25; // x24
void (__fastcall *v26)(__int64, __int64 *); // x3
__int64 v27; // x0
__int64 v29; // x0
__int64 v30; // x0
__int64 v31; // x0
void (__fastcall *v32)(__int64, __int64 *); // x2
__int64 v33; // x0
unsigned int v34; // [xsp+64h] [xbp+64h]
int v35; // [xsp+68h] [xbp+68h]
int active; // [xsp+6Ch] [xbp+6Ch]
__int64 v37; // [xsp+78h] [xbp+78h] BYREF
__int64 v38; // [xsp+80h] [xbp+80h] BYREF
*((_DWORD *)this + 165) = a2;
active = CharacterColorPage::activeColorForMode(this, 0);
v35 = CharacterColorPage::activeColorForMode(this, 1);
v34 = CharacterColorPage::activeColorForMode(this, 2);
v3 = *((_QWORD *)this + 86);
if ( v3 )
{
v4 = *(_QWORD *)(v3 + 56);
if ( v4 )
{
for ( i = *(_QWORD *)(v4 + 288); ; i = *(_QWORD *)(i + 288) )
{
v6 = *(_QWORD *)(v4 + 264);
v7 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 512LL))(v6);
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 64LL))(v7);
v9 = *((cocos2d::CCNode **)this + 73);
v10 = *((cocos2d::CCNode **)this + 69);
v11 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 512LL))(v6);
v12 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 192LL))(v11);
cocos2d::CCNode::convertToWorldSpace(&v38, v10, v12);
cocos2d::CCNode::convertToNodeSpace(&v37, v9, (const cocos2d::CCPoint *)&v38);
if ( active == v8 )
{
v31 = cocos2d::CCArray::objectAtIndex(*((cocos2d::CCArray **)this + 87), 0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v31 + 184LL))(v31, &v37);
}
if ( v35 == v8 )
{
v30 = cocos2d::CCArray::objectAtIndex(*((cocos2d::CCArray **)this + 87), 1u);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v30 + 184LL))(v30, &v37);
}
v13 = v34;
if ( v34 == v8 )
{
v29 = cocos2d::CCArray::objectAtIndex(*((cocos2d::CCArray **)this + 87), 2u);
v13 = (*(__int64 (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v29 + 184LL))(v29, &v37);
}
v14 = GameManager::sharedState((GameManager *)v13);
if ( *((_DWORD *)this + 165) )
v15 = 3;
else
v15 = 2;
isColorUnlocked = (unsigned __int8)GameManager::isColorUnlocked(v14, v8, v15);
v17 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v6 + 480LL))(v6, 100);
v18 = (GameStatsManager *)(*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v17 + 344LL))(
v17,
isColorUnlocked ^ 1u);
if ( isColorUnlocked
|| ((v20 = GameStatsManager::sharedState(v18), *((_DWORD *)this + 165)) ? (v21 = 3) : (v21 = 2),
(unsigned int)GameStatsManager::getItemUnlockState(v20, v8, v21)) )
{
v19 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v17 + 960LL);
LOWORD(v38) = -1;
BYTE2(v38) = -1;
v19(v17, &v38);
if ( !i )
break;
}
else
{
v22 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v17 + 960LL);
LOBYTE(v38) = 0;
*(_WORD *)((char *)&v38 + 1) = 255;
v22(v17, &v38);
if ( !i )
break;
}
v4 = i;
}
}
}
for ( j = 0; j != 3; ++j )
{
v24 = cocos2d::CCArray::objectAtIndex(*((cocos2d::CCArray **)this + 87), j);
v25 = (ButtonSprite *)cocos2d::CCArray::objectAtIndex(*((cocos2d::CCArray **)this + 85), j);
if ( *((_DWORD *)this + 165) == j )
{
v32 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v24 + 960LL);
LOWORD(v38) = -1;
BYTE2(v38) = -1;
v32(v24, &v38);
v33 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v24 + 512LL))(v24);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v33 + 592LL))(v33, v24, 11);
ButtonSprite::updateBGImage(v25, "GJ_button_01.png");
}
else
{
v26 = *(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v24 + 960LL);
memset(&v38, 50, 3);
v26(v24, &v38);
v27 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v24 + 512LL))(v24);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v27 + 592LL))(v27, v24, 1);
ButtonSprite::updateBGImage(v25, "GJ_button_04.png");
}
}
CharacterColorPage::toggleGlowItems(this, *((_DWORD *)this + 165) == 2);
return _stack_chk_guard;
}