//
// FMODAudioEngine::setupAudioEngine from 0x6ca600 to 0x6ca920 (800 bytes)
//
// 2 xrefs:
// > FMODAudioEngine::setup @ 0x6d2368
// > ??> @ 0x81e08
//
// 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 12:51:22 +0000
//
__int64 __fastcall FMODAudioEngine::setupAudioEngine(FMODAudioEngine *this)
{
FMOD::System *v2; // x0
FMOD::System *v3; // x0
GameManager *StreamBufferSize; // x0
GameManager *v5; // x0
GameManager *SoftwareFormat; // x0
GameManager *v7; // x0
char GameVariable; // w5
int v9; // w4
unsigned int v11; // [xsp+34h] [xbp+34h] BYREF
unsigned int v12; // [xsp+38h] [xbp+38h] BYREF
unsigned int v13; // [xsp+3Ch] [xbp+3Ch] BYREF
unsigned int v14; // [xsp+40h] [xbp+40h] BYREF
int v15[3]; // [xsp+44h] [xbp+44h] BYREF
FMOD::DSP *v16; // [xsp+58h] [xbp+58h]
FMOD::DSP *v17; // [xsp+60h] [xbp+60h]
*((_DWORD *)this + 134) = FMOD_System_Create();
ERRCHECK_fn();
v2 = *((FMOD::System **)this + 61);
v11 = 0;
FMOD::System::getVersion(v2, &v11);
FMOD_Debug_Initialize();
v12 = 0;
v3 = *((FMOD::System **)this + 61);
v13 = 1;
StreamBufferSize = (GameManager *)FMOD::System::getStreamBufferSize(v3, &v12, &v13);
v5 = (GameManager *)GameManager::sharedState(StreamBufferSize);
if ( !(unsigned __int8)GameManager::getGameVariable(v5, "0159") )
FMOD::System::setDSPBufferSize(*((FMOD::System **)this + 61), 0x200u, 4);
FMOD::System::getDSPBufferSize(*((FMOD::System **)this + 61), &v14, v15);
FMOD::System::getSoftwareFormat();
SoftwareFormat = (GameManager *)FMOD::System::getSoftwareFormat();
v7 = (GameManager *)GameManager::sharedState(SoftwareFormat);
GameVariable = GameManager::getGameVariable(v7, "0142");
if ( GameVariable )
v9 = 24000;
else
v9 = 44100;
*((_BYTE *)this + 544) = GameVariable;
v15[2] = v9;
FMOD::System::setSoftwareFormat();
*((_DWORD *)this + 134) = FMOD::System::init(*((FMOD::System **)this + 61), 128, 0, nullptr);
ERRCHECK_fn();
*((_DWORD *)this + 134) = FMOD::System::getSoftwareFormat();
ERRCHECK_fn();
FMOD::System::createChannelGroup(*((FMOD::System **)this + 61), nullptr, (FMOD::ChannelGroup **)this + 60);
FMOD::ChannelControl::setVolumeRamp(*((FMOD::ChannelControl **)this + 60), 0);
FMOD::ChannelControl::getDSP(*((FMOD::ChannelControl **)this + 60), -1, (FMOD::DSP **)this + 62);
FMOD::DSP::setMeteringEnabled(*((FMOD::DSP **)this + 62), 0, 1);
FMOD::System::createChannelGroup(*((FMOD::System **)this + 61), nullptr, (FMOD::ChannelGroup **)this + 64);
FMOD::System::createChannelGroup(*((FMOD::System **)this + 61), nullptr, (FMOD::ChannelGroup **)this + 65);
FMOD::ChannelGroup::addGroup();
FMOD::System::createChannelGroup(*((FMOD::System **)this + 61), nullptr, (FMOD::ChannelGroup **)this + 66);
v16 = nullptr;
FMOD::System::createDSPByType();
FMOD::DSP::setParameterFloat(v16, 1, 0.0);
FMOD::DSP::setParameterBool(v16, 3, 1);
*((_DWORD *)this + 134) = FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 64), 1, v16);
ERRCHECK_fn();
FMOD::System::createDSPByType();
FMOD::DSP::setParameterFloat(v16, 1, 0.0);
FMOD::DSP::setParameterBool(v16, 3, 1);
*((_DWORD *)this + 134) = FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 60), 1, v16);
ERRCHECK_fn();
v17 = nullptr;
FMOD::System::createDSPByType();
FMOD::ChannelControl::addDSP(*((FMOD::ChannelControl **)this + 65), 0, v17);
FMODAudioEngine::updateReverb((__int64)this, *((_DWORD *)this + 334), 1);
FMOD::ChannelControl::getDSP(*((FMOD::ChannelControl **)this + 64), -1, (FMOD::DSP **)this + 63);
FMOD::DSP::setMeteringEnabled(*((FMOD::DSP **)this + 63), 0, 1);
return _stack_chk_guard;
}