//
// FMODAudioEngine::stopAndGetFade from 0x1003e5f00 to 0x1003e604d (333 bytes)
//
// 6 xrefs:
// > FMODAudioEngine::stopChannel @ 0x1003e5c0a
// > FMODAudioEngine::stopChannel_1 @ 0x1003e5dd4
// > FMODAudioEngine::playMusic @ 0x1003e6fb6
// > FMODAudioEngine::fadeInMusic @ 0x1003e70ea
// > FMODAudioEngine::fadeOutMusic @ 0x1003e9f1a
// > FMODAudioEngine::fadeMusic @ 0x1003ea004
//
// 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
//
float __fastcall FMODAudioEngine::stopAndGetFade(FMODAudioEngine *a1, FMOD::Channel *a2)
{
float result; // xmm0_4
float v3; // xmm0_4
unsigned __int64 v4; // rcx
float v5; // xmm0_4
unsigned __int64 v6; // rcx
float v7; // xmm1_4
float v8; // xmm1_4
unsigned __int64 v9; // [rsp+0h] [rbp-50h] BYREF
int v10; // [rsp+Ch] [rbp-44h] BYREF
__int64 v11; // [rsp+10h] [rbp-40h] BYREF
__int64 v12; // [rsp+18h] [rbp-38h]
float v13[2]; // [rsp+28h] [rbp-28h] BYREF
result = 1.0;
if ( a2 )
{
v10 = 0;
a1->m_lastResult = FMOD_Channel_GetFadePoints(a2, &v10, 0, 0);
if ( !v10 )
return 1.0;
FMOD_Channel_GetDSPClock(a2, 0, &v9, 1.0);
a1->m_lastResult = FMOD::ChannelControl::getDSPClock(a2, nullptr, &v9);
a1->m_lastResult = FMOD_Channel_GetFadePoints(a2, &v10, &v11, v13);
FMOD_Channel_RemoveFadePoints(a2, v11, v12);
v3 = v13[1] - v13[0];
v4 = v12 - v11;
if ( v12 - v11 < 0 )
{
v8 = (float)(int)((v4 >> 1) | v4 & 1);
v5 = v3 / (float)(v8 + v8);
v6 = v9 - v11;
if ( (__int64)(v9 - v11) < 0 )
goto LABEL_5;
}
else
{
v5 = v3 / (float)(int)v4;
v6 = v9 - v11;
if ( (__int64)(v9 - v11) < 0 )
{
LABEL_5:
v7 = (float)(int)((v6 >> 1) | v6 & 1) + (float)(int)((v6 >> 1) | v6 & 1);
return (float)(v5 * v7) + v13[0];
}
}
v7 = (float)(int)v6;
return (float)(v5 * v7) + v13[0];
}
return result;
}