//
// SetupSFXPopup::onClose from 0x1405dd9e0 to 0x1405ddd73 (915 bytes)
//
// 2 xrefs:
// > ??> @ 0x1407feac0
// > ??> @ 0x14092ecc4
//
// This function is hookable on this platform (idp: pc, 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 11:34:59 +0000
//
// Hidden C++ exception states: #wind=9
__int64 __fastcall SetupSFXPopup::onClose(__int64 a1, __int64 a2)
{
unsigned int v3; // r14d
_QWORD *v4; // rcx
struct cocos2d::CCObject *v5; // rcx
cocos2d::CCArray *v6; // r12
unsigned int i; // r15d
struct cocos2d::CCObject *v8; // rdi
__int64 v9; // rcx
unsigned int v10; // ebx
int v11; // r14d
void **v12; // rax
void *v13; // rdx
_QWORD *v14; // rbx
__int64 v15; // rcx
_QWORD *v16; // rbx
__int64 v17; // rcx
int v18; // eax
int v19; // esi
int v20; // ebx
float v21; // xmm0_4
void *v24; // [rsp+38h] [rbp-69h]
void *v25; // [rsp+38h] [rbp-69h]
void *v26; // [rsp+48h] [rbp-59h]
void *v27; // [rsp+50h] [rbp-51h]
void *v28; // [rsp+58h] [rbp-49h]
void *v29; // [rsp+60h] [rbp-41h]
_QWORD Src[4]; // [rsp+68h] [rbp-39h] BYREF
_QWORD v31[4]; // [rsp+88h] [rbp-19h] BYREF
v3 = 0;
v4 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v24 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v4 = (_QWORD *)qword_14090BF60;
}
FMODAudioEngine::stopAllEffects(v4);
v5 = *(struct cocos2d::CCObject **)(a1 + 680);
if ( v5 )
v6 = cocos2d::CCArray::createWithObject(v5);
else
v6 = *(cocos2d::CCArray **)(a1 + 688);
for ( i = 0; i < cocos2d::CCArray::count(v6); ++i )
{
v8 = cocos2d::CCArray::objectAtIndex(v6, i);
v9 = qword_14090C070;
if ( !qword_14090C070 )
{
v25 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v9 = qword_14090C070;
}
if ( *(_QWORD *)(v9 + 408) )
{
cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v9 + 408), *((int *)v8 + 472));
v9 = qword_14090C070;
}
if ( !v9 )
{
v26 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v9 = qword_14090C070;
}
v10 = *((_DWORD *)v8 + 472);
MusicDownloadManager::pathForSFXFolder(v9, Src, v10);
v11 = v3 | 1;
sub_140044D80(Src, byte_14070D03C, 1u);
v12 = (void **)GameToolbox::intToString(v31, v10);
v13 = v12;
if ( (unsigned __int64)v12[3] > 0xF )
v13 = *v12;
sub_140044D80(Src, v13, (size_t)v12[2]);
sub_14003D310((__int64)v31);
sub_140044D80(Src, ".ogg", 4u);
v14 = (_QWORD *)sub_14003F4F0((__int64)v31, (__int64)Src);
v15 = qword_14090BF60;
if ( !qword_14090BF60 )
{
v27 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v15 = qword_14090BF60;
}
FMODAudioEngine::preloadEffect(v15, v14);
v16 = (_QWORD *)sub_14003F4F0((__int64)v31, (__int64)Src);
v17 = qword_14090BF60;
if ( !qword_14090BF60 )
{
v28 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v17 = qword_14090BF60;
}
v18 = FMODAudioEngine::lengthForSound(v17, v16);
v19 = *((_DWORD *)v8 + 478);
v20 = *((_DWORD *)v8 + 480);
if ( !v20 || v20 < v19 )
v20 = v18;
v21 = 1.0;
if ( *((_DWORD *)v8 + 475) )
{
if ( !qword_14090BF60 )
{
v29 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
}
v21 = FMODAudioEngine::pitchForIdx(*((_DWORD *)v8 + 475));
}
*((float *)v8 + 500) = (float)(int)(float)((float)(v20 - v19) / v21) / 1000.0;
v3 = v11 & 0xFFFFFFFE;
sub_14003D310((__int64)Src);
}
return SetupTriggerPopup::onClose(a1, a2);
}