//
// SelectSFXSortLayer::init from 0x140620b60 to 0x1406211f8 (1688 bytes)
//
// 2 xrefs:
// > SelectSFXSortLayer::create @ 0x140620b1a
// > ??> @ 0x140930440
//
// 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:35:22 +0000
//
// Hidden C++ exception states: #wind=3
bool __fastcall SelectSFXSortLayer::init(__int64 a1, int 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; // rbx
__int64 v13; // rax
__int64 v14; // rbx
__int64 v15; // rax
struct cocos2d::CCLabelBMFont *v16; // rdi
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rcx
__int64 v20; // rax
int v21; // eax
cocos2d::CCObject *v22; // rsi
__int64 v23; // rdi
__int64 v24; // rbx
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rbx
__int64 v28; // rax
signed int v29; // esi
int v30; // r15d
cocos2d::CCObject *v31; // rbx
const char *v32; // rax
__int64 *v33; // rdi
float v34; // xmm0_4
__int64 v35; // rax
void *v36; // rcx
int v37; // [rsp+58h] [rbp-79h] BYREF
float v38; // [rsp+60h] [rbp-71h] BYREF
float v39; // [rsp+64h] [rbp-6Dh]
void *v40; // [rsp+68h] [rbp-69h] BYREF
_BYTE v41[8]; // [rsp+70h] [rbp-61h] BYREF
void *v42; // [rsp+78h] [rbp-59h]
_BYTE v43[16]; // [rsp+80h] [rbp-51h] BYREF
__int128 v44; // [rsp+90h] [rbp-41h] BYREF
__int64 v45; // [rsp+A0h] [rbp-31h]
unsigned __int64 v46; // [rsp+A8h] [rbp-29h]
v37 = -1778384896;
result = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v37);
if ( result )
{
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
*(_DWORD *)(a1 + 664) = 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, &v38);
v9 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v9;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v9);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v43, 0.0, 0.0, 80.0, 80.0);
v11 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v10);
v12 = *v11;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v37, 360.0, 240.0);
(*(void (__fastcall **)(__int64 *, __int64))(v12 + 312))(v11, v13);
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v11,
0xFFFFFFFFLL);
v14 = *v11;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, v38 * 0.5, v39 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v14 + 184))(v11, v15);
v16 = cocos2d::CCLabelBMFont::create("Select Sorting", &qword_140704F78);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, v38 * 0.5, (float)((float)(v39 * 0.5) + 120.0) - 20.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v17 + 184))(v16, v18);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v16);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v16 + 160LL))(v16);
v20 = cocos2d::CCMenu::create(v19);
*(_QWORD *)(a1 + 552) = v20;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v20, 10);
v21 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v22 = CCMenuItemSpriteExtra::create(v21, 0, a1, (__int64)PagedListPopup::onClose);
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v22);
(*(void (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)v22 + 160LL))(v22);
*((_DWORD *)v22 + 93) = 1070386381;
v23 = *(_QWORD *)v22;
v24 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v37,
(float)((float)(v38 * 0.5) - 180.0) + 10.0,
(float)((float)(v39 * 0.5) + 120.0) - 10.0);
cocos2d::CCNode::convertToNodeSpace(v24, &v40, v25);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v23 + 184))(v22, v26);
v27 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v40, v38 * 0.5, (float)((float)(v39 * 0.5) + 30.0) + 15.0);
cocos2d::CCNode::convertToNodeSpace(v27, v41, v28);
v29 = 0;
while ( 1 )
{
v44 = 0;
v46 = 15;
LOBYTE(v44) = 0;
switch ( v29 )
{
case 0:
v45 = 3;
LOWORD(v44) = *(_WORD *)"A-Z";
WORD1(v44) = (unsigned __int8)aAZ[2];
break;
case 1:
v45 = 3;
LOWORD(v44) = *(_WORD *)"Z-A";
WORD1(v44) = (unsigned __int8)aZA[2];
break;
case 2:
v45 = 8;
strcpy((char *)&v44, "Shortest");
break;
case 3:
v45 = 7;
*(_QWORD *)&v44 = 0x747365676E6F4CLL;
break;
case 4:
v45 = 6;
strcpy((char *)&v44, "Newest");
break;
case 5:
v45 = 6;
strcpy((char *)&v44, "Oldest");
break;
default:
v45 = 2;
strcpy((char *)&v44, "NA");
break;
}
v30 = *(_DWORD *)(a1 + 664);
v40 = operator new(0x2C8u);
v31 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v40);
if ( v31 )
{
v32 = "GJ_button_05.png";
if ( v29 == v30 )
v32 = "GJ_button_02.png";
if ( ButtonSprite::init_1(
(__int64)v31,
(__int64)&v44,
60,
0,
1056964608,
1,
&qword_140704F78,
(__int64)v32,
1106247680) )
{
cocos2d::CCObject::autorelease(v31);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v31 + 8LL))(v31, 1);
v31 = nullptr;
}
}
v42 = operator new(0x208u);
v33 = (__int64 *)CCMenuItemSpriteExtra::CCMenuItemSpriteExtra((__int64)v42);
if ( !v33 )
goto LABEL_21;
if ( !CCMenuItemSpriteExtra::init(v33, (__int64 *)v31, 0, a1, (__int64)SelectSFXSortLayer::onSelect) )
break;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v33);
LABEL_22:
(*(void (__fastcall **)(__int64 *, _QWORD))(*v33 + 64))(v33, (unsigned int)v29);
(*(void (__fastcall **)(_QWORD, __int64 *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v33);
v34 = floorf((float)(v29 / 2)) * -60.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v43, (float)((float)((float)(v29 % 2) * 100.0) - 100.0) + 50.0, v34);
cocos2d::CCPoint::operator+(v41, &v37, v35);
(*(void (__fastcall **)(__int64 *, int *))(*v33 + 184))(v33, &v37);
if ( v46 > 0xF )
{
v36 = (void *)v44;
if ( v46 + 1 >= 0x1000 )
{
v36 = *(void **)(v44 - 8);
if ( (unsigned __int64)(v44 - (_QWORD)v36 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v36);
}
if ( ++v29 > 5 )
{
*(_DWORD *)(a1 + 640) = -1;
*(_BYTE *)(a1 + 596) = 1;
return 1;
}
}
(*(void (__fastcall **)(__int64 *, __int64))(*v33 + 8))(v33, 1);
LABEL_21:
v33 = nullptr;
goto LABEL_22;
}
return result;
}