//
// RewardsPage::init from 0x1001c3a94 to 0x1001c445c (2504 bytes)
//
// 2 xrefs:
// > RewardsPage::create @ 0x1001c3a48
// > ??> @ 0x1007b7c38
//
// 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
//
bool __fastcall RewardsPage::init(RewardsPage *a1)
{
_BOOL4 v2; // w20
cocos2d::CCDirector *v3; // x0
cocos2d::CCLayer *v4; // x0
cocos2d::extension::CCScale9Sprite *v5; // x21
__n128 v6; // q0
__n128 v7; // q1
cocos2d::CCSprite *v8; // x21
__n128 v9; // q0
__n128 v10; // q1
int i; // w23
cocos2d::CCSprite *v12; // x22
__n128 v13; // q0
__n128 v14; // q1
int v15; // w8
int v16; // w8
float v17; // w8
cocos2d::CCSprite *v18; // x0
CCMenuItemSpriteExtra *v19; // x21
cocos2d::CCMenu *v20; // x22
float v21; // s2
__n128 v22; // q0
__n128 v23; // q1
GameStatsManager *v24; // x21
GameStatsManager *v25; // x21
GameStatsManager *v26; // x21
GameStatsManager *v27; // x21
GameStatsManager *v28; // x21
GameStatsManager *v29; // x21
int v30; // w21
cocos2d::CCSprite *v31; // x21
CCMenuItemSpriteExtra *v32; // x22
__n128 v33; // q0
cocos2d::CCMenu *m_buttonMenu; // x23
__n128 v35; // q1
cocos2d::CCScaleTo *v36; // x0
cocos2d::CCEaseInOut *v37; // x22
cocos2d::CCScaleTo *v38; // x0
char v39; // w0
__int64 v40; // x1
__int64 v41; // x2
__int64 v42; // x3
__int64 v43; // x4
__int64 v44; // x5
__int64 v45; // x6
__int64 v46; // x7
cocos2d::CCSequence *v47; // x0
cocos2d::CCRepeatForever *v48; // x0
__n128 v49; // q0
__n128 v50; // q1
cocos2d::CCLabelBMFont *v51; // x0
__n128 v52; // q0
cocos2d::CCLabelBMFont *m_leftLabel; // x23
__n128 v54; // q1
double v55; // d0
cocos2d::CCLabelBMFont *v56; // x0
__n128 v57; // q0
cocos2d::CCLabelBMFont *m_rightLabel; // x21
__n128 v59; // q1
double v60; // d0
cocos2d::CCString *v61; // x0
const char *CString; // x0
cocos2d::CCSprite *v63; // x21
CCMenuItemSpriteExtra *v64; // x22
__n128 v65; // q0
CCMenuItemSpriteExtra *m_rightChest; // x22
cocos2d::CCMenu *v67; // x23
cocos2d::CCLayer *m_mainLayer; // x24
__n128 v69; // q1
cocos2d::CCString *v70; // x0
const char *v71; // x0
cocos2d::CCSprite *v72; // x22
float v73; // s8
CCMenuItemSpriteExtra *v74; // x0
CCMenuItemSpriteExtra *m_leftChest; // x21
float v76; // s8
__n128 v77; // q0
CCMenuItemSpriteExtra *v78; // x21
cocos2d::CCMenu *v79; // x22
cocos2d::CCLayer *v80; // x23
__n128 v81; // q1
GameStatsManager *v82; // x0
float v83; // s0
GameLevelManager *v84; // x0
std::string v86; // [xsp+18h] [xbp-148h] BYREF
float32x2_t v87; // [xsp+30h] [xbp-130h] BYREF
float32x2_t v88; // [xsp+38h] [xbp-128h] BYREF
std::string __str; // [xsp+40h] [xbp-120h] BYREF
float32x2_t v90; // [xsp+58h] [xbp-108h] BYREF
void *__p[2]; // [xsp+60h] [xbp-100h] BYREF
char v92; // [xsp+77h] [xbp-E9h]
void *v93[2]; // [xsp+78h] [xbp-E8h] BYREF
char v94; // [xsp+8Fh] [xbp-D1h]
void *v95[2]; // [xsp+90h] [xbp-D0h] BYREF
char v96; // [xsp+A7h] [xbp-B9h]
void *v97[2]; // [xsp+A8h] [xbp-B8h] BYREF
char v98; // [xsp+BFh] [xbp-A1h]
void *v99[2]; // [xsp+C0h] [xbp-A0h] BYREF
char v100; // [xsp+D7h] [xbp-89h]
void *v101[2]; // [xsp+D8h] [xbp-88h] BYREF
char v102; // [xsp+EFh] [xbp-71h]
float32x2_t v103; // [xsp+F0h] [xbp-70h] BYREF
float32x2_t v104[2]; // [xsp+F8h] [xbp-68h] BYREF
float v105; // [xsp+108h] [xbp-58h]
float v106; // [xsp+10Ch] [xbp-54h]
cocos2d::CCPoint v107; // 0:kr08_8.8
cocos2d::CCPoint v108; // 0:kr10_8.8
cocos2d::CCPoint v109; // 0:kr20_8.8
cocos2d::CCPoint v110; // 0:kr30_8.8
cocos2d::SEL_SCHEDULE v111; // 0:x1.16
cocos2d::SEL_MenuHandler v112; // 0:x3.16
cocos2d::SEL_MenuHandler v113; // 0:x3.16
cocos2d::SEL_MenuHandler v114; // 0:x3.16
cocos2d::SEL_MenuHandler v115; // 0:x3.16
cocos2d::CCRect v116; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
FLAlertLayer::incrementForcePrio(a1);
v104[0].i32[0] = -1778384896;
v2 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)v104);
if ( !v2 )
return v2;
((void (__fastcall *)(RewardsPage *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(RewardsPage *, __int64))a1->setKeypadEnabled)(a1, 1);
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v3);
v4 = cocos2d::CCLayer::create();
a1->m_mainLayer = v4;
((void (__fastcall *)(RewardsPage *, cocos2d::CCLayer *))a1->addChild)(a1, v4);
sub_100022990((float *)v104, 0.0, 0.0, 80.0, 80.0);
v5 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", v116);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v5->setOpacity)(v5, 255);
sub_100022988((float *)v104, 340.0, 220.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v5->setContentSize)(v5, v104);
v6 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v5,
0xFFFFFFFFLL);
v6.n128_f32[0] = v105 * 0.5;
v7.n128_f32[0] = v106 * 0.5;
sub_100022980(v6, v7, v104);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float32x2_t *))v5->setPosition)(v5, v104);
v8 = cocos2d::CCSprite::createWithSpriteFrameName("rewardsLabel_001.png");
v9 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v8,
20);
v9.n128_f32[0] = v105 * 0.5;
v10.n128_f32[0] = (float)((float)(v106 * 0.5) + 110.0) + -32.0;
sub_100022980(v9, v10, v104);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v8->setPosition)(v8, v104);
for ( i = 0; i != 4; ++i )
{
v12 = cocos2d::CCSprite::createWithSpriteFrameName("rewardCorner_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v12,
8);
if ( i > 1 )
{
if ( i != 2 )
{
cocos2d::CCSprite::setFlipX(v12, 1);
v15 = 1125187584;
goto LABEL_11;
}
cocos2d::CCSprite::setFlipX(v12, 1);
cocos2d::CCSprite::setFlipY(v12, 1);
v16 = 1125187584;
LABEL_9:
v13.n128_u32[0] = v16;
v17 = 85.0;
goto LABEL_12;
}
if ( i )
{
cocos2d::CCSprite::setFlipY(v12, 1);
v16 = -1022296064;
goto LABEL_9;
}
v15 = -1022296064;
LABEL_11:
v13.n128_u32[0] = v15;
v17 = -85.0;
LABEL_12:
v13.n128_f32[0] = v13.n128_f32[0] + (float)(v105 * 0.5);
v14.n128_f32[0] = v17 + (float)(v106 * 0.5);
sub_100022980(v13, v14, v104);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v12->setPosition)(v12, v104);
}
a1->m_joystickConnected = -1;
v18 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v112.ptr = (void (__cdecl *)(cocos2d::CCObject *))RewardsPage::onClose;
v112.adj = 0;
v19 = CCMenuItemSpriteExtra::create(v18, nullptr, a1, v112);
CCMenuItemSpriteExtra::setSizeMult(v19, 1.6);
v20 = (cocos2d::CCMenu *)sub_1001D7ED0(v19);
v21 = v106;
v22.n128_f32[0] = (float)((float)(v105 * 0.5) + -170.0) + 10.0;
a1->m_buttonMenu = v20;
v23.n128_f32[0] = (float)((float)(v21 * 0.5) + 110.0) + -10.0;
sub_100022980(v22, v23, &v103);
v107 = cocos2d::CCNode::convertToNodeSpace(v20, (const cocos2d::CCPoint *)&v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v19->setPosition)(
v19,
v104,
v107.x,
v107.y);
v24 = GameStatsManager::sharedState();
sub_100009900(v101, "0007");
if ( (unsigned int)GameStatsManager::isSpecialChestUnlocked(v24, v101) )
{
v25 = GameStatsManager::sharedState();
sub_100009900(v99, "0008");
if ( (unsigned int)GameStatsManager::isSpecialChestUnlocked(v25, v99) )
{
v26 = GameStatsManager::sharedState();
sub_100009900(v97, "0009");
if ( (unsigned int)GameStatsManager::isSpecialChestUnlocked(v26, v97) )
{
v27 = GameStatsManager::sharedState();
sub_100009900(v95, "0010");
if ( (unsigned int)GameStatsManager::isSpecialChestUnlocked(v27, v95) )
{
v28 = GameStatsManager::sharedState();
sub_100009900(v93, "0011");
if ( (unsigned int)GameStatsManager::isSpecialChestUnlocked(v28, v93) )
{
v29 = GameStatsManager::sharedState();
sub_100009900(__p, "0024");
v30 = GameStatsManager::isSpecialChestUnlocked(v29, __p) ^ 1;
if ( v92 < 0 )
operator delete(__p[0]);
}
else
{
v30 = 1;
}
if ( v94 < 0 )
operator delete(v93[0]);
}
else
{
v30 = 1;
}
if ( v96 < 0 )
operator delete(v95[0]);
}
else
{
v30 = 1;
}
if ( v98 < 0 )
operator delete(v97[0]);
}
else
{
v30 = 1;
}
if ( v100 < 0 )
operator delete(v99[0]);
}
else
{
v30 = 1;
}
if ( v102 < 0 )
{
operator delete(v101[0]);
if ( v30 )
{
LABEL_35:
v31 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_freeChestBtn_001.png");
v113.ptr = (void (__cdecl *)(cocos2d::CCObject *))RewardsPage::onFreeStuff;
v113.adj = 0;
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, a1, v113);
CCMenuItemSpriteExtra::setSizeMult(v32, 1.6);
v33 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v32);
m_buttonMenu = a1->m_buttonMenu;
v33.n128_f32[0] = (float)((float)(v105 * 0.5) + 170.0) + -10.0;
v35.n128_f32[0] = (float)((float)(v106 * 0.5) + 110.0) + -10.0;
sub_100022980(v33, v35, &v103);
v108 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)&v103);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v32->setPosition)(
v32,
v104,
v108.x,
v108.y);
v36 = cocos2d::CCScaleTo::create_1(0.5, 1.1);
v37 = cocos2d::CCEaseInOut::create(v36, 2.0);
v38 = cocos2d::CCScaleTo::create_1(0.5, 1.0);
v39 = (unsigned __int8)cocos2d::CCEaseInOut::create(v38, 2.0);
v47 = sub_10018A494(v37, v40, v41, v42, v43, v44, v45, v46, v39);
v48 = cocos2d::CCRepeatForever::create(v47);
cocos2d::CCNode::runAction(v31, v48);
}
}
else if ( v30 )
{
goto LABEL_35;
}
v49 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
a1->m_buttonMenu,
10);
v49.n128_f32[0] = v105 * 0.5;
v50.n128_f32[0] = (float)(v106 * 0.5) + -24.0;
sub_100022980(v49, v50, v104);
v51 = cocos2d::CCLabelBMFont::create_1("00:00:00", "bigFont.fnt");
a1->m_leftLabel = v51;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v51,
20);
v52 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_leftLabel->setScale)(a1->m_leftLabel, 0.5);
m_leftLabel = a1->m_leftLabel;
v52.n128_u32[0] = -1031012352;
v54.n128_u32[0] = -1035468800;
sub_100022980(v52, v54, &v90);
*(float32x2_t *)&v55 = sub_1000229DC(v104, &v90, &v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))m_leftLabel->setPosition)(
m_leftLabel,
&v103,
v55);
v56 = cocos2d::CCLabelBMFont::create_1("00:00:00", "bigFont.fnt");
a1->m_rightLabel = v56;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v56,
20);
v57 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_rightLabel->setScale)(a1->m_rightLabel, 0.5);
m_rightLabel = a1->m_rightLabel;
v57.n128_u32[0] = 1116471296;
v59.n128_u32[0] = -1035468800;
sub_100022980(v57, v59, &v90);
*(float32x2_t *)&v60 = sub_1000229DC(v104, &v90, &v103);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float32x2_t *, double))m_rightLabel->setPosition)(
m_rightLabel,
&v103,
v60);
v61 = (cocos2d::CCString *)sub_100268F4C("chest_%02d_%02d_001.png", 2, 1);
CString = cocos2d::CCString::getCString(v61);
v63 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
v114.ptr = (void (__cdecl *)(cocos2d::CCObject *))RewardsPage::onReward;
v114.adj = 0;
v64 = CCMenuItemSpriteExtra::create(v63, nullptr, a1, v114);
a1->m_rightChest = v64;
sub_100009900(&__str, "chestClick.ogg");
std::string::operator=((std::string *)&v64->m_selectSound, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))a1->m_rightChest->setTag)(a1->m_rightChest, 2);
v65 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
a1->m_rightChest);
m_rightChest = a1->m_rightChest;
v67 = a1->m_buttonMenu;
m_mainLayer = a1->m_mainLayer;
v65.n128_u32[0] = 1116471296;
v69.n128_u32[0] = 14.0;
sub_100022980(v65, v69, &v87);
sub_1000229DC(v104, &v87, &v88);
cocos2d::CCNode::convertToWorldSpace(m_mainLayer, (const cocos2d::CCPoint *)&v88);
v109 = cocos2d::CCNode::convertToNodeSpace(v67, (const cocos2d::CCPoint *)&v90);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))m_rightChest->setPosition)(
m_rightChest,
&v103,
v109.x,
v109.y);
a1->m_rightChest->m_scaleMultiplier = 1.08;
v70 = (cocos2d::CCString *)sub_100268F4C("chest_%02d_%02d_001.png", 1, 1);
v71 = cocos2d::CCString::getCString(v70);
v72 = cocos2d::CCSprite::createWithSpriteFrameName(v71);
v73 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))v63->getContentSize)(v63) + 4);
v115.ptr = (void (__cdecl *)(cocos2d::CCObject *))RewardsPage::onReward;
v115.adj = 0;
v74 = CCMenuItemSpriteExtra::create(v72, nullptr, a1, v115);
a1->m_leftChest = v74;
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v74->setTag)(v74, 1);
m_leftChest = a1->m_leftChest;
sub_100009900(&v86, "chestClick.ogg");
std::string::operator=((std::string *)&m_leftChest->m_selectSound, &v86);
v76 = v73 * 0.2;
if ( SHIBYTE(v86.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v86.__r_.__value_.__l.__data_);
v77 = ((__n128 (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
a1->m_leftChest);
v78 = a1->m_leftChest;
v79 = a1->m_buttonMenu;
v80 = a1->m_mainLayer;
v81.n128_f32[0] = (float)(v76 * -0.5) + 14.0;
v77.n128_u32[0] = -1031012352;
sub_100022980(v77, v81, &v87);
sub_1000229DC(v104, &v87, &v88);
cocos2d::CCNode::convertToWorldSpace(v80, (const cocos2d::CCPoint *)&v88);
v110 = cocos2d::CCNode::convertToNodeSpace(v79, (const cocos2d::CCPoint *)&v90);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v78->setPosition)(
v78,
&v103,
v110.x,
v110.y);
a1->m_leftChest->m_scaleMultiplier = 1.08;
GameLevelManager::sharedState()->m_GJRewardDelegate = &a1->GJRewardDelegate;
v82 = GameStatsManager::sharedState();
if ( GameStatsManager::areRewardsLoaded(v82) )
{
RewardsPage::updateTimers(a1, v83);
}
else
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_leftLabel->setVisible)(a1->m_leftLabel, 0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_rightLabel->setVisible)(a1->m_rightLabel, 0);
v84 = GameLevelManager::sharedState();
GameLevelManager::getGJRewards(v84, 0);
}
v111.ptr = (void (__cdecl *)(float))RewardsPage::updateTimers;
v111.adj = 0;
cocos2d::CCNode::schedule(a1, v111, 1.0);
return v2;
}