//
// MusicDownloadManager::parseSFXLibrary from 0x45a8a4 to 0x45abf2 (846 bytes)
//
// 3 xrefs:
// > MusicDownloadManager::onDownloadSFXLibraryCompleted @ 0x45ac82
// > MusicDownloadManager::tryLoadLibraries @ 0x45d5b4
// > sub_5836C8 @ 0x584176
//
// 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
//
void MusicDownloadManager::parseSFXLibrary(MusicDownloadManager *a1)
{
cocos2d::CCFileUtils *v2; // r0
unsigned __int8 *v3; // r1
cocos2d::CCDictionary *m_sfxObjects; // r0
cocos2d::CCDictionary *v5; // r0
cocos2d::CCArray *m_sfxArtists; // r0
cocos2d::CCArray *v7; // r0
cocos2d::CCArray *v8; // r0
unsigned int i; // r7
const char **v10; // r8
const char **v11; // r9
const char **j; // r6
const char **v13; // r0
const char **v14; // r6
int v15; // r9
const char **v16; // r6
int v17; // r11
SFXInfoObject *v18; // r0
SFXInfoObject *v19; // r0
unsigned int k; // r8
const char **v21; // r11
const char **v22; // r3
const char **m; // r6
const char **v24; // r0
cocos2d::CCArray *v25; // r11
int v26; // r2
int v27; // r3
cocos2d::CCObject *v28; // r0
int v29; // [sp+14h] [bp-78h]
int v30; // [sp+18h] [bp-74h]
const char **v31; // [sp+18h] [bp-74h]
int v32; // [sp+1Ch] [bp-70h]
int v33; // [sp+34h] [bp-58h] BYREF
int v34; // [sp+38h] [bp-54h] BYREF
_DWORD *v35; // [sp+3Ch] [bp-50h] BYREF
cocos2d::ZipUtils v36; // [sp+40h] [bp-4Ch] BYREF
char v37[4]; // [sp+44h] [bp-48h] BYREF
char v38[4]; // [sp+48h] [bp-44h] BYREF
char v39[4]; // [sp+4Ch] [bp-40h] BYREF
char v40[4]; // [sp+50h] [bp-3Ch] BYREF
_DWORD *v41; // [sp+54h] [bp-38h] BYREF
int v42; // [sp+58h] [bp-34h]
int v43; // [sp+5Ch] [bp-30h]
_DWORD *v44; // [sp+60h] [bp-2Ch] BYREF
int v45; // [sp+64h] [bp-28h]
int v46; // [sp+68h] [bp-24h]
const char **v47; // [sp+6Ch] [bp-20h] BYREF
const char **v48; // [sp+70h] [bp-1Ch]
int v49; // [sp+74h] [bp-18h]
const char *v50; // [sp+78h] [bp-14h] BYREF
int v51; // [sp+7Ch] [bp-10h]
int v52; // [sp+80h] [bp-Ch]
MusicDownloadManager::pathForSFXFolder((MusicDownloadManager *)&v33, a1, 0, _stack_chk_guard);
sub_774544((int)&v33, "sfxlibrary.dat");
v34 = 0;
v2 = cocos2d::CCFileUtils::sharedFileUtils();
v3 = (unsigned __int8 *)((int (__fastcall *)(cocos2d::CCFileUtils *, int, __int16 *, int *))v2->addSearchResolutionsOrder)(
v2,
v33,
&aO1i2r3e45s7t89[4],
&v34);
v35 = &unk_ACDDA8;
if ( v3 )
{
cocos2d::ZipUtils::decompressString2(&v36, v3, 0, v34, 11);
sub_774794(&v35, &v36);
sub_774008(&v36);
if ( *(v35 - 3) )
{
v41 = nullptr;
v42 = 0;
v43 = 0;
sub_45A6C8(&v35, "|", (int)&v41);
if ( (unsigned int)(v42 - (_DWORD)v41) > 7 )
{
v44 = nullptr;
v45 = 0;
v46 = 0;
sub_45A6C8(v41, ";", (int)&v44);
sub_7751A8(v41);
v47 = nullptr;
v48 = nullptr;
v49 = 0;
if ( (unsigned int)(v45 - (_DWORD)v44) >> 2 )
{
m_sfxObjects = a1->m_sfxObjects;
if ( m_sfxObjects )
{
cocos2d::CCObject::release(m_sfxObjects);
m_sfxArtists = a1->m_sfxArtists;
if ( m_sfxArtists )
cocos2d::CCObject::release(m_sfxArtists);
}
v5 = cocos2d::CCDictionary::create();
a1->m_sfxObjects = v5;
cocos2d::CCObject::retain(v5);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
a1->m_sfxArtists = v8;
cocos2d::CCObject::retain(v8);
a1->m_sfxObjectCount = 0;
}
for ( i = 0; i < (v45 - (int)v44) >> 2; ++i )
{
v10 = v47;
v11 = v48;
for ( j = v47; j != v11; ++j )
{
v13 = j;
sub_774008(v13);
}
v48 = v10;
sub_45A6C8(&v44[i], ",", (int)&v47);
v14 = v47;
if ( (unsigned int)((char *)v48 - (char *)v47) > 0x17 )
{
v15 = atoi(*v47);
sub_776584((int)&v50, (char *)v14[1]);
v16 = v47;
v29 = atoi(v47[2]);
v17 = atoi(v16[3]);
v30 = atoi(v16[4]);
v32 = atoi(v16[5]);
if ( v15 == 1 )
{
a1->m_sfxLibraryVersion = atoi(v50);
sub_7753D4((int)&v50, "Root");
}
if ( v29 )
{
sub_775C20(v38);
v19 = (SFXInfoObject *)SFXFolderObject::create(v15, (int)v38, v17);
MusicDownloadManager::storeSFXInfoObject(a1, v19);
sub_774008(v38);
}
else
{
sub_775C20(v37);
v18 = (SFXInfoObject *)SFXInfoObject::create(v15, (int)v37, v17, v30, v32);
MusicDownloadManager::storeSFXInfoObject(a1, v18);
sub_774008(v37);
++a1->m_sfxObjectCount;
}
sub_774008(&v50);
}
}
v50 = nullptr;
v51 = 0;
v52 = 0;
sub_45A6C8(v41 + 1, ";", (int)&v50);
for ( k = 0; k < (v51 - (int)v50) >> 2; ++k )
{
v21 = v47;
v22 = v48;
for ( m = v47; m != v22; ++m )
{
v24 = m;
v31 = v22;
sub_774008(v24);
v22 = v31;
}
v48 = v21;
sub_45A6C8(&v50[4 * k], ",", (int)&v47);
if ( (unsigned int)((char *)v48 - (char *)v47) > 7 )
{
v25 = a1->m_sfxArtists;
sub_775C20(v39);
sub_775C20(v40);
v28 = CCURLObject::create((int)v39, (int)v40, v26, v27);
cocos2d::CCArray::addObject(v25, v28);
sub_774008(v40);
sub_774008(v39);
}
}
std::vector::~vector((void **)&v50);
std::vector::~vector((void **)&v47);
std::vector::~vector((void **)&v44);
}
std::vector::~vector((void **)&v41);
}
}
sub_774008(&v35);
sub_774008(&v33);
}