//
// MusicDownloadManager::importCustomSFXFromFile from 0x1001d9440 to 0x1001d977c (828 bytes)
//
// 1 xrefs:
// > sub_1001F4350 @ 0x1001f4380
//
// 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 11:00:26 +0000
//
__int64 __fastcall MusicDownloadManager::importCustomSFXFromFile(__int64 a1, __int64 a2, int *a3, int *a4)
{
char v8; // w0
char v9; // w23
std::string *p_p; // x0
__int64 v11; // x0
char *CString; // x0
std::string::size_type v13; // x9
std::string::size_type size; // x10
std::string::size_type v15; // x11
std::string *v16; // x10
std::string::size_type v17; // x11
__int64 v18; // x19
std::string *p_str; // x9
std::string::size_type v20; // x10
std::string::size_type v21; // x8
std::string *v22; // x9
int v23; // w10
int v24; // t1
std::string::size_type v25; // x0
std::string::size_type v26; // x8
std::string v28; // [xsp+8h] [xbp-98h] BYREF
std::string __str; // [xsp+20h] [xbp-80h] BYREF
std::string v30; // [xsp+38h] [xbp-68h] BYREF
std::string __p; // [xsp+50h] [xbp-50h] BYREF
std::allocator __a; // [xsp+6Fh] [xbp-31h] BYREF
if ( *(char *)(a2 + 23) < 0 )
{
**(_BYTE **)a2 = 0;
*(_QWORD *)(a2 + 8) = 0;
}
else
{
*(_BYTE *)a2 = 0;
*(_BYTE *)(a2 + 23) = 0;
}
*a3 = 0;
*a4 = 0;
memset(&__p, 0, sizeof(__p));
sub_100009900(&v30, "customsfx.gdsfx");
v8 = sub_10004F820(
(__int64)"Import SFX Folders",
(__int64)"GD SFX Folder Files (*.gdsfx)",
(__int64)&v30,
(__int64)&__p);
v9 = v8;
if ( SHIBYTE(v30.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(v30.__r_.__value_.__l.__data_);
if ( (v9 & 1) != 0 )
goto LABEL_6;
LABEL_25:
v18 = 0xFFFFFFFFLL;
goto LABEL_64;
}
if ( (v8 & 1) == 0 )
goto LABEL_25;
LABEL_6:
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = &__p;
else
p_p = (std::string *)__p.__r_.__value_.__r.__words[0];
v11 = cocos2d::CCString::createWithContentsOfFile(p_p);
if ( !v11 )
{
v18 = 0;
goto LABEL_64;
}
CString = (char *)cocos2d::CCString::getCString(v11);
sub_100009900(&v30, CString);
while ( 1 )
{
v13 = HIBYTE(v30.__r_.__value_.__r.__words[2]);
if ( SHIBYTE(v30.__r_.__value_.__r.__words[2]) < 0 )
{
size = v30.__r_.__value_.__l.__size_;
if ( !v30.__r_.__value_.__l.__size_ )
goto LABEL_28;
}
else
{
if ( !*((_BYTE *)&v30.__r_.__value_.__s + 23) )
goto LABEL_29;
size = HIBYTE(v30.__r_.__value_.__r.__words[2]);
}
v15 = size - 1;
if ( (*((_BYTE *)&v30.__r_.__value_.__s + 23) & 0x80) == 0 )
break;
v16 = (std::string *)v30.__r_.__value_.__r.__words[0];
if ( *(_BYTE *)(v30.__r_.__value_.__r.__words[0] + v15) != 10 )
{
v17 = v30.__r_.__value_.__l.__size_;
goto LABEL_20;
}
LABEL_22:
v13 = v30.__r_.__value_.__l.__size_;
LABEL_23:
std::string::resize(&v30, v13 - 1, 0);
}
if ( v30.__r_.__value_.__s.__data_[v15] == 10 )
goto LABEL_23;
v16 = &v30;
v17 = HIBYTE(v30.__r_.__value_.__r.__words[2]);
LABEL_20:
if ( v16->__r_.__value_.__s.__data_[v17 - 1] == 13 )
{
if ( (*((_BYTE *)&v30.__r_.__value_.__s + 23) & 0x80) == 0 )
goto LABEL_23;
goto LABEL_22;
}
if ( (*((_BYTE *)&v30.__r_.__value_.__s + 23) & 0x80) == 0 )
goto LABEL_29;
LABEL_28:
v13 = v30.__r_.__value_.__l.__size_;
LABEL_29:
if ( v13 )
{
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__str, __p.__r_.__value_.__l.__data_, __p.__r_.__value_.__l.__size_);
else
__str = __p;
p_str = &__str;
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v20 = SHIBYTE(__str.__r_.__value_.__r.__words[2]);
else
v20 = __str.__r_.__value_.__l.__size_;
v21 = ~v20;
v22 = (std::string *)((char *)p_str + v20 - 1);
while ( v21 != -1 )
{
v24 = (unsigned __int8)v22->__r_.__value_.__s.__data_[0];
v22 = (std::string *)((char *)v22 - 1);
v23 = v24;
++v21;
if ( v24 == 92 || v23 == 47 )
{
if ( v21 )
{
std::string::basic_string(&v28, &__str, -(__int64)v21, 0xFFFFFFFFFFFFFFFFLL, &__a);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
__str = v28;
}
break;
}
}
v25 = std::string::rfind(&__str, 46, 0xFFFFFFFFFFFFFFFFLL);
if ( v25 - 1 <= 0xFFFFFFFFFFFFFFFDLL )
{
std::string::basic_string(&v28, &__str, 0, v25, &__a);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
__str = v28;
}
v26 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v26 = __str.__r_.__value_.__l.__size_;
if ( !v26 )
std::string::assign(&__str, "Imported");
MusicDownloadManager::importCustomSFXSetup(a1, (__int64)&v30, (__int64)&__str, 0, a3, a4);
if ( *a3 > 0 || *a4 >= 1 )
{
std::string::operator=((std::string *)a2, &__str);
v18 = 1;
}
else
{
v18 = 0;
}
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( (*((_BYTE *)&v30.__r_.__value_.__s + 23) & 0x80) != 0 )
LABEL_63:
operator delete(v30.__r_.__value_.__l.__data_);
}
else
{
v18 = 0;
if ( (*((_BYTE *)&v30.__r_.__value_.__s + 23) & 0x80) != 0 )
goto LABEL_63;
}
LABEL_64:
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
return v18;
}