//
// GJChestSprite::switchToState from 0x1002019b0 to 0x10020262f (3199 bytes)
//
// 20 xrefs:
// > GJChestSprite::create @ 0x100200417
// > RewardUnlockLayer::step2 @ 0x100200520
// > RewardUnlockLayer::playRewardEffect @ 0x100200810
// > GJChestSprite::init @ 0x100202f9d
// > GJNotificationCell::loadFromNotification @ 0x1002348da
// > GJNotificationCell::refreshChest @ 0x100236344
// > SecretLayer4::init @ 0x10039aad2
// > FollowRewardPage::init @ 0x10040cee6
// > FollowRewardPage::init @ 0x10040d136
// > FollowRewardPage::onSpecialItem @ 0x10040d9eb
// > FollowRewardPage::switchToOpenedState @ 0x10040dc14
// > SecretLayer3::init @ 0x10049d61f
// > SecretLayer3::init @ 0x10049d882
// > SecretRewardsLayer::init @ 0x10070dbc1
// > SecretRewardsLayer::init @ 0x10070e20d
// > SecretRewardsLayer::switchToOpenedState @ 0x10070eded
// > SecretRewardsLayer::onSpecialItem @ 0x10070fa55
// > SecretRewardsLayer::generateChestItems @ 0x100711076
// > SecretRewardsLayer::generateChestItems @ 0x10071129c
// > SecretRewardsLayer::onSelectItem @ 0x10071151b
//
// 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 12:26:52 +0000
//
void __fastcall GJChestSprite::switchToState(_DWORD *a1, int a2, int a3, double a4, double a5, __m128 a6)
{
size_t v6; // r14
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
const char *v12; // r15
size_t v13; // rax
size_t v14; // r12
char *v15; // r13
__int64 v16; // rax
const char *CString; // r12
size_t v18; // rax
size_t v19; // r15
char *v20; // r13
char *v21; // r15
char *v22; // rdi
__int64 v23; // rax
char *v24; // rsi
std::string::pointer v25; // rdi
char *v26; // r15
char *v27; // rdi
__int64 v28; // rax
char *v29; // rsi
std::string::pointer data; // rdi
__int64 v31; // rax
std::string::pointer v32; // r15
std::string::pointer v33; // rdi
__int64 v34; // r14
__int64 v35; // r15
__int64 v36; // rax
__int64 v37; // r14
int v38; // eax
unsigned int v39; // eax
unsigned int v40; // ebx
__int64 v41; // rax
std::string::pointer v42; // rdi
__int64 v43; // r14
__int64 v44; // rax
int v45; // r15d
__int64 v46; // rax
int v47; // eax
int v48; // ecx
int v49; // r8d
int v50; // r9d
__int64 v51; // rax
__int64 v52; // rax
int v53; // eax
unsigned int v54; // r13d
__m128 v55; // xmm0
__m128 v56; // xmm0
__m128 v57; // xmm1
__m128 v58; // xmm2
__int64 v59; // r14
bool v60; // r12
int v61; // eax
__m128 v62; // xmm2
__int64 v63; // rax
__int64 v64; // rax
__int64 v65; // r14
int v66; // eax
__int64 v67; // rax
__int64 v68; // rax
__int64 v69; // r14
__m128 v70; // xmm0
__m128 v71; // xmm1
__m128 v72; // xmm0
__m128 v73; // xmm1
__m128 v74; // xmm2
__int64 v75; // r14
__int64 v76; // r14
__int64 v77; // r14
__int64 v78; // r14
char v79; // [rsp+0h] [rbp-A0h]
float v80; // [rsp+4h] [rbp-9Ch]
std::string v81; // [rsp+8h] [rbp-98h] BYREF
std::string v82; // [rsp+20h] [rbp-80h] BYREF
size_t __dst; // [rsp+38h] [rbp-68h] BYREF
size_t v84; // [rsp+40h] [rbp-60h]
char *__s; // [rsp+48h] [rbp-58h]
__m128 v86; // [rsp+50h] [rbp-50h] BYREF
float v87; // [rsp+64h] [rbp-3Ch]
unsigned int v88; // [rsp+68h] [rbp-38h]
_WORD v89[2]; // [rsp+6Ch] [rbp-34h] BYREF
__int16 v90; // [rsp+70h] [rbp-30h] BYREF
char v91; // [rsp+72h] [rbp-2Eh]
__int16 v92; // [rsp+74h] [rbp-2Ch] BYREF
char v93; // [rsp+76h] [rbp-2Ah]
if ( a1[150] == a2 )
return;
LODWORD(v6) = a3;
a1[150] = a2;
(*(void (__fastcall **)(_DWORD *))(*(_QWORD *)a1 + 576LL))(a1);
v87 = *(float *)&dword_100A05F60[a1[149] == 1];
if ( a2 == 4 )
{
v16 = sub_10088E820("chest_%02d_%02d_001.png", v79);
CString = (const char *)cocos2d::CCString::getCString(v16);
v18 = strlen(CString);
if ( v18 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_74;
v19 = v18;
if ( v18 >= 0x17 )
{
v88 = v6;
v6 = 26;
if ( (v18 | 7) != 0x17 )
v6 = (v18 | 7) + 1;
v20 = (char *)operator new(v6);
__s = v20;
__dst = v6 + 1;
LOBYTE(v6) = v88;
v84 = v19;
}
else
{
LOBYTE(__dst) = 2 * v18;
v20 = (char *)&__dst + 1;
if ( !v18 )
goto LABEL_29;
}
memmove(v20, CString, v19);
LABEL_29:
v20[v19] = 0;
v26 = (char *)&__dst + 1;
v27 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v27 = __s;
v28 = cocos2d::CCSprite::createWithSpriteFrameName(v27);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v28, 4);
v29 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v29 = __s;
sub_100203180(&v81, v29, "_back_001");
if ( (*(_BYTE *)&v81.__r_.__value_.__s.0 & 1) != 0 )
data = v81.__r_.__value_.__l.__data_;
else
data = v81.__r_.__value_.__s.__data_;
v41 = cocos2d::CCSprite::createWithSpriteFrameName(data);
(*(void (__fastcall **)(_DWORD *, __int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, v41, 0);
if ( (_BYTE)v6 )
goto LABEL_70;
if ( (__dst & 1) != 0 )
v26 = __s;
sub_100203180(&v82, v26, "_glow_001");
if ( (*(_BYTE *)&v82.__r_.__value_.__s.0 & 1) != 0 )
v42 = v82.__r_.__value_.__l.__data_;
else
v42 = v82.__r_.__value_.__s.__data_;
v43 = cocos2d::CCSprite::createWithSpriteFrameName(v42);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v43, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v43 + 1080LL))(v43, 0x100000302LL);
v44 = cocos2d::CCFadeTo::create(175, 1.0);
v45 = cocos2d::CCEaseInOut::create(v44, 2.0);
v46 = cocos2d::CCFadeTo::create(255, 1.0);
v47 = cocos2d::CCEaseInOut::create(v46, 2.0);
v51 = sub_10039EB60(v45, v47, 0, v48, v49, v50);
v52 = cocos2d::CCRepeatForever::create(v51);
cocos2d::CCNode::runAction(v43, v52);
v91 = -1;
v90 = -27136;
v93 = -1;
v92 = -27136;
LOBYTE(v89[1]) = -103;
v89[0] = 17459;
v53 = a1[149];
v54 = 16776960;
*(float *)&v88 = 2.3418052e-38;
switch ( v53 )
{
case 1:
v91 = 0;
v90 = -14081;
v93 = 0;
v92 = -26881;
goto LABEL_64;
case 2:
case 5:
v91 = -1;
v90 = -14336;
v93 = -1;
v92 = 25600;
break;
case 4:
v91 = 0;
v90 = -256;
v93 = 50;
v92 = -256;
v54 = 65430;
v88 = 65280;
break;
case 6:
v91 = -1;
v90 = -14336;
v93 = -1;
v92 = 25600;
qmemcpy(v89, "\n6S", 3);
break;
case 7:
v91 = 0;
v90 = -256;
v93 = 50;
v92 = -256;
qmemcpy(v89, ")Q;", 3);
v54 = 65430;
v88 = 65380;
break;
case 8:
v91 = -1;
v90 = 255;
v93 = -1;
v92 = 255;
LOBYTE(v89[1]) = 75;
v89[0] = 6970;
v54 = 16750335;
*(float *)&v88 = 2.3418409e-38;
break;
case 9:
v91 = 0;
v90 = -14081;
v93 = 0;
v92 = -26881;
LOBYTE(v89[1]) = 44;
v89[0] = 7463;
LABEL_64:
v54 = 0xFFFF;
v88 = 25855;
break;
default:
break;
}
v59 = cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v59, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v59 + 1080LL))(v59, 0x100000302LL);
sub_100278250(&v86, 0.0, -5.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v59 + 184LL))(v59, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v59 + 160LL))(v59, 4.0 * v87);
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v59 + 960LL))(v59, &v90);
v60 = (float)((float)rand() * 4.6566129e-10) > 0.5;
v61 = rand();
v62 = (__m128)0x3F000000u;
v80 = flt_100A05F68[v60];
v63 = cocos2d::CCRotateBy::create_1(
1.0,
(float)((float)((float)((float)((float)v61 * 4.6566129e-10) * 0.5) + 0.5) * 180.0) * v80);
v64 = cocos2d::CCRepeatForever::create(v63);
cocos2d::CCNode::runAction(v59, v64);
v65 = cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v65, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v65 + 1080LL))(v65, 0x100000302LL);
sub_100278250(&v86, 0.0, -5.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v65 + 184LL))(v65, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v65 + 160LL))(v65, 3.5 * v87);
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v65 + 960LL))(v65, &v92);
v66 = rand();
v67 = cocos2d::CCRotateBy::create_1(
1.0,
(float)((float)((float)((float)((float)v66 * 4.6566129e-10) * 0.5) + 0.5) * -180.0) * v80);
v68 = cocos2d::CCRepeatForever::create(v67);
cocos2d::CCNode::runAction(v65, v68);
v69 = cocos2d::CCParticleSystemQuad::create("chestOpened.plist", 0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v69 + 1584LL))(v69, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v69, 1);
sub_100278250(&v86, 0.0, 0.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v69 + 184LL))(v69, &v86);
v70 = 0;
v71 = 0;
v70.f32[0] = (float)(unsigned __int8)v54 / 255.0;
v71.f32[0] = (float)BYTE1(v54) / 255.0;
v62.f32[0] = (float)HIWORD(v54) / 255.0;
v86 = _mm_movelh_ps(_mm_insert_ps(v70, v71, 16), _mm_blend_ps(v62, (__m128)xmmword_100A03610, 14));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v69 + 1360LL))(v69, &v86);
v72 = 0;
v73 = 0;
v72.f32[0] = (float)(unsigned __int8)v88 / 255.0;
v74 = 0;
v73.f32[0] = (float)BYTE1(v88) / 255.0;
v74.f32[0] = (float)HIWORD(v88) / 255.0;
v86 = _mm_movelh_ps(_mm_insert_ps(v72, v73, 16), _mm_blend_ps(v74, (__m128)xmmword_100A03610, 14));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v69 + 1392LL))(v69, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v69 + 160LL))(v69, v87);
cocos2d::CCParticleSystem::resetSystem(v69);
v75 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v75, 2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v75 + 160LL))(v75, v87);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v75 + 960LL))(v75, v89);
v76 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
cocos2d::CCSprite::setFlipX(v76, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v76, 2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v76 + 160LL))(v76, v87);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v76 + 960LL))(v76, v89);
v77 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
sub_100278250(&v86, 0.0, -52.0 * v87);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v77 + 184LL))(v77, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v77 + 128LL))(v77, 5.1999998 * v87);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v77 + 144LL))(v77, 2.2 * v87);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v77 + 960LL))(v77, v89);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v77, 2);
v78 = cocos2d::CCSprite::createWithSpriteFrameName("chest_shadow_001.png");
sub_100278250(&v86, 0.0, -48.0 * v87);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v78 + 184LL))(v78, &v86);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v78, 3);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v78 + 160LL))(v78, v87 * 0.94999999);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v78 + 912LL))(v78, 90);
goto LABEL_68;
}
if ( a2 != 3 )
{
if ( a2 == 2 )
{
v8 = sub_10088E820("chest_%02d_%02d_001.png", v79);
v9 = cocos2d::CCString::getCString(v8);
v10 = cocos2d::CCSprite::createWithSpriteFrameName(v9);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v10, 3);
}
return;
}
v11 = sub_10088E820("chest_%02d_%02d_001.png", v79);
v12 = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(v12);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_74:
sub_100003630();
v14 = v13;
if ( v13 >= 0x17 )
{
v88 = v6;
v6 = 26;
if ( (v13 | 7) != 0x17 )
v6 = (v13 | 7) + 1;
v15 = (char *)operator new(v6);
__s = v15;
__dst = v6 + 1;
LOBYTE(v6) = v88;
v84 = v14;
}
else
{
LOBYTE(__dst) = 2 * v13;
v15 = (char *)&__dst + 1;
if ( !v13 )
goto LABEL_19;
}
memmove(v15, v12, v14);
LABEL_19:
v21 = (char *)&__dst + 1;
v15[v14] = 0;
v22 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v22 = __s;
v23 = cocos2d::CCSprite::createWithSpriteFrameName(v22);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v23, 3);
v24 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v24 = __s;
sub_100203180(&v81, v24, "_back_001");
if ( (*(_BYTE *)&v81.__r_.__value_.__s.0 & 1) != 0 )
v25 = v81.__r_.__value_.__l.__data_;
else
v25 = v81.__r_.__value_.__s.__data_;
v31 = cocos2d::CCSprite::createWithSpriteFrameName(v25);
(*(void (__fastcall **)(_DWORD *, __int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, v31, 0);
if ( (_BYTE)v6 )
goto LABEL_70;
if ( (__dst & 1) != 0 )
v21 = __s;
sub_100203180(&v82, v21, "_glow_001");
v32 = v82.__r_.__value_.__s.__data_;
v33 = v82.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v82.__r_.__value_.__s.0 & 1) != 0 )
v33 = v82.__r_.__value_.__l.__data_;
v34 = cocos2d::CCSprite::createWithSpriteFrameName(v33);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v34, 1);
if ( (*(_BYTE *)&v82.__r_.__value_.__s.0 & 1) != 0 )
v32 = v82.__r_.__value_.__l.__data_;
v35 = cocos2d::CCSprite::createWithSpriteFrameName(v32);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v34 + 464LL))(v34, v35, 1);
v88 = *(unsigned int *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v34 + 328LL))(v34);
v36 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v34 + 328LL))(v34);
sub_100278250(&v86, *(float *)&v88 * 0.5, 0.5 * *(float *)(v36 + 4));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v35 + 184LL))(v35, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v35 + 128LL))(v35, 0.80000001);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v34 + 1080LL))(v34, 0x100000302LL);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v35 + 1080LL))(v35, 0x100000302LL);
v37 = cocos2d::CCParticleSystemQuad::create("chestOpen.plist", 0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v37 + 1584LL))(v37, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v37, 4);
v38 = a1[149];
switch ( v38 )
{
case 4:
v39 = 65430;
v40 = 65280;
break;
case 3:
v39 = 16776960;
v40 = 16711680;
break;
case 1:
v39 = 3342335;
v40 = 255;
break;
default:
v39 = 0xFFFFFF;
v40 = 16776960;
break;
}
v55 = 0;
v55.f32[0] = (float)(unsigned __int8)v39 / 255.0;
a6.f32[0] = (float)HIWORD(v39) / 255.0;
v86 = _mm_movelh_ps(_mm_blend_ps(v55, (__m128)xmmword_100A03610, 14), _mm_blend_ps(a6, (__m128)xmmword_100A03610, 14));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v37 + 1360LL))(v37, &v86);
v56 = 0;
v57 = 0;
v56.f32[0] = (float)(unsigned __int8)v40 / 255.0;
v58 = 0;
v57.f32[0] = (float)BYTE1(v40) / 255.0;
v58.f32[0] = (float)HIWORD(v40) / 255.0;
v86 = _mm_movelh_ps(_mm_insert_ps(v56, v57, 16), _mm_blend_ps(v58, (__m128)xmmword_100A03610, 14));
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v37 + 1392LL))(v37, &v86);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v37 + 160LL))(v37, v87);
sub_100278250(&v86, 0.0, 0.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v37 + 184LL))(v37, &v86);
cocos2d::CCParticleSystem::resetSystem(v37);
LABEL_68:
if ( (*(_BYTE *)&v82.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v82.__r_.__value_.__l.__data_);
LABEL_70:
if ( (*(_BYTE *)&v81.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v81.__r_.__value_.__l.__data_);
if ( (__dst & 1) != 0 )
operator delete(__s);
}