//
// GJChestSprite::switchToState from 0x617edc to 0x6188a2 (2502 bytes)
//
// 12 xrefs:
// > GJNotificationCell::refreshChest @ 0x4272ec
// > GJNotificationCell::loadFromNotification @ 0x432318
// > RewardUnlockLayer::step2 @ 0x6188e8
// > RewardUnlockLayer::playRewardEffect @ 0x618a2c
// > GJChestSprite::init @ 0x619614
// > SecretLayer3::init @ 0x620700
// > SecretLayer3::init @ 0x6208ae
// > SecretLayer4::init @ 0x6232a8
// > FollowRewardPage::switchToOpenedState @ 0x62fd40
// > FollowRewardPage::init @ 0x630e20
// > SecretRewardsLayer::switchToOpenedState @ 0x6cab6a
// > SecretRewardsLayer::generateChestItems @ 0x6cf8be
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:54:57 +0000
//
_DWORD *__fastcall GJChestSprite::switchToState(_DWORD *result, int a2, int a3)
{
_DWORD *v4; // r4
float v6; // s17
int v7; // r2
cocos2d::CCSprite *v8; // r0
const char *v9; // r1
int v10; // r0
const char *RewardFrame; // r6
size_t v12; // r0
const char *v13; // r1
cocos2d::CCSprite *v14; // r0
int v15; // r0
char *v16; // r1
cocos2d::CCSprite *v17; // r0
int v18; // r0
char *v19; // r1
const char *v20; // r1
cocos2d::CCSprite *v21; // r0
int *v22; // r5
const char *v23; // r1
cocos2d::CCSprite *v24; // r0
int v25; // r6
void (__fastcall *v26)(int, float *); // r7
float v27; // s18
int v28; // r0
int v29; // r3
bool v30; // r2
cocos2d::CCParticleSystem *v31; // r5
int v32; // r3
int v33; // r4
int v34; // r6
int v35; // r7
int v36; // r11
int v37; // r12
void (__fastcall *v38)(cocos2d::CCParticleSystem *, float *); // r11
void (__fastcall *v39)(cocos2d::CCParticleSystem *, float *); // r6
const char *v40; // r6
size_t v41; // r0
const char *v42; // r1
cocos2d::CCSprite *v43; // r0
int v44; // r0
char *v45; // r1
cocos2d::CCSprite *v46; // r0
int v47; // r0
char *v48; // r1
const char *v49; // r1
cocos2d::CCSprite *v50; // r0
cocos2d::CCNode *v51; // r5
void (__fastcall *v52)(cocos2d::CCNode *, int, int, int *); // r6
unsigned __int8 v53; // r2
cocos2d::CCEaseInOut *v54; // r0
float v55; // r2
cocos2d::CCSequence *v56; // r6
unsigned __int8 v57; // r2
cocos2d::CCEaseInOut *v58; // r0
float v59; // r2
cocos2d::CCFiniteTimeAction *v60; // r0
cocos2d::CCRepeatForever *v61; // r0
cocos2d::CCActionInterval *v62; // r1
cocos2d::CCAction *v63; // r0
int v64; // r1
const char *v65; // r1
int v66; // r5
int v67; // r6
int v68; // r7
int v69; // r11
int v70; // r8
cocos2d::CCNode *v71; // r9
float v72; // s19
int v73; // r0
float v74; // r2
cocos2d::CCRepeatForever *v75; // r0
cocos2d::CCActionInterval *v76; // r1
cocos2d::CCAction *v77; // r0
const char *v78; // r1
cocos2d::CCNode *v79; // r9
int v80; // r0
float v81; // r2
cocos2d::CCRepeatForever *v82; // r0
cocos2d::CCActionInterval *v83; // r1
cocos2d::CCAction *v84; // r0
bool v85; // r2
cocos2d::CCParticleSystem *v86; // r9
float v87; // s16
void (__fastcall *v88)(cocos2d::CCParticleSystem *, float *); // r5
const char *v89; // r1
int v90; // r5
const char *v91; // r1
cocos2d::CCSprite *v92; // r5
const char *v93; // r1
int v94; // r5
void (__fastcall *v95)(int, float *); // r7
const char *v96; // r1
int v97; // r5
void (__fastcall *v98)(int, float *); // r6
void (__fastcall *v99)(cocos2d::CCParticleSystem *, float *, int); // [sp+0h] [bp-64h]
void (__fastcall *v100)(cocos2d::CCNode *, float *); // [sp+4h] [bp-60h]
void (__fastcall *v101)(cocos2d::CCParticleSystem *, float *); // [sp+4h] [bp-60h]
void (__fastcall *v102)(cocos2d::CCParticleSystem *, float *); // [sp+4h] [bp-60h]
void (__fastcall *v103)(cocos2d::CCNode *, float *); // [sp+8h] [bp-5Ch]
char v104; // [sp+14h] [bp-50h] BYREF
char v105; // [sp+15h] [bp-4Fh]
char v106; // [sp+16h] [bp-4Eh]
char v107; // [sp+18h] [bp-4Ch] BYREF
char v108; // [sp+19h] [bp-4Bh]
char v109; // [sp+1Ah] [bp-4Ah]
_BYTE v110[4]; // [sp+1Ch] [bp-48h] BYREF
int v111; // [sp+20h] [bp-44h] BYREF
int v112; // [sp+24h] [bp-40h]
int v113; // [sp+28h] [bp-3Ch] BYREF
int v114; // [sp+2Ch] [bp-38h]
cocos2d::CCSprite *v115; // [sp+30h] [bp-34h]
int v116[2]; // [sp+34h] [bp-30h] BYREF
cocos2d::CCSprite *v117; // [sp+3Ch] [bp-28h]
int v118[2]; // [sp+40h] [bp-24h] BYREF
cocos2d::CCSprite *v119; // [sp+48h] [bp-1Ch]
float v120; // [sp+4Ch] [bp-18h] BYREF
float v121; // [sp+50h] [bp-14h]
float v122; // [sp+54h] [bp-10h]
int v123; // [sp+58h] [bp-Ch]
v4 = result;
if ( result[128] != a2 )
{
result[128] = a2;
v6 = 0.8;
(*(void (__fastcall **)(_DWORD *))(*result + 288))(result);
result = (_DWORD *)v4[127];
if ( result != (int *)((char *)&dword_0 + 1) )
v6 = 1.0;
switch ( a2 )
{
case 3:
v113 = 0;
v114 = 0;
v115 = nullptr;
RewardFrame = (const char *)RewardsPage::getRewardFrame((RewardsPage *)result, 3, v7);
v12 = strlen(RewardFrame);
std::string::__init(&v113, RewardFrame, v12);
if ( (v113 & 1) != 0 )
v14 = v115;
else
v14 = (cocos2d::CCSprite *)((char *)&v113 + 1);
v15 = cocos2d::CCSprite::createWithSpriteFrameName(v14, v13);
(*(void (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v15, 3);
if ( (v113 & 1) != 0 )
v16 = (char *)v115;
else
v16 = (char *)&v113 + 1;
sub_617D7C(v116, v16, "_back_001");
if ( (v116[0] & 1) != 0 )
v17 = v117;
else
v17 = (cocos2d::CCSprite *)((char *)v116 + 1);
v18 = cocos2d::CCSprite::createWithSpriteFrameName(v17, (const char *)(LOBYTE(v116[0]) << 31));
(*(void (__fastcall **)(_DWORD *, int, _DWORD))(*v4 + 232))(v4, v18, 0);
if ( !a3 )
{
if ( (v113 & 1) != 0 )
v19 = (char *)v115;
else
v19 = (char *)&v113 + 1;
sub_617D7C(v118, v19, "_glow_001");
if ( (v118[0] & 1) != 0 )
v21 = v119;
else
v21 = (cocos2d::CCSprite *)((char *)v118 + 1);
v22 = (int *)cocos2d::CCSprite::createWithSpriteFrameName(v21, v20);
(*(void (__fastcall **)(_DWORD *, int *, int))(*v4 + 232))(v4, v22, 1);
if ( (v118[0] & 1) != 0 )
v24 = v119;
else
v24 = (cocos2d::CCSprite *)((char *)v118 + 1);
v25 = cocos2d::CCSprite::createWithSpriteFrameName(v24, v23);
(*(void (__fastcall **)(int *, int, int))(*v22 + 232))(v22, v25, 1);
v26 = *(void (__fastcall **)(int, float *))(*(_DWORD *)v25 + 92);
v27 = *(float *)(*(int (__fastcall **)(int *))(*v22 + 164))(v22);
v28 = (*(int (__fastcall **)(int *))(*v22 + 164))(v22);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, v27 * 0.5, *(float *)(v28 + 4) * 0.5);
v26(v25, &v120);
(*(void (__fastcall **)(int, int))(*(_DWORD *)v25 + 64))(v25, 1061997773);
v29 = *v22;
v111 = 770;
v112 = 1;
(*(void (__fastcall **)(int *, int, int))(v29 + 540))(v22, 770, 1);
(*(void (__fastcall **)(int, int, int))(*(_DWORD *)v25 + 540))(v25, 770, 1);
v31 = (cocos2d::CCParticleSystem *)cocos2d::CCParticleSystemQuad::create(
(cocos2d::CCParticleSystemQuad *)"chestOpen.plist",
nullptr,
v30);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, int))(*(_DWORD *)v31 + 792))(v31, 1);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCParticleSystem *, int))(*v4 + 232))(v4, v31, 4);
v32 = v4[127];
switch ( v32 )
{
case 1:
v33 = 0;
v35 = 255;
v34 = 0;
v36 = 50;
v37 = 255;
break;
case 3:
v34 = 0;
v33 = 255;
v35 = 0;
v36 = 255;
v37 = 0;
break;
case 4:
v33 = 0;
v34 = 255;
v35 = 0;
v36 = 0;
v37 = 150;
break;
default:
v33 = 255;
v35 = 0;
v34 = 255;
v36 = 255;
v37 = 255;
break;
}
v99 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *, int))(*(_DWORD *)v31 + 680);
v123 = 1065353216;
v121 = 1.0;
v120 = (float)v37 / 255.0;
v122 = (float)v36 / 255.0;
v99(v31, &v120, 1065353216);
v38 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_DWORD *)v31 + 696);
v123 = 1065353216;
v120 = (float)v35 / 255.0;
v121 = (float)v34 / 255.0;
v122 = (float)v33 / 255.0;
v38(v31, &v120);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float))(*(_DWORD *)v31 + 80))(
v31,
COERCE_FLOAT(LODWORD(v6)));
v39 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_DWORD *)v31 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, 0.0);
v39(v31, &v120);
cocos2d::CCParticleSystem::resetSystem(v31);
std::string::~string((int)v118);
}
std::string::~string((int)v116);
break;
case 4:
v113 = 0;
v114 = 0;
v115 = nullptr;
v40 = (const char *)RewardsPage::getRewardFrame((RewardsPage *)result, 4, v7);
v41 = strlen(v40);
std::string::__init(&v113, v40, v41);
if ( (v113 & 1) != 0 )
v43 = v115;
else
v43 = (cocos2d::CCSprite *)((char *)&v113 + 1);
v44 = cocos2d::CCSprite::createWithSpriteFrameName(v43, v42);
(*(void (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v44, 4);
if ( (v113 & 1) != 0 )
v45 = (char *)v115;
else
v45 = (char *)&v113 + 1;
sub_617D7C(v116, v45, "_back_001");
if ( (v116[0] & 1) != 0 )
v46 = v117;
else
v46 = (cocos2d::CCSprite *)((char *)v116 + 1);
v47 = cocos2d::CCSprite::createWithSpriteFrameName(v46, (const char *)(LOBYTE(v116[0]) << 31));
(*(void (__fastcall **)(_DWORD *, int, _DWORD))(*v4 + 232))(v4, v47, 0);
if ( !a3 )
{
if ( (v113 & 1) != 0 )
v48 = (char *)v115;
else
v48 = (char *)&v113 + 1;
sub_617D7C(v118, v48, "_glow_001");
if ( (v118[0] & 1) != 0 )
v50 = v119;
else
v50 = (cocos2d::CCSprite *)((char *)v118 + 1);
v51 = (cocos2d::CCNode *)cocos2d::CCSprite::createWithSpriteFrameName(v50, v49);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCNode *, int))(*v4 + 232))(v4, v51, 1);
v52 = *(void (__fastcall **)(cocos2d::CCNode *, int, int, int *))(*(_DWORD *)v51 + 540);
v111 = 770;
v112 = 1;
v52(v51, 770, 1, &v111);
v54 = (cocos2d::CCEaseInOut *)cocos2d::CCFadeTo::create(
(cocos2d::CCFadeTo *)0x3F800000,
COERCE_FLOAT(175),
v53);
v56 = (cocos2d::CCSequence *)cocos2d::CCEaseInOut::create(v54, (cocos2d::CCActionInterval *)0x40000000, v55);
v58 = (cocos2d::CCEaseInOut *)cocos2d::CCFadeTo::create(
(cocos2d::CCFadeTo *)0x3F800000,
COERCE_FLOAT(255),
v57);
v60 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCEaseInOut::create(
v58,
(cocos2d::CCActionInterval *)0x40000000,
v59);
v61 = (cocos2d::CCRepeatForever *)cocos2d::CCSequence::create(v56, v60, 0);
v63 = (cocos2d::CCAction *)cocos2d::CCRepeatForever::create(v61, v62);
cocos2d::CCNode::runAction(v51, v63);
v105 = -106;
v108 = -106;
qmemcpy(v110, "3D", 2);
v110[2] = -103;
v64 = v4[127];
v104 = 0;
v65 = (const char *)(v64 - 1);
v106 = -1;
v107 = 0;
v109 = -1;
switch ( (unsigned int)v65 )
{
case 0u:
v66 = 0;
v104 = -1;
v105 = -56;
v106 = 0;
v107 = -1;
v109 = 0;
goto LABEL_61;
case 1u:
case 4u:
v105 = -56;
v108 = 100;
goto LABEL_63;
case 3u:
v105 = -1;
v67 = 255;
v108 = -1;
v68 = 0;
v106 = 0;
v109 = 50;
goto LABEL_58;
case 5u:
v105 = -56;
v108 = 100;
qmemcpy(v110, "\n6S", 3);
goto LABEL_63;
case 6u:
v67 = 255;
v68 = 100;
v105 = -1;
v108 = -1;
v106 = 0;
v109 = 50;
qmemcpy(v110, ")Q;", 3);
LABEL_58:
v66 = 0;
v69 = 255;
v70 = 150;
break;
case 7u:
v68 = 255;
v104 = -1;
v107 = -1;
v67 = 0;
v105 = 0;
v110[0] = 58;
v66 = 255;
v108 = 0;
v110[1] = 27;
v69 = 150;
v110[2] = 75;
goto LABEL_62;
case 8u:
v66 = 0;
v104 = -1;
v107 = -1;
v105 = -56;
v106 = 0;
v110[0] = 39;
v109 = 0;
v110[1] = 29;
v110[2] = 44;
LABEL_61:
v68 = 255;
v67 = 100;
v69 = 255;
LABEL_62:
v70 = 255;
break;
default:
LABEL_63:
v67 = 0;
v66 = 255;
v68 = 0;
v69 = 255;
v70 = 0;
break;
}
v71 = (cocos2d::CCNode *)cocos2d::CCSprite::createWithSpriteFrameName(
(cocos2d::CCSprite *)"shineBurst_001.png",
v65);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCNode *, int))(*v4 + 232))(v4, v71, 1);
(*(void (__fastcall **)(cocos2d::CCNode *, int, int))(*(_DWORD *)v71 + 540))(v71, v111, v112);
v103 = *(void (__fastcall **)(cocos2d::CCNode *, float *))(*(_DWORD *)v71 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, -5.0);
v103(v71, &v120);
(*(void (__fastcall **)(cocos2d::CCNode *, _DWORD))(*(_DWORD *)v71 + 80))(v71, v6 * 4.0);
(*(void (__fastcall **)(cocos2d::CCNode *, char *))(*(_DWORD *)v71 + 480))(v71, &v104);
v72 = -1.0;
if ( (float)((float)rand() * 4.6566e-10) > 0.5 )
v72 = 1.0;
v73 = rand();
v75 = (cocos2d::CCRepeatForever *)cocos2d::CCRotateBy::create(
(cocos2d::CCRotateBy *)0x3F800000,
(float)((float)((float)((float)((float)v73 * 4.6566e-10) * 0.5) + 0.5)
* 180.0)
* v72,
v74);
v77 = (cocos2d::CCAction *)cocos2d::CCRepeatForever::create(v75, v76);
cocos2d::CCNode::runAction(v71, v77);
v79 = (cocos2d::CCNode *)cocos2d::CCSprite::createWithSpriteFrameName(
(cocos2d::CCSprite *)"shineBurst_001.png",
v78);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCNode *, int))(*v4 + 232))(v4, v79, 1);
(*(void (__fastcall **)(cocos2d::CCNode *, int, int))(*(_DWORD *)v79 + 540))(v79, v111, v112);
v100 = *(void (__fastcall **)(cocos2d::CCNode *, float *))(*(_DWORD *)v79 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, -5.0);
v100(v79, &v120);
(*(void (__fastcall **)(cocos2d::CCNode *, _DWORD))(*(_DWORD *)v79 + 80))(v79, v6 * 3.5);
(*(void (__fastcall **)(cocos2d::CCNode *, char *))(*(_DWORD *)v79 + 480))(v79, &v107);
v80 = rand();
v82 = (cocos2d::CCRepeatForever *)cocos2d::CCRotateBy::create(
(cocos2d::CCRotateBy *)0x3F800000,
-(float)(v72
* (float)((float)((float)((float)((float)v80 * 4.6566e-10) * 0.5)
+ 0.5)
* 180.0)),
v81);
v84 = (cocos2d::CCAction *)cocos2d::CCRepeatForever::create(v82, v83);
cocos2d::CCNode::runAction(v79, v84);
v86 = (cocos2d::CCParticleSystem *)cocos2d::CCParticleSystemQuad::create(
(cocos2d::CCParticleSystemQuad *)"chestOpened.plist",
nullptr,
v85);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, int))(*(_DWORD *)v86 + 792))(v86, 1);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCParticleSystem *, int))(*v4 + 232))(v4, v86, 1);
v101 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_DWORD *)v86 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, 0.0);
v101(v86, &v120);
v102 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_DWORD *)v86 + 680);
v123 = 1065353216;
v120 = (float)v70 / 255.0;
v121 = (float)v69 / 255.0;
v87 = (float)v66 / 255.0;
v122 = v87;
v102(v86, &v120);
v88 = *(void (__fastcall **)(cocos2d::CCParticleSystem *, float *))(*(_DWORD *)v86 + 696);
v123 = 1065353216;
v122 = v87;
v120 = (float)v68 / 255.0;
v121 = (float)v67 / 255.0;
v88(v86, &v120);
(*(void (__fastcall **)(cocos2d::CCParticleSystem *, float))(*(_DWORD *)v86 + 80))(
v86,
COERCE_FLOAT(LODWORD(v6)));
cocos2d::CCParticleSystem::resetSystem(v86);
v90 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"chest_glow_bg_001.png", v89);
(*(void (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v90, 2);
(*(void (__fastcall **)(int, float))(*(_DWORD *)v90 + 80))(v90, COERCE_FLOAT(LODWORD(v6)));
(*(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v90 + 480))(v90, v110);
v92 = (cocos2d::CCSprite *)cocos2d::CCSprite::createWithSpriteFrameName(
(cocos2d::CCSprite *)"chest_glow_bg_001.png",
v91);
cocos2d::CCSprite::setFlipX(v92, 1);
(*(void (__fastcall **)(_DWORD *, cocos2d::CCSprite *, int))(*v4 + 232))(v4, v92, 2);
(*(void (__fastcall **)(cocos2d::CCSprite *, float))(*(_DWORD *)v92 + 80))(v92, COERCE_FLOAT(LODWORD(v6)));
(*(void (__fastcall **)(cocos2d::CCSprite *, _BYTE *))(*(_DWORD *)v92 + 480))(v92, v110);
v94 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"whiteSquare60_001.png", v93);
v95 = *(void (__fastcall **)(int, float *))(*(_DWORD *)v94 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, v6 * -52.0);
v95(v94, &v120);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v94 + 64))(v94, v6 * 5.2);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v94 + 72))(v94, v6 * 2.2);
(*(void (__fastcall **)(int, _BYTE *))(*(_DWORD *)v94 + 480))(v94, v110);
(*(void (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v94, 2);
v97 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"chest_shadow_001.png", v96);
v98 = *(void (__fastcall **)(int, float *))(*(_DWORD *)v97 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v120, 0.0, v6 * -48.0);
v98(v97, &v120);
(*(void (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v97, 3);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v97 + 80))(v97, v6 * 0.95);
(*(void (__fastcall **)(int, int))(*(_DWORD *)v97 + 456))(v97, 90);
std::string::~string((int)v118);
}
std::string::~string((int)v116);
break;
case 2:
v8 = (cocos2d::CCSprite *)RewardsPage::getRewardFrame((RewardsPage *)result, 2, v7);
v10 = cocos2d::CCSprite::createWithSpriteFrameName(v8, v9);
return (_DWORD *)(*(int (__fastcall **)(_DWORD *, int, int))(*v4 + 232))(v4, v10, 3);
default:
return result;
}
return (_DWORD *)std::string::~string((int)&v113);
}
return result;
}