//
// PlayLayer::prepareMusic from 0x5d29f8 to 0x5d2b90 (408 bytes)
//
// 3 xrefs:
// > PlayLayer::setupHasCompleted @ 0x5dcba0
// > PlayLayer::startMusic @ 0x5e45ac
// > ??> @ 0xa34d0
//
// 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 PlayLayer::prepareMusic(PlayLayer *a1, bool a2)
{
float *v2; // x20
FMODAudioEngine *v5; // x23
void *v6; // x0
LevelSettingsObject *m_levelSettings; // x0
double m_levelTime; // d9
float m_songOffset; // s8
FMODAudioEngine *v10; // x0
float v11; // s0
unsigned int *v12; // x2
int v13; // w1
__int64 v14; // [xsp+70h] [xbp+70h] BYREF
v2 = &a1->m_varianceValues.__elems_[1975];
if ( (!a1->m_isPracticeMode || a1->m_practiceMusicSync) && !a1->m_playerDied )
{
v5 = FMODAudioEngine::sharedEngine();
GJGameLevel::getAudioFileName(&v14, a1->m_level);
FMODAudioEngine::loadMusic(
(__int64)v5,
&v14,
*((_BYTE *)v2 + 270),
0,
0,
a1->m_levelSettings->m_dontReset,
1.0,
0.0,
1.0);
v6 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v14 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v6);
}
m_levelSettings = a1->m_levelSettings;
m_levelTime = a1->m_gameState.m_levelTime;
m_songOffset = m_levelSettings->m_songOffset;
if ( !m_levelSettings->m_dontReset )
{
v10 = FMODAudioEngine::sharedEngine();
v11 = (m_songOffset + m_levelTime) * 1000.0;
FMODAudioEngine::setMusicTimeMS(v10, (unsigned int)v11, a2, 0);
}
*((_BYTE *)v2 + 2632) = 1;
}
}