//
// SFXBrowser::setupSFXBrowser from 0xb92fa4 to 0xb9376c (1992 bytes)
//
// 2 xrefs:
// > SFXBrowser::trySetupSFXBrowser @ 0xb94788
// > ??> @ 0xb2c00
//
// This function is hookable on this platform (idp: arm, 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 13:02:40 +0000
//
__int64 __fastcall SFXBrowser::setupSFXBrowser(SFXBrowser *this)
{
unsigned __int8 *v2; // x2
MusicDownloadManager *v3; // x0
__int64 v4; // x1
SFXSearchResult *v5; // x0
int v6; // w22
_DWORD *v7; // x20
unsigned __int64 SFXFolderObjectForID; // x0
MusicDownloadManager *v9; // x0
unsigned __int64 v10; // x24
GameManager *v11; // x0
GameManager *v12; // x0
__int64 v13; // x0
int v14; // w25
MusicDownloadManager *v15; // x0
MusicDownloadManager *v16; // x23
int v17; // w0
MusicDownloadManager *v18; // x0
cocos2d::CCObject *CustomSFXFolderForID; // x1
int v20; // w1
MusicDownloadManager *v21; // x0
__int64 v22; // x20
__int64 v23; // x0
const void *v24; // x1
size_t v25; // x2
__int64 ActiveFolder; // x22
MusicDownloadManager *v27; // x0
MusicDownloadManager *v28; // x0
cocos2d::CCObject *v29; // x1
int v30; // w0
int v31; // w2
MusicDownloadManager *v33; // x0
MusicDownloadManager *v34; // x0
MusicDownloadManager *v35; // x0
MusicDownloadManager *v36; // x0
cocos2d::CCObject *v37; // x1
int v38; // w0
int v39; // w0
int v40; // w1
__int64 v41; // x0
__int64 v42; // x1
cocos2d::CCSpriteFrameCache **v43; // x24
void (__fastcall *v44)(cocos2d::CCSpriteFrameCache **, __int64); // x25
cocos2d::CCSpriteFrameCache *v45; // x0
__int64 v46; // x0
_QWORD *v47; // x23
const char *v48; // x1
size_t v49; // x0
__int64 v50; // x0
unsigned int *v51; // x1
__int64 *v52; // x22
__int64 *v53; // x23
__int64 v54; // x0
__int64 *v55; // x0
int v56; // w23
__int64 v57; // x1
MusicDownloadManager *v58; // x0
EditorSFXManager *v59; // x0
__int64 v60; // x23
MusicDownloadManager *v61; // x0
MusicDownloadManager *v62; // x0
MusicDownloadManager *v63; // x0
MusicDownloadManager *v64; // x0
cocos2d::CCObject *CustomSFXRoot; // x1
MusicDownloadManager *v66; // x0
char *v67; // [xsp+58h] [xbp+58h]
__int64 v68; // [xsp+68h] [xbp+68h] BYREF
MusicDownloadManager *v69; // [xsp+70h] [xbp+70h]
void *v70; // [xsp+78h] [xbp+78h]
__int64 v71; // [xsp+80h] [xbp+80h] BYREF
__int64 v72; // [xsp+88h] [xbp+88h]
void *v73; // [xsp+90h] [xbp+90h]
v2 = (unsigned __int8 *)(MusicDownloadManager::sharedState(_stack_chk_guard) + 368);
v3 = (MusicDownloadManager *)*v2;
v4 = (unsigned __int8)v3 >> 1;
if ( ((unsigned __int8)v3 & 1) != 0 )
v4 = *((_QWORD *)v2 + 1);
if ( !v4 )
{
v35 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v3);
MusicDownloadManager::getCustomContentURL(v35);
}
if ( !*((_QWORD *)this + 89) )
{
v5 = (SFXSearchResult *)*((unsigned int *)this + 274);
if ( (_DWORD)v5 || !SFXBrowser::s_savedHasState )
{
v7 = (_DWORD *)SFXSearchResult::create(v5);
SFXFolderObjectForID = *((unsigned int *)this + 256);
v6 = 0;
if ( (int)SFXFolderObjectForID <= 0 )
{
v14 = 0;
v10 = 0;
goto LABEL_51;
}
}
else
{
v6 = 1;
*((_DWORD *)this + 278) = SFXBrowser::s_savedSort;
v7 = (_DWORD *)SFXSearchResult::create(nullptr);
SFXFolderObjectForID = *((unsigned int *)this + 256);
if ( (int)SFXFolderObjectForID <= 0 )
{
v14 = 0;
v10 = 0;
SFXFolderObjectForID = (unsigned int)SFXBrowser::s_savedFolderID;
if ( SFXBrowser::s_savedFolderID > 0 )
{
LABEL_21:
v15 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)SFXFolderObjectForID);
SFXFolderObjectForID = (unsigned __int64)MusicDownloadManager::getSFXFolderObjectForID(
v15,
SFXBrowser::s_savedFolderID);
v16 = (MusicDownloadManager *)SFXFolderObjectForID;
if ( SFXFolderObjectForID )
{
v6 = 1;
goto LABEL_23;
}
}
LABEL_55:
v6 = 1;
goto LABEL_51;
}
}
v9 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)SFXFolderObjectForID);
SFXFolderObjectForID = MusicDownloadManager::getCustomSFXObject(v9, *((_DWORD *)this + 256));
v10 = SFXFolderObjectForID;
if ( SFXFolderObjectForID )
{
SFXFolderObjectForID = *(unsigned __int8 *)(SFXFolderObjectForID + 72);
if ( !(_DWORD)SFXFolderObjectForID )
{
SFXFolderObjectForID = *((unsigned int *)this + 274);
if ( *(_DWORD *)(v10 + 56) == (_DWORD)SFXFolderObjectForID )
{
v14 = 0;
if ( !v6 )
{
LABEL_51:
v33 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)SFXFolderObjectForID);
v16 = MusicDownloadManager::getSFXFolderObjectForID(v33, *((_DWORD *)this + 274));
if ( !v16 )
{
v34 = (MusicDownloadManager *)MusicDownloadManager::sharedState(nullptr);
v16 = MusicDownloadManager::getSFXFolderObjectForID(v34, 1);
SFXSearchResult::setActiveFolder((__int64)v7, v16);
v17 = 1;
if ( !v16 )
{
LABEL_25:
*((_DWORD *)this + 260) = v17;
*((_DWORD *)this + 261) = SFXBrowser::s_savedCustomFolderID;
if ( v10 )
{
v7[35] = (unsigned int)byte_4;
v18 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)byte_4);
CustomSFXFolderForID = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXFolderForID(
v18,
*(_DWORD *)(v10 + 60));
if ( !CustomSFXFolderForID )
{
v62 = (MusicDownloadManager *)MusicDownloadManager::sharedState(nullptr);
CustomSFXFolderForID = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXRoot(v62);
}
SFXSearchResult::setActiveFolder((__int64)v7, CustomSFXFolderForID);
*((_DWORD *)this + 279) = 4;
(*(void (__fastcall **)(_DWORD *, _QWORD))(*(_QWORD *)v7 + 80LL))(v7, *((unsigned int *)this + 278));
if ( !v6 )
goto LABEL_29;
}
else
{
if ( v14 )
{
v7[35] = 3;
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v7);
if ( !v6 )
{
*((_DWORD *)this + 279) = 0;
(*(void (__fastcall **)(_DWORD *, _QWORD))(*(_QWORD *)v7 + 80LL))(
v7,
*((unsigned int *)this + 278));
LABEL_29:
v20 = *((_DWORD *)this + 256);
LABEL_30:
v7[24] = SFXSearchResult::getSelectedPage((SFXSearchResult *)v7, v20, *((_DWORD *)this + 276));
LABEL_31:
*((_BYTE *)this + 1110) = 1;
v21 = (MusicDownloadManager *)SFXBrowser::setupList(this, (cocos2d::CCArray **)v7);
*((_BYTE *)this + 1110) = 0;
if ( !*(_BYTE *)(MusicDownloadManager::sharedState(v21) + 432) )
SFXBrowser::onUpdateLibrary(this, nullptr);
return _stack_chk_guard;
}
}
else
{
if ( !v6 )
{
*((_DWORD *)this + 279) = 0;
(*(void (__fastcall **)(_DWORD *, _QWORD))(*(_QWORD *)v7 + 80LL))(
v7,
*((unsigned int *)this + 278));
v20 = *((_DWORD *)this + 274);
goto LABEL_30;
}
v55 = (__int64 *)(v7 + 26);
if ( v7 + 26 != (_DWORD *)&SFXBrowser::s_savedSearchString )
{
if ( (SFXBrowser::s_savedSearchString & 1) != 0 )
std::string::assign(v55, (const void *)qword_155E740, qword_155E738);
else
std::string::assign(
v55,
(char *)&SFXBrowser::s_savedSearchString + 1,
(unsigned __int8)SFXBrowser::s_savedSearchString >> 1);
}
v56 = SFXBrowser::s_savedViewMode;
if ( SFXBrowser::s_savedViewMode == 3 )
{
if ( *(_QWORD *)(GameManager::sharedState((GameManager *)&SFXBrowser::s_savedViewMode) + 552) )
{
v7[35] = 3;
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v7);
}
else
{
v7[35] = 0;
}
}
else
{
v7[35] = SFXBrowser::s_savedViewMode;
if ( v56 == 4 )
{
v63 = (MusicDownloadManager *)*((unsigned int *)this + 261);
if ( (int)v63 > 0
&& (v66 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v63),
(v63 = (MusicDownloadManager *)MusicDownloadManager::getCustomSFXFolderForID(
v66,
*((_DWORD *)this + 261))) != nullptr) )
{
CustomSFXRoot = v63;
}
else
{
v64 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v63);
CustomSFXRoot = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXRoot(v64);
}
SFXSearchResult::setActiveFolder((__int64)v7, CustomSFXRoot);
}
}
}
v57 = *((unsigned int *)this + 278);
*((_DWORD *)this + 279) = SFXBrowser::s_savedTreeMode;
(*(void (__fastcall **)(_DWORD *, __int64))(*(_QWORD *)v7 + 80LL))(v7, v57);
}
v38 = cocos2d::CCArray::count(*((cocos2d::CCArray **)v7 + 8));
if ( v38 <= 0 )
v39 = 0;
else
v39 = (v38 - 1) / *((_DWORD *)this + 276);
v40 = SFXBrowser::s_savedPage;
if ( SFXBrowser::s_savedPage < 0 )
v40 = 0;
if ( v39 > v40 )
v39 = v40;
v7[24] = v39;
if ( (SFXBrowser::s_savedSearchString & 1) != 0 )
v41 = qword_155E738;
else
v41 = (unsigned __int8)SFXBrowser::s_savedSearchString >> 1;
if ( v41 )
{
v42 = *((_QWORD *)this + 104);
*((_BYTE *)this + 872) = 1;
v43 = (cocos2d::CCSpriteFrameCache **)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v42 + 1072LL))(v42);
v44 = *((void (__fastcall **)(cocos2d::CCSpriteFrameCache **, __int64))*v43 + 145);
v45 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(*v43);
v46 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v45, "gj_findBtnOff_001.png");
v44(v43, v46);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 106) + 344LL))(
*((_QWORD *)this + 106),
1);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 105) + 344LL))(
*((_QWORD *)this + 105),
1);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)this + 105) + 1000LL))(
*((_QWORD *)this + 105),
1);
v47 = *((_QWORD **)this + 105);
v48 = (char *)&SFXBrowser::s_savedSearchString + 1;
if ( (SFXBrowser::s_savedSearchString & 1) != 0 )
v48 = (const char *)qword_155E740;
v67 = (char *)v48;
v71 = 0;
v72 = 0;
v73 = nullptr;
v49 = strlen(v48);
std::string::__init(&v71, v67, v49);
CCTextInputNode::setString(v47, (char *)&v71);
if ( (v71 & 1) != 0 )
operator delete(v73);
v50 = *((_QWORD *)this + 108);
if ( v50 )
{
v51 = *(unsigned int **)(v50 + 56);
if ( *v51 )
{
v52 = *((__int64 **)v51 + 2);
v53 = &v52[*v51 - 1];
while ( v53 >= v52 )
{
v54 = *v52;
if ( !*v52 )
break;
++v52;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v54 + 344LL))(v54, 1);
}
}
}
}
goto LABEL_31;
}
LABEL_24:
v17 = *((_DWORD *)v16 + 14);
goto LABEL_25;
}
LABEL_23:
SFXSearchResult::setActiveFolder((__int64)v7, v16);
goto LABEL_24;
}
LABEL_20:
SFXFolderObjectForID = (unsigned int)SFXBrowser::s_savedFolderID;
if ( SFXBrowser::s_savedFolderID > 0 )
goto LABEL_21;
goto LABEL_55;
}
}
}
v11 = *(GameManager **)(GameManager::sharedState((GameManager *)SFXFolderObjectForID) + 552);
if ( v11 && (v12 = *(GameManager **)(*(_QWORD *)(GameManager::sharedState(v11) + 552) + 3272LL)) != nullptr )
{
v13 = GameManager::sharedState(v12);
LevelSettingsObject::getCustomSFXPathRaw(
*(LevelSettingsObject **)(*(_QWORD *)(v13 + 552) + 3272LL),
*((_DWORD *)this + 274),
*((_DWORD *)this + 256),
&v68);
}
else
{
v68 = 0;
v69 = nullptr;
v70 = nullptr;
std::string::__init(&v68, &byte_11B8890, 0);
}
if ( (v68 & 1) != 0 )
{
SFXFolderObjectForID = (unsigned __int64)v69;
v14 = 1;
if ( v69 )
{
LABEL_17:
operator delete(v70);
LABEL_18:
v10 = 0;
goto LABEL_19;
}
}
else
{
SFXFolderObjectForID = (int)(unsigned __int8)v68 >> 1;
v14 = 1;
if ( (_DWORD)SFXFolderObjectForID )
goto LABEL_18;
}
v59 = (EditorSFXManager *)EditorSFXManager::sharedState((EditorSFXManager *)SFXFolderObjectForID);
EditorSFXManager::getCustomSFXRawPath(&v71, v59, *((_DWORD *)this + 274), *((_DWORD *)this + 256));
v60 = (unsigned __int8)v71 >> 1;
if ( (v71 & 1) != 0 )
{
v60 = v72;
operator delete(v73);
}
if ( !v60 )
*((_DWORD *)this + 256) = 0;
SFXFolderObjectForID = (unsigned __int8)v68;
v14 = 0;
if ( (v68 & 1) == 0 )
{
v10 = 0;
LABEL_19:
if ( !v6 )
goto LABEL_51;
goto LABEL_20;
}
goto LABEL_17;
}
v22 = SFXSearchResult::create((SFXSearchResult *)*((unsigned int *)this + 274));
*(_DWORD *)(v22 + 140) = *(_DWORD *)(*((_QWORD *)this + 89) + 140LL);
v23 = *((_QWORD *)this + 89);
if ( v22 + 104 != v23 + 104 )
{
if ( (*(_BYTE *)(v23 + 104) & 1) != 0 )
{
v24 = *(const void **)(v23 + 120);
v25 = *(_QWORD *)(v23 + 112);
}
else
{
v24 = (const void *)(v23 + 105);
v25 = *(_BYTE *)(v23 + 104) >> 1;
}
std::string::assign((__int64 *)(v22 + 104), v24, v25);
v23 = *((_QWORD *)this + 89);
}
ActiveFolder = SFXSearchResult::getActiveFolder((SFXSearchResult *)v23);
v27 = (MusicDownloadManager *)*(unsigned int *)(v22 + 140);
if ( (_DWORD)v27 == 4 )
{
if ( ActiveFolder
&& (v36 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v27),
(v27 = (MusicDownloadManager *)MusicDownloadManager::getCustomSFXFolderForID(
v36,
*(_DWORD *)(ActiveFolder + 76))) != nullptr) )
{
v37 = v27;
}
else
{
v61 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v27);
v37 = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXRoot(v61);
}
SFXSearchResult::setActiveFolder(v22, v37);
}
else
{
if ( ActiveFolder
&& (v27 = (MusicDownloadManager *)*(unsigned int *)(ActiveFolder + 76), !(_DWORD)v27)
&& (v58 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v27),
(v27 = MusicDownloadManager::getSFXFolderObjectForID(v58, *(_DWORD *)(ActiveFolder + 56))) != nullptr) )
{
v29 = v27;
}
else
{
v28 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v27);
v29 = MusicDownloadManager::getSFXFolderObjectForID(v28, 1);
}
SFXSearchResult::setActiveFolder(v22, v29);
if ( *(_DWORD *)(v22 + 140) == 3 )
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v22);
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v22 + 80LL))(v22, *((unsigned int *)this + 278));
v30 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(v22 + 64));
if ( v30 <= 0 )
v31 = 0;
else
v31 = (v30 - 1) / *((_DWORD *)this + 276);
if ( v31 > *(_DWORD *)(*((_QWORD *)this + 89) + 96LL) )
v31 = *(_DWORD *)(*((_QWORD *)this + 89) + 96LL);
*(_DWORD *)(v22 + 96) = v31;
SFXBrowser::setupList(this, (cocos2d::CCArray **)v22);
return _stack_chk_guard;
}