//
// LevelSelectLayer::init from 0x10041f370 to 0x100420097 (3367 bytes)
//
// 2 xrefs:
// > LevelSelectLayer::scene @ 0x10041f216
// > LevelSelectLayer::create @ 0x10041f32e
//
// This function is hookable on this platform (idp: pc, 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 12:30:15 +0000
//
__int64 __fastcall LevelSelectLayer::init(_QWORD *a1, int a2)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rdi
__int64 v8; // rax
char *v9; // r15
__int64 v10; // r15
__int64 v11; // rdi
__int64 v12; // rax
__int64 v13; // rax
double v14; // xmm0_8
char *v15; // r15
__int64 v16; // rax
double v17; // xmm0_8
double v18; // xmm0_8
char *v19; // r12
__int64 v20; // rdi
__int64 v21; // rax
double v22; // xmm0_8
double v23; // xmm0_8
unsigned __int8 *v24; // r15
__int64 v25; // rdi
__int64 v26; // rax
double v27; // xmm0_8
float v28; // xmm1_4
double v29; // xmm0_8
__int64 v30; // r15
__int64 v31; // r12
__int64 v32; // rax
__int64 MainLevel; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rax
__int64 v42; // rax
__int64 v43; // rax
__int64 v44; // rax
__int64 v45; // rax
__int64 v46; // rax
__int64 v47; // rax
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // rax
__int64 v51; // rax
__int64 v52; // rax
__int64 v53; // rax
__int64 v54; // rax
__int64 v55; // rax
__int64 v56; // rax
__int64 v57; // rax
__int64 v58; // rax
__int64 v59; // rax
__int64 v60; // rax
__int64 v61; // rax
__int64 v62; // rax
__int64 v63; // rax
__int64 v64; // rax
__int64 v65; // rax
__int64 v66; // rax
__int64 v67; // rax
__int64 v68; // rax
__int64 v69; // rax
__int64 v70; // rax
__int64 v71; // rax
__int64 v72; // rax
__int64 v73; // rax
__int64 v74; // rax
__int64 v75; // rax
__int64 v76; // rax
__int64 v77; // rax
__int64 v78; // rax
_DWORD *v79; // r13
_DWORD *v80; // r13
void *v81; // rax
void *v82; // rsi
__int64 v83; // r15
__int64 v84; // rax
double v85; // xmm0_8
__int64 v86; // rdi
int v87; // esi
__int64 *v88; // r14
__int64 v89; // rax
void *v90; // rax
int v91; // edx
int v92; // ecx
int v93; // r8d
int v94; // r9d
__int64 v95; // rsi
__int64 v96; // rax
double v97; // xmm0_8
__int64 v98; // r15
double v99; // xmm0_8
char isControllerConnected; // r14
const char *v101; // rdi
unsigned __int8 *v102; // rax
__int64 v103; // r13
void *v104; // rsi
__int64 v105; // rax
float v106; // xmm0_4
double v107; // xmm0_8
char *v108; // rax
void *v109; // rsi
__int64 v110; // rax
double v111; // xmm0_8
char *v112; // rax
void *v113; // r15
int v114; // edx
int v115; // ecx
int v116; // r8d
int v117; // r9d
__int64 v118; // rsi
__int64 v119; // rdi
__int64 v120; // rax
double v121; // xmm0_8
__int64 v122; // r12
double v123; // xmm0_8
char *v124; // rax
void *v125; // r14
double v126; // xmm0_8
char *v127; // rax
void *v128; // rax
__int64 v129; // r14
__int64 v130; // rdi
unsigned __int64 v131; // rsi
__int64 v132; // rax
int v133; // r13d
int v134; // eax
__int64 v135; // rax
__int64 v136; // rdi
__int64 v137; // rax
double v138; // xmm0_8
unsigned int v139; // [rsp+8h] [rbp-58h] BYREF
const char *v140; // [rsp+10h] [rbp-50h]
float v141; // [rsp+1Ch] [rbp-44h] BYREF
float v142; // [rsp+20h] [rbp-40h]
unsigned __int8 v143; // [rsp+27h] [rbp-39h]
float v144; // [rsp+28h] [rbp-38h]
__int64 v145; // [rsp+2Ch] [rbp-34h] BYREF
float v146; // [rsp+34h] [rbp-2Ch]
result = cocos2d::CCLayer::init(a1);
if ( (_BYTE)result )
{
v143 = result;
v5 = GameStatsManager::sharedState();
if ( (unsigned __int8)GameStatsManager::isItemUnlocked(v5, 12, 4u) )
{
v6 = GameManager::sharedState();
GameManager::setUGV(v6, "6");
}
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 1072LL))(a1, 1);
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 1088LL))(a1, 1);
byte_100BE8B9C = 0;
v7 = AchievementManager::sharedState(a1, 1);
*((_BYTE *)a1 + 464) = AchievementManager::isAchievementEarned(v7, "geometry.ach.secret04");
v8 = cocos2d::CCDirector::sharedDirector(v7, "geometry.ach.secret04");
cocos2d::CCDirector::getWinSize(&v141, v8);
v9 = cocos2d::CCSprite::create_1((__int64)"GJ_gradientBG.png");
a1[54] = v9;
sub_100278250((float *)&v145, 0.0, 0.0);
(*(void (__fastcall **)(char *, __int64 *))(*(_QWORD *)v9 + 296LL))(v9, &v145);
(*(void (__fastcall **)(_QWORD *, _QWORD, __int64))(*a1 + 464LL))(a1, a1[54], 4294967294LL);
(*(void (__fastcall **)(_QWORD, float))(*(_QWORD *)a1[54] + 128LL))(
a1[54],
(float)(v141 + 10.0) / *(float *)(a1[54] + 432LL));
(*(void (__fastcall **)(_QWORD, float))(*(_QWORD *)a1[54] + 144LL))(
a1[54],
(float)(v142 + 10.0) / *(float *)(a1[54] + 436LL));
v10 = a1[54];
sub_100278250((float *)&v145, -5.0, -5.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v10 + 184LL))(v10, &v145);
v11 = a1[54];
BYTE2(v145) = -1;
LOWORD(v145) = 32040;
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v11 + 960LL))(v11, &v145);
v12 = GameManager::sharedState();
v13 = GJGroundLayer::create(*(unsigned int *)(v12 + 984), 1);
a1[55] = v13;
(*(void (__fastcall **)(_QWORD *, __int64, _QWORD))(*a1 + 464LL))(a1, v13, 0);
v14 = GJGroundLayer::positionGround(a1[55], fminf(128.0, (float)(v142 * 0.5) + -110.0));
v15 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_topBar_001.png", v14);
sub_100278250((float *)&v145, 0.5, 1.0);
(*(void (__fastcall **)(char *, __int64 *))(*(_QWORD *)v15 + 296LL))(v15, &v145);
v146 = v141 * 0.5;
v16 = cocos2d::CCDirector::sharedDirector(v15, &v145);
v17 = sub_100479740(v16);
sub_100278250((float *)&v145, v146, *(float *)&v17 + 1.0);
(*(void (__fastcall **)(char *, __int64 *))(*(_QWORD *)v15 + 184LL))(v15, &v145);
v18 = (*(double (__fastcall **)(_QWORD *, char *, __int64))(*a1 + 464LL))(a1, v15, 1);
v19 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_sideArt_001.png", v18);
sub_100278250((float *)&v145, 0.0, 0.0);
(*(void (__fastcall **)(char *, __int64 *))(*(_QWORD *)v19 + 296LL))(v19, &v145);
v20 = cocos2d::CCDirector::sharedDirector(v19, &v145);
v146 = sub_100479760(v20) + -1.0;
v21 = cocos2d::CCDirector::sharedDirector(v20, &v145);
v22 = sub_100479750(v21);
sub_100278250((float *)&v145, v146, *(float *)&v22 + -1.0);
(*(void (__fastcall **)(char *, __int64 *))(*(_QWORD *)v19 + 184LL))(v19, &v145);
v23 = (*(double (__fastcall **)(_QWORD *, char *, __int64))(*a1 + 464LL))(a1, v19, 1);
v24 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_sideArt_001.png", v23);
sub_100278250((float *)&v145, 1.0, 0.0);
(*(void (__fastcall **)(unsigned __int8 *, __int64 *))(*(_QWORD *)v24 + 296LL))(v24, &v145);
v25 = cocos2d::CCDirector::sharedDirector(v24, &v145);
v146 = sub_100479770(v25) + 1.0;
v26 = cocos2d::CCDirector::sharedDirector(v25, &v145);
v27 = sub_100479750(v26);
v28 = *(float *)&v27 + -1.0;
*(_QWORD *)&v29 = LODWORD(v146);
sub_100278250((float *)&v145, v146, v28);
(*(void (__fastcall **)(unsigned __int8 *, __int64 *))(*(_QWORD *)v24 + 184LL))(v24, &v145);
cocos2d::CCSprite::setFlipX(v24, 1u);
(*(void (__fastcall **)(_QWORD *, unsigned __int8 *, __int64))(*a1 + 464LL))(a1, v24, 1);
v30 = sub_1007FE900(a1);
v31 = sub_1007FE900(a1);
v32 = GameLevelManager::sharedState(v29);
MainLevel = GameLevelManager::getMainLevel(v32, 1, 1);
sub_1007FEBF0(v31, MainLevel);
v34 = GameLevelManager::sharedState(v29);
v35 = GameLevelManager::getMainLevel(v34, 2, 1);
sub_1007FEBF0(v31, v35);
v36 = GameLevelManager::sharedState(v29);
v37 = GameLevelManager::getMainLevel(v36, 3, 1);
sub_1007FEBF0(v31, v37);
v38 = GameLevelManager::sharedState(v29);
v39 = GameLevelManager::getMainLevel(v38, 4, 1);
sub_1007FEBF0(v31, v39);
v40 = GameLevelManager::sharedState(v29);
v41 = GameLevelManager::getMainLevel(v40, 5, 1);
sub_1007FEBF0(v31, v41);
v42 = GameLevelManager::sharedState(v29);
v43 = GameLevelManager::getMainLevel(v42, 6, 1);
sub_1007FEBF0(v31, v43);
v44 = GameLevelManager::sharedState(v29);
v45 = GameLevelManager::getMainLevel(v44, 7, 1);
sub_1007FEBF0(v31, v45);
v46 = GameLevelManager::sharedState(v29);
v47 = GameLevelManager::getMainLevel(v46, 8, 1);
sub_1007FEBF0(v31, v47);
v48 = GameLevelManager::sharedState(v29);
v49 = GameLevelManager::getMainLevel(v48, 9, 1);
sub_1007FEBF0(v31, v49);
v50 = GameLevelManager::sharedState(v29);
v51 = GameLevelManager::getMainLevel(v50, 10, 1);
sub_1007FEBF0(v31, v51);
v52 = GameLevelManager::sharedState(v29);
v53 = GameLevelManager::getMainLevel(v52, 11, 1);
sub_1007FEBF0(v31, v53);
v54 = GameLevelManager::sharedState(v29);
v55 = GameLevelManager::getMainLevel(v54, 12, 1);
sub_1007FEBF0(v31, v55);
v56 = GameLevelManager::sharedState(v29);
v57 = GameLevelManager::getMainLevel(v56, 13, 1);
sub_1007FEBF0(v31, v57);
v58 = GameLevelManager::sharedState(v29);
v59 = GameLevelManager::getMainLevel(v58, 14, 1);
sub_1007FEBF0(v31, v59);
v60 = GameLevelManager::sharedState(v29);
v61 = GameLevelManager::getMainLevel(v60, 15, 1);
sub_1007FEBF0(v31, v61);
v62 = GameLevelManager::sharedState(v29);
v63 = GameLevelManager::getMainLevel(v62, 16, 1);
sub_1007FEBF0(v31, v63);
v64 = GameLevelManager::sharedState(v29);
v65 = GameLevelManager::getMainLevel(v64, 17, 1);
sub_1007FEBF0(v31, v65);
v66 = GameLevelManager::sharedState(v29);
v67 = GameLevelManager::getMainLevel(v66, 18, 1);
sub_1007FEBF0(v31, v67);
v68 = GameLevelManager::sharedState(v29);
v69 = GameLevelManager::getMainLevel(v68, 19, 1);
sub_1007FEBF0(v31, v69);
v70 = GameLevelManager::sharedState(v29);
v71 = GameLevelManager::getMainLevel(v70, 20, 1);
sub_1007FEBF0(v31, v71);
v72 = GameLevelManager::sharedState(v29);
v73 = GameLevelManager::getMainLevel(v72, 21, 1);
sub_1007FEBF0(v31, v73);
v74 = GameLevelManager::sharedState(v29);
v75 = GameLevelManager::getMainLevel(v74, 22, 1);
sub_1007FEBF0(v31, v75);
v76 = LevelPage::create(0);
sub_1007FEBF0(v30, v76);
v77 = LevelPage::create(0);
sub_1007FEBF0(v30, v77);
v78 = LevelPage::create(0);
sub_1007FEBF0(v30, v78);
v79 = (_DWORD *)GJGameLevel::create_1();
v79[84] = -2;
*(float *)&v29 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v79[83] = (int)*(float *)&v29;
v79[82] = (int)*(float *)&v29 - 2;
sub_1007FEBF0(v31, v79);
v80 = (_DWORD *)GJGameLevel::create_1();
v80[84] = -1;
*(float *)&v29 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v80[83] = (int)*(float *)&v29;
v80[82] = (int)*(float *)&v29 - 1;
sub_1007FEBF0(v31, v80);
v81 = BoomScrollLayer::create(v30, 0, 1u, v31, (__int64)(a1 + 52));
a1[56] = v81;
v82 = v81;
(*(void (__fastcall **)(_QWORD *, void *))(*a1 + 456LL))(a1, v81);
v83 = a1[56];
v146 = v141 * 0.5;
v84 = cocos2d::CCDirector::sharedDirector(a1, v82);
v85 = sub_100479750(v84);
sub_100278250((float *)&v145, v146, *(float *)&v85 + 15.0);
BoomScrollLayer::setPagesIndicatorPosition(v83, &v145);
*((float *)a1 + 106) = v141;
v86 = a1[56];
*(_QWORD *)(*(_QWORD *)(v86 + 504) + 408LL) = a1 + 51;
if ( a2 )
{
if ( a2 == 23 )
{
BoomScrollLayer::instantMoveToPage(v86, 22);
v86 = a1[56];
v87 = 23;
}
else
{
v87 = a2;
}
BoomScrollLayer::instantMoveToPage(v86, v87);
}
else
{
sub_1002782D0(&v145, &qword_100BE3928);
(*(void (__fastcall **)(_QWORD *, __int64 *))(*a1 + 1160LL))(a1, &v145);
}
v88 = (__int64 *)cocos2d::CCLabelBMFont::create_3("Download the soundtrack", "bigFont.fnt");
v89 = *v88;
v144 = 0.5;
(*(void (__fastcall **)(__int64 *))(v89 + 160))(v88);
v90 = CCMenuItemSpriteExtra::create((__int64)v88, 0, (__int64)a1, (__int64)LevelSelectLayer::onDownload, 0);
LODWORD(v88) = (_DWORD)v90;
CCMenuItemSpriteExtra::setSizeMult((__int64)v90, 1.1);
v95 = sub_1008735E0((_DWORD)v88, 0, v91, v92, v93, v94);
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 456LL))(a1, v95);
v146 = v141 * 0.5;
v96 = cocos2d::CCDirector::sharedDirector(a1, v95);
v97 = sub_100479750(v96);
sub_100278250((float *)&v145, v146, *(float *)&v97 + 35.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v95 + 184LL))(v95, &v145);
v144 = v144 * v142;
v98 = cocos2d::CCMenu::create();
v99 = (*(double (__fastcall **)(_QWORD *, __int64, __int64))(*a1 + 464LL))(a1, v98, 5);
isControllerConnected = PlatformToolbox::isControllerConnected(v99);
v101 = "controllerBtn_DPad_Left_001.png";
if ( !isControllerConnected )
v101 = "navArrowBtn_001.png";
v102 = (unsigned __int8 *)cocos2d::CCSprite::createWithSpriteFrameName((__int64)v101, v99);
v103 = (__int64)v102;
LOBYTE(v146) = isControllerConnected;
if ( isControllerConnected )
{
v140 = "controllerBtn_DPad_Right_001.png";
}
else
{
cocos2d::CCSprite::setFlipX(v102, 1u);
v140 = "navArrowBtn_001.png";
}
v104 = CCMenuItemSpriteExtra::create(v103, 0, (__int64)a1, (__int64)LevelSelectLayer::onPrev, 0);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v98 + 456LL))(v98, v104);
CCMenuItemSpriteExtra::setSizeMult((__int64)v104, 2.0);
v105 = cocos2d::CCDirector::sharedDirector(v104, v104);
v106 = sub_100479760(v105);
sub_100278250((float *)&v139, v106 + 25.0, v144);
cocos2d::CCNode::convertToNodeSpace((double *)&v145, v98, &v139);
v107 = (*(double (__fastcall **)(void *, __int64 *))(*(_QWORD *)v104 + 184LL))(v104, &v145);
v108 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)v140, v107);
v109 = CCMenuItemSpriteExtra::create((__int64)v108, 0, (__int64)a1, (__int64)LevelSelectLayer::onNext, 0);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v98 + 456LL))(v98, v109);
CCMenuItemSpriteExtra::setSizeMult((__int64)v109, 2.0);
v110 = cocos2d::CCDirector::sharedDirector(v109, v109);
*(float *)&v107 = sub_100479770(v110);
sub_100278250((float *)&v139, *(float *)&v107 + -25.0, v144);
cocos2d::CCNode::convertToNodeSpace((double *)&v145, v98, &v139);
v111 = (*(double (__fastcall **)(void *, __int64 *))(*(_QWORD *)v109 + 184LL))(v109, &v145);
v112 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_arrow_01_001.png", v111);
v113 = CCMenuItemSpriteExtra::create((__int64)v112, 0, (__int64)a1, (__int64)LevelSelectLayer::onBack, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v113, 1.6);
v118 = sub_1008735E0((_DWORD)v113, 0, v114, v115, v116, v117);
(*(void (__fastcall **)(_QWORD *, __int64, __int64))(*a1 + 464LL))(a1, v118, 1);
v119 = cocos2d::CCDirector::sharedDirector(a1, v118);
v144 = sub_100479760(v119) + 25.0;
v120 = cocos2d::CCDirector::sharedDirector(v119, v118);
v121 = sub_100479740(v120);
sub_100278250((float *)&v145, v144, *(float *)&v121 + -22.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v118 + 184LL))(v118, &v145);
*(_BYTE *)(GameManager::sharedState() + 1064) = 0;
v122 = cocos2d::CCMenu::create();
v123 = (*(double (__fastcall **)(_QWORD *, __int64))(*a1 + 456LL))(a1, v122);
v124 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_infoIcon_001.png", v123);
v125 = CCMenuItemSpriteExtra::create((__int64)v124, 0, (__int64)a1, (__int64)LevelSelectLayer::onInfo, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v125, 2.0);
v126 = (*(double (__fastcall **)(__int64, void *))(*(_QWORD *)v122 + 456LL))(v122, v125);
v127 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"sideBtn_death_001.png", v126);
v128 = CCMenuItemSpriteExtra::create((__int64)v127, 0, (__int64)a1, (__int64)LevelSelectLayer::onDeathTracker, 0);
a1[59] = v128;
CCMenuItemSpriteExtra::setSizeMult((__int64)v128, 2.0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v122 + 456LL))(v122, a1[59]);
v129 = a1[59];
sub_100278250((float *)&v145, 0.0, -40.0);
v130 = v129;
v131 = (unsigned __int64)&v145;
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v129 + 184LL))(v129, &v145);
if ( a1[59] )
{
v132 = a1[56];
v130 = *(_QWORD *)(v132 + 448);
if ( v130 )
{
v133 = *(_DWORD *)(v132 + 588);
v134 = sub_1007FEF90(v130);
if ( v134 > 0 )
{
v135 = sub_1007FEFE0(*(_QWORD *)(a1[56] + 448LL), (unsigned int)((v133 % v134 + v134) % v134));
v130 = a1[59];
v131 = (unsigned int)(*(_DWORD *)(v135 + 328) - *(_DWORD *)(v135 + 332)) < 0xFFFFFFFE;
(*(void (__fastcall **)(__int64, unsigned __int64))(*(_QWORD *)v130 + 344LL))(v130, v131);
}
}
}
v136 = cocos2d::CCDirector::sharedDirector(v130, v131);
v144 = sub_100479770(v136) + -20.0;
v137 = cocos2d::CCDirector::sharedDirector(v136, v131);
v138 = sub_100479740(v137);
sub_100278250((float *)&v145, v144, *(float *)&v138 + -20.0);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v122 + 184LL))(v122, &v145);
if ( LOBYTE(v146) )
GameToolbox::addBackButton(a1, v113);
return v143;
}
return result;
}