//
// SetupSFXPopup::onClose from 0xb6c90c to 0xb6cb98 (652 bytes)
//
// 2 xrefs:
// > ??> @ 0xaa920
// > ??> @ 0x14c8e18
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:02:18 +0000
//
__int64 __fastcall SetupSFXPopup::onClose(SetupSFXPopup *this, cocos2d::CCObject *a2)
{
FMOD::ChannelControl **v3; // x0
cocos2d::CCObject *v4; // x1
cocos2d::CCArray *v5; // x0
cocos2d::CCArray *v6; // x26
unsigned int i; // w24
__int64 v8; // x21
MusicDownloadManager *v9; // x0
MusicDownloadManager *SFXObject; // x0
MusicDownloadManager *v11; // x0
__int64 *v12; // x0
__int64 v13; // x19
FMODAudioEngine *v14; // x0
__int64 v15; // x19
int v16; // w28
int v17; // w19
int v18; // w25
FMODAudioEngine *v19; // x0
float v20; // s0
char v21; // w0
__int64 v24; // [xsp+80h] [xbp+80h] BYREF
size_t v25; // [xsp+88h] [xbp+88h]
void *v26; // [xsp+90h] [xbp+90h]
__int64 v27; // [xsp+98h] [xbp+98h] BYREF
size_t v28; // [xsp+A0h] [xbp+A0h]
void *v29; // [xsp+A8h] [xbp+A8h]
__int64 v30; // [xsp+B0h] [xbp+B0h] BYREF
size_t v31; // [xsp+B8h] [xbp+B8h]
void *v32; // [xsp+C0h] [xbp+C0h]
v3 = (FMOD::ChannelControl **)FMODAudioEngine::sharedEngine(_stack_chk_guard);
FMODAudioEngine::stopAllEffects(v3);
v5 = *((cocos2d::CCArray **)this + 85);
if ( v5 )
v6 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject(v5, v4);
else
v6 = *((cocos2d::CCArray **)this + 86);
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v6); ++i )
{
v8 = cocos2d::CCArray::objectAtIndex(v6, i);
v9 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)v8);
SFXObject = (MusicDownloadManager *)MusicDownloadManager::getSFXObject(v9, *(_DWORD *)(v8 + 1864));
v11 = (MusicDownloadManager *)MusicDownloadManager::sharedState(SFXObject);
v12 = MusicDownloadManager::pathForSFX(&v24, v11, *(_DWORD *)(v8 + 1864));
v13 = FMODAudioEngine::sharedEngine((FMODAudioEngine *)v12);
v27 = 0;
v28 = 0;
v29 = nullptr;
if ( (v24 & 1) != 0 )
{
std::string::__init(&v27, v26, v25);
}
else
{
v29 = v26;
v27 = v24;
v28 = v25;
}
FMODAudioEngine::preloadEffect(v13, (__int64)&v27);
v14 = (FMODAudioEngine *)(unsigned __int8)v27;
if ( (v27 & 1) != 0 )
operator delete(v29);
v15 = FMODAudioEngine::sharedEngine(v14);
v30 = 0;
v31 = 0;
v32 = nullptr;
if ( (v24 & 1) != 0 )
{
std::string::__init(&v30, v26, v25);
}
else
{
v32 = v26;
v30 = v24;
v31 = v25;
}
v16 = FMODAudioEngine::lengthForSound(v15, &v30);
if ( (v30 & 1) != 0 )
{
operator delete(v32);
v17 = *(_DWORD *)(v8 + 1896);
v18 = *(_DWORD *)(v8 + 1888);
if ( !v17 )
goto LABEL_20;
}
else
{
v17 = *(_DWORD *)(v8 + 1896);
v18 = *(_DWORD *)(v8 + 1888);
if ( !v17 )
goto LABEL_20;
}
if ( v18 <= v17 )
{
v19 = (FMODAudioEngine *)*(unsigned int *)(v8 + 1876);
if ( (_DWORD)v19 )
goto LABEL_21;
goto LABEL_14;
}
LABEL_20:
v19 = (FMODAudioEngine *)*(unsigned int *)(v8 + 1876);
v17 = v16;
if ( (_DWORD)v19 )
{
LABEL_21:
FMODAudioEngine::sharedEngine(v19);
v20 = FMODAudioEngine::pitchForIdx((FMODAudioEngine *)*(unsigned int *)(v8 + 1876));
goto LABEL_15;
}
LABEL_14:
v20 = 1.0;
LABEL_15:
v21 = v24;
*(float *)(v8 + 1976) = (float)(int)(float)((float)(v17 - v18) / v20) / 1000.0;
if ( (v21 & 1) != 0 )
operator delete(v26);
}
SetupTriggerPopup::onClose((GameObject **)this, a2);
return _stack_chk_guard;
}