//
// GJBaseGameLayer::activateSongTrigger from 0x87b914 to 0x87bb08 (500 bytes)
//
// 5 xrefs:
// > LevelEditorLayer::activateTriggerEffect @ 0x66d6b0
// > EffectGameObject::triggerObject @ 0x76f9b0
// > GJBaseGameLayer::processQueuedAudioTriggers @ 0x88d4e8
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x88d604
// > ??> @ 0x62dc0
//
// 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
//
void GJBaseGameLayer::activateSongTrigger(GJBaseGameLayer *a1, SongTriggerGameObject *a2)
{
float *v3; // x22
std::vector *p_m_activeSfxTriggers; // x19
SFXTriggerGameObject **m_finish; // x0
SFXTriggerGameObject **m_reserveEnd; // x1
int m_songChannel; // w19
int v9; // w22
FMODAudioEngine *v10; // x24
MusicDownloadManager *v11; // x0
float v12; // s0
bool *p_m_applyDisabled; // x0
unsigned int *p_m_pitchSteps; // x2
int v15; // w1
FMODAudioEngine *v16; // x0
SongTriggerGameObject *v17; // [xsp+70h] [xbp+50h] BYREF
v3 = &a1->m_varianceValues.__elems_[1975];
if ( a1->m_practiceMusicSync || !a1->m_isPracticeMode )
{
a1->activatedAudioTrigger(a1, a2);
if ( !*((_BYTE *)v3 + 1860) )
{
if ( a1->m_startingFromBeginning )
{
p_m_activeSfxTriggers = &a1->m_activeSfxTriggers;
m_finish = p_m_activeSfxTriggers->m_finish;
m_reserveEnd = p_m_activeSfxTriggers->m_reserveEnd;
v17 = a2;
if ( m_finish == m_reserveEnd )
{
std::vector::_M_emplace_back_aux(
(__int64)p_m_activeSfxTriggers,
&v17);
}
else
{
if ( m_finish )
{
*m_finish = a2;
m_finish = p_m_activeSfxTriggers->m_finish;
}
p_m_activeSfxTriggers->m_finish = m_finish + 1;
}
}
else
{
m_songChannel = a2->m_songChannel;
v9 = ~m_songChannel;
if ( a2->m_loadPrep )
{
v16 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::activateQueuedMusic(v16, v9);
}
else
{
v10 = FMODAudioEngine::sharedEngine();
v11 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSong((__int64 *)&v17, v11, a2->m_soundID);
FMODAudioEngine::sharedEngine();
v12 = FMODAudioEngine::pitchForIdx(a2->m_speed);
FMODAudioEngine::queueStartMusic(
(__int64)v10,
(__int64)&v17,
a2->m_loop,
a2->m_start,
a2->m_end,
a2->m_fadeIn,
a2->m_fadeOut,
v9,
v12,
0.0,
a2->m_volume,
1,
m_songChannel,
!a2->m_prep,
a2->m_dontReset);
p_m_applyDisabled = &v17[-1].m_applyDisabled;
if ( &v17[-1].m_applyDisabled != (bool *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_pitchSteps = (unsigned int *)&v17[-1].m_pitchSteps;
do
v15 = __ldaxr(p_m_pitchSteps);
while ( __stlxr(v15 - 1, p_m_pitchSteps) );
}
else
{
v15 = *(_DWORD *)&v17[-1].m_pitchSteps;
*(_DWORD *)&v17[-1].m_pitchSteps = v15 - 1;
}
if ( v15 <= 0 )
operator delete(p_m_applyDisabled);
}
}
}
}
}
}