//
// SetupPersistentItemTriggerPopup::init from 0x1406062c0 to 0x1406068db (1563 bytes)
//
// 3 xrefs:
// > SetupPersistentItemTriggerPopup::create @ 0x14060627e
// > ??> @ 0x14092f984
// > ??> @ 0x14092f990
//
// 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:12 +0000
//
// Hidden C++ exception states: #wind=4
char __fastcall SetupPersistentItemTriggerPopup::init(_BYTE *a1, int a2, int a3, int a4)
{
char result; // al
int v6; // edi
__int64 v7; // rcx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rdx
void *v11; // rcx
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
void **v16; // [rsp+68h] [rbp-A0h] BYREF
float v17; // [rsp+70h] [rbp-98h] BYREF
float v18; // [rsp+74h] [rbp-94h]
void **v19; // [rsp+78h] [rbp-90h] BYREF
_BYTE v20[8]; // [rsp+80h] [rbp-88h] BYREF
void **v21; // [rsp+88h] [rbp-80h] BYREF
_BYTE v22[8]; // [rsp+90h] [rbp-78h] BYREF
__int128 v23; // [rsp+98h] [rbp-70h] BYREF
__int64 v24; // [rsp+A8h] [rbp-60h]
__int64 v25; // [rsp+B0h] [rbp-58h]
void *Block[2]; // [rsp+B8h] [rbp-50h] BYREF
__m128i si128; // [rsp+C8h] [rbp-40h]
result = SetupTriggerPopup::init((_DWORD)a1, a2, a3, a4, 1130758144, 1, 0);
if ( result )
{
a1[744] = 1;
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1096LL))(a1);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
si128.m128i_i64[0] = 21;
si128.m128i_i64[1] = 31;
strcpy((char *)Block[0], "Persistent Item Setup");
SetupTriggerPopup::addTitle(a1, Block);
*(_OWORD *)Block = 0;
v6 = 2;
si128.m128i_i64[0] = 2;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "OK");
SetupTriggerPopup::addCloseButton(a1, Block);
v16 = Block;
*(_OWORD *)Block = 0;
si128 = 0u;
Block[0] = sub_14003D460(0xE0u);
si128.m128i_i64[0] = 222;
si128.m128i_i64[1] = 223;
strcpy(
(char *)Block[0],
"Lets you set ItemID to be Persistent. This means it does not reset upon player death, but only on "
"level exit.\n"
"TargetAll targets all persistent Item IDs.\n"
"Reset resets the target item(s) to 0.");
v23 = 0;
v24 = 4;
v25 = 15;
strcpy((char *)&v23, "Help");
SetupTriggerPopup::addHelpButton(a1, &v23, Block);
SetupTriggerPopup::createMultiTriggerItemsDefault(a1);
v8 = cocos2d::CCDirector::sharedDirector(v7);
cocos2d::CCDirector::getWinSize(v8, &v17);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v22, v17 * 0.5, v18 * 0.5);
if ( (*(float (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 494) != 0.0 )
v6 = 4;
Block[1] = nullptr;
si128 = _mm_load_si128((const __m128i *)&xmmword_140836580);
Block[0] = (void *)0x4449206D657449LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v19, -40.0, 40.0);
cocos2d::CCPoint::operator+(v22, &v16, v9);
v10 = (__int64)(a1 + 544);
if ( !a1 )
v10 = 0;
IDNameInput::create(
(__int64)a1,
v10,
v6,
80,
(__int64)Block,
(const struct cocos2d::CCPoint *)&v16,
1061997773,
6,
0,
0,
0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v11 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v11);
}
v19 = Block;
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 5;
si128.m128i_i64[1] = 15;
strcpy((char *)Block, "Timer");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v21, 80.0, 40.0);
cocos2d::CCPoint::operator+(v22, &v16, v12);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
494,
(unsigned int)Block,
(unsigned int)&v16,
1,
0,
0,
1065353216);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v20, v17 * 0.5, (float)(v18 * 0.5) - 23.0);
v21 = Block;
Block[1] = (void *)29806;
si128.m128i_i64[0] = 10;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x6574736973726550LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v19, -80.0, 0.0);
cocos2d::CCPoint::operator+(v20, &v16, v13);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
491,
(unsigned int)Block,
(unsigned int)&v16,
1,
0,
0,
1065353216);
v21 = Block;
Block[1] = (void *)108;
si128.m128i_i64[0] = 9;
si128.m128i_i64[1] = 15;
Block[0] = (void *)0x6C41746567726154LL;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v19, 0.0, 0.0);
cocos2d::CCPoint::operator+(v20, &v16, v14);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
492,
(unsigned int)Block,
(unsigned int)&v16,
1,
0,
0,
1065353216);
v21 = Block;
*(_OWORD *)Block = 0;
si128.m128i_i64[0] = 5;
si128.m128i_i64[1] = 15;
LODWORD(Block[0]) = *(_DWORD *)"Reset";
WORD2(Block[0]) = (unsigned __int8)aReset[4];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v19, 80.0, 0.0);
cocos2d::CCPoint::operator+(v20, &v16, v15);
SetupTriggerPopup::createToggleValueControl(
(_DWORD)a1,
493,
(unsigned int)Block,
(unsigned int)&v16,
1,
0,
0,
1065353216);
(*(void (__fastcall **)(_BYTE *))(*(_QWORD *)a1 + 1136LL))(a1);
a1[744] = 0;
return 1;
}
return result;
}