//
// SetupSFXPopup::createSFXWidget from 0x140448900 to 0x140448c30 (816 bytes)
//
// 3 xrefs:
// > SetupSFXPopup::init @ 0x14044842b
// > SetupSFXPopup::valueDidChange @ 0x140448dd4
// > ??> @ 0x1406da670
//
// 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=6
void SetupSFXPopup::createSFXWidget(SetupSFXPopup *a1)
{
float v1; // xmm0_4
CustomSFXWidget *m_sfxWidget; // rcx
__int64 m_sfxID; // rdi
cocos2d::CCDictionary *m_sfxObjects; // rcx
SFXInfoObject *v6; // rax
bool v7; // r9
CustomSFXWidget *v8; // rax
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
MusicDownloadManager *v11; // rax
_QWORD *v12; // rdi
__int64 v13; // rcx
_QWORD *v14; // rdi
__int64 v15; // rcx
int v16; // eax
_BOOL8 v17; // rdx
struct cocos2d::CCFloat *v18; // rax
struct cocos2d::CCFloat *v19; // rax
float v20; // xmm0_4
float v21; // xmm0_4
CustomSFXWidget *v22; // rcx
bool v23; // [rsp+20h] [rbp-98h]
bool v24; // [rsp+28h] [rbp-90h]
float v25; // [rsp+40h] [rbp-78h]
FMODAudioEngine *v26; // [rsp+48h] [rbp-70h]
FMODAudioEngine *v27; // [rsp+48h] [rbp-70h]
_BYTE v28[8]; // [rsp+50h] [rbp-68h] BYREF
FMODAudioEngine *v29; // [rsp+58h] [rbp-60h]
_BYTE v30[32]; // [rsp+60h] [rbp-58h] BYREF
_QWORD v31[4]; // [rsp+80h] [rbp-38h] BYREF
m_sfxWidget = a1->m_sfxWidget;
if ( m_sfxWidget )
{
m_sfxWidget->removeMeAndCleanup(m_sfxWidget);
a1->m_sfxWidget = nullptr;
}
m_sfxID = a1->m_sfxID;
if ( (int)m_sfxID > 0 )
{
m_sfxObjects = MusicDownloadManager::sharedState()->m_sfxObjects;
if ( m_sfxObjects )
{
v6 = (SFXInfoObject *)cocos2d::CCDictionary::objectForKey(m_sfxObjects, m_sfxID);
a1->m_sfxLength = 0;
if ( v6 && !v6->m_folder )
{
v8 = CustomSFXWidget::create(v6, &a1->CustomSFXDelegate, 0, v7, v23, v24, 0);
a1->m_sfxWidget = v8;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v8, 2);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
cocos2d::CCPoint::CCPoint(v1, v25 * 0.5);
a1->m_sfxWidget->setPosition_0(a1->m_sfxWidget, (const cocos2d::CCPoint *)v28);
v11 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((__int64)v11, v31, a1->m_sfxID);
v29 = (FMODAudioEngine *)v30;
v12 = (_QWORD *)sub_14003BDB0((__int64)v30, (__int64)v31);
v13 = 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);
v13 = qword_1406C2E88;
}
FMODAudioEngine::preloadEffect(v13, v12);
v14 = (_QWORD *)sub_14003BDB0((__int64)v30, (__int64)v31);
v15 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v29 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v15 = qword_1406C2E88;
}
v16 = FMODAudioEngine::lengthForSound(v15, v14);
a1->m_sfxLength = v16;
if ( v16 )
{
v18 = cocos2d::CCFloat::create((float)v16);
cocos2d::CCDictionary::setObject(a1->m_maxSliderValues, v18, 408);
v19 = cocos2d::CCFloat::create((float)a1->m_sfxLength);
cocos2d::CCDictionary::setObject(a1->m_maxSliderValues, v19, 410);
SetupTriggerPopup::updateSlider(a1, 408);
SetupTriggerPopup::updateSlider(a1, 410);
}
if ( a1->m_sfxWidget )
{
if ( !qword_1406C2E88 )
{
v27 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
}
v20 = a1->getValue(a1, 404);
v21 = FMODAudioEngine::pitchForIdx((int)v20);
v22 = a1->m_sfxWidget;
v22->m_lengthMod = v21;
CustomSFXWidget::updateSFXInfo(v22);
}
LOBYTE(v17) = a1->m_page < 2;
a1->m_sfxWidget->setVisible(a1->m_sfxWidget, v17);
sub_14003A830((__int64)v31);
}
}
else
{
a1->m_sfxLength = 0;
}
}
}