//
// LevelPage::onPlay from 0x14031d880 to 0x14031dc10 (912 bytes)
//
// 3 xrefs:
// > LevelSelectLayer::keyDown @ 0x140319b98
// > LevelPage::init @ 0x140319eb0
// > ??> @ 0x1406d4b44
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=7
void LevelPage::onPlay(LevelPage *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // rcx
int Stat; // eax
GJGameLevel *m_level; // rcx
int m_requiredCoins; // edx
cocos2d::CCString *v7; // rax
const char *CString; // rax
size_t v9; // rbx
size_t v10; // r8
void **v11; // rdx
__int64 v12; // rax
FLAlertLayer *v13; // rbx
void *v14; // rcx
__int64 v15; // rbx
__int64 v16; // r8
__int64 v17; // r9
int v18; // ecx
__int64 v19; // rbx
struct cocos2d::CCDelayTime *v20; // rax
struct cocos2d::CCSequence *v21; // rax
cocos2d::ccColor3B *v22; // r8
float v23; // [rsp+20h] [rbp-59h]
void *v24; // [rsp+50h] [rbp-29h]
FMODAudioEngine *v25; // [rsp+50h] [rbp-29h]
__int128 v26; // [rsp+58h] [rbp-21h] BYREF
__int64 v27; // [rsp+68h] [rbp-11h]
__int64 v28; // [rsp+70h] [rbp-9h]
FMODAudioEngine *v29; // [rsp+78h] [rbp-1h]
_BYTE v30[32]; // [rsp+80h] [rbp+7h] BYREF
void *Block[2]; // [rsp+A0h] [rbp+27h] BYREF
__int64 v32; // [rsp+B0h] [rbp+37h]
unsigned __int64 v33; // [rsp+B8h] [rbp+3Fh]
if ( a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed != -1 )
{
v3 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v24 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v3 = (GameStatsManager *)qword_1406C2EE8;
}
Stat = GameStatsManager::getStat(v3, "8");
m_level = a1->m_level;
if ( m_level->m_levelID.random - m_level->m_levelID.seed == -2 )
{
LevelPage::onTheTower(a1, nullptr);
}
else
{
m_requiredCoins = m_level->m_requiredCoins;
if ( m_requiredCoins <= Stat )
{
if ( !a1->m_isBusy )
{
a1->m_isBusy = 1;
byte_1406C10B8 = 1;
v15 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v29 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v15 = qword_1406C2E88;
}
if ( *(_QWORD *)(v15 + 552) )
FMOD::ChannelControl::stop(*(FMOD::ChannelControl **)(v15 + 552));
sub_14005E0D0((_QWORD *)(v15 + 1064));
sub_14005E0D0((_QWORD *)(v15 + 1128));
sub_14005E0D0((_QWORD *)(v15 + 1192));
v29 = (FMODAudioEngine *)&v26;
v26 = 0;
v27 = 0;
v28 = 15;
*(_QWORD *)&v26 = sub_14003AA10(0x20u);
v27 = 16;
v28 = 31;
strcpy((char *)v26, "playSound_01.ogg");
v18 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v25 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v18 = qword_1406C2E88;
}
FMODAudioEngine::playEffect(v18, (__int64)&v26, v16, v17, 1050253722);
v19 = cocos2d::CCCallFunc::create(a1, LevelPage::playStep2);
v20 = cocos2d::CCDelayTime::create(0.0);
v21 = cocos2d::CCSequence::create(v20, v19, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v21, v22, 0.0, v23);
}
}
else
{
v7 = cocos2d::CCString::createWithFormat(
"Collect %i more Secret Coins to unlock this level!",
m_requiredCoins - Stat);
CString = cocos2d::CCString::getCString(v7);
*(_OWORD *)Block = 0;
v32 = 0;
v33 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003A930(Block, CString, v10);
v11 = Block;
if ( v33 > 0xF )
v11 = (void **)Block[0];
v26 = 0;
v27 = 0;
v28 = 0;
do
++v9;
while ( *((_BYTE *)v11 + v9) );
sub_14003A930(&v26, v11, v9);
v12 = sub_14003BDB0((__int64)v30, (__int64)&v26);
v13 = FLAlertLayer::create(0, (int)"Locked", v12, (__int64)"OK", 0, 1133903872, 0, 0, 1065353216);
sub_14003A830((__int64)&v26);
v13->show(v13);
if ( v33 > 0xF )
{
v14 = Block[0];
if ( v33 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
}
}
}
}