//
// ColorSelectPopup::determineStartValues from 0x3d9914 to 0x3d9cfa (998 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void ColorSelectPopup::determineStartValues(ColorSelectPopup *a1)
{
cocos2d::CCArray *v2; // r0
cocos2d::CCArray *m_gameObjects; // r7
float v4; // s16
int v5; // r6
unsigned int v6; // r11
int v7; // r10
int v8; // r8
int v9; // r9
float v10; // r0
float v11; // r1
float v12; // r2
int v13; // r3
float v14; // s17
int v15; // r0
int m_playerColor; // r3
int v17; // r3
int v18; // r3
bool v19; // r3
float *v20; // r3
float *v21; // r3
int v22; // r1
int v23; // r2
int v24; // r3
float v25; // r1
float v26; // r2
int v27; // r3
int v28; // r3
int m_colorID; // r2
int v30; // r3
int m_copyColorID; // r2
int v32; // r3
ColorAction *m_colorAction; // r3
int v34; // r2
bool v35; // r1
cocos2d::ccHSVValue *p_m_copyHSV; // r3
GLubyte h_low; // r0
GLubyte v38; // r1
int v39; // [sp+0h] [bp-2Ch]
float s; // [sp+1Ch] [bp-10h]
float v; // [sp+20h] [bp-Ch]
int v42; // [sp+24h] [bp-8h]
SetupTriggerPopup::determineStartValues(a1);
if ( a1->m_gameObject )
{
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::create(v2);
cocos2d::CCArray::addObject(m_gameObjects, a1->m_gameObject);
}
else
{
m_gameObjects = a1->m_gameObjects;
}
if ( m_gameObjects && cocos2d::CCArray::count(m_gameObjects) )
{
v4 = -1.0;
a1->m_opacity = 1.0;
a1->m_playerColor = -1;
v5 = 1;
a1->m_colorID = -1;
a1->m_copyColorID = -1;
v6 = 0;
v7 = 0;
v8 = 0;
v9 = 0;
*(_WORD *)&a1->m_currentColor.r = -1;
a1->m_currentColor.b = -1;
v10 = *(float *)&dword_AC5FC4;
v11 = *(float *)&dword_AC5FC8;
v12 = *(float *)&dword_AC5FCC;
v13 = *(_DWORD *)&byte_AC5FD0;
v14 = -1.0;
a1->m_blending = 1;
a1->m_copyOpacity = 1;
a1->m_backgroundTrigger = 1;
a1->m_tintGround = 1;
a1->m_legacyHSV = 1;
a1->m_hsv.h = v10;
a1->m_hsv.s = v11;
a1->m_hsv.v = v12;
*(_DWORD *)&a1->m_hsv.absoluteSaturation = v13;
v39 = 1;
while ( 1 )
{
if ( v6 >= cocos2d::CCArray::count(m_gameObjects) )
{
if ( v14 >= 0.0 )
a1->m_fadeTime = v14;
if ( v4 >= 0.0 )
a1->m_opacity = v4;
goto LABEL_80;
}
v15 = cocos2d::CCArray::objectAtIndex(m_gameObjects, v6);
if ( !*(_BYTE *)(v15 + 1444) )
a1->m_copyOpacity = 0;
if ( !*(_BYTE *)(v15 + 1448) )
a1->m_legacyHSV = 0;
if ( !v8 )
{
m_playerColor = a1->m_playerColor;
if ( m_playerColor == -1 )
{
if ( *(_BYTE *)(v15 + 1297) )
{
v17 = 1;
LABEL_18:
a1->m_playerColor = v17;
goto LABEL_24;
}
if ( *(_BYTE *)(v15 + 1298) )
{
v17 = 2;
goto LABEL_18;
}
a1->m_playerColor = 0;
}
else if ( *(_BYTE *)(v15 + 1297) && m_playerColor != 1 || *(_BYTE *)(v15 + 1298) && m_playerColor != 2 )
{
v8 = 1;
a1->m_playerColor = 0;
}
}
LABEL_24:
if ( *(_DWORD *)(v15 + 884) == 29 )
{
if ( a1->m_tintGround )
a1->m_tintGround = *(_BYTE *)(v15 + 1296);
}
else
{
a1->m_backgroundTrigger = 0;
}
if ( a1->m_blending == 1 )
a1->m_blending = *(unsigned __int8 *)(v15 + 1299);
if ( !a1->m_colorTrigger )
{
v18 = *(_DWORD *)(v15 + 884);
v19 = v18 == 744 || v18 == 899 || v18 == 915;
a1->m_colorTrigger = v19;
}
if ( !a1->m_newColorTrigger )
a1->m_newColorTrigger = *(_DWORD *)(v15 + 884) == 899;
v20 = (float *)(v15 + 1264);
if ( v14 == -1.0 )
{
v14 = *v20;
}
else if ( v14 != *v20 )
{
v14 = -2.0;
}
v21 = (float *)(v15 + 1268);
if ( v4 == -1.0 )
{
v4 = *v21;
}
else if ( v4 != *v21 )
{
v4 = -2.0;
}
if ( !v9 )
{
v22 = *(unsigned __int8 *)(v15 + 1260);
v23 = *(unsigned __int8 *)(v15 + 1261);
v24 = *(unsigned __int8 *)(v15 + 1262);
if ( v39 )
{
a1->m_currentColor.r = v22;
a1->m_currentColor.g = v23;
a1->m_currentColor.b = v24;
v39 = 0;
}
else if ( a1->m_currentColor.r != v22 || a1->m_currentColor.g != v23 || a1->m_currentColor.b != v24 )
{
v9 = 1;
*(_WORD *)&a1->m_currentColor.r = -1;
a1->m_currentColor.b = -1;
}
}
if ( !v7 )
{
v25 = *(float *)(v15 + 1428);
v26 = *(float *)(v15 + 1432);
v27 = *(_DWORD *)(v15 + 1436);
if ( v5 )
{
v5 = 0;
a1->m_hsv.h = *(float *)(v15 + 1424);
a1->m_hsv.s = v25;
a1->m_hsv.v = v26;
*(_DWORD *)&a1->m_hsv.absoluteSaturation = v27;
goto LABEL_63;
}
if ( a1->m_hsv.h == *(float *)(v15 + 1424)
&& a1->m_hsv.s == *(float *)(v15 + 1428)
&& a1->m_hsv.v == *(float *)(v15 + 1432) )
{
v28 = *(unsigned __int16 *)&a1->m_hsv.absoluteSaturation
- (unsigned __int16)v27
+ (*(unsigned __int16 *)&a1->m_hsv.absoluteSaturation == (unsigned __int16)v27)
+ (unsigned __int16)v27
- *(unsigned __int16 *)&a1->m_hsv.absoluteSaturation;
if ( v28 )
goto LABEL_63;
}
else
{
LOBYTE(v28) = 0;
}
a1->m_hsv.h = -0.001;
v7 = 1;
a1->m_hsv.absoluteSaturation = v28;
a1->m_hsv.absoluteBrightness = v28;
a1->m_hsv.s = 0.0;
a1->m_hsv.v = 0.0;
}
LABEL_63:
m_colorID = a1->m_colorID;
v30 = *(_DWORD *)(v15 + 880);
if ( m_colorID != -1 )
{
if ( m_colorID == v30 )
goto LABEL_67;
v30 = 0;
}
a1->m_colorID = v30;
LABEL_67:
m_copyColorID = a1->m_copyColorID;
v32 = *(_DWORD *)(v15 + 1440);
if ( m_copyColorID != -1 )
{
if ( m_copyColorID == v32 )
goto LABEL_71;
v32 = 0;
}
a1->m_copyColorID = v32;
LABEL_71:
++v6;
}
}
m_colorAction = a1->m_colorAction;
if ( m_colorAction )
{
a1->m_backgroundTrigger = 0;
a1->m_playerColor = m_colorAction->m_playerColor;
a1->m_blending = m_colorAction->m_blending;
a1->m_opacity = m_colorAction->m_fromOpacity;
v34 = m_colorAction->m_colorID;
v35 = (unsigned int)(v34 - 1002) <= 1 || (unsigned int)(v34 - 1) <= 0x3E6;
a1->m_colorTrigger = v35;
p_m_copyHSV = &m_colorAction->m_copyHSV;
a1->m_noChannel = v34 == 0;
h_low = LOBYTE(p_m_copyHSV[-2].h);
v38 = BYTE1(p_m_copyHSV[-2].h);
a1->m_currentColor.b = BYTE2(p_m_copyHSV[-2].h);
a1->m_currentColor.r = h_low;
a1->m_currentColor.g = v38;
a1->m_fadeTime = 0.0;
a1->m_copyColorID = LODWORD(p_m_copyHSV[1].h);
a1->m_copyOpacity = BYTE1(p_m_copyHSV[1].s);
s = p_m_copyHSV->s;
v = p_m_copyHSV->v;
v42 = *(_DWORD *)&p_m_copyHSV->absoluteSaturation;
a1->m_hsv.h = p_m_copyHSV->h;
a1->m_hsv.s = s;
a1->m_hsv.v = v;
*(_DWORD *)&a1->m_hsv.absoluteSaturation = v42;
}
LABEL_80:
a1->m_showCopyObjects = a1->m_copyColorID != 0;
a1->m_colorTrigger = 1;
}