//
// SelectSFXSortLayer::init from 0x10016ab4c to 0x10016af98 (1100 bytes)
//
// 1 xrefs:
// > SelectSFXSortLayer::create @ 0x10016a584
//
// 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
//
bool __fastcall SelectSFXSortLayer::init(SelectSFXSortLayer *a1, AudioSortType a2)
{
_BOOL4 v4; // w0
cocos2d::CCDirector *v5; // x0
cocos2d::CCLayer *v6; // x0
cocos2d::extension::CCScale9Sprite *v7; // x21
__n128 v8; // q0
__n128 v9; // q1
cocos2d::CCLabelBMFont *v10; // x22
__n128 v11; // q0
__n128 v12; // q1
cocos2d::CCMenu *v13; // x0
cocos2d::CCSprite *v14; // x0
CCMenuItemSpriteExtra *v15; // x22
cocos2d::CCMenu *m_buttonMenu; // x23
__n128 v17; // q0
__n128 v18; // q1
__n128 v19; // q0
cocos2d::CCMenu *v20; // x22
__n128 v21; // q1
__int64 v22; // x22
std::string *v23; // x0
const char *v24; // x5
ButtonSprite *v25; // x0
CCMenuItemSpriteExtra *v26; // x25
__n128 v27; // q1
__n128 v28; // q0
double v29; // d0
bool v31; // [xsp+4h] [xbp-ACh]
float32x2_t v32; // [xsp+8h] [xbp-A8h] BYREF
float32x2_t v33; // [xsp+10h] [xbp-A0h] BYREF
std::string v34; // [xsp+18h] [xbp-98h] BYREF
float32x2_t v35; // [xsp+30h] [xbp-80h] BYREF
float v36; // [xsp+38h] [xbp-78h]
float v37; // [xsp+3Ch] [xbp-74h]
cocos2d::CCPoint v38; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v39; // 0:x3.16
cocos2d::SEL_MenuHandler v40; // 0:x3.16
cocos2d::CCRect v41; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
LODWORD(v34.__r_.__value_.__l.__data_) = -1778384896;
v4 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::ccColor4B *)&v34);
if ( v4 )
{
v31 = v4;
FLAlertLayer::incrementForcePrio(a1);
a1->m_sortType = a2;
((void (__fastcall *)(SelectSFXSortLayer *, __int64))a1->setTouchEnabled)(a1, 1);
((void (__fastcall *)(SelectSFXSortLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
v6 = cocos2d::CCLayer::create();
a1->m_mainLayer = v6;
((void (__fastcall *)(SelectSFXSortLayer *, cocos2d::CCLayer *))a1->addChild)(a1, v6);
sub_100022990((float *)&v34, 0.0, 0.0, 80.0, 80.0);
v7 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v41);
sub_100022988((float *)&v34, 360.0, 240.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v7->setContentSize)(v7, &v34);
v8 = ((__n128 (__fastcall *)(cocos2d::CCLayer *, cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v7,
0xFFFFFFFFLL);
v8.n128_f32[0] = v36 * 0.5;
v9.n128_f32[0] = v37 * 0.5;
sub_100022980(v8, v9, &v34);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, std::string *))v7->setPosition)(v7, &v34);
v10 = cocos2d::CCLabelBMFont::create_1("Select Sorting", "bigFont.fnt");
v11.n128_f32[0] = v36 * 0.5;
v12.n128_f32[0] = (float)((float)(v37 * 0.5) + 120.0) + -20.0;
sub_100022980(v11, v12, &v34);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string *))v10->setPosition)(v10, &v34);
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild)(a1->m_mainLayer, v10);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v10->setScale)(v10, 0.8);
v13 = cocos2d::CCMenu::create();
a1->m_buttonMenu = v13;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCMenu *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v13,
10);
v14 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v39.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectSFXSortLayer::onClose;
v39.adj = 0;
v15 = CCMenuItemSpriteExtra::create(v14, nullptr, a1, v39);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(a1->m_buttonMenu, v15);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float))v15->setScale)(v15, 0.8);
CCMenuItemSpriteExtra::setSizeMult(v15, 1.6);
m_buttonMenu = a1->m_buttonMenu;
v17.n128_f32[0] = (float)((float)(v36 * 0.5) + -180.0) + 10.0;
v18.n128_f32[0] = (float)((float)(v37 * 0.5) + 120.0) + -10.0;
sub_100022980(v17, v18, &v35);
v38 = cocos2d::CCNode::convertToNodeSpace(m_buttonMenu, (const cocos2d::CCPoint *)&v35);
v19 = ((__n128 (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, float, float))v15->setPosition)(
v15,
&v34,
v38.x,
v38.y);
v20 = a1->m_buttonMenu;
v19.n128_f32[0] = v36 * 0.5;
v21.n128_f32[0] = (float)((float)(v37 * 0.5) + 30.0) + 15.0;
sub_100022980(v19, v21, &v34);
cocos2d::CCNode::convertToNodeSpace(v20, (const cocos2d::CCPoint *)&v34);
v22 = 0;
do
{
sub_100009900(&v34, "");
std::string::assign(&v34, off_10079ECD8[v22]);
if ( (v34.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v23 = &v34;
else
v23 = (std::string *)v34.__r_.__value_.__r.__words[0];
if ( (_DWORD)v22 == a1->m_sortType )
v24 = "GJ_button_02.png";
else
v24 = "GJ_button_05.png";
v25 = ButtonSprite::create_1((const char *)v23, 60, 0, 0.5, 1, "bigFont.fnt", v24, 30.0);
v40.ptr = (void (__cdecl *)(cocos2d::CCObject *))SelectSFXSortLayer::onSelect;
v40.adj = 0;
v26 = CCMenuItemSpriteExtra::create(v25, nullptr, a1, v40);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v26->setTag)(v26, v22);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild)(
a1->m_buttonMenu,
v26);
v28.n128_u32[0] = -1035468800;
if ( (v22 & 1) != 0 )
v28.n128_f32[0] = 50.0;
v27.n128_f32[0] = (float)((unsigned int)v22 >> 1) * -60.0;
sub_100022980(v28, v27, &v32);
*(float32x2_t *)&v29 = sub_1000229DC(&v35, &v32, &v33);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, double))v26->setPosition)(v26, &v33, v29);
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v34.__r_.__value_.__l.__data_);
++v22;
}
while ( (_DWORD)v22 != 6 );
a1->m_joystickConnected = -1;
a1->m_noElasticity = 1;
LOBYTE(v4) = v31;
}
return v4;
}