//
// PurchaseItemPopup::init from 0x1001cc484 to 0x1001cccc0 (2108 bytes)
//
// 1 xrefs:
// > PurchaseItemPopup::create @ 0x1001cacf4
//
// This function is hookable on this platform (idp: arm, 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:00:20 +0000
//
__int64 __fastcall PurchaseItemPopup::init(_QWORD *a1, __int64 a2)
{
__int64 v4; // x19
__n128 v5; // q0
__int64 v6; // x0
__int64 v7; // x0
void *v8; // x0
__int64 v9; // x21
float v10; // s8
__int64 v11; // x21
int *v12; // x8
__int64 v13; // x21
__int64 v14; // x22
__int64 v15; // x24
int v16; // w8
bool v17; // zf
int v18; // w27
float v19; // s11
unsigned __int64 v20; // x8
char *v21; // x1
__int64 v22; // x0
const std::string::value_type *CString; // x0
std::string *v24; // x1
void *v25; // x23
__int64 v26; // x0
__int64 v27; // x0
__int64 v28; // x23
void *v29; // x0
__int64 v30; // x24
void *v31; // x0
__int64 v32; // x24
__n128 v33; // q0
__int64 v34; // x24
__int64 v35; // kr00_8
__int64 v36; // x0
__n128 v37; // q0
const std::string::value_type *v38; // x1
std::string::size_type size; // x9
char v40; // w8
__int64 v41; // x21
__int64 v42; // x20
__n128 v43; // q0
float v45; // [xsp+18h] [xbp-178h] BYREF
std::string v46; // [xsp+20h] [xbp-170h] BYREF
void *v47[2]; // [xsp+40h] [xbp-150h] BYREF
__int64 v48; // [xsp+50h] [xbp-140h]
std::string v49; // [xsp+60h] [xbp-130h] BYREF
__int64 v50; // [xsp+78h] [xbp-118h] BYREF
void *__p[2]; // [xsp+80h] [xbp-110h] BYREF
char v52; // [xsp+97h] [xbp-F9h]
std::string v53; // [xsp+98h] [xbp-F8h] BYREF
void *v54; // [xsp+B0h] [xbp-E0h] BYREF
char v55; // [xsp+C7h] [xbp-C9h]
void *v56[2]; // [xsp+C8h] [xbp-C8h] BYREF
__int64 v57; // [xsp+D8h] [xbp-B8h]
__int128 __dst; // [xsp+E0h] [xbp-B0h] BYREF
__int64 v59; // [xsp+F0h] [xbp-A0h]
__int128 v60; // [xsp+100h] [xbp-90h] BYREF
__int64 v61; // [xsp+110h] [xbp-80h]
__int64 v62; // [xsp+118h] [xbp-78h] BYREF
LODWORD(v60) = 1258291200;
v4 = cocos2d::CCLayerColor::initWithColor((__int64)a1, (__int64)&v60);
if ( !(_DWORD)v4 )
return v4;
a1[83] = a2;
cocos2d::CCObject::retain(a2);
FLAlertLayer::incrementForcePrio(a1, v5);
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 1000LL))(a1, 1);
v6 = (*(__int64 (__fastcall **)(_QWORD *, __int64))(*a1 + 1072LL))(a1, 1);
v7 = cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(&v62, v7);
v8 = cocos2d::CCLayer::create();
a1[73] = v8;
(*(void (__fastcall **)(_QWORD *, void *))(*a1 + 456LL))(a1, v8);
sub_1000262CC((float *)&v60, 0.0, 0.0, 80.0, 80.0);
v9 = cocos2d::extension::CCScale9Sprite::create("GJ_square02.png", &v60);
if ( *(_DWORD *)(a1[83] + 340LL) - *(_DWORD *)(a1[83] + 344LL) == 11 )
v10 = 280.0;
else
v10 = 260.0;
sub_1000262C4((float *)&v60, v10, 190.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v9 + 320LL))(v9, &v60);
(*(void (__fastcall **)(_QWORD, __int64, __int64))(*(_QWORD *)a1[73] + 464LL))(a1[73], v9, 0xFFFFFFFFLL);
sub_1000262BC((float *)&v60, *(float *)&v62 * 0.5, *((float *)&v62 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v9 + 184LL))(v9, &v60);
v11 = cocos2d::CCLabelBMFont::create_1("Buy Item", "bigFont.fnt");
sub_1000262BC((float *)&v60, *(float *)&v62 * 0.5, (float)((float)(*((float *)&v62 + 1) * 0.5) + 95.0) + -16.0);
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v11 + 184LL))(v11, &v60);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[73] + 456LL))(a1[73], v11);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v11 + 160LL))(v11, 0.6);
v12 = (int *)a1[83];
v13 = v12[82] - (__int64)v12[83];
v14 = (unsigned int)(v12[85] - v12[86]);
v15 = sub_1003A46B0(v14, v13, 0, 0xFFFFFF);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v15 + 160LL))(v15, 1.2);
if ( (_DWORD)v14 == 6 )
v16 = -8;
else
v16 = 0;
v17 = (unsigned int)(v13 - 6) < 0xA && (_DWORD)v14 == 12;
v18 = v17;
if ( v17 )
v19 = flt_100761098[v13 - 6];
else
v19 = (float)v16;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(*(_QWORD *)a1[73] + 464LL))(a1[73], v15, 1);
sub_1000262BC((float *)&v60, *(float *)&v62 * 0.5, v19 + (float)((float)(*((float *)&v62 + 1) * 0.5) + 22.0));
(*(void (__fastcall **)(__int64, __int128 *))(*(_QWORD *)v15 + 184LL))(v15, &v60);
sub_1003A5F50(&v60, v13, v14);
if ( SHIBYTE(v61) < 0 )
{
sub_1000097D0(&__dst, (void *)v60, *((unsigned __int64 *)&v60 + 1));
}
else
{
__dst = v60;
v59 = v61;
}
v20 = HIBYTE(v59);
if ( v59 < 0 )
v20 = *((_QWORD *)&__dst + 1);
if ( v20 >= 8 )
{
std::operator+(v56, "\n", &__dst);
if ( SHIBYTE(v59) < 0 )
operator delete((void *)__dst);
__dst = *(_OWORD *)v56;
v59 = v57;
}
if ( *(_DWORD *)(a2 + 364) == 4 )
v21 = "Diamond Shards";
else
v21 = "Mana Orbs";
sub_100009900(v56, v21);
GameToolbox::pointsToString((unsigned int)(*(_DWORD *)(a1[83] + 352LL) - *(_DWORD *)(a1[83] + 356LL)), (__int64)&v54);
sub_100009900(&v53, "");
if ( v18 )
v22 = sub_1003065B0("Do you want to unlock%s\nfor %s %s?");
else
v22 = sub_1003065B0("Do you want to buy this %s\nfor %s %s?");
CString = (const std::string::value_type *)cocos2d::CCString::getCString(v22);
std::string::assign(&v53, CString);
if ( (v53.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v24 = &v53;
else
v24 = (std::string *)v53.__r_.__value_.__r.__words[0];
sub_100009900(__p, (char *)v24);
sub_1000262BC((float *)&v49, 0.5, 1.0);
v25 = TextArea::create((__int64)__p, (__int64)"bigFont.fnt", (double *)&v49, 0, 0, 1.0, 999.0, 35.0);
if ( v52 < 0 )
operator delete(__p[0]);
(*(void (__fastcall **)(void *, float))(*(_QWORD *)v25 + 160LL))(v25, 0.4);
(*(void (__fastcall **)(_QWORD, void *))(*(_QWORD *)a1[73] + 456LL))(a1[73], v25);
sub_1000262BC((float *)&v49, *(float *)&v62 * 0.5, (float)(*((float *)&v62 + 1) * 0.5) + -20.0);
v26 = (*(__int64 (__fastcall **)(void *, std::string *))(*(_QWORD *)v25 + 184LL))(v25, &v49);
*((_DWORD *)a1 + 160) = -1;
a1[69] = cocos2d::CCMenu::create(v26);
v27 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)a1[73] + 464LL))(a1[73]);
v28 = sub_1002E736C(v27);
v29 = ButtonSprite::create_1(
(__int64)"Cancel",
50,
0,
1,
(__int64)"bigFont.fnt",
(__int64)"GJ_button_06.png",
0.6,
30.0);
v30 = CCMenuItemSpriteExtra::create(v29, 0, a1, PurchaseItemPopup::onClose, 0);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[69] + 456LL))(a1[69], v30);
sub_1002E74E0(v28, v30);
v31 = ButtonSprite::create_1((__int64)"Buy", 50, 0, 1, (__int64)"bigFont.fnt", (__int64)"GJ_button_01.png", 0.6, 30.0);
v32 = CCMenuItemSpriteExtra::create(v31, 0, a1, PurchaseItemPopup::onPurchase, 0);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[69] + 456LL))(a1[69], v32);
v33 = sub_1002E74E0(v28, v32);
v34 = a1[69];
v35 = v62;
v36 = (*(__int64 (__fastcall **)(_QWORD, __n128))(*(_QWORD *)a1[73] + 192LL))(a1[73], v33);
sub_1000262BC(
(float *)&v50,
*(float *)&v35 * 0.5,
(float)((float)((float)(*((float *)&v35 + 1) * 0.5) + -95.0) + 22.0) + *(float *)(v36 + 4));
cocos2d::CCNode::convertToNodeSpace(&v49, v34, &v50, v37);
GameToolbox::alignItemsHorisontally(v28, (float32x2_t *)&v49, 0, 15.0);
if ( (_DWORD)v14 == 12 )
{
memset(&v49, 0, sizeof(v49));
if ( (_DWORD)v13 == 16 )
{
v38 = "This item lets you customize Practice and Menu music.\n"
"After purchasing this item you will be able to change practice and menu music from the more info page on custom songs.";
}
else if ( (_DWORD)v13 == 17 )
{
v38 = "This item lets you play\n"
"Normal mode music in sync in Practice mode.\n"
"After purchasing this item you will be able to toggle the option in the game menu.";
}
else
{
if ( (unsigned int)(v13 - 6) > 9 )
goto LABEL_45;
v38 = "When you activate a path, Stars and Moons you collect will level up your Path.\n"
"You can unlock multiple paths, but only one can be active at a time.";
}
std::string::assign(&v49, v38);
LABEL_45:
size = HIBYTE(v49.__r_.__value_.__r.__words[2]);
v40 = HIBYTE(v49.__r_.__value_.__r.__words[2]);
if ( (v49.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = v49.__r_.__value_.__l.__size_;
if ( !size )
goto LABEL_58;
if ( SHIBYTE(v61) < 0 )
{
sub_1000097D0(v47, (void *)v60, *((unsigned __int64 *)&v60 + 1));
if ( (*((_BYTE *)&v49.__r_.__value_.__s + 23) & 0x80) == 0 )
goto LABEL_50;
}
else
{
*(_OWORD *)v47 = v60;
v48 = v61;
if ( (*((_BYTE *)&v49.__r_.__value_.__s + 23) & 0x80) == 0 )
{
LABEL_50:
v46 = v49;
LABEL_53:
v41 = InfoAlertButton::create(v47, &v46, 1.0);
if ( SHIBYTE(v46.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v46.__r_.__value_.__l.__data_);
if ( SHIBYTE(v48) < 0 )
operator delete(v47[0]);
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)a1[69] + 456LL))(a1[69], v41);
v42 = a1[69];
sub_1000262BC(
&v45,
(float)((float)(v10 * 0.5) + (float)(*(float *)&v62 * 0.5)) + -20.0,
(float)((float)(*((float *)&v62 + 1) * 0.5) + 95.0) + -18.0);
cocos2d::CCNode::convertToNodeSpace(&v50, v42, &v45, v43);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v41 + 184LL))(v41, &v50);
v40 = HIBYTE(v49.__r_.__value_.__r.__words[2]);
LABEL_58:
if ( v40 < 0 )
operator delete(v49.__r_.__value_.__l.__data_);
goto LABEL_60;
}
}
sub_1000097D0(&v46, v49.__r_.__value_.__l.__data_, v49.__r_.__value_.__l.__size_);
goto LABEL_53;
}
LABEL_60:
if ( SHIBYTE(v53.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v53.__r_.__value_.__l.__data_);
if ( v55 < 0 )
operator delete(v54);
if ( SHIBYTE(v57) < 0 )
operator delete(v56[0]);
if ( SHIBYTE(v59) < 0 )
operator delete((void *)__dst);
if ( SHIBYTE(v61) < 0 )
operator delete((void *)v60);
return v4;
}