//
// MusicDownloadManager::importCustomSFXFromFile from 0x576544 to 0x576872 (814 bytes)
//
// 1 xrefs:
// > SFXBrowser::onImportFile @ 0x6c8594
//
// 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:52:42 +0000
//
int __fastcall MusicDownloadManager::importCustomSFXFromFile(cocos2d::CCDictionary **a1, int a2, int *a3, int *a4)
{
bool v6; // zf
_BYTE *v8; // r2
int v9; // r3
int v10; // r5
const char *v11; // r1
cocos2d::CCString *v12; // r0
cocos2d::CCString *v13; // r0
int v14; // r4
const char *CString; // r4
size_t v16; // r0
int v17; // r2
int v18; // r3
int v19; // r3
char *v20; // r1
unsigned int v21; // r3
unsigned int v22; // r3
int *v23; // r1
char *v24; // r9
int v25; // r4
char *v26; // r4
const char *v27; // r3
int v28; // t1
void *v29; // r0
size_t v30; // r3
int v31; // r3
int v33; // r3
unsigned int v34; // r3
unsigned int v35; // r5
size_t v36; // r5
int v37; // r4
unsigned int v38; // r1
char *v39; // r3
unsigned int v40; // r4
const char *v42; // [sp+1Ch] [bp-58h]
char *v43; // [sp+1Ch] [bp-58h]
_DWORD v44[2]; // [sp+24h] [bp-50h] BYREF
cocos2d::CCString *v45; // [sp+2Ch] [bp-48h]
int v46[3]; // [sp+30h] [bp-44h] BYREF
int v47; // [sp+3Ch] [bp-38h] BYREF
unsigned int v48; // [sp+40h] [bp-34h]
char *v49; // [sp+44h] [bp-30h]
int v50; // [sp+48h] [bp-2Ch] BYREF
int v51; // [sp+4Ch] [bp-28h]
char *v52; // [sp+50h] [bp-24h]
int v53; // [sp+54h] [bp-20h] BYREF
int v54; // [sp+58h] [bp-1Ch]
char *v55; // [sp+5Ch] [bp-18h]
int v56; // [sp+60h] [bp-14h] BYREF
int v57; // [sp+64h] [bp-10h]
char *v58; // [sp+68h] [bp-Ch]
int v59; // [sp+6Ch] [bp-8h]
v6 = (*(_BYTE *)a2 & 1) == 0;
v8 = &_stack_chk_guard;
v9 = _stack_chk_guard;
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v8 = *(_BYTE **)(a2 + 8);
}
else
{
*(_BYTE *)(a2 + 1) = 0;
*(_BYTE *)a2 = 0;
}
v59 = v9;
if ( !v6 )
{
*v8 = 0;
*(_DWORD *)(a2 + 4) = 0;
}
*a3 = 0;
*a4 = 0;
v44[0] = 0;
v44[1] = 0;
v45 = nullptr;
memset(v46, 0, sizeof(v46));
std::string::__init(v46, "customsfx.gdsfx", 0xFu);
v10 = GameToolbox::showOpenFileDialog(
(cocos2d::CCFileUtils *)"Import SFX Folders",
(int)"GD SFX Folder Files (*.gdsfx)",
(unsigned __int8 *)v46,
(int)v44);
std::string::~string((int)v46);
if ( !v10 )
{
v14 = -1;
goto LABEL_58;
}
if ( (v44[0] & 1) != 0 )
v12 = v45;
else
v12 = (cocos2d::CCString *)((char *)v44 + 1);
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithContentsOfFile(v12, v11);
v14 = (int)v13;
if ( v13 )
{
CString = (const char *)cocos2d::CCString::getCString(v13);
v47 = 0;
v48 = 0;
v49 = nullptr;
v16 = strlen(CString);
std::string::__init(&v47, CString, v16);
while ( 1 )
{
v17 = v47 & 1;
if ( v17 )
{
v18 = v48;
if ( !v48 )
goto LABEL_28;
}
else
{
v18 = (int)(unsigned __int8)v47 >> 1;
if ( !v18 )
goto LABEL_29;
}
v19 = v18 - 1;
if ( v17 )
v20 = v49;
else
v20 = (char *)&v47 + 1;
if ( v20[v19] != 10 )
{
v21 = v17 ? v48 : (int)(unsigned __int8)v47 >> 1;
v22 = v21 - 1;
v23 = v17 ? (int *)v49 : (int *)((char *)&v47 + 1);
if ( *((_BYTE *)v23 + v22) != 13 )
{
if ( v17 )
{
LABEL_28:
v14 = v48;
goto LABEL_30;
}
LABEL_29:
v14 = (int)(unsigned __int8)v47 >> 1;
LABEL_30:
if ( v14 )
{
std::string::basic_string(&v50, (int)v44);
if ( (v50 & 1) != 0 )
{
v24 = v52;
v25 = v51;
}
else
{
v25 = (int)(unsigned __int8)v50 >> 1;
v24 = (char *)&v50 + 1;
}
v26 = &v24[v25];
v27 = "\\/";
while ( v26 != v24 )
{
v28 = (unsigned __int8)*--v26;
v42 = v27;
v29 = memchr(v27, v28, 2u);
v27 = v42;
if ( v29 )
{
if ( v26 - v24 != -1 )
{
std::string::basic_string(&v53, (unsigned __int8 *)&v50, v26 - v24 + 1, 0xFFFFFFFF);
if ( (v50 & 1) != 0 )
{
*v52 = 0;
v51 = 0;
}
else
{
LOWORD(v50) = 0;
}
std::string::reserve(&v50, 0);
v50 = v53;
v51 = v54;
v52 = v55;
v53 = 0;
v54 = 0;
v55 = nullptr;
std::string::~string((int)&v53);
}
break;
}
}
v30 = std::string::rfind((unsigned __int8 *)&v50, 46, 0xFFFFFFFF);
if ( v30 - 1 <= 0xFFFFFFFD )
{
std::string::basic_string(&v56, (unsigned __int8 *)&v50, 0, v30);
if ( (v50 & 1) != 0 )
{
*v52 = 0;
v51 = 0;
}
else
{
LOWORD(v50) = 0;
}
std::string::reserve(&v50, 0);
v50 = v56;
v51 = v57;
v52 = v58;
v56 = 0;
v57 = 0;
v58 = nullptr;
std::string::~string((int)&v56);
}
if ( (v50 & 1) != 0 )
v31 = v51;
else
v31 = (int)(unsigned __int8)v50 >> 1;
if ( !v31 )
std::string::assign(&v50, "Imported");
MusicDownloadManager::importCustomSFXSetup(a1, (unsigned __int8 *)&v47, (int)&v50, 0, a3, a4);
if ( *a3 <= 0 && *a4 <= 0 )
{
v14 = 0;
}
else
{
std::string::operator=((unsigned __int8 *)a2, (unsigned __int8 *)&v50);
v14 = 1;
}
std::string::~string((int)&v50);
}
std::string::~string((int)&v47);
break;
}
}
if ( v17 )
v33 = v48;
else
v33 = (int)(unsigned __int8)v47 >> 1;
v34 = v33 - 1;
if ( v17 )
{
v35 = v48;
if ( v34 > v48 )
goto LABEL_66;
v49[v34] = 0;
v48 = v34;
}
else
{
v35 = (int)(unsigned __int8)v47 >> 1;
if ( v34 <= v35 )
{
*((_BYTE *)&v47 + v34 + 1) = 0;
LOBYTE(v47) = 2 * v34;
}
else
{
LABEL_66:
v36 = v34 - v35;
if ( v36 )
{
if ( v17 )
{
v37 = v48;
v38 = (v47 & 0xFFFFFFFE) - 1;
}
else
{
v37 = (int)(unsigned __int8)v47 >> 1;
v38 = 10;
}
if ( v38 - v37 < v36 )
std::string::__grow_by((int)&v47, v38, v37 + v36 - v38, v37, v37, 0, 0);
if ( (v47 & 1) != 0 )
v39 = v49;
else
v39 = (char *)&v47 + 1;
v43 = v39;
memset(&v39[v37], 0, v36);
v40 = v37 + v36;
if ( (v47 & 1) != 0 )
v48 = v40;
else
LOBYTE(v47) = 2 * v40;
v43[v40] = 0;
}
}
}
}
}
LABEL_58:
std::string::~string((int)v44);
return v14;
}