//
// FMODAudioEngine::preloadEffect from 0x5b4a0c to 0x5b4d54 (840 bytes)
//
// 6 xrefs:
// > FMODAudioEngine::setup @ 0x5b4f4c
// > FMODAudioEngine::playEffectAdvanced @ 0x5b7824
// > GJBaseGameLayer::processSFXObjects @ 0x880fb0
// > SetupSFXPopup::onClose @ 0xa3dbd0
// > SetupSFXPopup::createSFXWidget @ 0xa3ff2c
// > ??> @ 0xc2ee0
//
// 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
//
char *__fastcall FMODAudioEngine::preloadEffect(__int64 a1, const void **a2)
{
char **v2; // x19
cocos2d::CCFileUtils *v5; // x0
void *v6; // x0
const char *v7; // x1
FMOD::System *v8; // x0
FMOD::Sound *v9; // x19
char *v10; // x19
char *v11; // x0
char *v12; // x0
cocos2d::CCString *v14; // x0
size_t v15; // x0
unsigned int *v16; // x21
int v17; // w1
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x1
int v21; // w2
const char *CString; // [xsp+58h] [xbp+58h]
FMOD::Sound *v23; // [xsp+70h] [xbp+70h] BYREF
const char *v24; // [xsp+78h] [xbp+78h] BYREF
_DWORD *v25; // [xsp+80h] [xbp+80h] BYREF
FMOD_CREATESOUNDEXINFO v26; // [xsp+88h] [xbp+88h] BYREF
v2 = (char **)(a1 + 376);
if ( std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::count(
(_QWORD *)(a1 + 376),
a2) )
{
return std::__detail::_Map_base,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits,true>::operator[](
v2,
a2);
}
v23 = nullptr;
v5 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(FMOD_CREATESOUNDEXINFO *__return_ptr, cocos2d::CCFileUtils *, const void *, _QWORD))v5->createCCArrayWithContentsOfFile)(
&v26,
v5,
*a2,
0);
sub_D153B8((int)&v24, *(char **)&v26.cbsize);
v6 = (void *)(*(_QWORD *)&v26.cbsize - 24LL);
if ( (__int64 *)(*(_QWORD *)&v26.cbsize - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(*(_QWORD *)&v26.cbsize - 8LL);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(*(_QWORD *)&v26.cbsize - 8LL);
*(_DWORD *)(*(_QWORD *)&v26.cbsize - 8LL) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v6);
}
v7 = v24;
if ( *((_QWORD *)v24 - 3) )
{
if ( (*((_DWORD *)v24 - 2) & 0x80000000) == 0 )
{
sub_D176A8(&v24);
v7 = v24;
}
if ( *v7 != 47 )
{
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"file:///android_asset/%s",
(const char *)*a2);
CString = cocos2d::CCString::getCString(v14);
v15 = strlen(CString);
sub_D1798C(&v24, CString, v15);
v7 = v24;
}
}
v8 = *(FMOD::System **)(a1 + 536);
memset(&v26.fileoffset, 0, 104);
*(_QWORD *)&v26.suggestedsoundtype = 10;
memset(&v26.fileuseropen, 0, 104);
*(_QWORD *)&v26.cbsize = 224;
*(_DWORD *)(a1 + 576) = FMOD::System::createSound(v8, v7, 0x800000Au, &v26, &v23);
ERRCHECK_fn();
v9 = v23;
if ( v23 )
{
sub_D18D28(&v25, a2);
v10 = FMODAudioEngine::storeEffect(a1, v9, (const void **)&v25);
v11 = (char *)(v25 - 6);
if ( v25 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = v25 - 2;
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(v25 - 2);
*(v25 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v11);
}
}
else
{
v10 = nullptr;
}
v12 = (char *)(v24 - 24);
if ( v24 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v24 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v24 - 2);
*((_DWORD *)v24 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v12);
}
return v10;
}