//
// MusicDownloadManager::encodeCustomSFX from 0x1001d9058 to 0x1001d93bc (868 bytes)
//
// 3 xrefs:
// > sub_1001D8EB0 @ 0x1001d8ed8
// > MusicDownloadManager::encodeDataTo @ 0x1001d9f68
// > sub_1003FE824 @ 0x1003fe918
//
// 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
//
void __usercall MusicDownloadManager::encodeCustomSFX(__int64 a1@, _QWORD *a2@, std::string *a3@)
{
char v5; // w0
char v6; // w8
__int64 v7; // x8
__int64 v8; // x24
__int64 v9; // x26
int v10; // w8
_QWORD *i; // x9
int v12; // w10
std::string::size_type size; // x8
const std::string::value_type *v14; // x1
std::string::size_type v15; // x2
std::string *v16; // x0
std::string::size_type v17; // x8
std::string *v18; // x1
std::string::size_type v19; // x2
std::string *v20; // x1
std::string::size_type v21; // x2
void *__p[2]; // [xsp+20h] [xbp-110h] BYREF
__int64 v23; // [xsp+30h] [xbp-100h]
void *v24; // [xsp+38h] [xbp-F8h] BYREF
__int64 v25; // [xsp+40h] [xbp-F0h]
unsigned __int8 v26; // [xsp+4Fh] [xbp-E1h]
std::string v27; // [xsp+50h] [xbp-E0h] BYREF
std::string v28; // [xsp+68h] [xbp-C8h] BYREF
_QWORD **v29; // [xsp+80h] [xbp-B0h] BYREF
_QWORD *v30; // [xsp+88h] [xbp-A8h] BYREF
__int64 v31; // [xsp+90h] [xbp-A0h]
std::string::value_type __s[64]; // [xsp+98h] [xbp-98h] BYREF
if ( *(_QWORD *)(a1 + 824) )
{
v30 = nullptr;
v31 = 0;
v29 = &v30;
v5 = sub_1001D6594(a1, a2, (__int64)&v29);
if ( v31 )
v6 = 1;
else
v6 = v5;
if ( (v6 & 1) != 0 )
{
memset(&v28, 0, sizeof(v28));
memset(&v27, 0, sizeof(v27));
v7 = *(_QWORD *)(a1 + 824);
if ( v7 )
{
v8 = *(_QWORD *)(v7 + 56);
if ( v8 )
{
while ( 1 )
{
v9 = *(_QWORD *)(v8 + 264);
v8 = *(_QWORD *)(v8 + 288);
v10 = *(_DWORD *)(v9 + 76);
if ( v10 == 1 )
goto LABEL_45;
if ( v31 )
{
for ( i = v30; i; i = (_QWORD *)*i )
{
v12 = *((_DWORD *)i + 7);
if ( v10 >= v12 )
{
if ( v12 >= v10 )
goto LABEL_16;
++i;
}
}
goto LABEL_45;
}
LABEL_16:
if ( *(char *)(v9 + 103) < 0 )
{
sub_1000097D0(__p, *(void **)(v9 + 80), *(_QWORD *)(v9 + 88));
}
else
{
*(_OWORD *)__p = *(_OWORD *)(v9 + 80);
v23 = *(_QWORD *)(v9 + 96);
}
LevelTools::base64EncodeString(&v24, __p);
if ( SHIBYTE(v23) < 0 )
operator delete(__p[0]);
if ( *(_BYTE *)(v9 + 72) == 1 )
{
sprintf(__s, "%i,%i,", *(_DWORD *)(v9 + 76), *(_DWORD *)(v9 + 60));
size = HIBYTE(v28.__r_.__value_.__r.__words[2]);
if ( (v28.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = v28.__r_.__value_.__l.__size_;
if ( size )
std::string::append(&v28, ";");
std::string::append(&v28, __s);
v14 = (v26 & 0x80u) == 0 ? (const std::string::value_type *)&v24 : (const std::string::value_type *)v24;
v15 = (v26 & 0x80u) == 0 ? v26 : v25;
v16 = &v28;
}
else
{
sprintf(__s, "%i,%i,%i,", *(_DWORD *)(v9 + 76), *(_DWORD *)(v9 + 60), *(_DWORD *)(v9 + 56));
v17 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v17 = v27.__r_.__value_.__l.__size_;
if ( v17 )
std::string::append(&v27, ";");
std::string::append(&v27, __s);
v14 = (v26 & 0x80u) == 0 ? (const std::string::value_type *)&v24 : (const std::string::value_type *)v24;
v15 = (v26 & 0x80u) == 0 ? v26 : v25;
v16 = &v27;
}
std::string::append(v16, v14, v15);
if ( (char)v26 < 0 )
{
operator delete(v24);
if ( !v8 )
break;
}
else
{
LABEL_45:
if ( !v8 )
break;
}
}
}
}
sprintf(__s, "1|%i|", *(_DWORD *)(a1 + 832));
sub_100009900(a3, __s);
if ( (v28.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = &v28;
else
v18 = (std::string *)v28.__r_.__value_.__r.__words[0];
if ( (v28.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v19 = HIBYTE(v28.__r_.__value_.__r.__words[2]);
else
v19 = v28.__r_.__value_.__l.__size_;
std::string::append(a3, (const std::string::value_type *)v18, v19);
std::string::append(a3, "|");
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v20 = &v27;
else
v20 = (std::string *)v27.__r_.__value_.__r.__words[0];
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v21 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
else
v21 = v27.__r_.__value_.__l.__size_;
std::string::append(a3, (const std::string::value_type *)v20, v21);
if ( SHIBYTE(v27.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v27.__r_.__value_.__l.__data_);
if ( SHIBYTE(v28.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v28.__r_.__value_.__l.__data_);
}
else
{
sub_100009900(a3, "");
}
sub_1000187C4((__int64)&v29, v30);
}
else
{
sub_100009900(a3, "");
}
}