//
// GameManager::playSFXTrigger from 0x100312494 to 0x1003127f8 (868 bytes)
//
// 3 xrefs:
// > SetupReverbPopup::onPlay @ 0x10017f9d8
// > SetupSFXPopup::overridePlaySFX @ 0x100180ec0
// > GJBaseGameLayer::activateSFXTrigger @ 0x100203094
//
// 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 __fastcall GameManager::playSFXTrigger(GameManager *a1, SFXTriggerGameObject *a2)
{
SFXTriggerGameObject *v2; // x19
std::size_t size; // x8
void **p_m_soundPath; // x21
float v5; // s8
float m_volume; // s11
float v7; // s9
_BOOL4 m_pitchSteps; // w20
int m_speed; // w8
float v10; // s8
unsigned int v11; // w0
float v12; // s8
float v13; // s10
_BOOL4 v14; // w20
int m_pitchIndex; // w8
float v16; // s9
unsigned int v17; // w0
float v18; // s9
float v19; // s10
float m_volumeVariance; // s10
float v21; // s10
unsigned int m_reverb; // w22
__int64 m_start; // x23
__int64 m_end; // x24
__int64 m_fadeIn; // x25
__int64 m_fadeOut; // x26
unsigned __int8 m_loop; // w28
int UniqueSFXID; // w27
unsigned __int8 m_override; // w20
bool m_preload; // w21
int SFXRefID; // w0
unsigned int m_fastFourierTransform; // [xsp+24h] [xbp-BCh]
FMODAudioEngine *v34; // [xsp+28h] [xbp-B8h]
void *__p[2]; // [xsp+30h] [xbp-B0h] BYREF
char *longStorage; // [xsp+40h] [xbp-A0h]
std::string v37; // [xsp+48h] [xbp-98h] BYREF
v2 = a2;
if ( a2 )
{
size = a2->m_soundPath.m_data.m_short.shortStorage.__elems_[22];
if ( (size & 0x8000000000000000LL) != 0 )
size = a2->m_soundPath.m_data.m_long.size;
p_m_soundPath = (void **)&a2->m_soundPath;
if ( !size )
{
MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((unsigned int)v2->m_soundID, &v37);
if ( v2->m_soundPath.m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete(*p_m_soundPath);
*(_OWORD *)p_m_soundPath = *(_OWORD *)&v37.__r_.__value_.__l.__data_;
v2->m_soundPath.m_data.m_long.longStorage = (char *)v37.__r_.__value_.__r.__words[2];
}
FMODAudioEngine::sharedEngine();
v5 = FMODAudioEngine::pitchForIdx(v2->m_speed);
m_volume = v2->m_volume;
FMODAudioEngine::sharedEngine();
v7 = FMODAudioEngine::pitchForIdx(v2->m_pitchIndex);
if ( v2->m_speedVariance >= 1 )
{
m_pitchSteps = v2->m_pitchSteps;
FMODAudioEngine::sharedEngine();
m_speed = v2->m_speed;
if ( m_pitchSteps )
{
v10 = (float)m_speed;
v11 = rand();
v5 = FMODAudioEngine::pitchForIdx((int)(float)(roundf(
(float)((float)(vcvts_n_f32_s32(v11, 0x1Fu) * 2.0) + -1.0)
* (float)v2->m_speedVariance)
+ v10));
}
else
{
v12 = FMODAudioEngine::pitchForIdx(m_speed - v2->m_speedVariance);
FMODAudioEngine::sharedEngine();
v13 = FMODAudioEngine::pitchForIdx(v2->m_speedVariance + v2->m_speed);
v5 = v12 + (float)(vcvts_n_f32_s32(rand(), 0x1Fu) * (float)(v13 - v12));
}
}
if ( v2->m_pitchVariance >= 1 )
{
v14 = v2->m_pitchSteps;
FMODAudioEngine::sharedEngine();
m_pitchIndex = v2->m_pitchIndex;
if ( v14 )
{
v16 = (float)m_pitchIndex;
v17 = rand();
v7 = FMODAudioEngine::pitchForIdx((int)(float)(roundf(
(float)((float)(vcvts_n_f32_s32(v17, 0x1Fu) * 2.0) + -1.0)
* (float)v2->m_pitchVariance)
+ v16));
}
else
{
v18 = FMODAudioEngine::pitchForIdx(m_pitchIndex - v2->m_pitchVariance);
FMODAudioEngine::sharedEngine();
v19 = FMODAudioEngine::pitchForIdx(v2->m_pitchVariance + v2->m_pitchIndex);
v7 = v18 + (float)(vcvts_n_f32_s32(rand(), 0x1Fu) * (float)(v19 - v18));
}
}
m_volumeVariance = v2->m_volumeVariance;
if ( m_volumeVariance <= 0.0 )
{
v21 = m_volume;
}
else if ( (float)(m_volume
+ (float)(m_volumeVariance * (float)((float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 2.0) + -1.0))) >= 2.0
|| (v21 = 0.0,
(float)(m_volume
+ (float)(v2->m_volumeVariance * (float)((float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 2.0) + -1.0))) > 0.0) )
{
v21 = 2.0;
if ( (float)(m_volume
+ (float)(v2->m_volumeVariance * (float)((float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 2.0) + -1.0))) < 2.0 )
v21 = m_volume + (float)(v2->m_volumeVariance * (float)((float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 2.0) + -1.0));
}
v34 = FMODAudioEngine::sharedEngine();
if ( v2->m_soundPath.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__p, (void *)v2->m_soundPath.m_data.m_long.capacitym1, v2->m_soundPath.m_data.m_long.size);
}
else
{
*(_OWORD *)__p = *(_OWORD *)p_m_soundPath;
longStorage = v2->m_soundPath.m_data.m_long.longStorage;
}
m_fastFourierTransform = v2->m_fastFourierTransform;
m_reverb = v2->m_reverb;
m_start = (unsigned int)v2->m_start;
m_end = (unsigned int)v2->m_end;
m_fadeIn = (unsigned int)v2->m_fadeIn;
m_fadeOut = (unsigned int)v2->m_fadeOut;
m_loop = v2->m_loop;
UniqueSFXID = SFXTriggerGameObject::getUniqueSFXID(v2);
m_override = v2->m_override;
m_preload = v2->m_preload;
SFXRefID = SFXTriggerGameObject::getSFXRefID(v2);
LODWORD(v2) = FMODAudioEngine::playEffectAdvanced(
(__int64)v34,
(__int128 *)__p,
m_fastFourierTransform,
m_reverb,
m_start,
m_end,
m_fadeIn,
m_fadeOut,
v5,
0.0,
v21,
v7,
v2->m_minInterval,
m_loop,
UniqueSFXID,
m_override,
!m_preload,
0,
SFXRefID,
v2->m_sfxGroup);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__p[0]);
}
return (int)v2;
}