//
// FMODAudioEngine::preloadMusic from 0x3ef8f0 to 0x3efa36 (326 bytes)
//
// 2 xrefs:
// > FMODAudioEngine::queueStartMusic @ 0x3efaec
// > FMODAudioEngine::loadMusic @ 0x3efbc8
//
// 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:47:12 +0000
//
FMOD::Sound *__fastcall FMODAudioEngine::preloadMusic(
FMODAudioEngine *a1,
unsigned __int8 *a2,
int a3,
unsigned int a4)
{
_BOOL4 v7; // r4
FMOD::Sound *Stream; // r4
int v10; // r3
unsigned int v11; // r3
unsigned __int8 *v12; // r11
int v13; // r5
unsigned __int8 *v14; // r10
int *v15; // r0
int v16[2]; // [sp+14h] [bp-30h] BYREF
unsigned __int8 *v17; // [sp+1Ch] [bp-28h] BYREF
int v18; // [sp+24h] [bp-20h] BYREF
FMOD::Sound *v19; // [sp+28h] [bp-1Ch]
int v20[3]; // [sp+2Ch] [bp-18h] BYREF
bool v21; // [sp+38h] [bp-Ch]
char v22; // [sp+39h] [bp-Bh]
v16[0] = a4;
FMODAudioEngine::getActiveMusic((FMODAudioEngine *)&v18, (int)a1, a4);
v7 = sub_3E77C6((unsigned __int8 *)&v18, a2);
std::string::~string((int)&v18);
if ( v7 )
return (FMOD::Sound *)std::unordered_map::operator[]((int)a1 + 264, (unsigned int *)v16)[1];
FMODAudioEngine::stopAndRemoveMusic(a1, v16[0]);
std::string::basic_string(&v18, (int)a2);
Stream = FMODAudioEngine::createStream(a1, (unsigned __int8 *)&v18);
std::string::~string((int)&v18);
if ( Stream )
{
if ( !a3 && FMODAudioEngine::waitUntilSoundReady(a1, Stream) == 2 )
{
FMOD::Sound::release(Stream);
return nullptr;
}
v18 = 0;
v19 = nullptr;
memset(v20, 0, sizeof(v20));
std::string::__init(v20, &unk_B6B226, 0);
v21 = 0;
v22 = 0;
v18 = 0;
std::string::operator=((unsigned __int8 *)v20, a2);
v10 = *a2;
v19 = Stream;
if ( (v10 & 1) != 0 )
{
v11 = *((_DWORD *)a2 + 1);
v12 = *((unsigned __int8 **)a2 + 2);
}
else
{
v11 = v10 >> 1;
v12 = a2 + 1;
}
if ( v11 <= 3
|| (v14 = &v12[v11],
std::__search(
&v17,
v12,
&v12[v11],
".ogg",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v17 == v14) )
{
v13 = -1;
}
else
{
v13 = v17 - v12;
}
v21 = v13 != -1;
v15 = std::unordered_map::operator[]((int)a1 + 264, (unsigned int *)v16);
FMODMusic::operator=((unsigned __int8 *)v15, &v18);
std::string::~string((int)v20);
}
return Stream;
}