//
// SecretRewardsLayer::createSecondaryLayer from 0x1002ea964 to 0x1002ead0c (936 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::moveToSecondaryLayer @ 0x1002ea6b4
//
// 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
//
void __fastcall SecretRewardsLayer::createSecondaryLayer(SecretRewardsLayer *a1, int a2)
{
cocos2d::CCLayer *m_secondaryLayer; // x0
cocos2d::CCDirector *v5; // x0
cocos2d::CCLayer *v6; // x0
float v7; // s8
cocos2d::extension::CCScale9Sprite *v8; // x21
__n128 v9; // q0
__n128 v10; // q1
__int64 v11; // x0
char v12; // w8
char v13; // w24
cocos2d::CCSprite *v14; // x23
__n128 v15; // q0
__n128 v16; // q1
__n128 v17; // q0
__n128 v18; // q1
cocos2d::CCLabelBMFont *v19; // x0
__n128 v20; // q0
cocos2d::CCLabelBMFont *m_chestCounter; // x21
__n128 v22; // q1
cocos2d::CCArray *ChestItems; // x0
BoomScrollLayer *v24; // x0
BoomScrollLayer *m_secondaryScrollLayer; // x20
float v26; // s8
cocos2d::CCDirector *v27; // x0
__n128 v28; // q1
__n128 v29; // q0
BoomScrollLayer *v30; // x19
cocos2d::CCDirector *v31; // x0
float v32; // s8
cocos2d::CCDirector *v33; // x0
float v34; // s0
float v35; // [xsp+0h] [xbp-80h] BYREF
float v36; // [xsp+4h] [xbp-7Ch]
float v37[4]; // [xsp+8h] [xbp-78h] BYREF
float v38; // [xsp+18h] [xbp-68h]
float v39; // [xsp+1Ch] [xbp-64h]
cocos2d::CCPoint v40; // 0:s0.4,4:s1.4
cocos2d::CCRect v41; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
m_secondaryLayer = a1->m_secondaryLayer;
if ( m_secondaryLayer )
{
a1->m_secondaryScrollLayer = nullptr;
a1->m_chestCounter = nullptr;
((void (__fastcall *)(cocos2d::CCLayer *))m_secondaryLayer->removeFromParent)(m_secondaryLayer);
a1->m_secondaryLayer = nullptr;
}
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
v6 = cocos2d::CCLayer::create();
a1->m_secondaryLayer = v6;
((void (__fastcall *)(SecretRewardsLayer *, cocos2d::CCLayer *))a1->addChild)(a1, v6);
v7 = 0.0;
sub_100022990(v37, 0.0, 0.0, 80.0, 80.0);
v8 = cocos2d::extension::CCScale9Sprite::create("GJ_square05.png", v41);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v8->setOpacity)(v8, 75);
sub_100022988(&v35, 370.0, 255.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v8->setContentSize)(v8, &v35);
v9 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v8,
0xFFFFFFFFLL);
v9.n128_f32[0] = v38 * 0.5;
v10.n128_f32[0] = v39 * 0.5;
sub_100022980(v9, v10, v37);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v8->setPosition)(v8, v37);
v11 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_backgroundSprite->getColor)(a1->m_backgroundSprite);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v8->setColor)(v8, v11);
v12 = 1;
do
{
v13 = v12;
v14 = cocos2d::CCSprite::createWithSpriteFrameName("chain_01_001.png");
v15 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v14,
0xFFFFFFFFLL);
v15.n128_u32[0] = 0.5;
v16.n128_u32[0] = 0;
sub_100022980(v15, v16, v37);
v17 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float *))v14->setAnchorPoint)(v14, v37);
v17.n128_f32[0] = (float)((float)(v38 * 0.5) + -100.0) + (float)(v7 * 2.0);
v18.n128_f32[0] = (float)((float)(v39 * 0.5) + (float)(v36 * 0.5)) + -2.0;
sub_100022980(v17, v18, v37);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v14->setPosition)(v14, v37);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v14->setColor)(v14, &unk_100644A88);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v14->setOpacity)(v14, 75);
v12 = 0;
v7 = 100.0;
}
while ( (v13 & 1) != 0 );
v19 = cocos2d::CCLabelBMFont::create_1(" ", "goldFont.fnt");
a1->m_chestCounter = v19;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_secondaryLayer->addChild)(
a1->m_secondaryLayer,
v19);
v20 = ((__n128 (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_chestCounter->setScale)(a1->m_chestCounter, 0.6);
m_chestCounter = a1->m_chestCounter;
v20.n128_f32[0] = v38 * 0.5;
v22.n128_f32[0] = (float)((float)(v39 * 0.5) + (float)(v36 * 0.5)) + 17.0;
sub_100022980(v20, v22, v37);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))m_chestCounter->setPosition)(m_chestCounter, v37);
SecretRewardsLayer::updateUnlockedLabel(a1);
ChestItems = SecretRewardsLayer::generateChestItems(a1, a2);
v24 = BoomScrollLayer::create(ChestItems, 0, a2 < 6, nullptr, nullptr);
a1->m_secondaryScrollLayer = v24;
((void (__fastcall *)(cocos2d::CCLayer *, BoomScrollLayer *))a1->m_secondaryLayer->addChild)(
a1->m_secondaryLayer,
v24);
m_secondaryScrollLayer = a1->m_secondaryScrollLayer;
v26 = v38 * 0.5;
v27 = cocos2d::CCDirector::sharedDirector();
v28.n128_f32[0] = sub_1001768D0((__int64)v27) + 10.0;
v29.n128_f32[0] = v26;
sub_100022980(v29, v28, v37);
BoomScrollLayer::setPagesIndicatorPosition(m_secondaryScrollLayer, v40);
v30 = a1->m_secondaryScrollLayer;
v30->m_unkFloat2 = 0.9;
v30->m_doVisit = 1;
v31 = cocos2d::CCDirector::sharedDirector();
v32 = sub_1001768E0((__int64)v31);
v33 = cocos2d::CCDirector::sharedDirector();
v34 = sub_1001768C8((__int64)v33);
sub_100022990(v37, 0.0, 0.0, v32, v34);
sub_100022BB0(&v30->m_clippingRect.origin, (__int64)v37);
}