//
// ConfigureHSVWidget::getHSV from 0x140098160 to 0x1400983a4 (580 bytes)
//
// 9 xrefs:
// > CustomizeObjectLayer::updateHSVButtons @ 0x1400a89cd
// > CustomizeObjectLayer::updateHSVButtons @ 0x1400a89f9
// > CustomizeObjectLayer::onHSV @ 0x1400a8cbe
// > CustomizeObjectLayer::onHSV @ 0x1400a8d39
// > HSVLiveOverlay::createHSVWidget @ 0x1402ba1c3
// > ??> @ 0x140669a30
// > ??> @ 0x140669a64
// > ??> @ 0x140669a74
// > ??> @ 0x1406c7338
//
// 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
//
cocos2d::ccHSVValue *ConfigureHSVWidget::getHSV(
cocos2d::ccHSVValue *__return_ptr retstr,
GameObject *a2,
cocos2d::CCArray *a3,
int a4)
{
unsigned int v7; // ebx
char v8; // r14
cocos2d::ccHSVValue v9; // xmm6
char v10; // r15
__int8 absoluteSaturation; // r12
float h; // xmm9_4
float v13; // xmm7_4
float v14; // xmm8_4
struct cocos2d::CCObject *v15; // rcx
cocos2d::CCObjectType m_eObjType; // eax
GJSpriteColor *RelativeSpriteColor; // rax
__m128 m_hsv; // xmm1
cocos2d::ccHSVValue v20; // [rsp+20h] [rbp-78h]
if ( a2 )
a3 = cocos2d::CCArray::createWithObject(a2);
if ( !a3 )
{
*retstr = (cocos2d::ccHSVValue)unk_1406BA128;
return retstr;
}
v7 = 0;
v8 = 1;
v9 = (cocos2d::ccHSVValue)unk_1406BA128;
if ( !cocos2d::CCArray::count(a3) )
{
LABEL_21:
*retstr = v9;
return retstr;
}
v10 = _mm_cvtsi128_si32(_mm_srli_si128((__m128i)v9, 13));
absoluteSaturation = v9.absoluteSaturation;
h = v9.h;
v13 = _mm_shuffle_ps((__m128)v9, (__m128)v9, 170).m128_f32[0];
v14 = _mm_shuffle_ps((__m128)v9, (__m128)v9, 85).m128_f32[0];
while ( 1 )
{
v15 = cocos2d::CCArray::objectAtIndex(a3, v7);
m_eObjType = v15[18].m_eObjType;
if ( m_eObjType == 1006 || m_eObjType == 899 )
break;
RelativeSpriteColor = GameObject::getRelativeSpriteColor((GameObject *)v15, a4);
if ( RelativeSpriteColor )
{
m_hsv = (__m128)RelativeSpriteColor->m_hsv;
goto LABEL_12;
}
LABEL_20:
if ( ++v7 >= cocos2d::CCArray::count(a3) )
goto LABEL_21;
}
if ( a4 != 1 )
goto LABEL_20;
m_hsv = *(__m128 *)((char *)&v15[29].__vftable + 4);
LABEL_12:
if ( m_hsv.m128_f32[0] == -0.001 )
goto LABEL_20;
if ( v8 )
{
v9 = (cocos2d::ccHSVValue)m_hsv;
v10 = _mm_cvtsi128_si32(_mm_srli_si128((__m128i)m_hsv, 13));
v8 = 0;
v13 = _mm_shuffle_ps(m_hsv, m_hsv, 170).m128_f32[0];
h = m_hsv.m128_f32[0];
v14 = _mm_shuffle_ps(m_hsv, m_hsv, 85).m128_f32[0];
absoluteSaturation = m_hsv.m128_i8[12];
goto LABEL_20;
}
if ( h == m_hsv.m128_f32[0]
&& v14 == _mm_shuffle_ps(m_hsv, m_hsv, 85).m128_f32[0]
&& v13 == _mm_shuffle_ps(m_hsv, m_hsv, 170).m128_f32[0]
&& absoluteSaturation == m_hsv.m128_i8[12]
&& v10 == (unsigned __int8)_mm_cvtsi128_si32(_mm_srli_si128((__m128i)m_hsv, 13)) )
{
goto LABEL_20;
}
v20.h = -0.001;
*(_QWORD *)&v20.s = 0;
*(_WORD *)&v20.absoluteSaturation = 0;
*retstr = v20;
return retstr;
}