//
// SelectSFXSortLayer::init from 0x140481030 to 0x1404816b0 (1664 bytes)
//
// 2 xrefs:
// > SFXBrowser::onSorting @ 0x140480386
// > ??> @ 0x1406dbae0
//
// 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
//
// Hidden C++ exception states: #wind=3
bool SelectSFXSortLayer::init(SelectSFXSortLayer *a1, AudioSortType a2)
{
bool result; // al
_BOOL8 v5; // rdx
__int64 v6; // rcx
__int64 v7; // rax
cocos2d::CCTouchDispatcher *v8; // rax
_BOOL8 v9; // rdx
__int64 v10; // rcx
cocos2d::CCDirector *v11; // rax
cocos2d::CCLayer *v12; // rax
struct cocos2d::CCRect *v13; // rax
struct cocos2d::extension::CCScale9Sprite *v14; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v15; // rbx
const cocos2d::CCSize *v16; // rax
float v17; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v18; // rbx
double v19; // xmm0_8
const cocos2d::CCPoint *v20; // rax
struct cocos2d::CCLabelBMFont *v21; // rdi
cocos2d::CCLabelBMFont_vtbl *v22; // rbx
const cocos2d::CCPoint *v23; // rax
__int64 v24; // rcx
cocos2d::CCMenu *v25; // rax
struct cocos2d::CCSprite *v26; // rax
cocos2d::CCNode *v27; // rdi
float v28; // xmm0_4
cocos2d::CCNode_vtbl *v29; // rbx
struct cocos2d::CCPoint v30; // rax
float v31; // xmm0_4
int v32; // esi
const char *v33; // r15
ButtonSprite *v34; // rbx
CCMenuItemSpriteExtra *v35; // rdi
float v36; // xmm0_4
void *v37; // rcx
cocos2d::CCSize v38; // [rsp+58h] [rbp-79h] BYREF
float v39; // [rsp+60h] [rbp-71h]
ButtonSprite *v40; // [rsp+68h] [rbp-69h] BYREF
struct cocos2d::CCPoint v41; // [rsp+70h] [rbp-61h] BYREF
CCMenuItemSpriteExtra *v42; // [rsp+78h] [rbp-59h]
cocos2d::CCRect v43; // [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]
v38.width = -1.0339758e-25;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v38);
if ( result )
{
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v7 = cocos2d::CCDirector::sharedDirector(v6);
v8 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 144LL))(v7);
cocos2d::CCTouchDispatcher::registerForcePrio(v8, a1, 2);
}
a1->m_sortType = a2;
LOBYTE(v5) = 1;
a1->setTouchEnabled(a1, v5);
LOBYTE(v9) = 1;
a1->setKeypadEnabled(a1, v9);
v11 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v10);
cocos2d::CCDirector::getWinSize(v11);
v12 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v12;
a1->addChild_1(a1, v12);
cocos2d::CCRect::CCRect(&v43, 0.0, 0.0, 80.0, 80.0);
v14 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v13);
v15 = v14->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v38, 360.0, 240.0);
v15->setContentSize(v14, v16);
v17 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v14,
0xFFFFFFFFLL);
v18 = v14->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = cocos2d::CCPoint::CCPoint(v17, v39 * 0.5);
v18->setPosition_0(v14, v20);
v21 = cocos2d::CCLabelBMFont::create("Select Sorting", &qword_14052A4D8);
v22 = v21->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v19, v39 * 0.5);
v22->setPosition_0(v21, v23);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v21);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v21->setScale_0)(v21);
v25 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v24);
a1->m_buttonMenu = v25;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v25, 10);
v26 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v27 = CCMenuItemSpriteExtra::create(v26, nullptr, a1, (cocos2d::SEL_MenuHandler *)AudioAssetsBrowser::onClose);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v27);
v28 = ((float (__fastcall *)(cocos2d::CCNode *))v27->setScale_0)(v27);
v27[1].m_unknown5 = 1070386381;
v29 = v27->__vftable;
cocos2d::CCPoint::CCPoint(v28, (float)((float)(v39 * 0.5) - 180.0) + 10.0);
v30 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v40);
v31 = ((float (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCPoint))v29->setPosition_0)(v27, v30);
cocos2d::CCPoint::CCPoint(v31, v39 * 0.5);
cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, &v41);
v32 = 0;
while ( 1 )
{
v44 = 0;
v46 = 15;
LOBYTE(v44) = 0;
switch ( v32 )
{
case 0:
v45 = 5;
strcpy((char *)&v44, "Name+");
break;
case 1:
v45 = 5;
strcpy((char *)&v44, "Name-");
break;
case 2:
v45 = 4;
strcpy((char *)&v44, "Len+");
break;
case 3:
v45 = 4;
strcpy((char *)&v44, "Len-");
break;
case 4:
v45 = 3;
LODWORD(v44) = 2835529;
break;
case 5:
v45 = 3;
LODWORD(v44) = 2966601;
break;
default:
v45 = 2;
strcpy((char *)&v44, "NA");
break;
}
v33 = "GJ_button_05.png";
if ( v32 == a1->m_sortType )
v33 = "GJ_button_02.png";
v40 = (ButtonSprite *)operator new(0x2C0u);
v34 = ButtonSprite::ButtonSprite(v40);
if ( v34 )
{
if ( ButtonSprite::init_1(v34, (const char *)&v44, 60, 0, 0.5, 1, (const char *)&qword_14052A4D8, v33, 30.0) )
{
cocos2d::CCObject::autorelease(v34);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v34->~ButtonSprite)(v34, 1);
v34 = nullptr;
}
}
v42 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v35 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v42);
if ( !v35 )
goto LABEL_23;
if ( !CCMenuItemSpriteExtra::init(v35, v34, nullptr, a1, (cocos2d::SEL_MenuHandler *)SelectSFXSortLayer::onSelect) )
break;
cocos2d::CCObject::autorelease(v35);
LABEL_24:
v35->setTag(v35, v32);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v35);
v36 = floorf((float)(v32 / 2)) * -60.0;
cocos2d::CCPoint::CCPoint(v36, (float)((float)((float)(v32 % 2) * 100.0) - 100.0) + 50.0);
cocos2d::CCPoint::operator+(&v41, &v38);
v35->setPosition_0(v35, (const cocos2d::CCPoint *)&v38);
if ( v46 > 0xF )
{
v37 = (void *)v44;
if ( v46 + 1 >= 0x1000 )
{
v37 = *(void **)(v44 - 8);
if ( (unsigned __int64)(v44 - (_QWORD)v37 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v37);
}
if ( ++v32 > 5 )
{
a1->m_joystickConnected = -1;
a1->m_noElasticity = 1;
return 1;
}
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v35->~CCMenuItemSpriteExtra)(v35, 1);
LABEL_23:
v35 = nullptr;
goto LABEL_24;
}
return result;
}