//
// CharacterColorPage::updateColorMode from 0x1400a20e0 to 0x1400a2674 (1428 bytes)
//
// 3 xrefs:
// > CharacterColorPage::init @ 0x1400a14e4
// > CharacterColorPage::onMode @ 0x1400a20b6
// > ??> @ 0x1409130dc
//
// This function is hookable on this platform (idp: pc, 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 11:26:07 +0000
//
// Hidden C++ exception states: #wind=11
__int64 __fastcall CharacterColorPage::updateColorMode(__int64 a1, int a2)
{
int *v3; // r15
_DWORD *v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 i; // r14
__int64 v8; // r13
__int64 v9; // rax
unsigned int v10; // r12d
__int64 v11; // rax
__int64 v12; // rbx
__int64 v13; // rdi
__int64 v14; // rax
__int64 v15; // rax
struct cocos2d::CCObject *v16; // rax
struct cocos2d::CCObject *v17; // rax
struct cocos2d::CCObject *v18; // rax
int v19; // ebx
__int64 v20; // rcx
unsigned __int8 isColorUnlocked; // bl
void (__fastcall ***v22)(_QWORD, _QWORD); // rdi
int v23; // ebx
__int64 v24; // rcx
__int16 *v25; // rdx
struct cocos2d::CCObject *v26; // rbx
struct cocos2d::CCObject *v27; // r14
void (__fastcall *v28)(char *, void **); // r9
const char *v29; // rdi
char *v30; // rcx
__int64 v31; // rax
const char *v32; // rdx
__int64 v33; // rax
struct cocos2d::CCObject *v34; // rbx
struct cocos2d::CCObject *v35; // r14
char *v36; // rcx
void (__fastcall *v37)(char *, __int16 *); // r8
__int64 v38; // rax
const char *v39; // rdx
__int64 v40; // rax
struct cocos2d::CCObject *v41; // rbx
struct cocos2d::CCObject *v42; // r14
char *v43; // rcx
void (__fastcall *v44)(char *, __int16 *); // r9
__int64 v45; // rax
__int64 v46; // rax
bool v47; // bl
int v49; // [rsp+20h] [rbp-38h]
int v50; // [rsp+24h] [rbp-34h]
int v51; // [rsp+28h] [rbp-30h]
_BYTE v52[8]; // [rsp+30h] [rbp-28h] BYREF
_BYTE v53[8]; // [rsp+38h] [rbp-20h] BYREF
void *v54; // [rsp+40h] [rbp-18h]
void *v55; // [rsp+48h] [rbp-10h]
void *v56; // [rsp+A0h] [rbp+48h] BYREF
__int16 v57; // [rsp+A8h] [rbp+50h]
__int16 v58; // [rsp+B0h] [rbp+58h]
__int16 v59; // [rsp+B8h] [rbp+60h] BYREF
char v60; // [rsp+BAh] [rbp+62h]
v3 = (int *)(a1 + 664);
*(_DWORD *)(a1 + 664) = a2;
v4 = (_DWORD *)qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v56 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v56);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v4 = (_DWORD *)qword_14090BFD0;
}
v49 = v4[211] - v4[212];
v50 = v4[214] - v4[215];
v51 = v4[217] - v4[218];
v5 = *(_QWORD *)(a1 + 696);
if ( v5 )
{
v6 = *(_QWORD *)(v5 + 56);
if ( v6 )
{
for ( i = *(_QWORD *)(v6 + 288); ; i = *(_QWORD *)(i + 288) )
{
v8 = *(_QWORD *)(v6 + 264);
v9 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 504LL))(v8);
v10 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 56LL))(v9);
v11 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 504LL))(v8);
v12 = *(_QWORD *)(a1 + 552);
v13 = *(_QWORD *)(a1 + 584);
v14 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 200LL))(v11);
cocos2d::CCNode::convertToWorldSpace(v12, v53, v14);
cocos2d::CCNode::convertToNodeSpace(v13, v52, v15);
if ( v10 == v49 )
{
v16 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 0);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v16 + 184LL))(v16, v52);
}
if ( v10 == v50 )
{
v17 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 1u);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v17 + 184LL))(v17, v52);
}
if ( v10 == v51 )
{
v18 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 2u);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v18 + 184LL))(v18, v52);
}
v19 = *v3;
v20 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v54 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v20 = qword_14090BFD0;
}
isColorUnlocked = GameManager::isColorUnlocked(v20, v10, (unsigned int)(v19 != 0) + 2);
v22 = (void (__fastcall ***)(_QWORD, _QWORD))(*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v8 + 472LL))(
v8,
100);
(*v22)[42](v22, isColorUnlocked ^ 1u);
if ( isColorUnlocked )
goto LABEL_19;
v23 = *v3;
v24 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v55 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480(v55);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v24 = qword_14090BFE0;
}
if ( (unsigned int)GameStatsManager::getItemUnlockState(v24, v10, (unsigned int)(v23 != 0) + 2) )
{
LABEL_19:
v58 = -1;
v59 = -1;
v60 = -1;
v25 = &v59;
}
else
{
v57 = -256;
LOWORD(v56) = -256;
BYTE2(v56) = 0;
v25 = (__int16 *)&v56;
}
(*v22[40])(v22 + 40, v25);
v6 = i;
if ( !i )
break;
}
v3 = (int *)(a1 + 664);
}
}
v26 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 0);
v27 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 688), 0);
v28 = **((void (__fastcall ***)(char *, void **))v26 + 40);
v29 = "GJ_button_04.png";
v30 = (char *)v26 + 320;
if ( *v3 )
{
v57 = 12850;
memset(&v56, 50, 3);
v28(v30, &v56);
v31 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v26 + 504LL))(v26);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v31 + 584LL))(v31, v26, 1);
v32 = "GJ_button_04.png";
}
else
{
v58 = -1;
v59 = -1;
v60 = -1;
v28(v30, (void **)&v59);
v33 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v26 + 504LL))(v26);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v33 + 584LL))(v33, v26, 11);
v32 = "GJ_button_01.png";
}
ButtonSprite::updateBGImage((__int64)v27, v32);
v34 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 1u);
v35 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 688), 1u);
v36 = (char *)v34 + 320;
v37 = **((void (__fastcall ***)(char *, __int16 *))v34 + 40);
if ( *v3 == 1 )
{
v58 = -1;
v59 = -1;
v60 = -1;
v37(v36, &v59);
v40 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v34 + 504LL))(v34);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v40 + 584LL))(v40, v34, 11);
v39 = "GJ_button_01.png";
}
else
{
v57 = 12850;
memset(&v56, 50, 3);
v37(v36, (__int16 *)&v56);
v38 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v34 + 504LL))(v34);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v38 + 584LL))(v38, v34, 1);
v39 = "GJ_button_04.png";
}
ButtonSprite::updateBGImage((__int64)v35, v39);
v41 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 704), 2u);
v42 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 688), 2u);
v43 = (char *)v41 + 320;
v44 = **((void (__fastcall ***)(char *, __int16 *))v41 + 40);
if ( *v3 == 2 )
{
v58 = -1;
v59 = -1;
v60 = -1;
v44(v43, &v59);
v46 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v41 + 504LL))(v41);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v46 + 584LL))(v46, v41, 11);
v29 = "GJ_button_01.png";
}
else
{
v57 = 12850;
memset(&v56, 50, 3);
v44(v43, (__int16 *)&v56);
v45 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v41 + 504LL))(v41);
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, __int64))(*(_QWORD *)v45 + 584LL))(v45, v41, 1);
}
ButtonSprite::updateBGImage((__int64)v42, v29);
v47 = *v3 == 2;
(*(void (__fastcall **)(_QWORD, bool))(**(_QWORD **)(a1 + 720) + 936LL))(*(_QWORD *)(a1 + 720), v47);
(*(void (__fastcall **)(_QWORD, bool))(**(_QWORD **)(a1 + 720) + 336LL))(*(_QWORD *)(a1 + 720), v47);
return (*(__int64 (__fastcall **)(_QWORD, bool))(**(_QWORD **)(a1 + 728) + 336LL))(*(_QWORD *)(a1 + 728), v47);
}