//
// SetupSFXEditPopup::init from 0x1405dec00 to 0x1405df8b8 (3256 bytes)
//
// 2 xrefs:
// > SetupSFXEditPopup::create @ 0x1405debbc
// > ??> @ 0x14092ed6c
//
// 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=5
char __fastcall SetupSFXEditPopup::init(__int64 a1, int a2, int a3, int a4)
{
char v4; // si
char result; // al
const char *v7; // rdx
size_t v8; // rdi
size_t v9; // r8
_BYTE *v10; // r9
_BYTE *v11; // rcx
const char *v12; // rdx
__int64 v13; // r8
_BYTE *v14; // rcx
const char *v15; // rdx
__int64 v16; // rax
__int64 v17; // rcx
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rdx
void *v21; // rcx
__int64 v22; // rax
__int64 v23; // rax
__int64 *v24; // rdi
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // rax
__int64 v30; // rax
__int64 v31; // rax
__int64 v32; // rax
void *v33; // rcx
__int64 v34; // [rsp+78h] [rbp-88h]
__int64 v35; // [rsp+78h] [rbp-88h]
__int64 v36; // [rsp+78h] [rbp-88h]
__int64 v37; // [rsp+78h] [rbp-88h]
__int128 *v38; // [rsp+80h] [rbp-80h] BYREF
void **v39; // [rsp+88h] [rbp-78h] BYREF
void **v40; // [rsp+90h] [rbp-70h] BYREF
_BYTE v41[8]; // [rsp+98h] [rbp-68h] BYREF
float v42; // [rsp+A0h] [rbp-60h] BYREF
float v43; // [rsp+A4h] [rbp-5Ch]
_BYTE v44[8]; // [rsp+A8h] [rbp-58h] BYREF
__int128 v45; // [rsp+B0h] [rbp-50h] BYREF
__int64 v46; // [rsp+C0h] [rbp-40h]
__int64 v47; // [rsp+C8h] [rbp-38h]
void *Block[2]; // [rsp+D0h] [rbp-30h] BYREF
__m128i si128; // [rsp+E0h] [rbp-20h]
void *v50[2]; // [rsp+F0h] [rbp-10h]
__int64 v51; // [rsp+100h] [rbp+0h]
unsigned __int64 v52; // [rsp+108h] [rbp+8h]
v4 = a4;
result = SetupTriggerPopup::init(a1, a2, a3, a4, 1133248512, 1, 0);
if ( result )
{
*(_BYTE *)(a1 + 744) = 1;
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1096LL))(a1);
v7 = "Edit SFX Trigger";
if ( v4 )
v7 = "Edit Song Trigger";
*(_OWORD *)Block = 0;
si128 = 0u;
v8 = -1;
v9 = -1;
do
++v9;
while ( v7[v9] );
sub_14003D230(Block, v7, v9);
SetupTriggerPopup::addTitle(a1, Block);
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 2;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "OK");
SetupTriggerPopup::addCloseButton(a1, Block);
*(_OWORD *)v50 = 0;
v51 = 0;
v52 = 15;
LOBYTE(v50[0]) = 0;
if ( v4 )
{
v10 = sub_14003D460(0x1C0u);
v51 = 438;
v52 = 447;
v11 = v10;
v12 = "Lets you edit the properties of a song in a specified Channel.\n"
"Page 2 lets you change the volume depending on proximity.\n"
"Group ID 1 is the target that volume is calculated around. Use the arrow buttons to define which dir"
"ection it works in.\n"
"By default, the player changes the volume depending on how close they are to this group. You can also use Group ID 2 on an object to make this object control volume.";
v13 = 3;
do
{
*(_OWORD *)v11 = *(_OWORD *)v12;
*((_OWORD *)v11 + 1) = *((_OWORD *)v12 + 1);
*((_OWORD *)v11 + 2) = *((_OWORD *)v12 + 2);
*((_OWORD *)v11 + 3) = *((_OWORD *)v12 + 3);
*((_OWORD *)v11 + 4) = *((_OWORD *)v12 + 4);
*((_OWORD *)v11 + 5) = *((_OWORD *)v12 + 5);
*((_OWORD *)v11 + 6) = *((_OWORD *)v12 + 6);
v11 += 128;
*((_OWORD *)v11 - 1) = *((_OWORD *)v12 + 7);
v12 += 128;
--v13;
}
while ( v13 );
*(_OWORD *)v11 = *(_OWORD *)v12;
*((_OWORD *)v11 + 1) = *((_OWORD *)v12 + 1);
*((_OWORD *)v11 + 2) = *((_OWORD *)v12 + 2);
*((_DWORD *)v11 + 12) = *((_DWORD *)v12 + 12);
*((_WORD *)v11 + 26) = *((_WORD *)v12 + 26);
v10[438] = 0;
}
else
{
v10 = sub_14003D460(0x200u);
v51 = 505;
v52 = 511;
v14 = v10;
v15 = "Lets you edit the properties of a sound effect. Use Group ID, SFXGroup, or Uniqu"
"e ID to refer to the correct one.\n"
"Page 2 lets you change the volume depending on proximity.\n"
"Group ID 1 is the target that volume is calculated around. Use the arrow buttons to define which dir"
"ection it works in.\n"
"By default, the player changes the volume depending on how close they are to this group. You can also use Group ID 2 on an object to make this object control volume.";
v16 = 3;
do
{
*(_OWORD *)v14 = *(_OWORD *)v15;
*((_OWORD *)v14 + 1) = *((_OWORD *)v15 + 1);
*((_OWORD *)v14 + 2) = *((_OWORD *)v15 + 2);
*((_OWORD *)v14 + 3) = *((_OWORD *)v15 + 3);
*((_OWORD *)v14 + 4) = *((_OWORD *)v15 + 4);
*((_OWORD *)v14 + 5) = *((_OWORD *)v15 + 5);
*((_OWORD *)v14 + 6) = *((_OWORD *)v15 + 6);
v14 += 128;
*((_OWORD *)v14 - 1) = *((_OWORD *)v15 + 7);
v15 += 128;
--v16;
}
while ( v16 );
*(_OWORD *)v14 = *(_OWORD *)v15;
*((_OWORD *)v14 + 1) = *((_OWORD *)v15 + 1);
*((_OWORD *)v14 + 2) = *((_OWORD *)v15 + 2);
*((_OWORD *)v14 + 3) = *((_OWORD *)v15 + 3);
*((_OWORD *)v14 + 4) = *((_OWORD *)v15 + 4);
*((_OWORD *)v14 + 5) = *((_OWORD *)v15 + 5);
*((_OWORD *)v14 + 6) = *((_OWORD *)v15 + 6);
*((_QWORD *)v14 + 14) = *((_QWORD *)v15 + 14);
v14[120] = v15[120];
v10[505] = 0;
}
v50[0] = v10;
v38 = &v45;
v45 = 0;
v46 = 0;
v47 = 0;
do
++v8;
while ( v10[v8] );
sub_14003D230(&v45, v10, v8);
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 4;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Help");
SetupTriggerPopup::addHelpButton(a1, Block, &v45);
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
*(_BYTE *)(a1 + 888) = 1;
v18 = cocos2d::CCDirector::sharedDirector(v17);
cocos2d::CCDirector::getWinSize(v18, &v42);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, v42 * 0.5, v43 * 0.5);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v41, v42 * 0.5, (float)(v43 * 0.5) + 35.0);
*(_OWORD *)Block = 0;
if ( v4 )
{
v40 = Block;
si128.m128i_i64[0] = 8;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Channel:");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 0.0, 80.0);
cocos2d::CCPoint::operator+(v44, &v38, v25);
SetupTriggerPopup::createValueControlAdvanced(
a1,
432,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
1,
3,
10,
1,
0,
1082130432,
0,
0,
0,
2,
0,
v38);
LODWORD(v38) = 432;
v24 = (__int64 *)(a1 + 856);
*(_BYTE *)sub_14016EE40((__int64 *)(a1 + 856), (int *)&v38) = 1;
}
else
{
si128 = _mm_load_si128((const __m128i *)&xmmword_1408365A0);
strcpy((char *)Block, "Group ID:");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, -110.0, 80.0);
cocos2d::CCPoint::operator+(v44, &v38, v19);
v20 = a1 + 544;
if ( !a1 )
v20 = 0;
IDNameInput::create(
a1,
v20,
1,
457,
(__int64)Block,
(const struct cocos2d::CCPoint *)&v38,
1059481190,
6,
0,
0,
0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v21 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v21 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v21 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v21);
}
v39 = Block;
Block[1] = (void *)58;
si128.m128i_i64[0] = 9;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x70756F7247584653LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v40, 0.0, 80.0);
cocos2d::CCPoint::operator+(v44, &v38, v22);
SetupTriggerPopup::createValueControlAdvanced(
a1,
455,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
1,
2,
10,
1,
-1027080192,
1120403456,
0,
0,
0,
0,
0,
v38);
v40 = Block;
Block[1] = (void *)14916;
si128.m128i_i64[0] = 10;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x4920657571696E55LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 110.0, 80.0);
cocos2d::CCPoint::operator+(v44, &v38, v23);
LOBYTE(v34) = 0;
SetupTriggerPopup::createValueControlAdvanced(
a1,
416,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
1,
3,
10,
1,
0,
1120403456,
0,
0,
0,
0,
v34);
v24 = (__int64 *)(a1 + 856);
}
v40 = Block;
si128.m128i_i64[0] = 9;
si128.m128i_i64[1] = 15;
Block[0] = *(void **)"Duration:";
Block[1] = (void *)(unsigned __int8)aDuration[8];
BYTE1(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, -84.5, -0.0);
cocos2d::CCPoint::operator+(v41, &v38, v26);
LOBYTE(v35) = 0;
SetupTriggerPopup::createValueControlAdvanced(
a1,
10,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
0,
1,
6,
0,
0,
0x40000000,
0,
0,
1,
2,
v35);
v40 = Block;
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 6;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Speed:");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, -84.5, -35.75);
cocos2d::CCPoint::operator+(v41, &v38, v27);
LOBYTE(v36) = 0;
SetupTriggerPopup::createValueControlAdvanced(
a1,
404,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
0,
2,
6,
0,
-1052770304,
1094713344,
0,
0,
1,
2,
v36);
v40 = Block;
Block[1] = nullptr;
si128.m128i_i64[0] = 7;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x3A656D756C6F56LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, -84.5, -71.5);
cocos2d::CCPoint::operator+(v41, &v38, v28);
LOBYTE(v37) = 0;
SetupTriggerPopup::createValueControlAdvanced(
a1,
406,
(unsigned int)Block,
(unsigned int)&v38,
1059481190,
0,
1,
6,
0,
0,
0x40000000,
0,
0,
1,
2,
v37);
v40 = Block;
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 4;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Stop");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 34.5, -0.0);
cocos2d::CCPoint::operator+(v41, &v38, v29);
SetupTriggerPopup::createToggleValueControl(a1, 417, (unsigned int)Block, (unsigned int)&v38, 0, 0, 0, 1065353216);
v40 = Block;
Block[1] = (void *)112;
si128.m128i_i64[0] = 9;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x6F6F4C0A706F7453LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 114.5, -0.0);
cocos2d::CCPoint::operator+(v41, &v38, v30);
SetupTriggerPopup::createToggleValueControl(a1, 414, (unsigned int)Block, (unsigned int)&v38, 0, 0, 0, 1065353216);
v40 = Block;
si128.m128i_i64[0] = 12;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Change Speed");
BYTE5(Block[1]) = 0;
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 34.5, -35.75);
cocos2d::CCPoint::operator+(v41, &v38, v31);
SetupTriggerPopup::createToggleValueControl(a1, 419, (unsigned int)Block, (unsigned int)&v38, 0, 0, 0, 1065353216);
v40 = Block;
si128.m128i_i64[0] = 13;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Change Volume");
HIWORD(Block[1]) = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v39, 34.5, -71.5);
cocos2d::CCPoint::operator+(v41, &v38, v32);
SetupTriggerPopup::createToggleValueControl(a1, 418, (unsigned int)Block, (unsigned int)&v38, 0, 0, 0, 1065353216);
LODWORD(v38) = 404;
*(_BYTE *)sub_14016EE40(v24, (int *)&v38) = 1;
LODWORD(v38) = 406;
*(_BYTE *)sub_14016EE40(v24, (int *)&v38) = 1;
SetupAudioTriggerPopup::addProxVolControls(a1, 1u);
SetupTriggerPopup::createPageButtons(a1);
SetupTriggerPopup::goToPage(a1, 0, 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1136LL))(a1);
*(_BYTE *)(a1 + 744) = 0;
if ( v52 > 0xF )
{
v33 = v50[0];
if ( v52 + 1 >= 0x1000 )
{
v33 = *((void **)v50[0] - 1);
if ( (unsigned __int64)((char *)v50[0] - (char *)v33 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v33);
}
return 1;
}
return result;
}