//
// GJBaseGameLayer::canProcessSFX from 0x1402431a0 to 0x1402437f4 (1620 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x1402441f7
// > ??> @ 0x1406820fc
// > ??> @ 0x140682164
// > ??> @ 0x1406ce508
//
// 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
//
bool GJBaseGameLayer::canProcessSFX(
GJBaseGameLayer *a1,
SFXTriggerState *a2,
std::unordered_map *a3,
std::unordered_map *a4,
std::vector *a5)
{
SFXTriggerGameObject *m_sfxTriggerGameObject; // rax
int v9; // ebx
int m_sfxUniqueID; // edx
char v11; // si
std::_Vector_val>>>>>::pointer Myfirst; // rcx
__int64 v13; // rax
__int64 v14; // rcx
std::_Vector_val>>>>>::pointer v15; // rcx
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr Ptr; // rax
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr v17; // rcx
__int64 v18; // rax
std::_Simple_types::value_type *v19; // rcx
int m_unkInt2; // ebx
float m_unkDouble1; // xmm10_4
float m_unkFloat1; // xmm8_4
float v24; // xmm6_4
float m_unkFloat2; // xmm7_4
int i; // edx
std::array *p_m_sfxStateContainers; // rax
float v28; // xmm1_4
std::array *v29; // rax
float v30; // xmm1_4
int j; // edx
std::array *v32; // rax
float v33; // xmm3_4
double m_unkDouble2; // xmm4_8
float v35; // xmm1_4
int v36; // r8d
std::array *v37; // rax
float v38; // xmm3_4
double v39; // xmm4_8
float v40; // xmm1_4
double v41; // xmm0_8
double v42; // xmm3_8
double v43; // xmm2_8
double v44; // xmm3_8
float v45; // xmm2_4
float v46; // xmm5_4
float v47; // xmm4_4
double v48; // xmm2_8
double v49; // xmm1_8
SFXTriggerGameObject *v50; // rax
_BYTE v51[16]; // [rsp+20h] [rbp-B8h] BYREF
GJBaseGameLayer *v52; // [rsp+E0h] [rbp+8h] BYREF
v52 = a1;
m_sfxTriggerGameObject = a2->m_sfxTriggerGameObject;
if ( a2->m_sfxTriggerGameObject->m_unique )
{
m_sfxUniqueID = m_sfxTriggerGameObject->m_sfxUniqueID;
if ( m_sfxUniqueID > 0 )
{
v9 = m_sfxTriggerGameObject->m_sfxUniqueID;
}
else
{
v9 = -m_sfxTriggerGameObject->m_uniqueID;
m_sfxUniqueID = v9;
if ( !m_sfxTriggerGameObject->m_uniqueID )
m_sfxUniqueID = -m_sfxTriggerGameObject->m_uniqueID;
}
}
else
{
v9 = 0;
m_sfxUniqueID = -m_sfxTriggerGameObject->m_uniqueID;
}
LODWORD(v52) = m_sfxUniqueID;
v11 = 0;
if ( m_sfxTriggerGameObject->m_minInterval <= 0.0 )
goto LABEL_18;
Myfirst = a4->_Vec._Mypair._Myval2._Myfirst;
v13 = *((_QWORD *)Myfirst
+ 2
* ((0x100000001B3LL
* (BYTE3(v52)
^ (0x100000001B3LL
* (BYTE2(v52)
^ (0x100000001B3LL
* (BYTE1(v52) ^ (0x100000001B3LL * ((unsigned __int8)m_sfxUniqueID ^ 0xCBF29CE484222325uLL))))))))
& a4->_Mask)
+ 1);
if ( (std::_List_val>>::_Nodeptr)v13 == a4->_List._Mypair._Myval2._Myhead )
goto LABEL_13;
v14 = *((_QWORD *)Myfirst
+ 2
* ((0x100000001B3LL
* (BYTE3(v52)
^ (0x100000001B3LL
* (BYTE2(v52)
^ (0x100000001B3LL
* (BYTE1(v52) ^ (0x100000001B3LL * ((unsigned __int8)m_sfxUniqueID ^ 0xCBF29CE484222325uLL))))))))
& a4->_Mask));
if ( m_sfxUniqueID != *(_DWORD *)(v13 + 16) )
{
while ( v13 != v14 )
{
v13 = *(_QWORD *)(v13 + 8);
if ( m_sfxUniqueID == *(_DWORD *)(v13 + 16) )
goto LABEL_14;
}
LABEL_13:
v13 = 0;
}
LABEL_14:
if ( v13 )
{
if ( a2->m_sfxTriggerGameObject->m_minInterval > a2->m_unkDouble1
- *(float *)(*(_QWORD *)sub_140060B20(
&a4->_Traitsobj._Mypair._Myval2._Myval2,
(__int64)v51,
(unsigned __int8 *)&v52)
+ 20LL) )
return 0;
m_sfxUniqueID = (int)v52;
}
v11 = 1;
LABEL_18:
if ( !v9 )
goto LABEL_28;
v15 = a3->_Vec._Mypair._Myval2._Myfirst;
Ptr = v15[2
* ((0x100000001B3LL
* (BYTE3(v52)
^ (0x100000001B3LL
* (BYTE2(v52)
^ (0x100000001B3LL
* (BYTE1(v52) ^ (0x100000001B3LL * ((unsigned __int8)m_sfxUniqueID ^ 0xCBF29CE484222325uLL))))))))
& a3->_Mask)
+ 1]._Ptr;
if ( Ptr == a3->_List._Mypair._Myval2._Myhead )
{
LABEL_24:
Ptr = nullptr;
goto LABEL_25;
}
v17 = v15[2
* ((0x100000001B3LL
* (BYTE3(v52)
^ (0x100000001B3LL
* (BYTE2(v52)
^ (0x100000001B3LL
* (BYTE1(v52) ^ (0x100000001B3LL * ((unsigned __int8)m_sfxUniqueID ^ 0xCBF29CE484222325uLL))))))))
& a3->_Mask)]._Ptr;
if ( m_sfxUniqueID != *((_DWORD *)Ptr + 4) )
{
while ( Ptr != v17 )
{
Ptr = *((std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr *)Ptr
+ 1);
if ( m_sfxUniqueID == *((_DWORD *)Ptr + 4) )
goto LABEL_25;
}
goto LABEL_24;
}
LABEL_25:
if ( !Ptr )
goto LABEL_28;
v18 = sub_140060B20(&a3->_Traitsobj._Mypair._Myval2._Myval2, (__int64)v51, (unsigned __int8 *)&v52);
v19 = &a5->_Mypair._Myval2._Myfirst[*(int *)(*(_QWORD *)v18 + 20LL)];
if ( a2->m_sfxTriggerGameObject->m_override )
{
v19->m_processed = 1;
goto LABEL_28;
}
if ( v19->m_processed )
goto LABEL_28;
m_unkDouble1 = a2->m_unkDouble1;
if ( m_unkDouble1 <= v19->m_unkDouble3 )
goto LABEL_70;
do
{
m_unkFloat1 = v19->m_unkFloat1;
v24 = m_unkDouble1;
m_unkFloat2 = v19->m_unkFloat2;
for ( i = 0; i < 2; i += 2 )
{
p_m_sfxStateContainers = &v19->m_sfxStateContainers;
if ( i )
p_m_sfxStateContainers = (std::array *)&v19->m_sfxStateContainers._Elems[1];
if ( p_m_sfxStateContainers->_Elems[0].m_unkBool )
{
v28 = p_m_sfxStateContainers->_Elems[0].m_unkDouble2 + p_m_sfxStateContainers->_Elems[0].m_unkDouble1;
v24 = fminf(v28, v24);
}
v29 = &v19->m_sfxStateContainers;
if ( i != -1 )
v29 = (std::array *)&v19->m_sfxStateContainers._Elems[1];
if ( v29->_Elems[0].m_unkBool )
{
v30 = v29->_Elems[0].m_unkDouble2 + v29->_Elems[0].m_unkDouble1;
v24 = fminf(v30, v24);
}
}
for ( j = 0; j < 2; j += 2 )
{
v32 = &v19->m_sfxStateContainers;
if ( j )
v32 = (std::array *)&v19->m_sfxStateContainers._Elems[1];
if ( !v32->_Elems[0].m_unkBool )
goto LABEL_56;
if ( j )
v33 = v19->m_unkFloat2;
else
v33 = v19->m_unkFloat1;
m_unkDouble2 = v32->_Elems[0].m_unkDouble2;
v35 = v32->_Elems[0].m_unkFloat1;
if ( v32->_Elems[0].m_unkDouble1 + m_unkDouble2 <= v24 )
v32->_Elems[0].m_unkBool = 0;
else
v35 = (float)(v24 - v32->_Elems[0].m_unkDouble1) / m_unkDouble2 * (float)(v35 - v33) + v33;
if ( j )
{
v19->m_unkFloat2 = v35;
m_unkFloat2 = (float)(v35 + v33) * 0.5;
LABEL_56:
v36 = j + 1;
v37 = &v19->m_sfxStateContainers;
if ( j == -1 )
goto LABEL_58;
goto LABEL_57;
}
v19->m_unkFloat1 = v35;
v36 = 1;
m_unkFloat1 = (float)(v35 + v33) * 0.5;
LABEL_57:
v37 = (std::array *)&v19->m_sfxStateContainers._Elems[1];
LABEL_58:
if ( v37->_Elems[0].m_unkBool )
{
if ( v36 )
v38 = v19->m_unkFloat2;
else
v38 = v19->m_unkFloat1;
v39 = v37->_Elems[0].m_unkDouble2;
v40 = v37->_Elems[0].m_unkFloat1;
if ( v37->_Elems[0].m_unkDouble1 + v39 <= v24 )
v37->_Elems[0].m_unkBool = 0;
else
v40 = (float)(v24 - v37->_Elems[0].m_unkDouble1) / v39 * (float)(v40 - v38) + v38;
if ( j == -1 )
{
v19->m_unkFloat1 = v40;
m_unkFloat1 = (float)(v40 + v38) * 0.5;
}
else
{
v19->m_unkFloat2 = v40;
m_unkFloat2 = (float)(v40 + v38) * 0.5;
}
}
}
v41 = v24 - v19->m_unkDouble3;
v19->m_unkDouble3 = v24;
v19->m_unkDouble2 = (float)((float)((float)((float)v41 * m_unkFloat1) * m_unkFloat2) * 1000.0) + v19->m_unkDouble2;
}
while ( m_unkDouble1 > (double)v24 );
LABEL_70:
if ( v19->m_sfxStateContainers._Elems[0].m_unkBool )
{
v42 = v19->m_sfxStateContainers._Elems[0].m_unkDouble1;
v43 = v19->m_sfxStateContainers._Elems[0].m_unkDouble2;
if ( m_unkDouble1 <= v42 + v43 )
{
v19->m_sfxStateContainers._Elems[0].m_unkDouble1 = m_unkDouble1;
v19->m_sfxStateContainers._Elems[0].m_unkDouble2 = v43 - (float)(m_unkDouble1 - v42);
}
else
{
v19->m_sfxStateContainers._Elems[0].m_unkBool = 0;
}
}
if ( v19->m_sfxStateContainers._Elems[2].m_unkBool )
{
v44 = v19->m_sfxStateContainers._Elems[2].m_unkDouble2;
v45 = v19->m_sfxStateContainers._Elems[2].m_unkFloat1;
v46 = v44;
if ( v46 > 0.0 )
{
v47 = m_unkDouble1 - v19->m_sfxStateContainers._Elems[2].m_unkDouble1;
if ( v46 > v47 )
v45 = (float)((float)(v47 / v46) * (float)(v45 - v19->m_unkFloat3)) + v19->m_unkFloat3;
}
v19->m_unkFloat3 = v45;
v48 = v19->m_sfxStateContainers._Elems[2].m_unkDouble1;
v49 = m_unkDouble1;
if ( m_unkDouble1 <= v48 + v44 )
{
v19->m_sfxStateContainers._Elems[2].m_unkDouble1 = v49;
v19->m_sfxStateContainers._Elems[2].m_unkDouble2 = v44 - (float)(v49 - v48);
}
else
{
v19->m_sfxStateContainers._Elems[2].m_unkBool = 0;
}
}
v50 = v19->m_sfxTriggerGameObject;
v19->m_unkDouble4 = m_unkDouble1;
if ( v50->m_objectID == 3602 && !v19->m_unkBool1 && v19->m_unkDouble2 > v19->m_unkFloat4 )
v19->m_processed = 1;
if ( !v19->m_processed )
return 0;
LABEL_28:
m_unkInt2 = a2->m_unkInt2;
*(_DWORD *)(*(_QWORD *)sub_140060B20(&a3->_Traitsobj._Mypair._Myval2._Myval2, (__int64)v51, (unsigned __int8 *)&v52)
+ 20LL) = m_unkInt2;
if ( v11 )
*(float *)(*(_QWORD *)sub_140060B20(&a4->_Traitsobj._Mypair._Myval2._Myval2, (__int64)v51, (unsigned __int8 *)&v52)
+ 20LL) = a2->m_unkDouble1;
return 1;
}