//
// GJBaseGameLayer::processSFXState from 0x47883c to 0x478bce (914 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::canProcessSFX @ 0x48b218
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x48b658
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x48b6c8
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x48b7a0
//
// 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::processSFXState(
GJBaseGameLayer *a1,
SFXTriggerState *a2,
SFXTriggerState *a3,
int a4,
float m_unkDouble1)
{
SFXTriggerState *v7; // r0
SFXTriggerGameObject *m_sfxTriggerGameObject; // r1
double v9; // d4
double m_unkDouble3; // d6
float m_unkFloat1; // s2
float m_unkFloat2; // s1
float v13; // s14
_BOOL4 m_unkBool; // r6
float v15; // s10
double v16; // d10
double v17; // d9
float v18; // s4
float v19; // s10
double v20; // d10
double m_unkDouble2; // d9
float v22; // s4
float v23; // s10
double v24; // d7
double v25; // d5
float v26; // s12
std::array *p_m_sfxStateContainers; // r1
float v28; // lr
double m_duration; // r6
double v30; // d6
double v31; // d7
float v32; // s12
_BOOL4 v33; // r1
double v34; // d3
float v35; // s14
float v36; // s15
float v37; // s8
double v38; // d6
double v39; // d4
bool v40; // r3
double v41; // d7
float v42; // s10
float m_unkFloat4; // s18
double v44; // d8
if ( a2->m_processed )
return;
v7 = a3;
if ( a3 )
v7 = (SFXTriggerState *)(&dword_0 + 1);
if ( v7 )
{
m_sfxTriggerGameObject = a3->m_sfxTriggerGameObject;
if ( a3->m_sfxTriggerGameObject->m_stop )
{
LABEL_6:
a2->m_processed = 1;
return;
}
m_unkDouble1 = a3->m_unkDouble1;
if ( !m_sfxTriggerGameObject->m_changeVolume && !m_sfxTriggerGameObject->m_stopLoop )
{
LABEL_70:
if ( a4 )
goto LABEL_62;
LABEL_44:
if ( a3->m_sfxTriggerGameObject->m_changeSpeed )
goto LABEL_47;
goto LABEL_45;
}
}
v9 = m_unkDouble1;
while ( 1 )
{
m_unkDouble3 = a2->m_unkDouble3;
if ( m_unkDouble3 >= v9 )
break;
m_unkFloat1 = a2->m_unkFloat1;
m_unkFloat2 = a2->m_unkFloat2;
if ( a2->m_sfxStateContainers.__elems_[0].m_unkBool )
{
v13 = a2->m_sfxStateContainers.__elems_[0].m_unkDouble1 + a2->m_sfxStateContainers.__elems_[0].m_unkDouble2;
if ( v13 >= m_unkDouble1 )
v13 = m_unkDouble1;
}
else
{
v13 = m_unkDouble1;
}
m_unkBool = a2->m_sfxStateContainers.__elems_[1].m_unkBool;
if ( a2->m_sfxStateContainers.__elems_[1].m_unkBool )
{
v15 = a2->m_sfxStateContainers.__elems_[1].m_unkDouble1 + a2->m_sfxStateContainers.__elems_[1].m_unkDouble2;
if ( v15 < v13 )
v13 = a2->m_sfxStateContainers.__elems_[1].m_unkDouble1 + a2->m_sfxStateContainers.__elems_[1].m_unkDouble2;
if ( !a2->m_sfxStateContainers.__elems_[0].m_unkBool )
{
LABEL_27:
v20 = a2->m_sfxStateContainers.__elems_[1].m_unkDouble1;
m_unkDouble2 = a2->m_sfxStateContainers.__elems_[1].m_unkDouble2;
v22 = a2->m_sfxStateContainers.__elems_[1].m_unkFloat1;
if ( v20 + m_unkDouble2 > v13 )
{
v23 = v13 - v20;
v22 = m_unkFloat2 + (float)(v22 - m_unkFloat2) * (v23 / m_unkDouble2);
}
else
{
a2->m_sfxStateContainers.__elems_[1].m_unkBool = 0;
}
a2->m_unkFloat2 = v22;
m_unkFloat2 = (float)(m_unkFloat2 + v22) * 0.5;
goto LABEL_31;
}
}
else if ( !a2->m_sfxStateContainers.__elems_[0].m_unkBool )
{
goto LABEL_31;
}
v16 = a2->m_sfxStateContainers.__elems_[0].m_unkDouble1;
v17 = a2->m_sfxStateContainers.__elems_[0].m_unkDouble2;
v18 = a2->m_sfxStateContainers.__elems_[0].m_unkFloat1;
if ( v16 + v17 > v13 )
{
v19 = v13 - v16;
v18 = m_unkFloat1 + (float)(v18 - m_unkFloat1) * (v19 / v17);
}
else
{
a2->m_sfxStateContainers.__elems_[0].m_unkBool = 0;
}
a2->m_unkFloat1 = v18;
m_unkFloat1 = (float)(m_unkFloat1 + v18) * 0.5;
if ( m_unkBool )
goto LABEL_27;
LABEL_31:
v24 = v13;
v25 = a2->m_unkDouble2;
a2->m_unkDouble3 = v24;
v26 = v24 - m_unkDouble3;
a2->m_unkDouble2 = v25 + (float)((float)((float)(v26 * m_unkFloat1) * m_unkFloat2) * 1000.0);
}
if ( a4 )
p_m_sfxStateContainers = (std::array *)&a2->m_sfxStateContainers.__elems_[1];
else
p_m_sfxStateContainers = &a2->m_sfxStateContainers;
if ( v7 && a3->m_sfxTriggerGameObject->m_changeVolume )
{
v28 = a3->m_unkFloat1;
m_duration = a3->m_sfxTriggerGameObject->m_duration;
LODWORD(p_m_sfxStateContainers->__elems_[0].m_unkDouble1) = LODWORD(v9);
p_m_sfxStateContainers->__elems_[0].m_unkDouble2 = m_duration;
HIDWORD(p_m_sfxStateContainers->__elems_[0].m_unkDouble1) = HIDWORD(v9);
p_m_sfxStateContainers->__elems_[0].m_unkFloat1 = v28;
p_m_sfxStateContainers->__elems_[0].m_unkFloat2 = 0.0;
p_m_sfxStateContainers->__elems_[0].m_unkBool = 1;
goto LABEL_70;
}
if ( p_m_sfxStateContainers->__elems_[0].m_unkBool )
{
v30 = p_m_sfxStateContainers->__elems_[0].m_unkDouble1;
v31 = p_m_sfxStateContainers->__elems_[0].m_unkDouble2;
if ( p_m_sfxStateContainers->__elems_[0].m_unkDouble1 + v31 >= v9 )
{
p_m_sfxStateContainers->__elems_[0].m_unkDouble1 = v9;
v32 = v9 - v30;
p_m_sfxStateContainers->__elems_[0].m_unkDouble2 = v31 - v32;
}
else
{
p_m_sfxStateContainers->__elems_[0].m_unkBool = 0;
}
}
if ( a4 )
goto LABEL_62;
if ( v7 )
goto LABEL_44;
LABEL_47:
v33 = a2->m_sfxStateContainers.__elems_[2].m_unkBool;
v34 = m_unkDouble1;
if ( !a2->m_sfxStateContainers.__elems_[2].m_unkBool )
{
if ( !v7 )
goto LABEL_61;
goto LABEL_55;
}
v35 = a2->m_sfxStateContainers.__elems_[2].m_unkDouble2;
v36 = a2->m_sfxStateContainers.__elems_[2].m_unkFloat1;
if ( v35 > 0.0 )
{
v37 = v34 - a2->m_sfxStateContainers.__elems_[2].m_unkDouble1;
if ( v35 > v37 )
v36 = a2->m_unkFloat3 + (float)((float)(v36 - a2->m_unkFloat3) * (float)(v37 / v35));
}
a2->m_unkFloat3 = v36;
if ( v7 )
{
LABEL_55:
if ( a3->m_sfxTriggerGameObject->m_changeSpeed )
{
v41 = a3->m_sfxTriggerGameObject->m_duration;
a2->m_sfxStateContainers.__elems_[2].m_unkFloat1 = a3->m_unkFloat3;
a2->m_sfxStateContainers.__elems_[2].m_unkFloat2 = 0.0;
v40 = 1;
LODWORD(a2->m_sfxStateContainers.__elems_[2].m_unkDouble1) = LODWORD(v34);
a2->m_sfxStateContainers.__elems_[2].m_unkDouble2 = v41;
HIDWORD(a2->m_sfxStateContainers.__elems_[2].m_unkDouble1) = HIDWORD(v34);
LABEL_59:
a2->m_sfxStateContainers.__elems_[2].m_unkBool = v40;
}
else if ( v33 )
{
goto LABEL_52;
}
goto LABEL_61;
}
LABEL_52:
v38 = a2->m_sfxStateContainers.__elems_[2].m_unkDouble1;
v39 = a2->m_sfxStateContainers.__elems_[2].m_unkDouble2;
if ( v38 + v39 < v34 )
{
v40 = 0;
goto LABEL_59;
}
a2->m_sfxStateContainers.__elems_[2].m_unkDouble1 = v34;
v42 = v34 - v38;
a2->m_sfxStateContainers.__elems_[2].m_unkDouble2 = v39 - v42;
LABEL_61:
a2->m_unkDouble4 = v34;
LABEL_62:
if ( v7 )
{
LABEL_45:
if ( a3->m_sfxTriggerGameObject->m_stopLoop && a2->m_unkBool1 )
{
m_unkFloat4 = a2->m_unkFloat4;
a2->m_unkBool1 = 0;
v44 = a2->m_unkDouble2;
a2->m_unkDouble2 = v44 - (float)((float)(int)floor(v44 / m_unkFloat4) * m_unkFloat4);
}
}
if ( a2->m_sfxTriggerGameObject->m_objectID == 3602 && !a2->m_unkBool1 && a2->m_unkDouble2 > a2->m_unkFloat4 )
goto LABEL_6;
}