//
// SecretRewardsLayer::createSecondaryLayer from 0x100633620 to 0x100633a91 (1137 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::moveToSecondaryLayer @ 0x1006330e9
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall SecretRewardsLayer::createSecondaryLayer(SecretRewardsLayer *a1, int a2)
{
cocos2d::CCLayer *m_secondaryLayer; // rdi
cocos2d::CCLayer *v4; // rax
cocos2d::extension::CCScale9Sprite *v5; // r14
__int64 v6; // rax
cocos2d::CCSprite *v7; // r13
cocos2d::CCSprite *v8; // r13
cocos2d::CCLabelBMFont *v9; // rax
cocos2d::CCLabelBMFont *m_chestCounter; // r14
cocos2d::CCArray *ChestItems; // rax
BoomScrollLayer *v12; // rax
BoomScrollLayer *m_secondaryScrollLayer; // r14
cocos2d::CCDirector *v14; // rax
BoomScrollLayer *v15; // rbx
cocos2d::CCDirector *v16; // rax
cocos2d::CCDirector *v17; // rax
unsigned __int64 v18[2]; // [rsp+0h] [rbp-50h] BYREF
float v19; // [rsp+10h] [rbp-40h] BYREF
float v20; // [rsp+14h] [rbp-3Ch]
int v21; // [rsp+18h] [rbp-38h]
float v22; // [rsp+1Ch] [rbp-34h] BYREF
float v23; // [rsp+20h] [rbp-30h]
float v24; // [rsp+24h] [rbp-2Ch]
double v25; // 0:xmm0_8.8
unsigned __int128 v26; // 0:xmm0_8.8,8:xmm1_8.8 OVERLAPPED
v21 = a2;
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;
}
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v25 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v22);
v4 = cocos2d::CCLayer::create();
a1->m_secondaryLayer = v4;
((void (__fastcall *)(SecretRewardsLayer *, cocos2d::CCLayer *, double))a1->addChild)(a1, v4, v25);
*(_QWORD *)&v26 = 0;
*((_QWORD *)&v26 + 1) = 0;
sub_10028CC00((__int64)v18, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v5 = cocos2d::extension::CCScale9Sprite::create_2("GJ_square05.png", (cocos2d::CCRect)v26);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v5->setOpacity)(v5, 75);
sub_10028CBF0(&v19, 370.0, 255.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, float *))v5->setContentSize)(v5, &v19);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v5,
0xFFFFFFFFLL);
sub_10028CBE0((float *)v18, v22 * 0.5, v23 * 0.5);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v5->setPosition)(v5, v18);
v6 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_backgroundSprite->getColor)(a1->m_backgroundSprite);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v5->setColor)(v5, v6);
v7 = cocos2d::CCSprite::createWithSpriteFrameName("chain_01_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v7,
0xFFFFFFFFLL);
sub_10028CBE0((float *)v18, 0.5, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v7->setAnchorPoint)(v7, v18);
sub_10028CBE0((float *)v18, (float)(v22 * 0.5) + -100.0, (float)((float)(v20 * 0.5) + (float)(v23 * 0.5)) + -2.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v7->setPosition)(v7, v18);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v7->setColor)(v7, &unk_1008227B8);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v7->setOpacity)(v7, 75);
v8 = cocos2d::CCSprite::createWithSpriteFrameName("chain_01_001.png");
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCSprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v8,
0xFFFFFFFFLL);
sub_10028CBE0((float *)v18, 0.5, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v8->setAnchorPoint)(v8, v18);
sub_10028CBE0(
(float *)v18,
(float)((float)(v22 * 0.5) + -100.0) + 200.0,
(float)((float)(v20 * 0.5) + (float)(v23 * 0.5)) + -2.0);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int64 *))v8->setPosition)(v8, v18);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v8->setColor)(v8, &unk_1008227B8);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v8->setOpacity)(v8, 75);
v9 = cocos2d::CCLabelBMFont::create_3(" ", "goldFont.fnt");
a1->m_chestCounter = v9;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_secondaryLayer->addChild)(
a1->m_secondaryLayer,
v9);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_chestCounter->setScale)(a1->m_chestCounter, 0.60000002);
m_chestCounter = a1->m_chestCounter;
v24 = 0.5;
sub_10028CBE0((float *)v18, v22 * 0.5, (float)((float)(v20 * 0.5) + (float)(v23 * 0.5)) + 17.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))m_chestCounter->setPosition)(m_chestCounter, v18);
SecretRewardsLayer::updateUnlockedLabel(a1);
LODWORD(m_chestCounter) = v21;
ChestItems = SecretRewardsLayer::generateChestItems(a1, v21);
v12 = BoomScrollLayer::create(ChestItems, 0, (int)m_chestCounter < 6, nullptr, nullptr);
a1->m_secondaryScrollLayer = v12;
((void (__fastcall *)(cocos2d::CCLayer *, BoomScrollLayer *))a1->m_secondaryLayer->addChild)(
a1->m_secondaryLayer,
v12);
m_secondaryScrollLayer = a1->m_secondaryScrollLayer;
v24 = v24 * v22;
v14 = cocos2d::CCDirector::sharedDirector();
*((float *)&v26 + 2) = sub_100484D80((__int64)v14) + 10.0;
v26 = LODWORD(v24);
sub_10028CBE0((float *)v18, v24, *((float *)&v26 + 2));
BoomScrollLayer::setPagesIndicatorPosition(m_secondaryScrollLayer, (cocos2d::CCPoint)v26);
v15 = a1->m_secondaryScrollLayer;
v15->m_unkFloat2 = 0.89999998;
v15->m_doVisit = 1;
v16 = cocos2d::CCDirector::sharedDirector();
v24 = sub_100484DA0((__int64)v16);
v17 = cocos2d::CCDirector::sharedDirector();
*(float *)&v26 = sub_100484D70((__int64)v17);
sub_10028CC00((__int64)v18, 0.0, 0.0, (__m128)LODWORD(v24), (__m128)v26);
sub_10028D1A0((__m128 *)&v15->m_clippingRect, v18);
}