//
// LevelSelectLayer::init from 0x1004821b8 to 0x100482b10 (2392 bytes)
//
// 1 xrefs:
// > LevelSelectLayer::create @ 0x10048216c
//
// 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:05:47 +0000
//
bool __fastcall LevelSelectLayer::init(__int64 a1, int a2)
{
_BOOL8 v4; // x19
__int64 v5; // x0
__int64 v6; // x0
__int64 v7; // x22
__int64 v8; // x0
void *v9; // x23
__int64 v10; // x23
__int64 v11; // x0
__int64 v12; // x0
void *v13; // x0
float v14; // s0
void *v15; // x23
float v16; // s8
__int64 v17; // x0
float v18; // s0
void *v19; // x24
__int64 v20; // x0
float v21; // s8
__int64 v22; // x0
float v23; // s0
unsigned __int8 *v24; // x23
__int64 v25; // x0
float v26; // s8
__int64 v27; // x0
float v28; // s0
_QWORD *v29; // x23
_QWORD *v30; // x24
__int64 v31; // x0
int v32; // w22
_DWORD *v33; // x22
float v34; // s0
_DWORD *v35; // x22
float v36; // s0
void *v37; // x0
__int64 v38; // x22
float v39; // s8
__int64 v40; // x0
float v41; // s0
__int64 v42; // x0
int v43; // w1
double v44; // d0
void *v45; // x21
void *v46; // x21
__int64 v47; // x1
__int64 v48; // x2
__int64 v49; // x3
__int64 v50; // x4
__int64 v51; // x5
__int64 v52; // x6
__int64 v53; // x7
__int64 v54; // x21
float v55; // s8
__int64 v56; // x0
float v57; // s0
__int64 v58; // x0
float v59; // s8
__int64 v60; // x1
float v61; // s10
__int64 v62; // x22
int isControllerConnected; // w21
const char *v64; // x0
unsigned __int8 *v65; // x0
__int64 v66; // x24
const char *v67; // x23
void *v68; // x24
__int64 v69; // x0
float v70; // s0
void *v71; // x0
void *v72; // x23
__int64 v73; // x0
float v74; // s0
void *v75; // x0
void *v76; // x22
__int64 v77; // x1
__int64 v78; // x2
__int64 v79; // x3
__int64 v80; // x4
__int64 v81; // x5
__int64 v82; // x6
__int64 v83; // x7
__int64 v84; // x23
__int64 v85; // x0
float v86; // s8
__int64 v87; // x0
float v88; // s0
__int64 v89; // x23
void *v90; // x0
void *v91; // x24
void *v92; // x0
void *v93; // x0
__int64 v94; // x24
__int64 v95; // x0
float v96; // s8
__int64 v97; // x0
float v98; // s0
float v100; // [xsp+8h] [xbp-68h] BYREF
__int64 v101; // [xsp+10h] [xbp-60h] BYREF
__int64 v102; // [xsp+18h] [xbp-58h] BYREF
v4 = cocos2d::CCLayer::init((_WORD *)a1);
if ( v4 )
{
v5 = GameStatsManager::sharedState();
if ( (unsigned int)GameStatsManager::isItemUnlocked(v5, 12, 4) )
{
v6 = GameManager::sharedState();
GameManager::setUGV(v6, "6", 1);
}
v7 = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1072LL))(a1, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1088LL))(a1, 1);
byte_100A109D8 = 0;
AchievementManager::sharedState();
*(_BYTE *)(a1 + 464) = AchievementManager::isAchievementEarned();
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v8, &v102);
v9 = cocos2d::CCSprite::create((__int64)"GJ_gradientBG.png");
*(_QWORD *)(a1 + 432) = v9;
sub_1000262BC((float *)&v101, 0.0, 0.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v9 + 296LL))(v9, &v101);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)a1 + 464LL))(a1, *(_QWORD *)(a1 + 432), 4294967294LL);
(*(void (__fastcall **)(_QWORD, float))(**(_QWORD **)(a1 + 432) + 128LL))(
*(_QWORD *)(a1 + 432),
(float)(*(float *)&v102 + 10.0) / *(float *)(*(_QWORD *)(a1 + 432) + 432LL));
(*(void (__fastcall **)(_QWORD, float))(**(_QWORD **)(a1 + 432) + 144LL))(
*(_QWORD *)(a1 + 432),
(float)(*((float *)&v102 + 1) + 10.0) / *(float *)(*(_QWORD *)(a1 + 432) + 436LL));
v10 = *(_QWORD *)(a1 + 432);
sub_1000262BC((float *)&v101, -5.0, -5.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v10 + 184LL))(v10, &v101);
v11 = *(_QWORD *)(a1 + 432);
BYTE2(v101) = -1;
LOWORD(v101) = 32040;
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v11 + 960LL))(v11, &v101);
v12 = GameManager::sharedState();
v13 = GJGroundLayer::create(*(unsigned int *)(v12 + 984), 1);
*(_QWORD *)(a1 + 440) = v13;
(*(void (__fastcall **)(__int64, void *, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, v13, 0);
v14 = (float)(*((float *)&v102 + 1) * 0.5) + -110.0;
if ( v14 > 128.0 )
v14 = 128.0;
sub_100030098(*(_QWORD *)(a1 + 440), v14);
v15 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_topBar_001.png");
sub_1000262BC((float *)&v101, 0.5, 1.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v15 + 296LL))(v15, &v101);
v16 = *(float *)&v102 * 0.5;
v17 = cocos2d::CCDirector::sharedDirector();
v18 = sub_100207E98(v17);
sub_1000262BC((float *)&v101, v16, v18 + 1.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v15 + 184LL))(v15, &v101);
(*(void (__fastcall **)(__int64, void *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v15, 1);
v19 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_sideArt_001.png");
sub_1000262BC((float *)&v101, 0.0, 0.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v19 + 296LL))(v19, &v101);
v20 = cocos2d::CCDirector::sharedDirector();
v21 = sub_100207EA8(v20) + -1.0;
v22 = cocos2d::CCDirector::sharedDirector();
v23 = sub_100207EA0(v22);
sub_1000262BC((float *)&v101, v21, v23 + -1.0);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v19 + 184LL))(v19, &v101);
(*(void (__fastcall **)(__int64, void *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v19, 1);
v24 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_sideArt_001.png");
sub_1000262BC((float *)&v101, 1.0, 0.0);
(*(void (__fastcall **)(unsigned __int8 *, __int64 *))(*(_QWORD *)v24 + 296LL))(v24, &v101);
v25 = cocos2d::CCDirector::sharedDirector();
v26 = sub_100207EB0(v25) + 1.0;
v27 = cocos2d::CCDirector::sharedDirector();
v28 = sub_100207EA0(v27);
sub_1000262BC((float *)&v101, v26, v28 + -1.0);
(*(void (__fastcall **)(unsigned __int8 *, __int64 *))(*(_QWORD *)v24 + 184LL))(v24, &v101);
cocos2d::CCSprite::setFlipX(v24, 1);
(*(void (__fastcall **)(__int64, unsigned __int8 *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v24, 1);
v29 = sub_1002E736C();
v30 = sub_1002E736C();
do
{
v31 = GameLevelManager::sharedState();
GameLevelManager::getMainLevel(v31, v7, 1);
sub_1002E74E0((__int64)v30);
v7 = (unsigned int)(v7 + 1);
}
while ( (_DWORD)v7 != 23 );
v32 = 3;
do
{
LevelPage::create(0);
sub_1002E74E0((__int64)v29);
--v32;
}
while ( v32 );
v33 = GJGameLevel::create_1();
v33[84] = -2;
v34 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v33[83] = (int)v34;
v33[82] = (int)v34 - 2;
sub_1002E74E0((__int64)v30);
v35 = GJGameLevel::create_1();
v35[84] = -1;
v36 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v35[83] = (int)v36;
v35[82] = (int)v36 - 1;
sub_1002E74E0((__int64)v30);
v37 = BoomScrollLayer::create((__int64)v29, 0, 1, (__int64)v30, a1 + 416);
*(_QWORD *)(a1 + 448) = v37;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1 + 456LL))(a1, v37);
v38 = *(_QWORD *)(a1 + 448);
v39 = *(float *)&v102 * 0.5;
v40 = cocos2d::CCDirector::sharedDirector();
v41 = sub_100207EA0(v40);
sub_1000262BC((float *)&v101, v39, v41 + 15.0);
BoomScrollLayer::setPagesIndicatorPosition(v38, (double *)&v101);
*(_DWORD *)(a1 + 424) = v102;
v42 = *(_QWORD *)(a1 + 448);
*(_QWORD *)(*(_QWORD *)(v42 + 504) + 408LL) = a1 + 408;
if ( a2 )
{
if ( a2 == 23 )
{
BoomScrollLayer::instantMoveToPage(v42, 22);
v42 = *(_QWORD *)(a1 + 448);
v43 = 23;
}
else
{
v43 = a2;
}
BoomScrollLayer::instantMoveToPage(v42, v43);
}
else
{
v44 = sub_1000262F4(&v101, &dbl_1009F7930);
(*(void (__fastcall **)(__int64, __int64 *, double))(*(_QWORD *)a1 + 1160LL))(a1, &v101, v44);
}
v45 = cocos2d::CCLabelBMFont::create_1("Download the soundtrack", "bigFont.fnt");
(*(void (__fastcall **)(void *, float))(*(_QWORD *)v45 + 160LL))(v45, 0.5);
v46 = CCMenuItemSpriteExtra::create((__int64)v45, 0, a1, (__int64)LevelSelectLayer::onDownload, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v46, 1.1);
v54 = sub_100270434((__int64)v46, v47, v48, v49, v50, v51, v52, v53, 0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v54);
v55 = *(float *)&v102 * 0.5;
v56 = cocos2d::CCDirector::sharedDirector();
v57 = sub_100207EA0(v56);
sub_1000262BC((float *)&v101, v55, v57 + 35.0);
v58 = (*(__int64 (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v54 + 184LL))(v54, &v101);
v59 = *((float *)&v102 + 1) * 0.5;
if ( *(_BYTE *)(AppDelegate::get(v58, v60) + 37) )
v61 = 50.0;
else
v61 = 25.0;
v62 = cocos2d::CCMenu::create();
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v62, 5);
isControllerConnected = PlatformToolbox::isControllerConnected();
if ( isControllerConnected )
v64 = "controllerBtn_DPad_Left_001.png";
else
v64 = "navArrowBtn_001.png";
v65 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)v64);
v66 = (__int64)v65;
if ( (isControllerConnected & 1) != 0 )
{
v67 = "controllerBtn_DPad_Right_001.png";
}
else
{
cocos2d::CCSprite::setFlipX(v65, 1);
v67 = "navArrowBtn_001.png";
}
v68 = CCMenuItemSpriteExtra::create(v66, 0, a1, (__int64)LevelSelectLayer::onPrev, 0);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v62 + 456LL))(v62, v68);
CCMenuItemSpriteExtra::setSizeMult((__int64)v68, 2.0);
v69 = cocos2d::CCDirector::sharedDirector();
v70 = sub_100207EA8(v69);
sub_1000262BC(&v100, v61 + v70, v59);
cocos2d::CCNode::convertToNodeSpace(v62, (__int64)&v100, &v101);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v68 + 184LL))(v68, &v101);
v71 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)v67);
v72 = CCMenuItemSpriteExtra::create((__int64)v71, 0, a1, (__int64)LevelSelectLayer::onNext, 0);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v62 + 456LL))(v62, v72);
CCMenuItemSpriteExtra::setSizeMult((__int64)v72, 2.0);
v73 = cocos2d::CCDirector::sharedDirector();
v74 = sub_100207EB0(v73);
sub_1000262BC(&v100, v74 - v61, v59);
cocos2d::CCNode::convertToNodeSpace(v62, (__int64)&v100, &v101);
(*(void (__fastcall **)(void *, __int64 *))(*(_QWORD *)v72 + 184LL))(v72, &v101);
v75 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_arrow_01_001.png");
v76 = CCMenuItemSpriteExtra::create((__int64)v75, 0, a1, (__int64)sub_100482C34, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v76, 1.6);
v84 = sub_100270434((__int64)v76, v77, v78, v79, v80, v81, v82, v83, 0);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v84, 1);
v85 = cocos2d::CCDirector::sharedDirector();
v86 = sub_100207EA8(v85) + 25.0;
v87 = cocos2d::CCDirector::sharedDirector();
v88 = sub_100207E98(v87);
sub_1000262BC((float *)&v101, v86, v88 + -22.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v84 + 184LL))(v84, &v101);
*(_BYTE *)(GameManager::sharedState() + 1064) = 0;
v89 = cocos2d::CCMenu::create();
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v89);
v90 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_infoIcon_001.png");
v91 = CCMenuItemSpriteExtra::create((__int64)v90, 0, a1, (__int64)sub_100482C7C, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v91, 2.0);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v89 + 456LL))(v89, v91);
v92 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"sideBtn_death_001.png");
v93 = CCMenuItemSpriteExtra::create((__int64)v92, 0, a1, (__int64)sub_100482C98, 0);
*(_QWORD *)(a1 + 472) = v93;
CCMenuItemSpriteExtra::setSizeMult((__int64)v93, 2.0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v89 + 456LL))(v89, *(_QWORD *)(a1 + 472));
v94 = *(_QWORD *)(a1 + 472);
sub_1000262BC((float *)&v101, 0.0, -40.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v94 + 184LL))(v94, &v101);
sub_100482CB4(a1, *(unsigned int *)(*(_QWORD *)(a1 + 448) + 588LL));
v95 = cocos2d::CCDirector::sharedDirector();
v96 = sub_100207EB0(v95) + -20.0;
v97 = cocos2d::CCDirector::sharedDirector();
v98 = sub_100207E98(v97);
sub_1000262BC((float *)&v101, v96, v98 + -20.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v89 + 184LL))(v89, &v101);
if ( isControllerConnected )
GameToolbox::addBackButton(a1, (__int64)v76);
}
return v4;
}