//
// GameManager::playSFXTrigger from 0x5e8e0c to 0x5e92d0 (1220 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::activateSFXTrigger @ 0x88d08c
// > SetupReverbPopup::onPlay @ 0xa3da24
// > SetupSFXPopup::overridePlaySFX @ 0xa3da58
// > ??> @ 0x973f8
//
// 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
//
int GameManager::playSFXTrigger(GameManager *a1, SFXTriggerGameObject *a2)
{
std::string *p_m_soundPath; // x22
float v4; // s0
float m_volume; // s10
float v6; // s9
float v7; // s8
float m_speed; // s9
int v9; // w0
float m_pitchIndex; // s8
int v11; // w0
float m_volumeVariance; // s11
float v13; // s11
FMODAudioEngine *v14; // x27
unsigned __int8 m_fastFourierTransform; // w26
int m_start; // w25
int m_end; // w24
int m_fadeOut; // w22
int UniqueSFXID; // w28
int SFXRefID; // w0
int v21; // w21
char *v22; // x22
MusicDownloadManager *v24; // x0
char *v25; // x0
unsigned int *v26; // x1
int v27; // w2
float v28; // s9
float v29; // s0
float v30; // s8
float v31; // s0
float v32; // s11
unsigned int *v33; // x19
int v34; // w0
float v35; // s11
char v36; // [xsp+E0h] [xbp+A0h]
unsigned __int8 m_override; // [xsp+E4h] [xbp+A4h]
unsigned __int8 m_loop; // [xsp+E8h] [xbp+A8h]
int m_fadeIn; // [xsp+ECh] [xbp+ACh]
char m_reverb; // [xsp+F0h] [xbp+B0h]
_DWORD *v41; // [xsp+110h] [xbp+D0h] BYREF
if ( !a2 )
return 0;
p_m_soundPath = &a2->m_soundPath;
if ( !*((_QWORD *)a2->m_soundPath.m_data.m_data - 3) )
{
v24 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((__int64 *)&v41, v24, a2->m_soundID);
sub_D163D4(p_m_soundPath, &v41);
v25 = (char *)(v41 - 6);
if ( v41 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = v41 - 2;
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(v41 - 2);
*(v41 - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v25);
}
}
FMODAudioEngine::sharedEngine();
v4 = FMODAudioEngine::pitchForIdx(a2->m_speed);
m_volume = a2->m_volume;
v6 = v4;
FMODAudioEngine::sharedEngine();
v7 = FMODAudioEngine::pitchForIdx(a2->m_pitchIndex);
if ( a2->m_speedVariance > 0 )
{
if ( a2->m_pitchSteps )
{
FMODAudioEngine::sharedEngine();
m_speed = (float)a2->m_speed;
v9 = rand();
v6 = FMODAudioEngine::pitchForIdx((int)(float)(m_speed
+ roundf(
(float)((float)((float)((float)v9 * 4.6566e-10) * 2.0) + -1.0)
* (float)a2->m_speedVariance)));
}
else
{
FMODAudioEngine::sharedEngine();
v28 = FMODAudioEngine::pitchForIdx(a2->m_speed - a2->m_speedVariance);
FMODAudioEngine::sharedEngine();
v29 = FMODAudioEngine::pitchForIdx(a2->m_speed + a2->m_speedVariance);
v6 = v28 + (float)((float)((float)rand() * 4.6566e-10) * (float)(v29 - v28));
}
}
if ( a2->m_pitchVariance > 0 )
{
if ( a2->m_pitchSteps )
{
FMODAudioEngine::sharedEngine();
m_pitchIndex = (float)a2->m_pitchIndex;
v11 = rand();
v7 = FMODAudioEngine::pitchForIdx((int)(float)(m_pitchIndex
+ roundf(
(float)((float)((float)((float)v11 * 4.6566e-10) * 2.0) + -1.0)
* (float)a2->m_pitchVariance)));
}
else
{
FMODAudioEngine::sharedEngine();
v30 = FMODAudioEngine::pitchForIdx(a2->m_pitchIndex - a2->m_pitchVariance);
FMODAudioEngine::sharedEngine();
v31 = FMODAudioEngine::pitchForIdx(a2->m_pitchIndex + a2->m_pitchVariance);
v7 = v30 + (float)((float)((float)rand() * 4.6566e-10) * (float)(v31 - v30));
}
}
m_volumeVariance = a2->m_volumeVariance;
if ( m_volumeVariance > 0.0 )
{
if ( (float)(m_volume
+ (float)(m_volumeVariance * (float)((float)((float)((float)rand() * 4.6566e-10) * 2.0) + -1.0))) >= 2.0
|| (v32 = a2->m_volumeVariance,
(float)(m_volume + (float)(v32 * (float)((float)((float)((float)rand() * 4.6566e-10) * 2.0) + -1.0))) > 0.0) )
{
v13 = a2->m_volumeVariance;
if ( (float)(m_volume + (float)(v13 * (float)((float)((float)((float)rand() * 4.6566e-10) * 2.0) + -1.0))) < 2.0 )
{
v35 = a2->m_volumeVariance;
m_volume = m_volume + (float)(v35 * (float)((float)((float)((float)rand() * 4.6566e-10) * 2.0) + -1.0));
}
else
{
m_volume = 2.0;
}
}
else
{
m_volume = 0.0;
}
}
v14 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v41, p_m_soundPath);
m_fastFourierTransform = a2->m_fastFourierTransform;
m_reverb = a2->m_reverb;
m_start = a2->m_start;
m_end = a2->m_end;
m_fadeIn = a2->m_fadeIn;
m_fadeOut = a2->m_fadeOut;
m_loop = a2->m_loop;
UniqueSFXID = SFXTriggerGameObject::getUniqueSFXID(a2);
m_override = a2->m_override;
v36 = !a2->m_preload;
SFXRefID = SFXTriggerGameObject::getSFXRefID(a2);
v21 = FMODAudioEngine::playEffectAdvanced(
(__int64)v14,
(const void **)&v41,
m_fastFourierTransform,
m_reverb,
m_start,
m_end,
m_fadeIn,
m_fadeOut,
v6,
0.0,
m_volume,
v7,
a2->m_minInterval,
m_loop,
UniqueSFXID,
m_override,
v36,
0,
SFXRefID,
a2->m_sfxGroup);
v22 = (char *)(v41 - 6);
if ( v41 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = v41 - 2;
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(v41 - 2);
*(v41 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v22);
}
return v21;
}