//
// SFXBrowser::setupSFXBrowser from 0x6c660c to 0x6c6ab0 (1188 bytes)
//
// 1 xrefs:
// > SFXBrowser::trySetupSFXBrowser @ 0x6c6af4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:56:55 +0000
//
int *__fastcall SFXBrowser::setupSFXBrowser(SFXBrowser *this)
{
int v2; // r0
int v3; // r1
int v4; // r6
int v5; // r3
MusicDownloadManager *v6; // r0
_BOOL4 v7; // r6
int v8; // r9
cocos2d::CCObject *CustomSFXObject; // r0
int v10; // r5
char *v11; // r0
cocos2d::CCDictionary *ActiveFolder; // r0
cocos2d::CCDictionary *v13; // r6
cocos2d::CCDictionary **v14; // r0
MusicDownloadManager *v15; // r0
MusicDownloadManager *v16; // r0
MusicDownloadManager *v17; // r0
int v18; // r0
int v19; // r0
int v20; // r3
int *result; // r0
MusicDownloadManager *v22; // r0
cocos2d::CCObject *v23; // r10
int v24; // r6
GameManager *v25; // r0
GameManager *v26; // r0
int v27; // r0
int v28; // r3
int v29; // r0
MusicDownloadManager *v30; // r0
cocos2d::CCDictionary *SFXFolderObjectForID; // r11
MusicDownloadManager *v32; // r0
MusicDownloadManager *v33; // r0
cocos2d::CCObject *v34; // r0
int v35; // r3
MusicDownloadManager *v36; // r0
cocos2d::CCObject *CustomSFXFolderForID; // r0
cocos2d::CCDictionary **v38; // r0
int v39; // r3
unsigned __int8 *CustomSFXRoot; // r0
int v41; // r11
cocos2d::CCDictionary **v42; // r0
MusicDownloadManager *v43; // r0
int v44; // r0
int v45; // r0
int v46; // r3
int *v47; // r6
int v48; // r3
int v49; // r1
int v50; // r0
cocos2d::CCSpriteFrameCache *v51; // r9
void (__fastcall *v52)(cocos2d::CCSpriteFrameCache *, int); // r10
cocos2d::CCSpriteFrameCache *v53; // r0
int v54; // r0
int v55; // r9
size_t v56; // r0
int v57; // r3
_DWORD *v58; // r3
int *v59; // r7
int *v60; // r6
int v61; // r0
int v62; // t1
int *v63; // r0
int v64; // [sp+Ch] [bp-20h] BYREF
int v65; // [sp+10h] [bp-1Ch]
int v66; // [sp+14h] [bp-18h]
int v67; // [sp+18h] [bp-14h] BYREF
int v68; // [sp+1Ch] [bp-10h]
int v69; // [sp+20h] [bp-Ch]
v2 = MusicDownloadManager::sharedState(this);
v4 = *(unsigned __int8 *)(v2 + 288);
if ( (v4 & 1) != 0 )
v5 = *(_DWORD *)(v2 + 292);
else
v5 = v4 >> 1;
if ( !v5 )
{
v6 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)v2);
MusicDownloadManager::getCustomContentURL(v6);
}
v7 = *((_DWORD *)this + 136) == 0;
if ( *((_DWORD *)this + 136) || *((_DWORD *)this + 189) || !SFXBrowser::s_savedHasState )
{
v8 = 0;
}
else
{
v8 = 1;
*((_DWORD *)this + 193) = SFXBrowser::s_savedSort;
}
CustomSFXObject = SFXSearchResult::create(*((SFXSearchResult **)this + 189), v3);
v10 = (int)CustomSFXObject;
if ( !v7 )
{
v11 = (char *)CustomSFXObject + 80;
*((_DWORD *)v11 + 6) = *(_DWORD *)(*((_DWORD *)this + 136) + 104);
std::string::operator=((unsigned __int8 *)v11, (unsigned __int8 *)(*((_DWORD *)this + 136) + 80));
ActiveFolder = (cocos2d::CCDictionary *)SFXSearchResult::getActiveFolder(*((SFXSearchResult **)this + 136));
v13 = ActiveFolder;
if ( *(_DWORD *)(v10 + 104) == 4 )
{
if ( !ActiveFolder
|| (v15 = (MusicDownloadManager *)MusicDownloadManager::sharedState(ActiveFolder),
(ActiveFolder = (cocos2d::CCDictionary *)MusicDownloadManager::getCustomSFXFolderForID(
v15,
*((_DWORD *)v13 + 18))) == nullptr) )
{
v14 = (cocos2d::CCDictionary **)MusicDownloadManager::sharedState(ActiveFolder);
ActiveFolder = (cocos2d::CCDictionary *)MusicDownloadManager::getCustomSFXRoot(v14);
}
SFXSearchResult::setActiveFolder(v10, ActiveFolder);
}
else
{
if ( !ActiveFolder
|| *((_DWORD *)ActiveFolder + 18)
|| (v17 = (MusicDownloadManager *)MusicDownloadManager::sharedState(ActiveFolder),
(ActiveFolder = MusicDownloadManager::getSFXFolderObjectForID(v17, *((_DWORD *)v13 + 13))) == nullptr) )
{
v16 = (MusicDownloadManager *)MusicDownloadManager::sharedState(ActiveFolder);
ActiveFolder = MusicDownloadManager::getSFXFolderObjectForID(v16, 1);
}
SFXSearchResult::setActiveFolder(v10, ActiveFolder);
if ( *(_DWORD *)(v10 + 104) == 3 )
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v10);
}
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v10 + 40))(v10, *((_DWORD *)this + 193));
v18 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(v10 + 56));
if ( v18 <= 0 )
v19 = 0;
else
v19 = (v18 - 1) / *((_DWORD *)this + 191);
v20 = *(_DWORD *)(*((_DWORD *)this + 136) + 72);
if ( v19 > v20 )
*(_DWORD *)(v10 + 72) = v20;
else
*(_DWORD *)(v10 + 72) = v19;
return SFXBrowser::setupList((int *)this, (cocos2d::CCArray **)v10);
}
if ( *((int *)this + 175) <= 0 )
{
v24 = 0;
v23 = nullptr;
}
else
{
v22 = (MusicDownloadManager *)MusicDownloadManager::sharedState(CustomSFXObject);
CustomSFXObject = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXObject(v22, *((_DWORD *)this + 175));
v23 = CustomSFXObject;
if ( !CustomSFXObject
|| (v24 = *((unsigned __int8 *)CustomSFXObject + 68), *((_BYTE *)CustomSFXObject + 68))
|| *((_DWORD *)CustomSFXObject + 13) != *((_DWORD *)this + 189) )
{
v25 = (GameManager *)GameManager::sharedState(CustomSFXObject);
if ( *((_DWORD *)v25 + 102)
&& (v26 = (GameManager *)GameManager::sharedState(v25), *(_DWORD *)(*((_DWORD *)v26 + 102) + 2084)) )
{
v27 = GameManager::sharedState(v26);
LevelSettingsObject::getCustomSFXPathRaw(
(LevelSettingsObject *)&v64,
*(_DWORD *)(*(_DWORD *)(v27 + 408) + 2084),
*((_DWORD *)this + 189),
*((_DWORD *)this + 175));
}
else
{
v64 = 0;
v65 = 0;
v66 = 0;
std::string::__init(&v64, &unk_B6B226, 0);
}
if ( (v64 & 1) != 0 )
v28 = v65;
else
v28 = (int)(unsigned __int8)v64 >> 1;
if ( v28 )
{
v24 = 1;
}
else
{
v29 = EditorSFXManager::sharedState((EditorSFXManager *)((unsigned __int8)v64 << 31));
EditorSFXManager::getCustomSFXRawPath((EditorSFXManager *)&v67, v29, *((_DWORD *)this + 189));
if ( (v67 & 1) != 0 )
v24 = v68;
else
v24 = (int)(unsigned __int8)v67 >> 1;
std::string::~string((int)&v67);
if ( v24 )
v24 = 0;
else
*((_DWORD *)this + 175) = 0;
}
v23 = nullptr;
CustomSFXObject = (cocos2d::CCObject *)std::string::~string((int)&v64);
}
}
if ( !v8
|| SFXBrowser::s_savedFolderID <= 0
|| (v33 = (MusicDownloadManager *)MusicDownloadManager::sharedState(CustomSFXObject),
CustomSFXObject = MusicDownloadManager::getSFXFolderObjectForID(v33, SFXBrowser::s_savedFolderID),
(SFXFolderObjectForID = CustomSFXObject) == nullptr) )
{
v30 = (MusicDownloadManager *)MusicDownloadManager::sharedState(CustomSFXObject);
SFXFolderObjectForID = MusicDownloadManager::getSFXFolderObjectForID(v30, *((_DWORD *)this + 189));
if ( !SFXFolderObjectForID )
{
v32 = (MusicDownloadManager *)MusicDownloadManager::sharedState(nullptr);
SFXFolderObjectForID = MusicDownloadManager::getSFXFolderObjectForID(v32, 1);
}
}
v34 = SFXSearchResult::setActiveFolder(v10, SFXFolderObjectForID);
if ( SFXFolderObjectForID )
v35 = *((_DWORD *)SFXFolderObjectForID + 13);
else
v35 = 1;
*((_DWORD *)this + 179) = v35;
*((_DWORD *)this + 180) = SFXBrowser::s_savedCustomFolderID;
if ( v23 )
{
*(_DWORD *)(v10 + 104) = 4;
v36 = (MusicDownloadManager *)MusicDownloadManager::sharedState(v34);
CustomSFXFolderForID = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXFolderForID(
v36,
*((_DWORD *)v23 + 14));
if ( !CustomSFXFolderForID )
{
v38 = (cocos2d::CCDictionary **)MusicDownloadManager::sharedState(nullptr);
CustomSFXFolderForID = (cocos2d::CCObject *)MusicDownloadManager::getCustomSFXRoot(v38);
}
SFXSearchResult::setActiveFolder(v10, CustomSFXFolderForID);
v39 = 4;
goto LABEL_78;
}
if ( v24 )
{
*(_DWORD *)(v10 + 104) = 3;
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v10);
if ( !v8 )
goto LABEL_77;
}
else
{
if ( !v8 )
{
LABEL_77:
v39 = 0;
goto LABEL_78;
}
CustomSFXRoot = std::string::operator=(
(unsigned __int8 *)(v10 + 80),
(unsigned __int8 *)&SFXBrowser::s_savedSearchString);
v41 = SFXBrowser::s_savedViewMode;
if ( SFXBrowser::s_savedViewMode == 3 )
{
CustomSFXRoot = (unsigned __int8 *)GameManager::sharedState((GameManager *)CustomSFXRoot);
if ( !*((_DWORD *)CustomSFXRoot + 102) )
v41 = 0;
}
*(_DWORD *)(v10 + 104) = v41;
if ( v41 == 3 )
{
SFXBrowser::refreshLevelIDList(this, (SFXSearchResult *)v10);
}
else if ( v41 == 4 )
{
if ( *((int *)this + 180) <= 0
|| (v43 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)CustomSFXRoot),
(CustomSFXRoot = (unsigned __int8 *)MusicDownloadManager::getCustomSFXFolderForID(
v43,
*((_DWORD *)this + 180))) == nullptr) )
{
v42 = (cocos2d::CCDictionary **)MusicDownloadManager::sharedState((MusicDownloadManager *)CustomSFXRoot);
CustomSFXRoot = (unsigned __int8 *)MusicDownloadManager::getCustomSFXRoot(v42);
}
SFXSearchResult::setActiveFolder(v10, (cocos2d::CCObject *)CustomSFXRoot);
}
}
v39 = SFXBrowser::s_savedTreeMode;
LABEL_78:
*((_DWORD *)this + 194) = v39;
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v10 + 40))(v10, *((_DWORD *)this + 193));
if ( v8 )
{
v44 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(v10 + 56));
if ( v44 <= 0 )
v45 = 0;
else
v45 = (v44 - 1) / *((_DWORD *)this + 191);
v46 = SFXBrowser::s_savedPage & ~(SFXBrowser::s_savedPage >> 31);
if ( v45 > v46 )
*(_DWORD *)(v10 + 72) = v46;
else
*(_DWORD *)(v10 + 72) = v45;
v47 = &SFXBrowser::s_savedSearchString;
if ( (SFXBrowser::s_savedSearchString & 1) != 0 )
v48 = dword_D2D840;
else
v48 = (int)(unsigned __int8)SFXBrowser::s_savedSearchString >> 1;
if ( v48 )
{
v50 = *((_DWORD *)this + 151);
*((_BYTE *)this + 624) = 1;
v51 = (cocos2d::CCSpriteFrameCache *)(*(int (__fastcall **)(int))(*(_DWORD *)v50 + 536))(v50);
v52 = *(void (__fastcall **)(cocos2d::CCSpriteFrameCache *, int))(*(_DWORD *)v51 + 580);
v53 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v51);
v54 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v53, "gj_findBtnOff_001.png");
v52(v51, v54);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 153) + 172))(*((_DWORD *)this + 153), 1);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 152) + 172))(*((_DWORD *)this + 152), 1);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 152) + 500))(*((_DWORD *)this + 152), 1);
v55 = *((_DWORD *)this + 152);
if ( (SFXBrowser::s_savedSearchString & 1) == 0 )
v47 = (int *)((char *)&SFXBrowser::s_savedSearchString + 1);
v67 = 0;
if ( (SFXBrowser::s_savedSearchString & 1) != 0 )
v47 = (int *)v47[2];
v68 = 0;
v69 = 0;
v56 = strlen((const char *)v47);
std::string::__init(&v67, v47, v56);
CCTextInputNode::setString(v55, (int)&v67);
std::string::~string((int)&v67);
v57 = *((_DWORD *)this + 155);
if ( v57 )
{
v58 = *(_DWORD **)(v57 + 52);
if ( *v58 )
{
v59 = (int *)v58[3];
v60 = &v59[*v58 - 1];
while ( v59 <= v60 )
{
v62 = *v59++;
v61 = v62;
if ( !v62 )
break;
(*(void (__fastcall **)(int, int))(*(_DWORD *)v61 + 172))(v61, 1);
}
}
}
}
}
else
{
if ( v23 || v24 )
v49 = *((_DWORD *)this + 175);
else
v49 = *((_DWORD *)this + 189);
*(_DWORD *)(v10 + 72) = SFXSearchResult::getSelectedPage((SFXSearchResult *)v10, v49, *((_DWORD *)this + 191));
}
*((_BYTE *)this + 770) = 1;
v63 = SFXBrowser::setupList((int *)this, (cocos2d::CCArray **)v10);
*((_BYTE *)this + 770) = 0;
result = (int *)MusicDownloadManager::sharedState((MusicDownloadManager *)v63);
if ( !*((_BYTE *)result + 328) )
return (int *)SFXBrowser::onUpdateLibrary(this, (cocos2d::CCObject *)*((unsigned __int8 *)result + 328));
return result;
}