//
// LevelPage::onPlay from 0x100434980 to 0x100434c39 (697 bytes)
//
// 3 xrefs:
// > LevelSelectLayer::keyDown @ 0x100434840
// > LevelSelectLayer::onPlay @ 0x100434954
// > LevelPage::init @ 0x10043559f
//
// 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
//
void __fastcall LevelPage::onPlay(LevelPage *a1, cocos2d::CCObject *a2)
{
double v2; // xmm0_8
GameStatsManager *v3; // rax
int Stat; // eax
GJGameLevel *m_level; // rcx
cocos2d::CCString *v6; // rax
const char *CString; // r14
size_t v8; // rax
size_t v9; // rbx
char *v10; // r15
char *v11; // rbx
FMODAudioEngine *v12; // rax
FMODAudioEngine *v13; // rax
cocos2d::CCDelayTime *v14; // r14
cocos2d::CCCallFunc *v15; // rax
cocos2d::CCSequence *v16; // rax
size_t v17; // r12
size_t v18; // rax
size_t v19; // r14
char *v20; // r15
size_t v21; // r12
__int64 v22; // rbx
char v23; // [rsp+0h] [rbp-70h]
void *v24[3]; // [rsp+8h] [rbp-68h] BYREF
_QWORD v25[2]; // [rsp+20h] [rbp-50h] BYREF
void *v26; // [rsp+30h] [rbp-40h]
_QWORD __dst[2]; // [rsp+38h] [rbp-38h] BYREF
char *__s; // [rsp+48h] [rbp-28h]
if ( a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed == -1 )
return;
v3 = GameStatsManager::sharedState();
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, (cocos2d::CCObject *)"8");
return;
}
if ( m_level->m_requiredCoins > Stat )
{
v6 = (cocos2d::CCString *)sub_1007AB580("Collect %i more Secret Coins to unlock this level!", v23);
CString = cocos2d::CCString::getCString(v6);
v8 = strlen(CString);
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v9 = v8;
if ( v8 >= 0x17 )
{
v17 = 26;
if ( (v8 | 7) != 0x17 )
v17 = (v8 | 7) + 1;
v10 = (char *)operator new(v17);
__s = v10;
__dst[0] = v17 + 1;
__dst[1] = v9;
}
else
{
LOBYTE(__dst[0]) = 2 * v8;
v10 = (char *)__dst + 1;
if ( !v8 )
{
BYTE1(__dst[0]) = 0;
if ( (__dst[0] & 1) != 0 )
{
LABEL_9:
v11 = __s;
goto LABEL_19;
}
LABEL_18:
v11 = (char *)__dst + 1;
LABEL_19:
v18 = strlen(v11);
if ( v18 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v19 = v18;
if ( v18 >= 0x17 )
{
v21 = 26;
if ( (v18 | 7) != 0x17 )
v21 = (v18 | 7) + 1;
v20 = (char *)operator new(v21);
v26 = v20;
v25[0] = v21 | 1;
v25[1] = v19;
}
else
{
LOBYTE(v25[0]) = 2 * v18;
v20 = (char *)v25 + 1;
if ( !v18 )
goto LABEL_27;
}
memmove(v20, v11, v19);
LABEL_27:
v20[v19] = 0;
v22 = FLAlertLayer::create_1(0, "Locked", v25, "OK", 0, 300.0);
if ( (v25[0] & 1) != 0 )
operator delete(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v22 + 1288LL))(v22);
if ( (__dst[0] & 1) != 0 )
operator delete(__s);
return;
}
}
memmove(v10, CString, v9);
v10[v9] = 0;
if ( (__dst[0] & 1) != 0 )
goto LABEL_9;
goto LABEL_18;
}
if ( !a1->m_isBusy )
{
a1->m_isBusy = 1;
byte_1009A4F9C = 1;
v12 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllMusic(v12, 1);
v13 = FMODAudioEngine::sharedEngine();
strcpy((char *)v24, " playSound_01.ogg");
FMODAudioEngine::playEffect((__int64)v13, (__int64)v24, (__m128)0x3F800000u, 0.0, 0.30000001);
if ( ((__int64)v24[0] & 1) != 0 )
operator delete(v24[2]);
v14 = cocos2d::CCDelayTime::create(0.0);
v15 = cocos2d::CCCallFunc::create(a1, (cocos2d::SEL_CallFunc)(unsigned __int64)LevelPage::playStep2);
v16 = sub_1003B5760(v14, v15, 0);
cocos2d::CCNode::runAction(a1, v16);
}
}