//
// GJBaseGameLayer::processSFXObjects from 0x880ee4 to 0x88121c (824 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x897fd4
// > ??> @ 0x4cf68
//
// 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::processSFXObjects(GJBaseGameLayer *a1)
{
unsigned __int64 v2; // x0
__int64 *v3; // x0
cocos2d::CCArray *m_objects; // x1
cocos2d::ccArray *data; // x1
__int64 *v6; // x19
int v7; // w23
unsigned int v8; // w22
MusicDownloadManager *v9; // x0
FMODAudioEngine *v10; // x22
char *v11; // x22
char *v12; // x0
_QWORD *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
cocos2d::CCObject **arr; // x19
cocos2d::CCObject **v19; // x20
cocos2d::CCObject *v20; // x1
_QWORD *v21; // x0
unsigned int *v22; // x1
int v23; // w2
_DWORD *v24; // [xsp+80h] [xbp+80h] BYREF
_QWORD *v25; // [xsp+88h] [xbp+88h] BYREF
_QWORD v26[2]; // [xsp+90h] [xbp+90h] BYREF
__int64 *v27; // [xsp+A0h] [xbp+A0h]
__int64 v28; // [xsp+A8h] [xbp+A8h]
float v29; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v30; // [xsp+B8h] [xbp+B8h]
__int64 v31; // [xsp+C0h] [xbp+C0h] BYREF
v27 = nullptr;
v28 = 0;
v29 = 1.0;
v30 = 0;
v2 = sub_D146DC(&v29, 10);
v26[1] = v2;
if ( v2 == 1 )
{
v31 = 0;
v3 = &v31;
}
else
{
v3 = (__int64 *)sub_8563A4(v2);
}
m_objects = a1->m_objects;
v26[0] = v3;
if ( m_objects )
{
data = m_objects->data;
if ( data->num )
{
arr = data->arr;
v19 = &arr[data->num - 1];
if ( arr <= v19 )
{
v20 = *arr;
if ( *arr )
{
if ( HIDWORD(v20[18].__vftable) == 3602 )
goto LABEL_30;
while ( v19 >= ++arr )
{
v20 = *arr;
if ( !*arr )
break;
if ( HIDWORD(v20[18].__vftable) == 3602 )
{
LABEL_30:
if ( BYTE5(v20[34].__vftable) && v20[32].m_unknown2 > 0 )
{
v25 = v26;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v26,
&v20[32].m_unknown2);
}
}
}
}
}
}
}
v6 = v27;
v7 = 0;
if ( v27 )
{
while ( 1 )
{
v8 = *((_DWORD *)v6 + 2);
v9 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((__int64 *)&v25, v9, v8);
v10 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v24);
v11 = FMODAudioEngine::preloadEffect((__int64)v10, (const void **)&v24);
v12 = (char *)(v24 - 6);
if ( v24 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = v24 - 2;
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(v24 - 2);
*(v24 - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v12);
}
if ( v11 )
{
v7 += *((_DWORD *)v11 + 4);
if ( v7 > 120000 )
break;
}
v13 = v25 - 3;
if ( v25 - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v25 - 1);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v13);
}
v6 = (__int64 *)*v6;
if ( !v6 )
goto LABEL_11;
}
v21 = v25 - 3;
if ( v25 - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v25 - 1);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v21);
}
}
LABEL_11:
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)v26);
}