//
// GJChestSprite::switchToState from 0x140567150 to 0x140567e04 (3252 bytes)
//
// 14 xrefs:
// > GJNotificationCell::loadFromNotification @ 0x14015bb1f
// > GJNotificationCell::loadFromNotification @ 0x14015be05
// > GJNotificationCell::refreshChest @ 0x14015c626
// > FollowRewardPage::init @ 0x14020cbf9
// > FollowRewardPage::switchToOpenedState @ 0x14020ebc4
// > RewardUnlockLayer::step2 @ 0x140564684
// > RewardUnlockLayer::playRewardEffect @ 0x1405649b7
// > GJChestSprite::create @ 0x140566fe4
// > SecretRewardsLayer::generateChestItems @ 0x14056b8a0
// > SecretRewardsLayer::switchToOpenedState @ 0x14056c98d
// > SecretLayer3::init @ 0x140580a9a
// > SecretLayer3::init @ 0x140580db3
// > SecretLayer4::init @ 0x140586313
// > ??> @ 0x14092c594
//
// 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:34:17 +0000
//
// Hidden C++ exception states: #wind=3
void __fastcall GJChestSprite::switchToState(_DWORD *a1, int a2, char a3)
{
int v6; // edx
float v7; // xmm8_4
int v8; // ebx
int v9; // ebx
cocos2d::CCString *v10; // rax
const char *v11; // rax
size_t v12; // r8
const char *v13; // rcx
struct cocos2d::CCSprite *v14; // rax
__int64 v15; // r8
void **v16; // rdx
const char *v17; // rcx
struct cocos2d::CCSprite *v18; // rax
__int64 v19; // r8
void **v20; // rdx
const char *v21; // rcx
struct cocos2d::CCSprite *v22; // rsi
struct cocos2d::CCActionInterval *v23; // rax
struct cocos2d::CCFiniteTimeAction *v24; // rdi
struct cocos2d::CCActionInterval *v25; // rax
struct cocos2d::CCEaseInOut *v26; // rax
struct cocos2d::CCActionInterval *v27; // rax
struct cocos2d::CCAction *v28; // rax
int v29; // r12d
int v30; // esi
int v31; // r13d
int v32; // r14d
int v33; // kr08_4
__int64 v34; // rdi
__int64 v35; // rax
cocos2d::CCNode *v36; // rdi
float v37; // xmm9_4
int v38; // eax
struct cocos2d::CCActionInterval *v39; // rax
struct cocos2d::CCAction *v40; // rax
cocos2d::CCNode *v41; // rdi
__int64 v42; // rbx
__int64 v43; // rax
int v44; // eax
struct cocos2d::CCActionInterval *v45; // rax
struct cocos2d::CCAction *v46; // rax
cocos2d::CCParticleSystem *v47; // rdi
__int64 v48; // rdx
__int64 v49; // rbx
__int64 v50; // rax
struct cocos2d::CCSprite *v51; // rbx
struct cocos2d::CCSprite *v52; // rbx
struct cocos2d::CCSprite *v53; // rdi
__int64 v54; // rbx
__int64 v55; // rax
struct cocos2d::CCSprite *v56; // rdi
__int64 v57; // rbx
__int64 v58; // rax
__int64 v59; // rdx
cocos2d::CCString *v60; // rax
const char *v61; // rax
size_t v62; // r8
const char *v63; // rcx
struct cocos2d::CCSprite *v64; // rax
__int64 v65; // r8
void **v66; // rdx
const char *v67; // rcx
struct cocos2d::CCSprite *v68; // rax
__int64 v69; // r8
void **v70; // rdx
const char *v71; // rcx
struct cocos2d::CCSprite *v72; // r14
const char *v73; // rcx
struct cocos2d::CCSprite *v74; // rsi
float *v75; // rbx
__int64 v76; // rdi
__int64 v77; // rax
__int64 v78; // rax
cocos2d::CCParticleSystem *v79; // r14
__int64 v80; // rdx
int v81; // ecx
int v82; // edi
int v83; // esi
int v84; // eax
int v85; // ebx
int v86; // r15d
__int64 v87; // rbx
__int64 v88; // rax
void *v89; // rcx
cocos2d::CCString *v90; // rax
const char *CString; // rax
struct cocos2d::CCSprite *v92; // rax
_BYTE v93[3]; // [rsp+38h] [rbp-D0h] BYREF
_WORD v94[2]; // [rsp+3Ch] [rbp-CCh] BYREF
__int64 v95; // [rsp+40h] [rbp-C8h] BYREF
__int64 v96; // [rsp+48h] [rbp-C0h]
__int64 v97; // [rsp+50h] [rbp-B8h]
float v98; // [rsp+58h] [rbp-B0h] BYREF
float v99; // [rsp+5Ch] [rbp-ACh]
float Block; // [rsp+60h] [rbp-A8h]
int Block_4; // [rsp+64h] [rbp-A4h]
void *Block_8[2]; // [rsp+68h] [rbp-A0h] BYREF
__int128 v103; // [rsp+78h] [rbp-90h]
_QWORD v104[3]; // [rsp+88h] [rbp-80h] BYREF
unsigned __int64 v105; // [rsp+A0h] [rbp-68h]
_QWORD v106[3]; // [rsp+A8h] [rbp-60h] BYREF
unsigned __int64 v107; // [rsp+C0h] [rbp-48h]
if ( a1[151] == a2 )
return;
a1[151] = a2;
(*(void (__fastcall **)(_DWORD *))(*(_QWORD *)a1 + 568LL))(a1);
v6 = a1[150];
if ( v6 == 1 )
v7 = 0.80000001;
else
v7 = 1.0;
v8 = a2 - 2;
if ( !v8 )
{
v90 = cocos2d::CCString::createWithFormat("chest_%02d_%02d_001.png", v6, 2);
CString = cocos2d::CCString::getCString(v90);
v92 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v92, 3);
return;
}
v9 = v8 - 1;
if ( v9 )
{
if ( v9 == 1 )
{
v10 = cocos2d::CCString::createWithFormat("chest_%02d_%02d_001.png", v6, 4);
v11 = cocos2d::CCString::getCString(v10);
*(_OWORD *)Block_8 = 0;
v103 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003D230(Block_8, v11, v12);
v13 = (const char *)Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v13 = (const char *)Block_8[0];
v14 = cocos2d::CCSprite::createWithSpriteFrameName(v13);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v14, 4);
v16 = Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v16 = (void **)Block_8[0];
sub_140561800(v106, v16, v15, "_back_001");
v17 = (const char *)v106;
if ( v107 > 0xF )
v17 = (const char *)v106[0];
v18 = cocos2d::CCSprite::createWithSpriteFrameName(v17);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, _QWORD))(*(_QWORD *)a1 + 456LL))(a1, v18, 0);
if ( !a3 )
{
v20 = Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v20 = (void **)Block_8[0];
sub_140561800(v104, v20, v19, "_glow_001");
v21 = (const char *)v104;
if ( v105 > 0xF )
v21 = (const char *)v104[0];
v22 = cocos2d::CCSprite::createWithSpriteFrameName(v21);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v22, 1);
v96 = 0x100000302LL;
(**((void (__fastcall ***)(__int64, __int64))v22 + 43))((__int64)v22 + 344, 0x100000302LL);
v23 = cocos2d::CCFadeTo::create(1.0, 0xAFu);
v24 = cocos2d::CCEaseInOut::create(v23, 2.0);
v25 = cocos2d::CCFadeTo::create(1.0, 0xFFu);
v26 = cocos2d::CCEaseInOut::create(v25, 2.0);
v27 = cocos2d::CCSequence::create(v24, v26, 0);
v28 = cocos2d::CCRepeatForever::create(v27);
cocos2d::CCNode::runAction(v22, v28);
*(_WORD *)v93 = -27136;
v93[2] = -1;
LOWORD(v95) = -27136;
BYTE2(v95) = -1;
v94[0] = 17459;
LOBYTE(v94[1]) = -103;
v29 = 0;
v30 = 255;
v31 = 255;
v32 = 0;
v33 = a1[150] - 1;
LODWORD(v96) = 0;
switch ( v33 )
{
case 0:
goto LABEL_29;
case 1:
case 4:
v93[1] = -56;
BYTE1(v95) = 100;
goto LABEL_23;
case 2:
LABEL_23:
LODWORD(v96) = 0;
break;
case 3:
*(_WORD *)&v93[1] = 255;
*(_WORD *)((char *)&v95 + 1) = 13055;
v29 = 150;
v31 = 0;
LODWORD(v96) = 0;
v32 = 255;
break;
case 5:
v93[1] = -56;
BYTE1(v95) = 100;
qmemcpy(v94, "\n6S", 3);
LODWORD(v96) = 0;
break;
case 6:
*(_WORD *)&v93[1] = 255;
*(_WORD *)((char *)&v95 + 1) = 13055;
qmemcpy(v94, ")Q;", 3);
v29 = 150;
LODWORD(v96) = 100;
v32 = 255;
goto LABEL_30;
case 7:
*(_WORD *)v93 = 255;
LOWORD(v95) = 255;
v94[0] = 6970;
LOBYTE(v94[1]) = 75;
v29 = 255;
v30 = 150;
LODWORD(v96) = 255;
break;
case 8:
v94[0] = 7463;
LOBYTE(v94[1]) = 44;
LABEL_29:
v93[2] = 0;
BYTE2(v95) = 0;
v32 = 100;
LODWORD(v96) = 255;
v29 = 255;
LOBYTE(v95) = -1;
*(_WORD *)v93 = -14081;
LABEL_30:
v31 = 0;
break;
default:
break;
}
v97 = (__int64)cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v97, 1);
(**(void (__fastcall ***)(__int64, __int64))(v97 + 344))(v97 + 344, 0x100000302LL);
v34 = *(_QWORD *)v97;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, -5.0);
(*(void (__fastcall **)(__int64, __int64))(v34 + 184))(v97, v35);
v36 = (cocos2d::CCNode *)v97;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v97 + 160LL))(v97);
(**((void (__fastcall ***)(__int64, _BYTE *))v36 + 40))((__int64)v36 + 320, v93);
if ( (float)((float)rand() / 32767.0) <= 0.5 )
v37 = -1.0;
else
v37 = 1.0;
v38 = rand();
v39 = cocos2d::CCRotateBy::create(
1.0,
(float)((float)((float)((float)((float)v38 / 32767.0) * 0.5) + 0.5) * 180.0) * v37);
v40 = cocos2d::CCRepeatForever::create(v39);
cocos2d::CCNode::runAction(v36, v40);
v41 = cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, cocos2d::CCNode *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v41, 1);
(**((void (__fastcall ***)(__int64, __int64))v41 + 43))((__int64)v41 + 344, 0x100000302LL);
v42 = *(_QWORD *)v41;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, -5.0);
(*(void (__fastcall **)(cocos2d::CCNode *, __int64))(v42 + 184))(v41, v43);
(*(void (__fastcall **)(cocos2d::CCNode *))(*(_QWORD *)v41 + 160LL))(v41);
(**((void (__fastcall ***)(__int64, __int64 *))v41 + 40))((__int64)v41 + 320, &v95);
v44 = rand();
v45 = cocos2d::CCRotateBy::create(
1.0,
(float)((float)((float)((float)((float)v44 / 32767.0) * 0.5) + 0.5) * 180.0) * (float)-v37);
v46 = cocos2d::CCRepeatForever::create(v45);
cocos2d::CCNode::runAction(v41, v46);
v47 = cocos2d::CCParticleSystemQuad::create("chestOpened.plist", 0);
LOBYTE(v48) = 1;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, __int64))(*(_QWORD *)v47 + 1544LL))(v47, v48);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCParticleSystem *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v47, 1);
v49 = *(_QWORD *)v47;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, 0.0);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, __int64))(v49 + 184))(v47, v50);
v98 = (float)v29 / 255.0;
v99 = (float)v30 / 255.0;
Block = (float)v31 / 255.0;
Block_4 = 1065353216;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_QWORD *)v47 + 1352LL))(v47, &v98);
v98 = (float)(int)v96 / 255.0;
v99 = (float)v32 / 255.0;
Block = (float)v31 / 255.0;
Block_4 = 1065353216;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_QWORD *)v47 + 1384LL))(v47, &v98);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *))(*(_QWORD *)v47 + 160LL))(v47);
cocos2d::CCParticleSystem::resetSystem(v47);
v51 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v51, 2);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v51 + 160LL))(v51);
(**((void (__fastcall ***)(__int64, _WORD *))v51 + 40))((__int64)v51 + 320, v94);
v52 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
cocos2d::CCSprite::setFlipX(v52, 1);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v52, 2);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v52 + 160LL))(v52);
(**((void (__fastcall ***)(__int64, _WORD *))v52 + 40))((__int64)v52 + 320, v94);
v53 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
v54 = *(_QWORD *)v53;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, v7 * -52.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v54 + 184))(v53, v55);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v53 + 120LL))(v53);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v53 + 136LL))(v53);
(**((void (__fastcall ***)(__int64, _WORD *))v53 + 40))((__int64)v53 + 320, v94);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v53, 2);
v56 = cocos2d::CCSprite::createWithSpriteFrameName("chest_shadow_001.png");
v57 = *(_QWORD *)v56;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, v7 * -48.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v57 + 184))(v56, v58);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v56, 3);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v56 + 160LL))(v56);
LOBYTE(v59) = 90;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v56 + 40) + 40LL))((__int64)v56 + 320, v59);
sub_14003D310((__int64)v104);
}
sub_14003D310((__int64)v106);
sub_14003D310((__int64)Block_8);
}
return;
}
v60 = cocos2d::CCString::createWithFormat("chest_%02d_%02d_001.png", v6, 3);
v61 = cocos2d::CCString::getCString(v60);
*(_OWORD *)Block_8 = 0;
v103 = 0;
v62 = -1;
do
++v62;
while ( v61[v62] );
sub_14003D230(Block_8, v61, v62);
v63 = (const char *)Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v63 = (const char *)Block_8[0];
v64 = cocos2d::CCSprite::createWithSpriteFrameName(v63);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v64, 3);
v66 = Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v66 = (void **)Block_8[0];
sub_140561800(v106, v66, v65, "_back_001");
v67 = (const char *)v106;
if ( v107 > 0xF )
v67 = (const char *)v106[0];
v68 = cocos2d::CCSprite::createWithSpriteFrameName(v67);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, _QWORD))(*(_QWORD *)a1 + 456LL))(a1, v68, 0);
if ( !a3 )
{
v70 = Block_8;
if ( *((_QWORD *)&v103 + 1) > 0xFu )
v70 = (void **)Block_8[0];
sub_140561800(v104, v70, v69, "_glow_001");
v71 = (const char *)v104;
if ( v105 > 0xF )
v71 = (const char *)v104[0];
v72 = cocos2d::CCSprite::createWithSpriteFrameName(v71);
(*(void (__fastcall **)(_DWORD *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v72, 1);
v73 = (const char *)v104;
if ( v105 > 0xF )
v73 = (const char *)v104[0];
v74 = cocos2d::CCSprite::createWithSpriteFrameName(v73);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)v72 + 456LL))(
v72,
v74,
1);
v75 = (float *)(*(__int64 (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v72 + 320LL))(v72);
v76 = *(_QWORD *)v74;
v77 = (*(__int64 (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v72 + 320LL))(v72);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, *v75 * 0.5, *(float *)(v77 + 4) * 0.5);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v76 + 184))(v74, v78);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v74 + 120LL))(v74);
v97 = 0x100000302LL;
(**((void (__fastcall ***)(__int64, __int64))v72 + 43))((__int64)v72 + 344, 0x100000302LL);
(**((void (__fastcall ***)(__int64, __int64))v74 + 43))((__int64)v74 + 344, 0x100000302LL);
v79 = cocos2d::CCParticleSystemQuad::create("chestOpen.plist", 0);
LOBYTE(v80) = 1;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, __int64))(*(_QWORD *)v79 + 1544LL))(v79, v80);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCParticleSystem *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v79, 4);
v81 = a1[150];
v82 = 255;
if ( v81 == 1 )
{
v83 = 255;
v84 = 50;
v85 = 255;
v86 = 0;
LABEL_57:
v82 = 0;
goto LABEL_58;
}
v85 = 0;
v84 = 255;
if ( v81 == 3 )
{
v83 = 0;
v86 = 0;
}
else
{
v83 = 255;
v86 = 255;
if ( v81 == 4 )
{
v83 = 150;
v84 = 0;
goto LABEL_57;
}
}
LABEL_58:
v98 = (float)v83 / 255.0;
v99 = 1.0;
Block = (float)v84 / 255.0;
Block_4 = 1065353216;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_QWORD *)v79 + 1352LL))(v79, &v98);
v98 = (float)v85 / 255.0;
v99 = (float)v86 / 255.0;
Block = (float)v82 / 255.0;
Block_4 = 1065353216;
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_QWORD *)v79 + 1384LL))(v79, &v98);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *))(*(_QWORD *)v79 + 160LL))(v79);
v87 = *(_QWORD *)v79;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v98, 0.0, 0.0);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, __int64))(v87 + 184))(v79, v88);
cocos2d::CCParticleSystem::resetSystem(v79);
sub_14003D310((__int64)v104);
}
sub_14003D310((__int64)v106);
if ( *((_QWORD *)&v103 + 1) > 0xFu )
{
v89 = Block_8[0];
if ( (unsigned __int64)(*((_QWORD *)&v103 + 1) + 1LL) >= 0x1000 )
{
v89 = *((void **)Block_8[0] - 1);
if ( (unsigned __int64)((char *)Block_8[0] - (char *)v89 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v89);
}
}