//
// GJChestSprite::switchToState from 0x10025c874 to 0x10025d45c (3048 bytes)
//
// 12 xrefs:
// > GJNotificationCell::loadFromNotification @ 0x10013149c
// > sub_1001327F8 @ 0x100132888
// > RewardUnlockLayer::step2 @ 0x10025b838
// > RewardUnlockLayer::playRewardEffect @ 0x10025bab4
// > sub_10025DCCC @ 0x10025dd18
// > SecretRewardsLayer::switchToOpenedState @ 0x100384c2c
// > SecretRewardsLayer::generateChestItems @ 0x1003862b8
// > SecretLayer3::init @ 0x1003ab73c
// > SecretLayer3::init @ 0x1003ab960
// > SecretLayer4::init @ 0x1003f3fe4
// > FollowRewardPage::init @ 0x1004a75f0
// > sub_1004A8030 @ 0x1004a806c
//
// This function is hookable on this platform (idp: arm, 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:01:37 +0000
//
void __fastcall GJChestSprite::switchToState(_DWORD *a1, int a2, char a3)
{
float v6; // s8
__int64 v7; // x0
__int64 CString; // x0
__int64 v9; // x0
__int64 v10; // x0
char *v11; // x0
void **v12; // x0
__int64 v13; // x0
char *v14; // x0
void **v15; // x0
__int64 v16; // x0
char *v17; // x0
void **v18; // x0
__int64 v19; // x20
void **v20; // x0
__int64 v21; // x21
float v22; // s10
__int64 v23; // x0
__int64 v24; // x20
unsigned int v25; // w8
unsigned __int32 v26; // w19
unsigned int v27; // w8
__int64 v28; // x0
char *v29; // x0
void **v30; // x0
__int64 v31; // x0
char *v32; // x0
void **v33; // x0
__int64 v34; // x0
char *v35; // x0
void **v36; // x0
__int64 v37; // x20
float *v38; // x0
__int64 v39; // x21
float *v40; // x0
char v41; // w0
__int64 v42; // x1
__int64 v43; // x2
__int64 v44; // x3
__int64 v45; // x4
__int64 v46; // x5
__int64 v47; // x6
__int64 v48; // x7
__int64 v49; // x0
_DWORD *v50; // x0
int v51; // w8
unsigned __int32 v52; // w22
unsigned __int32 v53; // w21
int8x8_t v54; // d2
__int16 v55; // w8
__int64 v56; // x20
float v57; // s9
unsigned int v58; // w0
float *v59; // x0
_DWORD *v60; // x0
__int64 v61; // x20
unsigned int v62; // w0
float *v63; // x0
_DWORD *v64; // x0
__int64 v65; // x20
int8x8_t v66; // d1
float32x2_t v67; // d10
int8x8_t v68; // d1
__int64 v69; // x20
__int64 v70; // x20
__int64 v71; // x20
__int64 v72; // x20
_WORD v73[2]; // [xsp+1Ch] [xbp-B4h] BYREF
__int16 v74; // [xsp+20h] [xbp-B0h] BYREF
char v75; // [xsp+22h] [xbp-AEh]
__int16 v76; // [xsp+24h] [xbp-ACh] BYREF
char v77; // [xsp+26h] [xbp-AAh]
float32x2_t v78; // [xsp+28h] [xbp-A8h] BYREF
float v79; // [xsp+30h] [xbp-A0h]
int v80; // [xsp+34h] [xbp-9Ch]
void *__p[2]; // [xsp+38h] [xbp-98h] BYREF
char v82; // [xsp+4Fh] [xbp-81h]
void *v83[2]; // [xsp+50h] [xbp-80h] BYREF
char v84; // [xsp+67h] [xbp-69h]
void *v85[2]; // [xsp+68h] [xbp-68h] BYREF
char v86; // [xsp+7Fh] [xbp-51h]
if ( a1[150] == a2 )
return;
a1[150] = a2;
(*(void (__fastcall **)(_DWORD *))(*(_QWORD *)a1 + 576LL))(a1);
if ( a1[149] == 1 )
v6 = 0.8;
else
v6 = 1.0;
if ( a2 != 4 )
{
if ( a2 != 3 )
{
if ( a2 == 2 )
{
v7 = sub_1003065B0("chest_%02d_%02d_001.png", a1[149], 2);
CString = cocos2d::CCString::getCString(v7);
v9 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v9, 3);
}
return;
}
v10 = sub_1003065B0("chest_%02d_%02d_001.png", a1[149], 3);
v11 = (char *)cocos2d::CCString::getCString(v10);
sub_100009900(v85, v11);
if ( v86 >= 0 )
v12 = v85;
else
v12 = (void **)v85[0];
v13 = cocos2d::CCSprite::createWithSpriteFrameName(v12);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v13, 3);
if ( v86 >= 0 )
v14 = (char *)v85;
else
v14 = (char *)v85[0];
sub_10025DE74((__int64 *)v83, v14);
if ( v84 >= 0 )
v15 = v83;
else
v15 = (void **)v83[0];
v16 = cocos2d::CCSprite::createWithSpriteFrameName(v15);
(*(void (__fastcall **)(_DWORD *, __int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, v16, 0);
if ( (a3 & 1) != 0 )
goto LABEL_72;
if ( v86 >= 0 )
v17 = (char *)v85;
else
v17 = (char *)v85[0];
sub_10025DE74((__int64 *)__p, v17);
if ( v82 >= 0 )
v18 = __p;
else
v18 = (void **)__p[0];
v19 = cocos2d::CCSprite::createWithSpriteFrameName(v18);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v19, 1);
if ( v82 >= 0 )
v20 = __p;
else
v20 = (void **)__p[0];
v21 = cocos2d::CCSprite::createWithSpriteFrameName(v20);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v19 + 464LL))(v19, v21, 1);
v22 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 328LL))(v19);
v23 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 328LL))(v19);
sub_1000262BC((float *)&v78, v22 * 0.5, *(float *)(v23 + 4) * 0.5);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v21 + 184LL))(v21, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v21 + 128LL))(v21, 0.8);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v19 + 1080LL))(v19, 0x100000302LL);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v21 + 1080LL))(v21, 0x100000302LL);
v24 = cocos2d::CCParticleSystemQuad::create("chestOpen.plist", 0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v24 + 1584LL))(v24, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v24, 4);
v25 = a1[149] - 1;
if ( v25 >= 4 )
{
v27 = 0xFFFFFF;
v26 = 16776960;
}
else
{
v26 = dword_100762BD0[v25];
v27 = dword_100762BE0[v25];
}
v78.f32[0] = (float)(unsigned __int8)v27 / 255.0;
v78.i32[1] = 1065353216;
v79 = (float)HIWORD(v27) / 255.0;
v80 = 1065353216;
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v24 + 1360LL))(v24, &v78);
v54.i32[0] = v26;
v54.i32[1] = v26 >> 8;
v78 = vdiv_f32(
vcvt_f32_u32((uint32x2_t)vand_s8(v54, (int8x8_t)0xFF000000FFLL)),
(float32x2_t)vdup_n_s32(0x437F0000u));
v79 = (float)HIWORD(v26) / 255.0;
v80 = 1065353216;
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v24 + 1392LL))(v24, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v24 + 160LL))(v24, v6);
sub_1000262BC((float *)&v78, 0.0, 0.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v24 + 184LL))(v24, &v78);
cocos2d::CCParticleSystem::resetSystem(v24);
goto LABEL_70;
}
v28 = sub_1003065B0("chest_%02d_%02d_001.png", a1[149], 4);
v29 = (char *)cocos2d::CCString::getCString(v28);
sub_100009900(v85, v29);
if ( v86 >= 0 )
v30 = v85;
else
v30 = (void **)v85[0];
v31 = cocos2d::CCSprite::createWithSpriteFrameName(v30);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v31, 4);
if ( v86 >= 0 )
v32 = (char *)v85;
else
v32 = (char *)v85[0];
sub_10025DE74((__int64 *)v83, v32);
if ( v84 >= 0 )
v33 = v83;
else
v33 = (void **)v83[0];
v34 = cocos2d::CCSprite::createWithSpriteFrameName(v33);
(*(void (__fastcall **)(_DWORD *, __int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, v34, 0);
if ( (a3 & 1) == 0 )
{
if ( v86 >= 0 )
v35 = (char *)v85;
else
v35 = (char *)v85[0];
sub_10025DE74((__int64 *)__p, v35);
if ( v82 >= 0 )
v36 = __p;
else
v36 = (void **)__p[0];
v37 = cocos2d::CCSprite::createWithSpriteFrameName(v36);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v37, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v37 + 1080LL))(v37, 0x100000302LL);
v38 = cocos2d::CCFadeTo::create(175, 1.0);
v39 = cocos2d::CCEaseInOut::create(v38, 2.0);
v40 = cocos2d::CCFadeTo::create(255, 1.0);
v41 = cocos2d::CCEaseInOut::create(v40, 2.0);
v49 = sub_10021D420(v39, v42, v43, v44, v45, v46, v47, v48, v41);
v50 = cocos2d::CCRepeatForever::create(v49);
cocos2d::CCNode::runAction(v37, v50);
v77 = -1;
v76 = -27136;
v75 = -1;
v74 = -27136;
LOBYTE(v73[1]) = -103;
v73[0] = 17459;
v51 = a1[149];
v52 = 16776960;
v53 = 16711680;
if ( v51 <= 5 )
{
if ( v51 > 3 )
{
if ( v51 == 4 )
{
v77 = 0;
v53 = 65280;
v76 = -256;
v74 = -256;
v75 = 50;
v52 = 65430;
goto LABEL_66;
}
}
else
{
if ( v51 == 1 )
{
v77 = 0;
v76 = -14081;
v75 = 0;
v74 = -26881;
v52 = 0xFFFF;
v53 = 25855;
goto LABEL_66;
}
if ( v51 != 2 )
goto LABEL_66;
}
v77 = -1;
v76 = -14336;
v75 = -1;
v74 = 25600;
LABEL_66:
v56 = cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v56, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v56 + 1080LL))(v56, 0x100000302LL);
sub_1000262BC((float *)&v78, 0.0, -5.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v56 + 184LL))(v56, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 160LL))(v56, v6 * 4.0);
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v56 + 960LL))(v56, &v76);
if ( vcvts_n_f32_s32(rand(), 0x1Fu) <= 0.5 )
v57 = -1.0;
else
v57 = 1.0;
v58 = rand();
v59 = cocos2d::CCRotateBy::create_1(
1.0,
v57 * (float)((float)((float)(vcvts_n_f32_s32(v58, 0x1Fu) * 0.5) + 0.5) * 180.0));
v60 = cocos2d::CCRepeatForever::create((__int64)v59);
cocos2d::CCNode::runAction(v56, v60);
v61 = cocos2d::CCSprite::createWithSpriteFrameName("shineBurst_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v61, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v61 + 1080LL))(v61, 0x100000302LL);
sub_1000262BC((float *)&v78, 0.0, -5.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v61 + 184LL))(v61, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v61 + 160LL))(v61, v6 * 3.5);
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v61 + 960LL))(v61, &v74);
v62 = rand();
v63 = cocos2d::CCRotateBy::create_1(
1.0,
(float)((float)((float)(vcvts_n_f32_s32(v62, 0x1Fu) * 0.5) + 0.5) * -180.0) * v57);
v64 = cocos2d::CCRepeatForever::create((__int64)v63);
cocos2d::CCNode::runAction(v61, v64);
v65 = cocos2d::CCParticleSystemQuad::create("chestOpened.plist", 0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v65 + 1584LL))(v65, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v65, 1);
sub_1000262BC((float *)&v78, 0.0, 0.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v65 + 184LL))(v65, &v78);
v66.i32[0] = v52;
v66.i32[1] = v52 >> 8;
v67 = (float32x2_t)vdup_n_s32(0x437F0000u);
v78 = vdiv_f32(vcvt_f32_u32((uint32x2_t)vand_s8(v66, (int8x8_t)0xFF000000FFLL)), v67);
v79 = (float)HIWORD(v52) / 255.0;
v80 = 1065353216;
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v65 + 1360LL))(v65, &v78);
v68.i32[0] = v53;
v68.i32[1] = v53 >> 8;
v78 = vdiv_f32(vcvt_f32_u32((uint32x2_t)vand_s8(v68, (int8x8_t)0xFF000000FFLL)), v67);
v79 = (float)HIWORD(v53) / 255.0;
v80 = 1065353216;
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v65 + 1392LL))(v65, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v65 + 160LL))(v65, v6);
cocos2d::CCParticleSystem::resetSystem(v65);
v69 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v69, 2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v69 + 160LL))(v69, v6);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v69 + 960LL))(v69, v73);
v70 = cocos2d::CCSprite::createWithSpriteFrameName("chest_glow_bg_001.png");
cocos2d::CCSprite::setFlipX(v70, 1);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v70, 2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v70 + 160LL))(v70, v6);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v70 + 960LL))(v70, v73);
v71 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
sub_1000262BC((float *)&v78, 0.0, v6 * -52.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v71 + 184LL))(v71, &v78);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v71 + 128LL))(v71, v6 * 5.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v71 + 144LL))(v71, v6 * 2.2);
(*(void (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v71 + 960LL))(v71, v73);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v71, 2);
v72 = cocos2d::CCSprite::createWithSpriteFrameName("chest_shadow_001.png");
sub_1000262BC((float *)&v78, 0.0, v6 * -48.0);
(*(void (__fastcall **)(__int64, float32x2_t *))(*(_QWORD *)v72 + 184LL))(v72, &v78);
(*(void (__fastcall **)(_DWORD *, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v72, 3);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v72 + 160LL))(v72, v6 * 0.95);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v72 + 912LL))(v72, 90);
LABEL_70:
if ( v82 < 0 )
operator delete(__p[0]);
goto LABEL_72;
}
if ( v51 > 7 )
{
if ( v51 == 8 )
{
v77 = -1;
v76 = 255;
v75 = -1;
v74 = 255;
LOBYTE(v73[1]) = 75;
v55 = 6970;
v52 = 16750335;
v53 = 16711935;
}
else
{
if ( v51 != 9 )
goto LABEL_66;
v77 = 0;
v76 = -14081;
v75 = 0;
v74 = -26881;
LOBYTE(v73[1]) = 44;
v55 = 7463;
v52 = 0xFFFF;
v53 = 25855;
}
}
else
{
if ( v51 != 6 )
{
v77 = 0;
v76 = -256;
v74 = -256;
v75 = 50;
qmemcpy(v73, ")Q;", 3);
v52 = 65430;
v53 = 65380;
goto LABEL_66;
}
v77 = -1;
v76 = -14336;
v75 = -1;
v74 = 25600;
LOBYTE(v73[1]) = 83;
v55 = 13834;
}
v73[0] = v55;
goto LABEL_66;
}
LABEL_72:
if ( v84 < 0 )
operator delete(v83[0]);
if ( v86 < 0 )
operator delete(v85[0]);
}