//
// SetupSFXPopup::onPlusButton from 0x1405de640 to 0x1405dea03 (963 bytes)
//
// 2 xrefs:
// > ??> @ 0x1407fead0
// > ??> @ 0x14092ed3c
//
// 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:35:00 +0000
//
// Hidden C++ exception states: #wind=8
__int64 __fastcall SetupSFXPopup::onPlusButton(__int64 a1, __int64 a2)
{
int v3; // eax
__int64 result; // rax
__int64 v5; // rbx
__int64 v6; // rdi
cocos2d::CCObject *v7; // rsi
int v8; // r9d
__int64 (__fastcall *v9)(__int64); // rdx
_QWORD *v10; // rax
__int64 v11; // rcx
void *v12; // rcx
_QWORD **v13; // rdi
_QWORD *v14; // rcx
_QWORD *v15; // rbx
__int64 v16; // rdx
_QWORD *v17; // rax
__int64 v18; // rcx
void *v19; // rcx
_QWORD **v20; // rdi
_QWORD *v21; // rcx
_QWORD *v22; // rbx
int v23; // [rsp+30h] [rbp-40h] BYREF
void *Block; // [rsp+38h] [rbp-38h]
__int64 v25; // [rsp+40h] [rbp-30h]
void *v26[2]; // [rsp+48h] [rbp-28h] BYREF
__int64 v27; // [rsp+58h] [rbp-18h]
__int64 v28; // [rsp+60h] [rbp-10h]
__int64 v29; // [rsp+68h] [rbp-8h]
void *v30; // [rsp+98h] [rbp+28h]
void *v31; // [rsp+98h] [rbp+28h]
v3 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
if ( !v3 )
{
v25 = 0;
v17 = operator new(0x18u);
*v17 = v17;
v17[1] = v17;
Block = v17;
*(_OWORD *)v26 = 0;
v27 = 0;
v28 = 7;
v29 = 8;
v23 = 1065353216;
sub_14003F200((__int64)v26, 0x10u, (unsigned __int64)v17);
v18 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v31 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v18 = qword_14090BFD0;
}
LevelEditorLayer::getNextFreeSFXID(*(_QWORD *)(v18 + 568), (__int64)&v23);
v19 = v26[0];
if ( v26[0] )
{
if ( ((v27 - (unsigned __int64)v26[0]) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 )
{
v19 = *((void **)v26[0] - 1);
if ( (unsigned __int64)((char *)v26[0] - (char *)v19 - 8) > 0x1F )
goto LABEL_24;
}
j_j_free(v19);
}
v20 = (_QWORD **)Block;
**((_QWORD **)Block + 1) = 0;
v21 = *v20;
if ( *v20 )
{
do
{
v22 = (_QWORD *)*v21;
j_j_free(v21);
v21 = v22;
}
while ( v22 );
}
j_j_free(v20);
v16 = 416;
return SetupTriggerPopup::updateValue(a1, v16);
}
result = (unsigned int)(v3 - 1);
if ( !(_DWORD)result )
{
v25 = 0;
v10 = operator new(0x18u);
*v10 = v10;
v10[1] = v10;
Block = v10;
*(_OWORD *)v26 = 0;
v27 = 0;
v28 = 7;
v29 = 8;
v23 = 1065353216;
sub_14003F200((__int64)v26, 0x10u, (unsigned __int64)v10);
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v30 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
LevelEditorLayer::getNextFreeSFXGroupID(*(_QWORD *)(v11 + 568), (__int64)&v23);
v12 = v26[0];
if ( !v26[0] )
goto LABEL_16;
if ( ((v27 - (unsigned __int64)v26[0]) & 0xFFFFFFFFFFFFFFF8uLL) < 0x1000
|| (v12 = *((void **)v26[0] - 1), (unsigned __int64)((char *)v26[0] - (char *)v12 - 8) <= 0x1F) )
{
j_j_free(v12);
LABEL_16:
v13 = (_QWORD **)Block;
**((_QWORD **)Block + 1) = 0;
v14 = *v13;
if ( *v13 )
{
do
{
v15 = (_QWORD *)*v14;
j_j_free(v14);
v14 = v15;
}
while ( v15 );
}
j_j_free(v13);
v16 = 455;
return SetupTriggerPopup::updateValue(a1, v16);
}
LABEL_24:
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
if ( (_DWORD)result == 1 )
{
v5 = *(_QWORD *)(a1 + 688);
v6 = *(_QWORD *)(a1 + 680);
v7 = (cocos2d::CCObject *)operator new(0x3F0u);
SetupTriggerPopup::SetupTriggerPopup((__int64)v7);
*(_QWORD *)v7 = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 40) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 41) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 42) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 43) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 44) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 51) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 54) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 68) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 83) = &SetupReverbPopup::`vftable';
*((_QWORD *)v7 + 84) = &SetupReverbPopup::`vftable';
if ( SetupReverbPopup::init((__int64)v7, v6, v5, v8) )
{
cocos2d::CCObject::autorelease(v7);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v7 + 8LL))(v7, 1);
v7 = nullptr;
}
v9 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 1064LL);
if ( v9 == SetupTriggerPopup::show )
return SetupTriggerPopup::show((__int64)v7);
else
return v9((__int64)v7);
}
return result;
}