//
// PlayLayer::init from 0x1403a5b00 to 0x1403a66ce (3022 bytes)
//
// 2 xrefs:
// > PlayLayer::scene @ 0x1403a5aaf
// > ??> @ 0x1406d6b48
//
// 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=25
bool PlayLayer::init(PlayLayer *a1, GJGameLevel *a2, bool a3, bool a4)
{
bool v4; // r15
bool result; // al
__int64 v8; // rcx
__int64 v9; // rax
GameManager *v10; // rcx
__int64 v11; // rcx
cocos2d::CCEGLView *v12; // rax
GameManager *v13; // rcx
__int64 v14; // rcx
cocos2d::CCEGLView *v15; // rax
GameManager *v16; // rcx
bool GameVariable; // al
GameManager *v18; // rcx
GameManager *v19; // rcx
bool m_lowDetailModeToggled; // al
__int64 v21; // rbx
char v22; // r14
GJLevelType m_levelType; // eax
bool v24; // al
__int64 v25; // rdx
__int64 v26; // rcx
__int64 v27; // rdx
__int64 v28; // rcx
cocos2d::CCArray *v29; // rax
__int64 v30; // rcx
int v31; // edi
GravityEffectSprite *v32; // rbx
cocos2d::CCArray *v33; // rax
__int64 v34; // rcx
__int64 v35; // rax
cocos2d::CCDictionary *v36; // rax
__int64 v37; // rcx
cocos2d::CCDirector *v38; // rax
__int64 v39; // rcx
cocos2d::CCArray *v40; // rax
__int64 v41; // rcx
cocos2d::CCArray *v42; // rax
__int64 v43; // rcx
cocos2d::CCArray *v44; // rax
__int64 v45; // rcx
cocos2d::CCArray *v46; // rax
int v47; // eax
float v48; // xmm0_4
float v49; // xmm0_4
float v50; // xmm0_4
cocos2d::CCParticleSystemQuad *v51; // rax
cocos2d::CCParticleSystemQuad_vtbl *v52; // rbx
__int64 v53; // rcx
cocos2d::CCDirector *v54; // rax
__int64 v55; // rcx
cocos2d::CCDirector *v56; // rax
float v57; // xmm0_4
const cocos2d::CCPoint *v58; // rax
__int64 v59; // rcx
cocos2d::CCDrawNode *v60; // rax
GameManager *v61; // rcx
struct cocos2d::CCLabelBMFont *v62; // rax
__int64 v63; // rdx
float v64; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v65; // rbx
const cocos2d::CCPoint *v66; // rax
cocos2d::CCLabelBMFont_vtbl *v67; // rbx
__int64 v68; // rcx
cocos2d::CCDirector *v69; // rax
float v70; // xmm0_4
const cocos2d::CCPoint *v71; // rax
GameManager *v72; // rcx
bool v73; // al
_QWORD *v74; // rdx
size_t v75; // r8
void *v76; // rcx
GJGameLevel *m_level; // rcx
GJLevelType v78; // eax
__int64 v79; // rax
bool v80; // al
struct cocos2d::CCLabelBMFont *v81; // rdi
float v82; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v83; // rbx
const cocos2d::CCPoint *v84; // rax
void *v85; // [rsp+28h] [rbp-99h]
void *v86; // [rsp+28h] [rbp-99h]
void *v87; // [rsp+28h] [rbp-99h]
void *v88; // [rsp+28h] [rbp-99h]
void *v89; // [rsp+28h] [rbp-99h]
void *v90; // [rsp+28h] [rbp-99h]
void *v91; // [rsp+28h] [rbp-99h]
void *v92; // [rsp+28h] [rbp-99h]
void *v93; // [rsp+28h] [rbp-99h]
void *v94; // [rsp+28h] [rbp-99h]
void *v95; // [rsp+28h] [rbp-99h]
void *v96; // [rsp+28h] [rbp-99h]
struct cocos2d::_ccBlendFunc v98; // [rsp+38h] [rbp-89h] BYREF
float v99; // [rsp+40h] [rbp-81h]
void *Block[2]; // [rsp+48h] [rbp-79h] BYREF
__int64 v101; // [rsp+58h] [rbp-69h]
unsigned __int64 v102; // [rsp+60h] [rbp-61h]
_QWORD v103[4]; // [rsp+68h] [rbp-59h] BYREF
_BYTE v104[16]; // [rsp+88h] [rbp-39h] BYREF
__int64 v105; // [rsp+98h] [rbp-29h]
v4 = a4;
result = GJBaseGameLayer::init(a1);
if ( !result )
return result;
a1->m_level = a2;
cocos2d::CCObject::retain(a2);
v9 = cocos2d::CCDirector::sharedDirector(v8);
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 176LL))(v9) + 92) = 1;
*(_BYTE *)(((__int64 (*)(void))cocos2d::CCEGLView::sharedOpenGLView)() + 237) = 1;
v10 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v85 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v85);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v10, "0128") )
{
v12 = (cocos2d::CCEGLView *)cocos2d::CCEGLView::sharedOpenGLView(v11);
cocos2d::CCEGLView::toggleLockCursor(v12, 1);
}
else
{
v13 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v86 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v86);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v13 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v13, "0024") )
{
v15 = (cocos2d::CCEGLView *)cocos2d::CCEGLView::sharedOpenGLView(v14);
cocos2d::CCEGLView::showCursor(v15, 0);
}
}
a1->toggleMusicInPractice(a1);
v16 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v87 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = (GameManager *)qword_1406C2ED8;
}
v16->m_somethingInMenuLayer = 1;
a1->m_damageVerified = 0;
a1->m_nextColorKey = 1;
a1->m_unk376d = 0;
if ( a1->m_level->m_disableShakeToggled
|| (GameVariable = GameManager::getGameVariable(v16, "0172"), v16 = (GameManager *)qword_1406C2ED8, GameVariable) )
{
GameVariable = 1;
}
a1->m_skipCameraShake = GameVariable;
if ( !v16 )
{
v88 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v88);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = (GameManager *)qword_1406C2ED8;
}
a1->m_doNot = GameManager::getGameVariable(v16, "0095");
v18 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v89 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v89);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v18 = (GameManager *)qword_1406C2ED8;
}
a1->m_showLeaderboardPercentage = GameManager::getGameVariable(v18, "0099");
v19 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v90 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v90);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v19 = (GameManager *)qword_1406C2ED8;
}
a1->m_decimalPercentage = GameManager::getGameVariable(v19, "0126");
m_lowDetailModeToggled = a2->m_lowDetailModeToggled;
a1->m_lowDetailMode = m_lowDetailModeToggled;
if ( m_lowDetailModeToggled && a1->m_extraLDM )
{
v21 = qword_1406C2ED8;
LABEL_24:
v22 = 1;
goto LABEL_25;
}
v21 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v93 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v93);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v21 = qword_1406C2ED8;
}
if ( *(_BYTE *)(v21 + 917) )
goto LABEL_24;
v22 = 0;
LABEL_25:
if ( !v21 )
{
v91 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v91);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v21 = qword_1406C2ED8;
}
*(_BYTE *)(v21 + 918) = v22;
*(_BYTE *)(v21 + 1005) = 1;
if ( *(_BYTE *)(v21 + 577) )
{
*(double *)(v21 + 432) = sub_14003CF30() - 180.0 + 180.0;
v21 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v92 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v92);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v21 = qword_1406C2ED8;
}
*(_BYTE *)(v21 + 577) = 0;
}
if ( *(_BYTE *)(v21 + 915) )
cocos2d::CCNode::stopActionByTag(a1, 31);
a1->m_isTestMode = 0;
m_levelType = a2->m_levelType;
v24 = m_levelType != Main && (m_levelType == Editor || a2->m_demon.random - a2->m_demon.seed == 1);
a1->m_recordInputs = v24;
a1->m_attempts = 0;
GJBaseGameLayer::resetActiveEnterEffects(a1);
a1->m_maxObjectX = 0.0;
a1->m_gameState.m_totalTime = 0.0;
a1->m_gameState.m_unkDouble3 = 0.0;
a1->m_gameState.m_levelTime = 0.0;
a1->m_jumps = 0;
a1->m_levelEndAnimationStarted = 0;
a1->m_skipArtReload = 1;
a1->m_gameState.m_isDualMode = 0;
a1->m_totalGravityEffects = 4;
if ( *(_BYTE *)(cocos2d::CCApplication::sharedApplication(v26, v25) + 235)
|| *(_BYTE *)(cocos2d::CCApplication::sharedApplication(v28, v27) + 236) )
{
a1->m_totalGravityEffects = 2;
}
v29 = (cocos2d::CCArray *)cocos2d::CCArray::create(v28);
a1->m_gravityEffects = v29;
cocos2d::CCObject::retain(v29);
v31 = 0;
if ( a1->m_totalGravityEffects > 0 )
{
do
{
v32 = (GravityEffectSprite *)operator new(0x258u);
memset(v32, 0, sizeof(GravityEffectSprite));
cocos2d::CCSprite::CCSprite(v32);
v32->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = (GravityEffectSprite_vtbl *)&GravityEffectSprite::`vftable';
v32->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable = (cocos2d::CCRGBAProtocol_vtbl *)&GravityEffectSprite::`vftable';
v32->cocos2d::CCSprite::cocos2d::CCTextureProtocol::cocos2d::CCBlendProtocol::__vftable = (cocos2d::CCTextureProtocol_vtbl *)&GravityEffectSprite::`vftable';
if ( GravityEffectSprite::init(v32) )
{
cocos2d::CCObject::autorelease(v32);
}
else
{
((void (__fastcall *)(GravityEffectSprite *, __int64))v32->~GravityEffectSprite)(v32, 1);
v32 = nullptr;
}
cocos2d::CCArray::addObject(a1->m_gravityEffects, v32);
++v31;
}
while ( v31 < a1->m_totalGravityEffects );
v4 = a4;
}
v33 = (cocos2d::CCArray *)cocos2d::CCArray::create(v30);
a1->m_collectibles = v33;
cocos2d::CCObject::retain(v33);
v35 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v94 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v94);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v35 = qword_1406C2ED8;
}
*(_WORD *)(v35 + 697) = 0;
*(_QWORD *)(v35 + 520) = a1;
v36 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v34);
a1->m_colorKeyDict = v36;
cocos2d::CCObject::retain(v36);
v38 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v37);
cocos2d::CCDirector::getWinSize(v38);
v40 = (cocos2d::CCArray *)cocos2d::CCArray::create(v39);
a1->m_checkpointArray = v40;
cocos2d::CCObject::retain(v40);
v42 = (cocos2d::CCArray *)cocos2d::CCArray::create(v41);
a1->m_speedObjects = v42;
cocos2d::CCObject::retain(v42);
v44 = (cocos2d::CCArray *)cocos2d::CCArray::create(v43);
a1->m_circleWaveArray = v44;
cocos2d::CCObject::retain(v44);
v46 = (cocos2d::CCArray *)cocos2d::CCArray::create(v45);
a1->m_unk37c0 = v46;
cocos2d::CCObject::retain(v46);
GJBaseGameLayer::setupLayers(a1);
v47 = rand();
if ( (float)((float)((float)v47 / 32767.0) + (float)((float)v47 / 32767.0)) < 0.0 )
{
v50 = (float)rand();
v49 = ceilf((float)((float)(v50 / 32767.0) + (float)(v50 / 32767.0)) - 0.5);
}
else
{
v48 = (float)rand();
v49 = floorf((float)((float)(v48 / 32767.0) + (float)(v48 / 32767.0)) + 0.5);
}
a1->m_pulseRodIndex = (int)(float)(v49 + 1.0);
v51 = cocos2d::CCParticleSystemQuad::create("glitterEffect.plist", 0);
a1->m_glitterParticles = v51;
v51->setPositionType(v51, kCCPositionTypeRelative);
a1->m_objectLayer->addChild_0(a1->m_objectLayer, a1->m_glitterParticles, 0);
v52 = a1->m_glitterParticles->GJBaseGameLayer::__vftable;
v54 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v53);
cocos2d::CCDirector::getScreenScaleFactorH(v54);
v56 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v55);
v57 = (float)(cocos2d::CCDirector::getScreenScaleFactorW(v56) * 480.0) / 1.8;
cocos2d::CCPoint::CCPoint(v57, v57);
v52->setPosVar(a1->m_glitterParticles, v58);
cocos2d::CCParticleSystem::stopSystem(a1->m_glitterParticles);
v60 = (cocos2d::CCDrawNode *)cocos2d::CCDrawNode::create(v59);
a1->m_debugDrawNode = v60;
v98.src = 770;
v98.dst = 771;
cocos2d::CCDrawNode::setBlendFunc(v60, &v98);
a1->m_debugDrawNode->setTag(a1->m_debugDrawNode, -9999);
a1->m_aboveShaderObjectLayer->addChild_0(a1->m_aboveShaderObjectLayer, a1->m_debugDrawNode, 1401);
PlayLayer::updateDebugDrawSettings(a1);
GJBaseGameLayer::createPlayer(a1);
if ( a1->m_level->m_levelType == Editor )
{
v61 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v95 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v95);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v61 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getGameVariable(v61, "0174") )
{
v62 = cocos2d::CCLabelBMFont::create((const char *)&qword_140551DB0, (const char *)&qword_14052A4D8);
a1->m_statusLabel = v62;
LOBYTE(v63) = 50;
v62->setOpacity(&v62->cocos2d::CCRGBAProtocol, v63);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_statusLabel->setScale_0)(a1->m_statusLabel);
v64 = ((float (__fastcall *)(PlayLayer *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(
a1,
a1->m_statusLabel,
1000);
v65 = a1->m_statusLabel->__vftable;
cocos2d::CCPoint::CCPoint(v64, 0.0);
v65->setAnchorPoint(a1->m_statusLabel, v66);
v67 = a1->m_statusLabel->__vftable;
v69 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v68);
v70 = (float)(cocos2d::CCDirector::getScreenTop(v69) - 5.0) + 1.0;
cocos2d::CCPoint::CCPoint(v70, 5.0);
v67->setPosition_0(a1->m_statusLabel, v71);
a1->m_statusLabel->setVisible(a1->m_statusLabel, 0);
}
v72 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v96 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v96);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v72 = (GameManager *)qword_1406C2ED8;
}
v73 = GameManager::getGameVariable(v72, "0173");
a1->m_ignoreDamage = v73;
if ( v73 )
a1->m_isIgnoreDamageEnabled = v73;
a1->m_player1->m_maybeCanRunIntoBlocks = v73;
a1->m_player2->m_maybeCanRunIntoBlocks = v73;
PlayLayer::updateTestModeLabel(a1);
}
a1->m_passedIntegrity = 1;
sub_14003BDB0((__int64)v103, (__int64)&a1->m_level->m_levelString);
v74 = v103;
if ( v103[3] > 0xFu )
v74 = (_QWORD *)v103[0];
*(_OWORD *)Block = 0;
v101 = 0;
v102 = 0;
v75 = -1;
do
++v75;
while ( *((_BYTE *)v74 + v75) );
sub_14003A930(Block, v74, v75);
cocos2d::ZipUtils::decompressString(v104, Block, 0, 11);
if ( v102 > 0xF )
{
v76 = Block[0];
if ( v102 + 1 >= 0x1000 )
{
v76 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v76 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v76);
}
v101 = 0;
v102 = 15;
LOBYTE(Block[0]) = 0;
sub_14003A830((__int64)v103);
m_level = a1->m_level;
v78 = m_level->m_levelType;
if ( v78 == Main )
{
v79 = sub_14003BDB0((__int64)v103, (__int64)v104);
v80 = LevelTools::verifyLevelIntegrity(v79, a1->m_level->m_levelID.random - a1->m_level->m_levelID.seed);
}
else
{
if ( v78 == Editor && m_level->m_stars.random - m_level->m_stars.seed <= 0 )
goto LABEL_81;
v80 = v105 != 0;
}
a1->m_passedIntegrity = v80;
LABEL_81:
if ( !a1->m_passedIntegrity )
{
v81 = cocos2d::CCLabelBMFont::create("Load Failed!", (const char *)&qword_14052A4D8);
v82 = ((float (__fastcall *)(PlayLayer *, struct cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v81, 100);
v83 = v81->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v82, v99 * 0.5);
v83->setPosition_0(v81, v84);
}
PlayLayer::prepareCreateObjectsFromSetup(a1, v104);
if ( !v4 && a1->m_loadingProgress < 1.0 )
{
do
PlayLayer::processCreateObjectsFromSetup(a1);
while ( a1->m_loadingProgress < 1.0 );
}
sub_14003A830((__int64)v104);
return 1;
}