//
// SetupSFXPopup::onClose from 0x140448540 to 0x140448871 (817 bytes)
//
// 2 xrefs:
// > ??> @ 0x1405ef798
// > ??> @ 0x1406da658
//
// 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
//
// Hidden C++ exception states: #wind=7
void SetupSFXPopup::onClose(SetupSFXPopup *a1, cocos2d::CCObject *a2)
{
unsigned int v4; // ebp
FMODAudioEngine *v5; // rcx
EffectGameObject *m_gameObject; // rcx
struct cocos2d::CCArray *m_gameObjects; // r15
unsigned int i; // r14d
struct cocos2d::CCObject *v9; // rdi
__int64 m_unknown2; // rbx
cocos2d::CCDictionary *m_sfxObjects; // rcx
unsigned int v12; // ebx
MusicDownloadManager *v13; // rax
int v14; // ebp
void **v15; // rax
void *v16; // rdx
_QWORD *v17; // rbx
__int64 v18; // rcx
_QWORD *v19; // rbx
__int64 v20; // rcx
int v21; // eax
int v22; // esi
int m_nLuaID; // ebx
float v24; // xmm0_4
FMODAudioEngine *v25; // [rsp+28h] [rbp-B0h]
FMODAudioEngine *v26; // [rsp+30h] [rbp-A8h]
FMODAudioEngine *v27; // [rsp+38h] [rbp-A0h]
FMODAudioEngine *v28; // [rsp+40h] [rbp-98h]
_QWORD Src[4]; // [rsp+48h] [rbp-90h] BYREF
_QWORD v30[4]; // [rsp+68h] [rbp-70h] BYREF
v4 = 0;
v5 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v25 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v5 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::stopAllEffects(v5);
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
m_gameObjects = cocos2d::CCArray::createWithObject(m_gameObject);
else
m_gameObjects = a1->m_gameObjects;
for ( i = 0; i < cocos2d::CCArray::count(m_gameObjects); ++i )
{
v9 = cocos2d::CCArray::objectAtIndex(m_gameObjects, i);
m_unknown2 = v9[33].m_unknown2;
m_sfxObjects = MusicDownloadManager::sharedState()->m_sfxObjects;
if ( m_sfxObjects )
cocos2d::CCDictionary::objectForKey(m_sfxObjects, m_unknown2);
v12 = v9[33].m_unknown2;
v13 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFXFolder((__int64)v13, Src, v12);
v14 = v4 | 1;
sub_140041270(Src, "s", 1u);
v15 = (void **)GameToolbox::intToString(v30, v12);
v16 = v15;
if ( (unsigned __int64)v15[3] > 0xF )
v16 = *v15;
sub_140041270(Src, v16, (size_t)v15[2]);
sub_14003A830((__int64)v30);
sub_140041270(Src, ".ogg", 4u);
v17 = (_QWORD *)sub_14003BDB0((__int64)v30, (__int64)Src);
v18 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v26 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v18 = qword_1406C2E88;
}
FMODAudioEngine::preloadEffect(v18, v17);
v19 = (_QWORD *)sub_14003BDB0((__int64)v30, (__int64)Src);
v20 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v27 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v20 = qword_1406C2E88;
}
v21 = FMODAudioEngine::lengthForSound(v20, v19);
v22 = HIDWORD(v9[34].__vftable);
m_nLuaID = v9[34].m_nLuaID;
if ( !m_nLuaID || m_nLuaID < v22 )
m_nLuaID = v21;
v24 = 1.0;
if ( v9[33].m_uOrderOfArrival )
{
if ( !qword_1406C2E88 )
{
v28 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
}
v24 = FMODAudioEngine::pitchForIdx(v9[33].m_uOrderOfArrival);
}
*(float *)&v9[35].m_uUnknown = (float)(int)(float)((float)(m_nLuaID - v22) / v24) / 1000.0;
v4 = v14 & 0xFFFFFFFE;
sub_14003A830((__int64)Src);
}
SetupTriggerPopup::onClose(a1, a2);
}