//
// SetupSFXPopup::createSFXWidget from 0x1405dde10 to 0x1405de413 (1539 bytes)
//
// 3 xrefs:
// > SetupSFXPopup::init @ 0x1405dd8bb
// > SetupSFXPopup::valueDidChange @ 0x1405de604
// > ??> @ 0x14092ecdc
//
// 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=15
void __fastcall SetupSFXPopup::createSFXWidget(__int64 a1)
{
__int64 v2; // rcx
__int64 v3; // rax
cocos2d::CCDictionary *v4; // rcx
struct cocos2d::CCObject *v5; // rsi
__int64 v6; // r9
int v7; // r14d
__int64 v8; // rax
__int64 v9; // rcx
__int64 v10; // rcx
__int64 CustomSFXPathRaw; // rax
char v12; // bl
void *v13; // rcx
int v14; // ebx
__int64 v15; // rax
__int64 CustomSFXRawPath; // rbx
void *v17; // rax
__int64 v18; // rcx
struct cocos2d::CCObject *v19; // rax
cocos2d::CCNode *v20; // rax
__int64 v21; // rcx
__int64 v22; // rax
__int64 v23; // rcx
_QWORD *v24; // rbx
__int64 v25; // rcx
_QWORD *v26; // rbx
__int64 v27; // rcx
int v28; // eax
__int64 v29; // rdx
struct cocos2d::CCObject *v30; // rax
cocos2d::CCDictionary *v31; // rbx
struct cocos2d::CCObject *v32; // rax
float v33; // xmm0_4
float v34; // xmm0_4
__int64 v35; // rcx
uintptr_t Reserved; // [rsp+20h] [rbp-79h]
__int64 v37; // [rsp+28h] [rbp-71h]
void *v38; // [rsp+50h] [rbp-49h] BYREF
float v39[2]; // [rsp+58h] [rbp-41h] BYREF
_BYTE *v40; // [rsp+60h] [rbp-39h]
_BYTE *v41; // [rsp+68h] [rbp-31h]
void *v42[2]; // [rsp+70h] [rbp-29h] BYREF
__int128 v43; // [rsp+80h] [rbp-19h]
void *Block[2]; // [rsp+90h] [rbp-9h] BYREF
__int64 v45; // [rsp+A0h] [rbp+7h]
unsigned __int64 v46; // [rsp+A8h] [rbp+Fh]
_BYTE v47[32]; // [rsp+B0h] [rbp+17h] BYREF
v39[0] = 0.0;
v2 = *(_QWORD *)(a1 + 1032);
if ( v2 )
{
(*(void (__fastcall **)(__int64))(*(_QWORD *)v2 + 528LL))(v2);
*(_QWORD *)(a1 + 1032) = 0;
}
if ( *(int *)(a1 + 1024) > 0 )
{
v3 = qword_14090C070;
if ( !qword_14090C070 )
{
v38 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager((__int64)v38);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v3 = qword_14090C070;
}
v4 = *(cocos2d::CCDictionary **)(v3 + 408);
if ( v4 )
v5 = cocos2d::CCDictionary::objectForKey(v4, *(int *)(a1 + 1024));
else
v5 = nullptr;
*(_DWORD *)(a1 + 1040) = 0;
v7 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 601);
if ( v7 > 0 )
{
v8 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v38 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v38);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v8 = qword_14090BFD0;
}
v9 = *(_QWORD *)(v8 + 568);
if ( v9 && (v10 = *(_QWORD *)(v9 + 3528)) != 0 )
{
CustomSFXPathRaw = LevelSettingsObject::getCustomSFXPathRaw(v10, (__int64)v47, *(_DWORD *)(a1 + 1024), v7);
v12 = 1;
}
else
{
*(_OWORD *)Block = 0;
v45 = 0;
v46 = 15;
LOBYTE(Block[0]) = 0;
CustomSFXPathRaw = (__int64)Block;
v12 = 2;
}
*(_OWORD *)v42 = 0;
v43 = 0u;
*(_OWORD *)v42 = *(_OWORD *)CustomSFXPathRaw;
v43 = *(_OWORD *)(CustomSFXPathRaw + 16);
*(_QWORD *)(CustomSFXPathRaw + 16) = 0;
*(_QWORD *)(CustomSFXPathRaw + 24) = 15;
*(_BYTE *)CustomSFXPathRaw = 0;
if ( (v12 & 2) != 0 )
{
v12 &= ~2u;
if ( v46 > 0xF )
{
v13 = Block[0];
if ( v46 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
}
if ( (v12 & 1) != 0 )
sub_14003D310((__int64)v47);
if ( !(_QWORD)v43 )
{
v14 = *(_DWORD *)(a1 + 1024);
v15 = EditorSFXManager::sharedState();
CustomSFXRawPath = EditorSFXManager::getCustomSFXRawPath(v15, (__int64)Block, v14, v7);
if ( v42 != (void **)CustomSFXRawPath )
{
if ( *((_QWORD *)&v43 + 1) > 0xFu )
{
v17 = v42[0];
if ( (unsigned __int64)(*((_QWORD *)&v43 + 1) + 1LL) >= 0x1000 )
{
v17 = *((void **)v42[0] - 1);
if ( (unsigned __int64)((char *)v42[0] - (char *)v17 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v17);
}
*(_QWORD *)&v43 = 0;
*((_QWORD *)&v43 + 1) = 15;
LOBYTE(v42[0]) = 0;
*(_OWORD *)v42 = *(_OWORD *)CustomSFXRawPath;
v43 = *(_OWORD *)(CustomSFXRawPath + 16);
*(_QWORD *)(CustomSFXRawPath + 16) = 0;
*(_QWORD *)(CustomSFXRawPath + 24) = 15;
*(_BYTE *)CustomSFXRawPath = 0;
}
sub_14003D310((__int64)Block);
}
v18 = qword_14090C070;
if ( !qword_14090C070 )
{
v38 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager((__int64)v38);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v18 = qword_14090C070;
}
v19 = MusicDownloadManager::resolveSFXPlacement(v18, *(_DWORD *)(a1 + 1024), v7, (__int64 *)v42);
if ( v19 )
v5 = v19;
sub_14003D310((__int64)v42);
}
if ( v5 && !*((_BYTE *)v5 + 72) )
{
v20 = CustomSFXWidget::create((int)v5, (int)a1 + 1008, 0, v6, Reserved, v37, 0, 0, 0);
*(_QWORD *)(a1 + 1032) = v20;
(*(void (__fastcall **)(_QWORD, cocos2d::CCNode *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v20,
2);
v22 = cocos2d::CCDirector::sharedDirector(v21);
cocos2d::CCDirector::getWinSize(v22, v39);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v38, v39[0] * 0.5, (float)(v39[1] * 0.5) + 70.0);
(*(void (__fastcall **)(_QWORD, void **))(**(_QWORD **)(a1 + 1032) + 184LL))(*(_QWORD *)(a1 + 1032), &v38);
v23 = qword_14090C070;
if ( !qword_14090C070 )
{
v40 = operator new(0x3D0u);
qword_14090C070 = MusicDownloadManager::MusicDownloadManager((__int64)v40);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090C070 + 72LL))(qword_14090C070);
v23 = qword_14090C070;
}
MusicDownloadManager::pathForSFX(v23, Block, *(_DWORD *)(a1 + 1024));
v40 = v47;
v24 = (_QWORD *)sub_14003F4F0((__int64)v47, (__int64)Block);
v25 = qword_14090BF60;
if ( !qword_14090BF60 )
{
v41 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v41);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v25 = qword_14090BF60;
}
FMODAudioEngine::preloadEffect(v25, v24);
v41 = v47;
v26 = (_QWORD *)sub_14003F4F0((__int64)v47, (__int64)Block);
v27 = qword_14090BF60;
if ( !qword_14090BF60 )
{
v40 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v40);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v27 = qword_14090BF60;
}
v28 = FMODAudioEngine::lengthForSound(v27, v26);
*(_DWORD *)(a1 + 1040) = v28;
if ( v28 )
{
v30 = cocos2d::CCFloat::create((float)v28);
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 848), v30, 408);
v31 = *(cocos2d::CCDictionary **)(a1 + 848);
v32 = cocos2d::CCFloat::create((float)*(int *)(a1 + 1040));
cocos2d::CCDictionary::setObject(v31, v32, 410);
SetupTriggerPopup::updateSlider(a1, 408);
SetupTriggerPopup::updateSlider(a1, 410);
}
if ( *(_QWORD *)(a1 + 1032) )
{
if ( !qword_14090BF60 )
{
v41 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v41);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
}
v33 = (*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 404);
v34 = FMODAudioEngine::pitchForIdx((int)v33);
v35 = *(_QWORD *)(a1 + 1032);
*(float *)(v35 + 500) = v34;
CustomSFXWidget::updateSFXInfo(v35);
}
LOBYTE(v29) = *(_DWORD *)(a1 + 904) < 2;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 1032) + 336LL))(*(_QWORD *)(a1 + 1032), v29);
sub_14003D310((__int64)Block);
}
}
}