//
// CustomSongLayer::init from 0x140163ca0 to 0x140164931 (3217 bytes)
//
// 2 xrefs:
// > SongSelectNode::showCustomSongSelect @ 0x140168cf2
// > ??> @ 0x140917e34
//
// 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 11:27:26 +0000
//
// Hidden C++ exception states: #wind=1
bool __fastcall CustomSongLayer::init(__int64 a1, __int64 a2)
{
bool result; // al
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 *v11; // rdi
__int64 v12; // rdx
void (__fastcall *v13)(__int64 *, __int64); // r8
__int64 v14; // rbx
__int64 v15; // rax
__int64 v16; // rbx
__int64 v17; // rax
struct cocos2d::CCLabelBMFont *v18; // rdi
__int64 v19; // rbx
__int64 v20; // rax
int v21; // eax
cocos2d::CCObject *v22; // rax
struct cocos2d::CCMenu *v23; // rdi
__int64 v24; // rbx
__int64 v25; // rax
int v26; // eax
cocos2d::CCObject *v27; // r15
__int64 v28; // rdi
__int64 v29; // rbx
__int64 v30; // rax
__int64 v31; // rax
struct cocos2d::CCSprite *v32; // rax
cocos2d::CCObject *v33; // rsi
__int64 v34; // rdi
__int64 v35; // rbx
__int64 v36; // rax
__int64 v37; // rax
struct cocos2d::CCSprite *v38; // rax
cocos2d::CCObject *v39; // rsi
__int64 v40; // rdi
__int64 v41; // rbx
__int64 v42; // rax
__int64 v43; // rax
struct cocos2d::CCSprite *v44; // rax
cocos2d::CCObject *v45; // rsi
__int64 v46; // rdi
__int64 v47; // rbx
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // rcx
int v51; // eax
cocos2d::CCObject *v52; // rsi
__int64 v53; // rdi
__int64 v54; // rbx
__int64 v55; // rax
__int64 v56; // rax
__int64 v57; // rcx
struct cocos2d::CCSprite *v58; // rax
int v59; // ebx
cocos2d::CCObject *v60; // rsi
__int64 v61; // rdi
__int64 v62; // rbx
__int64 v63; // rax
__int64 v64; // rax
__int64 v65; // rax
_QWORD *v66; // rbx
__int64 v67; // rdx
void (__fastcall *v68)(_QWORD *, __int64); // r8
__int64 v69; // rax
_QWORD *v70; // rbx
__int64 v71; // rdx
void (__fastcall *v72)(_QWORD *, __int64); // r8
__int64 v73; // rdx
__int64 v74; // rcx
char *v75; // rax
__int64 v76; // rax
__int64 *v77; // rdi
__int64 v78; // rbx
__int64 v79; // rax
__int64 *v80; // rdi
__int64 v81; // rbx
__int64 v82; // rax
__int64 v83; // rcx
__int64 v84; // rcx
__int64 v85; // rcx
__int64 v86; // rcx
cocos2d::CCObject *v87; // rbx
cocos2d::CCObject *v88; // rdi
__int64 v89; // rax
__int64 v90; // rbx
__int64 v91; // rax
int v92; // ebx
unsigned int v93; // eax
int v94; // r9d
__int64 v95; // rax
__int64 v96; // rdi
__int64 v97; // rbx
__int64 v98; // rax
_BYTE v99[8]; // [rsp+68h] [rbp-A0h] BYREF
int v100; // [rsp+70h] [rbp-98h] BYREF
float v101[2]; // [rsp+78h] [rbp-90h] BYREF
void *v102[4]; // [rsp+80h] [rbp-88h] BYREF
float v103[2]; // [rsp+A0h] [rbp-68h] BYREF
_BYTE v104[8]; // [rsp+A8h] [rbp-60h] BYREF
_BYTE v105[136]; // [rsp+B0h] [rbp-58h] BYREF
void *v106; // [rsp+178h] [rbp+70h] BYREF
float v107; // [rsp+180h] [rbp+78h] BYREF
float v108; // [rsp+184h] [rbp+7Ch]
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
LODWORD(v106) = -1778384896;
result = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v106);
if ( result )
{
*(_QWORD *)(a1 + 680) = a2;
LOBYTE(v5) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 920LL))(a1, v5);
LOBYTE(v6) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 992LL))(a1, v6);
v8 = cocos2d::CCDirector::sharedDirector(v7);
cocos2d::CCDirector::getWinSize(v8, &v107);
v9 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v9;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v9);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v102, 0.0, 0.0, 40.0, 40.0);
v11 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_button_05.png", v10);
v12 = v11[40];
v13 = *(void (__fastcall **)(__int64 *, __int64))(v12 + 40);
LOBYTE(v12) = -1;
v13(v11 + 40, v12);
v14 = *v11;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v106, 440.0, 290.0);
(*(void (__fastcall **)(__int64 *, __int64))(v14 + 312))(v11, v15);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v11,
0xFFFFFFFFLL);
v16 = *v11;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, v107 * 0.5, v108 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v16 + 184))(v11, v17);
*(_DWORD *)(a1 + 640) = -1;
v18 = cocos2d::CCLabelBMFont::create("Custom Song Selection", "goldFont.fnt");
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v18 + 160LL))(v18);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v18);
v19 = *(_QWORD *)v18;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, v107 * 0.5, (float)((float)(v108 * 0.5) + 145.0) - 22.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v19 + 184))(v18, v20);
v21 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v22 = CCMenuItemSpriteExtra::create(v21, 0, a1, (__int64)CustomSongLayer::onClose);
*((_DWORD *)v22 + 93) = 1070386381;
v23 = cocos2d::CCMenu::create(v22, 0);
*(_QWORD *)(a1 + 552) = v23;
v24 = *(_QWORD *)v23;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v106,
(float)((float)(v107 * 0.5) - 220.0) + 10.0,
(float)((float)(v108 * 0.5) + 145.0) - 10.0);
(*(void (__fastcall **)(struct cocos2d::CCMenu *, __int64))(v24 + 184))(v23, v25);
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
*(_QWORD *)(a1 + 552),
10);
v26 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_savedSongsBtn_001.png");
v27 = CCMenuItemSpriteExtra::create(v26, 0, a1, (__int64)CustomSongLayer::onSongBrowser);
*((_DWORD *)v27 + 93) = 1067030938;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v27);
v28 = *(_QWORD *)v27;
v29 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v106,
(float)((float)(v107 * 0.5) + 220.0) - 24.0,
(float)((float)((float)(v108 * 0.5) - 145.0) + 24.0) + 2.0);
cocos2d::CCNode::convertToNodeSpace(v29, v99, v30);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v28 + 184))(v27, v31);
v32 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_ncsLibraryBtn_001.png");
LODWORD(v29) = (_DWORD)v32;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v32 + 160LL))(v32);
v33 = CCMenuItemSpriteExtra::create(v29, 0, a1, (__int64)CustomSongLayer::onNCSBrowser);
*((_DWORD *)v33 + 93) = 1067030938;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v33);
v34 = *(_QWORD *)v33;
v35 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, (float)(v107 * 0.5) + 105.0, (float)(v108 * 0.5) + 55.0);
cocos2d::CCNode::convertToNodeSpace(v35, v99, v36);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v34 + 184))(v33, v37);
v38 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_musicLibraryBtn_001.png");
LODWORD(v35) = (_DWORD)v38;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v38 + 160LL))(v38);
v39 = CCMenuItemSpriteExtra::create(v35, 0, a1, (__int64)CustomSongLayer::onMusicBrowser);
*((_DWORD *)v39 + 93) = 1067030938;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v39);
v40 = *(_QWORD *)v39;
v41 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, v107 * 0.5, (float)(v108 * 0.5) + 55.0);
cocos2d::CCNode::convertToNodeSpace(v41, v99, v42);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v40 + 184))(v39, v43);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_ngBtn_001.png");
LODWORD(v41) = (_DWORD)v44;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v44 + 160LL))(v44);
v45 = CCMenuItemSpriteExtra::create(v41, 0, a1, (__int64)CustomSongLayer::onNewgroundsBrowser);
*((_DWORD *)v45 + 93) = 1067030938;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v45);
v46 = *(_QWORD *)v45;
v47 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, (float)(v107 * 0.5) - 105.0, (float)(v108 * 0.5) + 55.0);
cocos2d::CCNode::convertToNodeSpace(v47, v99, v48);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v46 + 184))(v45, v49);
v50 = *(_QWORD *)(a1 + 680);
if ( v50 && (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v50 + 24LL))(v50) )
{
v51 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_createLinesBtn_001.png");
v52 = CCMenuItemSpriteExtra::create(v51, 0, a1, (__int64)CustomSongLayer::onCreateLines);
*((_DWORD *)v27 + 93) = 1067030938;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v52);
v53 = *(_QWORD *)v52;
v54 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v106,
(float)((float)(v107 * 0.5) - 220.0) + 24.0,
(float)((float)((float)(v108 * 0.5) - 145.0) + 24.0) + 2.0);
cocos2d::CCNode::convertToNodeSpace(v54, v99, v55);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v53 + 184))(v52, v56);
}
v57 = *(_QWORD *)(a1 + 680);
if ( v57 && (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v57 + 24LL))(v57) )
{
v58 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
v59 = (int)v58;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v58 + 160LL))(v58);
v60 = CCMenuItemSpriteExtra::create(v59, 0, a1, (__int64)CustomSongLayer::onOptions);
*((_DWORD *)v60 + 93) = 0x40000000;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v60);
v61 = *(_QWORD *)v60;
v62 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v106,
(float)((float)(v107 * 0.5) + 220.0) - 27.0,
(float)((float)(v108 * 0.5) + 145.0) - 27.0);
cocos2d::CCNode::convertToNodeSpace(v62, v99, v63);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v61 + 184))(v60, v64);
}
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v105, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v100, (float)(v107 * 0.5) - 42.0, (float)(v108 * 0.5) - 20.0);
v65 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v102, (const struct cocos2d::CCRect *)v105);
v66 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("square02_small.png", v65);
v67 = v66[40];
v68 = *(void (__fastcall **)(_QWORD *, __int64))(v67 + 40);
LOBYTE(v67) = 100;
v68(v66 + 40, v67);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v101, 210.0, 35.0);
(*(void (__fastcall **)(_QWORD *, float *))(*v66 + 312LL))(v66, v101);
(*(void (__fastcall **)(_QWORD, _QWORD *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v66,
0xFFFFFFFFLL);
(*(void (__fastcall **)(_QWORD *, int *))(*v66 + 184LL))(v66, &v100);
v69 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v102, (const struct cocos2d::CCRect *)v105);
v70 = (_QWORD *)cocos2d::extension::CCScale9Sprite::create("square02_small.png", v69);
v71 = v70[40];
v72 = *(void (__fastcall **)(_QWORD *, __int64))(v71 + 40);
LOBYTE(v71) = 40;
v72(v70 + 40, v71);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v103, 7.0, 6.0);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v104, v101[0] - v103[0], v101[1] - v103[1]);
(*(void (__fastcall **)(_QWORD *, _BYTE *))(*v70 + 312LL))(v70, v104);
(*(void (__fastcall **)(_QWORD, _QWORD *, _QWORD))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v70, 0);
(*(void (__fastcall **)(_QWORD *, int *))(*v70 + 184LL))(v70, &v100);
v75 = CCTextInputNode::create(v74, v73, (__int64)"Enter song ID");
*(_QWORD *)(a1 + 688) = v75;
(*(void (__fastcall **)(_QWORD, char *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v75, 20);
*(_QWORD *)(*(_QWORD *)(a1 + 688) + 600LL) = a1 + 544;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v99, -95.0, 0.0);
cocos2d::CCPoint::operator+(&v100, &v106, v76);
(*(void (__fastcall **)(_QWORD, void **))(**(_QWORD **)(a1 + 688) + 184LL))(*(_QWORD *)(a1 + 688), &v106);
v77 = *(__int64 **)(*(_QWORD *)(a1 + 688) + 592LL);
v78 = *v77;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, 0.0, 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v78 + 288))(v77, v79);
v80 = *(__int64 **)(*(_QWORD *)(a1 + 688) + 616LL);
v81 = *v80;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, 0.0, 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v81 + 288))(v80, v82);
v83 = *(_QWORD *)(a1 + 688);
*(_DWORD *)(v83 + 564) = 1060320051;
CCTextInputNode::refreshLabel(v83);
v84 = *(_QWORD *)(a1 + 688);
*(_DWORD *)(v84 + 560) = 1129447424;
CCTextInputNode::refreshLabel(v84);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(a1 + 688) + 592LL) + 336LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 688) + 592LL),
0);
*(_DWORD *)(*(_QWORD *)(a1 + 688) + 608LL) = 15;
HIDWORD(v102[1]) = 0;
v102[2] = (void *)11;
v102[3] = (void *)15;
strcpy((char *)v102, "0123456789-");
CCTextInputNode::setAllowedChars(*(_QWORD *)(a1 + 688), v102);
LOWORD(v106) = -21896;
v85 = *(_QWORD *)(a1 + 688);
*(_WORD *)(v85 + 572) = -21896;
*(_BYTE *)(v85 + 574) = -16;
CCTextInputNode::refreshLabel(v85);
v86 = *(_QWORD *)(a1 + 688);
*(_DWORD *)(v86 + 568) = 1056964608;
CCTextInputNode::refreshLabel(v86);
v106 = operator new(0x2C8u);
v87 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v106);
if ( v87 )
{
if ( ButtonSprite::init_1(
(__int64)v87,
(__int64)"Search",
50,
0,
1061997773,
1,
"goldFont.fnt",
(__int64)"GJ_button_04.png",
1108082688) )
{
cocos2d::CCObject::autorelease(v87);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v87 + 8LL))(v87, 1);
LODWORD(v87) = 0;
}
}
v88 = CCMenuItemSpriteExtra::create((int)v87, 0, a1, (__int64)CustomSongLayer::onSearch);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v88);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v99, 155.0, 0.0);
cocos2d::CCPoint::operator+(&v100, &v106, v89);
v90 = *(_QWORD *)v88;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), v102, &v106);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v90 + 184))(v88, v91);
v92 = 0;
v93 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 680) + 8LL))(*(_QWORD *)(a1 + 680));
if ( v93 )
v92 = SongInfoObject::create_1(v93);
LOBYTE(v94) = 1;
v95 = CustomSongWidget::create(v92, *(_QWORD *)(a1 + 680), 1, v94, 1, 0, 0, 0, 0, 0, 0);
*(_QWORD *)(a1 + 696) = v95;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v95, 2);
v96 = **(_QWORD **)(a1 + 696);
v97 = *(_QWORD *)(a1 + 696);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v106, v107 * 0.5, (float)((float)(v108 * 0.5) - 145.0) + 50.0);
(*(void (__fastcall **)(__int64, __int64))(v96 + 184))(v97, v98);
CustomSongWidget::getSongInfoIfUnloaded(*(_QWORD *)(a1 + 696));
return 1;
}
return result;
}