//
// MenuGameLayer::init from 0x140331420 to 0x140331b46 (1830 bytes)
//
// 4 xrefs:
// > MenuLayer::init @ 0x140333c79
// > MenuLayer::init @ 0x140333c6a
// > ??> @ 0x1405aa7a0
// > ??> @ 0x1406d5060
//
// 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=21
bool MenuGameLayer::init(MenuGameLayer *a1)
{
bool result; // al
_BOOL8 v3; // rdx
__int64 v4; // rcx
cocos2d::CCDirector *v5; // rax
GameManager *v6; // r8
GameManager *v7; // rbx
int m_loadedBgID; // ecx
int v9; // ebx
cocos2d::CCString *v10; // rax
const char *CString; // rax
struct cocos2d::CCSprite *v12; // rax
cocos2d::CCTexture2D *v13; // rax
float v14; // xmm0_4
cocos2d::CCSprite_vtbl *v15; // rbx
const cocos2d::CCPoint *v16; // rax
__int64 v17; // rdx
__int64 v18; // rcx
__int64 v19; // rcx
cocos2d::CCDirector *v20; // rax
float v21; // xmm0_4
float width; // xmm1_4
__int64 v23; // rcx
GJGroundLayer *v24; // rax
float v25; // xmm0_4
GJGroundLayer_vtbl *v26; // rbx
const cocos2d::CCPoint *v27; // rax
__int64 v28; // rbx
int v29; // esi
char v30; // r15
float v31; // xmm0_4
__int64 v32; // rax
PlayerObject *v33; // rax
PlayerObject_vtbl *v34; // rbx
const cocos2d::CCPoint *v35; // rax
cocos2d::ccColor3B *v36; // r14
cocos2d::CCRGBAProtocol_vtbl *v37; // rbx
int v38; // eax
cocos2d::ccColor3B *v39; // rax
cocos2d::ccColor3B *v40; // rbx
int v41; // eax
cocos2d::ccColor3B *v42; // rax
__int64 v43; // rbx
float v44; // xmm0_4
__int64 v45; // rax
PlayerObject *m_playerObject; // rbx
HardStreak *m_waveTrail; // rbx
__int16 v48; // [rsp+38h] [rbp-19h] BYREF
__int16 v49; // [rsp+3Ch] [rbp-15h] BYREF
char v50; // [rsp+3Eh] [rbp-13h]
void *v51; // [rsp+40h] [rbp-11h]
void *v52; // [rsp+48h] [rbp-9h]
char v53; // [rsp+50h] [rbp-1h] BYREF
cocos2d::CCRect v54; // [rsp+58h] [rbp+7h] BYREF
struct cocos2d::_ccTexParams v55; // [rsp+70h] [rbp+1Fh] BYREF
result = cocos2d::CCLayer::init(a1);
if ( result )
{
LOBYTE(v3) = 1;
a1->setTouchEnabled(a1, v3);
v5 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v4);
cocos2d::CCDirector::getWinSize(v5);
v6 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v52 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (GameManager *)qword_1406C2ED8;
}
v7 = v6;
if ( !v6 )
{
v52 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (GameManager *)qword_1406C2ED8;
}
m_loadedBgID = 59;
if ( v7->m_loadedBgID < 59 )
m_loadedBgID = v7->m_loadedBgID;
v9 = 1;
if ( m_loadedBgID > 1 )
v9 = m_loadedBgID;
GameManager::loadBackground(v6, v9);
v10 = cocos2d::CCString::createWithFormat("game_bg_%02d_001.png", v9);
CString = cocos2d::CCString::getCString(v10);
v12 = cocos2d::CCSprite::create(CString);
a1->m_backgroundSprite = v12;
v55.minFilter = 9729;
v55.magFilter = 9729;
v55.wrapS = 10497;
v55.wrapT = 10497;
v13 = v12->getTexture(&v12->cocos2d::CCTextureProtocol);
cocos2d::CCTexture2D::setTexParameters(v13, &v55);
v14 = ((float (__fastcall *)(MenuGameLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(
a1,
a1->m_backgroundSprite,
4294967196LL);
v15 = a1->m_backgroundSprite->__vftable;
cocos2d::CCPoint::CCPoint(v14, 0.0);
v15->setAnchorPoint(a1->m_backgroundSprite, v16);
cocos2d::CCApplication::sharedApplication(v18, v17);
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v19);
cocos2d::CCDirector::getScreenScaleFactorMax(v20);
((void (__fastcall *)(cocos2d::CCSprite *))a1->m_backgroundSprite->setScale_0)(a1->m_backgroundSprite);
v48 = 26112;
v49 = 26112;
v50 = -1;
++a1->m_initCount;
a1->m_backgroundSprite->setColor(&a1->m_backgroundSprite->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v49);
cocos2d::CCRect::CCRect(&v54, &a1->m_backgroundSprite->m_obRect);
v21 = a1->m_backgroundSprite->getScale(a1->m_backgroundSprite);
width = v54.size.width;
a1->m_backgroundWrapPosition = v21 * v54.size.width;
v54.size.width = width * 2.0;
a1->m_backgroundSprite->setTextureRect_0(a1->m_backgroundSprite, &v54);
v23 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v52 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = qword_1406C2ED8;
}
v24 = GJGroundLayer::create(*(_DWORD *)(v23 + 964), 1);
a1->m_groundLayer = v24;
v25 = ((float (__fastcall *)(MenuGameLayer *, GJGroundLayer *, __int64))a1->addChild_0)(a1, v24, 100);
v26 = a1->m_groundLayer->__vftable;
cocos2d::CCPoint::CCPoint(v25, 0.0);
v26->setPosition_0(a1->m_groundLayer, v27);
v28 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v28 = qword_1406C2ED8;
}
v29 = *(_DWORD *)(v28 + 840) - *(_DWORD *)(v28 + 844);
v30 = *(_BYTE *)(v28 + 904);
*(_DWORD *)(v28 + 848) = 1;
v31 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v28 + 844) = (int)v31;
*(_DWORD *)(v28 + 840) = (int)v31 + 1;
v32 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v32 = qword_1406C2ED8;
}
*(_BYTE *)(v32 + 904) = 0;
v33 = PlayerObject::create(1, 1, nullptr, a1, 0);
a1->m_playerObject = v33;
a1->addChild_0(a1, v33, 60);
PlayerObject::addAllParticles(a1->m_playerObject);
v34 = a1->m_playerObject->__vftable;
cocos2d::CCPoint::CCPoint(v31, 0.0);
v34->setPosition_0(a1->m_playerObject, v35);
v36 = (cocos2d::ccColor3B *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v52 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v36 = (cocos2d::ccColor3B *)qword_1406C2ED8;
}
v37 = a1->m_playerObject->__vftable;
v38 = rand();
v39 = GameManager::colorForIdx(v36, (GameManager *)&v48, (int)(float)((float)((float)v38 / 32767.0) * 108.0));
v37->setColor(&a1->m_playerObject->cocos2d::CCRGBAProtocol, v39);
v40 = (cocos2d::ccColor3B *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v40 = (cocos2d::ccColor3B *)qword_1406C2ED8;
}
v41 = rand();
v42 = GameManager::colorForIdx(v40, (GameManager *)&v53, (int)(float)((float)((float)v41 / 32767.0) * 108.0));
PlayerObject::setSecondColor(a1->m_playerObject, v42);
PlayerObject::updateGlowColor(a1->m_playerObject);
a1->m_playerObject->m_audioScale = 0.5;
v43 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v43 = qword_1406C2ED8;
}
if ( !*(_BYTE *)(v43 + 1060) )
{
*(_BYTE *)(v43 + 1060) = 1;
PlayerObject::toggleDartMode(a1->m_playerObject, 1, 0);
PlayerObject::toggleDartMode(a1->m_playerObject, 0, 0);
v43 = qword_1406C2ED8;
}
if ( !v43 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v43 = qword_1406C2ED8;
}
*(_DWORD *)(v43 + 848) = v29;
v44 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v43 + 844) = (int)v44;
*(_DWORD *)(v43 + 840) = v29 + (int)v44;
v45 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v51 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v45 = qword_1406C2ED8;
}
*(_BYTE *)(v45 + 904) = v30;
cocos2d::CCNode::scheduleUpdate(a1);
cocos2d::CCNode::schedule(a1, MenuGameLayer::tryJump);
cocos2d::CCNode::schedule(a1, MenuGameLayer::updateColor);
MenuGameLayer::updateColor(a1, 0.0);
m_playerObject = a1->m_playerObject;
cocos2d::CCNode::stopActionByTag(m_playerObject->m_waveTrail, 8);
m_playerObject->m_waveTrail->setOpacity(&m_playerObject->m_waveTrail->cocos2d::CCRGBAProtocol, 0);
m_waveTrail = m_playerObject->m_waveTrail;
cocos2d::CCNode::unschedule(m_waveTrail, HardStreak::updateStroke);
m_waveTrail->m_drawStreak = 0;
cocos2d::CCDrawNode::clear(m_waveTrail);
cocos2d::CCArray::removeAllObjects(m_waveTrail->m_pointArray);
MenuGameLayer::resetPlayer(a1);
return 1;
}
return result;
}