//
// SetupSFXPopup::onClose from 0xa3db08 to 0xa3de3c (820 bytes)
//
// 2 xrefs:
// > ??> @ 0x80118
// > ??> @ 0x11dfc28
//
// 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 SetupSFXPopup::onClose(SetupSFXPopup *a1, cocos2d::CCObject *a2)
{
FMODAudioEngine *v3; // x0
cocos2d::CCObject *v4; // x1
EffectGameObject *m_gameObject; // x0
cocos2d::CCArray *m_gameObjects; // x28
unsigned int v7; // w21
__int64 v8; // x20
MusicDownloadManager *v9; // x0
MusicDownloadManager *v10; // x0
FMODAudioEngine *v11; // x19
char *v12; // x0
FMODAudioEngine *v13; // x19
int v14; // w3
char *v15; // x0
int v16; // w19
int v17; // w27
float v18; // s0
__int64 v19; // x1
__int64 *v20; // x0
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
int v27; // [xsp+78h] [xbp+78h]
__int64 v30; // [xsp+A0h] [xbp+A0h] BYREF
_DWORD *v31; // [xsp+A8h] [xbp+A8h] BYREF
_DWORD *v32; // [xsp+B0h] [xbp+B0h] BYREF
v3 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v3);
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
m_gameObjects = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)m_gameObject, v4);
else
m_gameObjects = a1->m_gameObjects;
v7 = 0;
while ( v7 < (unsigned int)cocos2d::CCArray::count(m_gameObjects) )
{
v8 = cocos2d::CCArray::objectAtIndex(m_gameObjects, v7);
v9 = MusicDownloadManager::sharedState();
MusicDownloadManager::getSFXObject(v9, *(_DWORD *)(v8 + 1832));
v10 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX(&v30, v10, *(_DWORD *)(v8 + 1832));
v11 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v31);
FMODAudioEngine::preloadEffect((__int64)v11, (const void **)&v31);
v12 = (char *)(v31 - 6);
if ( v31 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = v31 - 2;
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(v31 - 2);
*(v31 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v12);
}
v13 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v32);
v14 = FMODAudioEngine::lengthForSound((__int64)v13, (const void **)&v32);
v15 = (char *)(v32 - 6);
if ( v32 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = v32 - 2;
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(v32 - 2);
*(v32 - 2) = v26 - 1;
}
if ( v26 <= 0 )
{
v27 = v14;
operator delete(v15);
v14 = v27;
}
}
v16 = *(_DWORD *)(v8 + 1860);
v17 = *(_DWORD *)(v8 + 1852);
if ( !v16 || v17 > v16 )
v16 = v14;
if ( *(_DWORD *)(v8 + 1840) )
{
FMODAudioEngine::sharedEngine();
v18 = FMODAudioEngine::pitchForIdx(*(_DWORD *)(v8 + 1840));
}
else
{
v18 = 1.0;
}
v19 = v30;
v20 = (__int64 *)(v30 - 24);
*(float *)(v8 + 1940) = (float)(int)(float)((float)(v16 - v17) / v18) / 1000.0;
if ( v20 == &qword_124B6B0 )
goto LABEL_11;
if ( &pthread_create )
{
v21 = (unsigned int *)(v19 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v22 - 1;
}
if ( v22 > 0 )
{
LABEL_11:
++v7;
}
else
{
++v7;
operator delete(v20);
}
}
SetupTriggerPopup::onClose(a1, a2);
}