//
// sub_100387984 from 0x100387984 to 0x1003882f0 (2412 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onShop @ 0x1003851ec
//
// 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:03:33 +0000
//
__int64 __fastcall sub_100387984(_DWORD *a1)
{
_QWORD *v2; // x20
int v3; // w0
__int64 Stat; // x0
__int64 v5; // x0
int v6; // w21
int v7; // w8
void *v8; // x0
char *v9; // x0
void *v10; // x0
void *v11; // x0
char *CString; // x0
__int64 v13; // x0
__int64 v14; // x0
int v15; // w8
int v16; // w8
_QWORD *v17; // x20
void *v19[2]; // [xsp+10h] [xbp-3E0h] BYREF
char v20; // [xsp+27h] [xbp-3C9h]
_QWORD v21[2]; // [xsp+28h] [xbp-3C8h] BYREF
char v22; // [xsp+3Fh] [xbp-3B1h]
void *v23[2]; // [xsp+40h] [xbp-3B0h] BYREF
char v24; // [xsp+57h] [xbp-399h]
void *v25[2]; // [xsp+58h] [xbp-398h] BYREF
char v26; // [xsp+6Fh] [xbp-381h]
void *__p[2]; // [xsp+70h] [xbp-380h] BYREF
char v28; // [xsp+87h] [xbp-369h]
void *v29[2]; // [xsp+88h] [xbp-368h] BYREF
char v30; // [xsp+9Fh] [xbp-351h]
void *v31[2]; // [xsp+A0h] [xbp-350h] BYREF
char v32; // [xsp+B7h] [xbp-339h]
void *v33[2]; // [xsp+B8h] [xbp-338h] BYREF
char v34; // [xsp+CFh] [xbp-321h]
void *v35[2]; // [xsp+D0h] [xbp-320h] BYREF
char v36; // [xsp+E7h] [xbp-309h]
void *v37[2]; // [xsp+E8h] [xbp-308h] BYREF
char v38; // [xsp+FFh] [xbp-2F1h]
void *v39[2]; // [xsp+100h] [xbp-2F0h] BYREF
char v40; // [xsp+117h] [xbp-2D9h]
void *v41[2]; // [xsp+118h] [xbp-2D8h] BYREF
char v42; // [xsp+12Fh] [xbp-2C1h]
void *v43[2]; // [xsp+130h] [xbp-2C0h] BYREF
char v44; // [xsp+147h] [xbp-2A9h]
_QWORD v45[2]; // [xsp+148h] [xbp-2A8h] BYREF
char v46; // [xsp+15Fh] [xbp-291h]
void *v47[2]; // [xsp+160h] [xbp-290h] BYREF
char v48; // [xsp+177h] [xbp-279h]
void *v49[2]; // [xsp+178h] [xbp-278h] BYREF
char v50; // [xsp+18Fh] [xbp-261h]
void *v51[2]; // [xsp+190h] [xbp-260h] BYREF
char v52; // [xsp+1A7h] [xbp-249h]
void *v53[2]; // [xsp+1A8h] [xbp-248h] BYREF
char v54; // [xsp+1BFh] [xbp-231h]
void *v55[2]; // [xsp+1C0h] [xbp-230h] BYREF
char v56; // [xsp+1D7h] [xbp-219h]
void *v57[2]; // [xsp+1D8h] [xbp-218h] BYREF
char v58; // [xsp+1EFh] [xbp-201h]
void *v59[2]; // [xsp+1F0h] [xbp-200h] BYREF
char v60; // [xsp+207h] [xbp-1E9h]
_QWORD v61[2]; // [xsp+208h] [xbp-1E8h] BYREF
char v62; // [xsp+21Fh] [xbp-1D1h]
void *v63[2]; // [xsp+220h] [xbp-1D0h] BYREF
char v64; // [xsp+237h] [xbp-1B9h]
void *v65[2]; // [xsp+238h] [xbp-1B8h] BYREF
char v66; // [xsp+24Fh] [xbp-1A1h]
void *v67[2]; // [xsp+250h] [xbp-1A0h] BYREF
char v68; // [xsp+267h] [xbp-189h]
void *v69[2]; // [xsp+268h] [xbp-188h] BYREF
char v70; // [xsp+27Fh] [xbp-171h]
void *v71[2]; // [xsp+280h] [xbp-170h] BYREF
char v72; // [xsp+297h] [xbp-159h]
void *v73[2]; // [xsp+298h] [xbp-158h] BYREF
char v74; // [xsp+2AFh] [xbp-141h]
void *v75[2]; // [xsp+2B0h] [xbp-140h] BYREF
char v76; // [xsp+2C7h] [xbp-129h]
void *v77[2]; // [xsp+2C8h] [xbp-128h] BYREF
char v78; // [xsp+2DFh] [xbp-111h]
void *v79[2]; // [xsp+2E0h] [xbp-110h] BYREF
char v80; // [xsp+2F7h] [xbp-F9h]
void *v81[2]; // [xsp+2F8h] [xbp-F8h] BYREF
char v82; // [xsp+30Fh] [xbp-E1h]
void *v83[2]; // [xsp+310h] [xbp-E0h] BYREF
char v84; // [xsp+327h] [xbp-C9h]
void *v85[2]; // [xsp+328h] [xbp-C8h] BYREF
char v86; // [xsp+33Fh] [xbp-B1h]
void *v87[2]; // [xsp+340h] [xbp-B0h] BYREF
char v88; // [xsp+357h] [xbp-99h]
void *v89[2]; // [xsp+358h] [xbp-98h] BYREF
char v90; // [xsp+36Fh] [xbp-81h]
void *v91[2]; // [xsp+370h] [xbp-80h] BYREF
char v92; // [xsp+387h] [xbp-69h]
void *v93[2]; // [xsp+388h] [xbp-68h] BYREF
char v94; // [xsp+39Fh] [xbp-51h]
void *v95[2]; // [xsp+3A0h] [xbp-50h] BYREF
char v96; // [xsp+3B7h] [xbp-39h]
void *v97[2]; // [xsp+3B8h] [xbp-38h] BYREF
char v98; // [xsp+3CFh] [xbp-21h]
v2 = sub_1002E736C();
v3 = GameStatsManager::sharedState(v2);
Stat = GameStatsManager::getStat(v3, "13");
if ( (int)Stat < 200 || (v5 = GameManager::sharedState(Stat), !(unsigned int)GameManager::getUGV(v5, "21")) )
{
v7 = a1[143];
if ( v7 <= 1 )
{
if ( v7 )
{
if ( v7 != 1 )
goto LABEL_92;
sub_100009900(v69, "Potbor");
sub_100009900(v67, "Let me check the manual.");
DialogObject::create((__int64)v69, (__int64)v67, 24, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v68 < 0 )
operator delete(v67[0]);
if ( v70 < 0 )
operator delete(v69[0]);
sub_100009900(v65, "Potbor");
sub_100009900(v63, "The Shopkeepers handbook: \nYou give stuff, they pay money.");
DialogObject::create((__int64)v65, (__int64)v63, 22, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v64 < 0 )
operator delete(v63[0]);
if ( v66 < 0 )
operator delete(v65[0]);
sub_100009900(v61, "Potbor");
sub_100009900(v59, "... Sounds simple enough.");
DialogObject::create((__int64)v61, (__int64)v59, 23, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v60 < 0 )
operator delete(v59[0]);
if ( (v62 & 0x80000000) == 0 )
goto LABEL_92;
v10 = (void *)v61[0];
}
else
{
sub_100009900(v81, "Potbor");
sub_100009900(v79, "Oh, a customer!");
DialogObject::create((__int64)v81, (__int64)v79, 21, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v80 < 0 )
operator delete(v79[0]);
if ( v82 < 0 )
operator delete(v81[0]);
sub_100009900(v77, "Potbor");
sub_100009900(v75, "I never had a customer before.");
DialogObject::create((__int64)v77, (__int64)v75, 22, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v76 < 0 )
operator delete(v75[0]);
if ( v78 < 0 )
operator delete(v77[0]);
sub_100009900(v73, "Potbor");
sub_100009900(v71, "... Not sure what to do.");
DialogObject::create((__int64)v73, (__int64)v71, 19, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v72 < 0 )
operator delete(v71[0]);
if ( (v74 & 0x80000000) == 0 )
goto LABEL_92;
v10 = v73[0];
}
}
else
{
switch ( v7 )
{
case 2:
sub_100009900(v57, "Potbor");
sub_100009900(v55, "Page 2: Refund policy\nNo refunds!");
DialogObject::create((__int64)v57, (__int64)v55, 25, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v56 < 0 )
operator delete(v55[0]);
if ( v58 < 0 )
operator delete(v57[0]);
sub_100009900(v53, "Potbor");
sub_100009900(
v51,
"Page 3: Shopkeeper etiquette\n... Probably not important.");
DialogObject::create((__int64)v53, (__int64)v51, 20, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v52 < 0 )
operator delete(v51[0]);
if ( v54 < 0 )
operator delete(v53[0]);
sub_100009900(v49, "Potbor");
sub_100009900(v47, "Page 4: Self destruct mechanism\nThe page is missing...");
DialogObject::create((__int64)v49, (__int64)v47, 22, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v48 < 0 )
operator delete(v47[0]);
if ( v50 < 0 )
operator delete(v49[0]);
sub_100009900(v45, "Potbor");
sub_100009900(v43, "Not sure if I should be worried about this.");
DialogObject::create((__int64)v45, (__int64)v43, 23, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v44 < 0 )
operator delete(v43[0]);
if ( (v46 & 0x80000000) == 0 )
goto LABEL_92;
v10 = (void *)v45[0];
break;
case 3:
sub_100009900(v41, "Potbor");
v11 = sub_1003065B0("Page 394: Customer must have %i diamonds.", 200);
CString = (char *)cocos2d::CCString::getCString((__int64)v11);
sub_100009900(v39, CString);
DialogObject::create((__int64)v41, (__int64)v39, 24, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v40 < 0 )
operator delete(v39[0]);
if ( v42 < 0 )
operator delete(v41[0]);
sub_100009900(v37, "Potbor");
sub_100009900(v35, "What's a diamond?");
DialogObject::create((__int64)v37, (__int64)v35, 22, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v36 < 0 )
operator delete(v35[0]);
if ( v38 < 0 )
operator delete(v37[0]);
sub_100009900(v33, "Potbor");
sub_100009900(v31, "...");
DialogObject::create((__int64)v33, (__int64)v31, 20, 0, 0xFFFFFF, 1.0);
v13 = sub_1002E74E0((__int64)v2);
if ( v32 < 0 )
operator delete(v31[0]);
if ( v34 < 0 )
operator delete(v33[0]);
v14 = GameManager::sharedState(v13);
GameManager::setUGV(v14, "21", 1);
goto LABEL_92;
case 4:
sub_100009900(v29, "Potbor");
v8 = sub_1003065B0(
"You must collect %i Diamonds before I can let you in the Shop!",
200);
v9 = (char *)cocos2d::CCString::getCString((__int64)v8);
sub_100009900(__p, v9);
DialogObject::create((__int64)v29, (__int64)__p, 25, 0, 0xFFFFFF, 0.8);
sub_1002E74E0((__int64)v2);
if ( v28 < 0 )
operator delete(__p[0]);
if ( v30 < 0 )
operator delete(v29[0]);
sub_100009900(v25, "Potbor");
sub_100009900(v23, "It says so in the handbook...");
DialogObject::create((__int64)v25, (__int64)v23, 23, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v24 < 0 )
operator delete(v23[0]);
if ( v26 < 0 )
operator delete(v25[0]);
sub_100009900(v21, "Potbor");
sub_100009900(v19, "...");
DialogObject::create((__int64)v21, (__int64)v19, 20, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v20 < 0 )
operator delete(v19[0]);
if ( (v22 & 0x80000000) == 0 )
{
LABEL_92:
v6 = 0;
v15 = a1[143];
if ( v15 <= 3 )
v16 = v15 + 1;
else
v16 = 0;
a1[143] = v16;
goto LABEL_96;
}
v10 = (void *)v21[0];
break;
default:
goto LABEL_92;
}
}
operator delete(v10);
goto LABEL_92;
}
sub_100009900(v97, "Potbor");
sub_100009900(v95, "You found all the diamonds!?");
DialogObject::create((__int64)v97, (__int64)v95, 21, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v96 < 0 )
operator delete(v95[0]);
if ( v98 < 0 )
operator delete(v97[0]);
sub_100009900(v93, "Potbor");
sub_100009900(
v91,
"Just need to check: \n 1, 2, 3, 200. Yup, all there!");
DialogObject::create((__int64)v93, (__int64)v91, 22, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v92 < 0 )
operator delete(v91[0]);
if ( v94 < 0 )
operator delete(v93[0]);
sub_100009900(v89, "Potbor");
sub_100009900(v87, "My first customer, how exciting!");
DialogObject::create((__int64)v89, (__int64)v87, 20, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v88 < 0 )
operator delete(v87[0]);
if ( v90 < 0 )
operator delete(v89[0]);
sub_100009900(v85, "Potbor");
sub_100009900(v83, "...");
DialogObject::create((__int64)v85, (__int64)v83, 19, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v2);
if ( v84 < 0 )
operator delete(v83[0]);
if ( v86 < 0 )
operator delete(v85[0]);
v6 = 1;
LABEL_96:
v17 = DialogLayer::createWithObjects((__int64)v2, 2);
(*(void (__fastcall **)(_DWORD *, _QWORD *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v17, 100);
(*(void (__fastcall **)(_QWORD *, __int64))(*v17 + 72LL))(v17, 2);
if ( v6 )
v17[78] = a1 + 102;
DialogLayer::updateChatPlacement((__int64)v17, 0);
return DialogLayer::animateInRandomSide((__int64)v17);
}