//
// LevelAreaInnerLayer::init from 0xa30510 to 0xa311ec (3292 bytes)
//
// 2 xrefs:
// > LevelAreaInnerLayer::create @ 0xa312b4
// > ??> @ 0x79020
//
// 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
//
bool LevelAreaInnerLayer::init(LevelAreaInnerLayer *a1, bool a2)
{
cocos2d::CCDirector *v4; // x0
cocos2d::CCTextureCache *v5; // x0
cocos2d::CCSpriteFrameCache *v6; // x0
cocos2d::CCSprite *v7; // x20
CCMenuItemSpriteExtra *v8; // x21
cocos2d::CCFadeIn *v9; // x0
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x20
cocos2d::CCDirector *v11; // x0
float v12; // s0
float v13; // s8
cocos2d::CCDirector *v14; // x0
float v15; // s0
cocos2d::CCNode *v16; // x21
__int64 v17; // x20
cocos2d::CCMenu *v18; // x25
cocos2d::CCSprite *v19; // x0
void (__fastcall *v20)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
cocos2d::CCPoint *v21; // x0
int v22; // w24
float v23; // s0
float v24; // s1
float v25; // s0
float v26; // s1
float v27; // s0
float v28; // s1
float v29; // s0
float v30; // s1
GameLevelManager *v31; // x0
GameStatsManager *v32; // x0
unsigned int hasCompletedMainLevel; // w27
GameStatsManager *v34; // x0
_BOOL4 v35; // w28
cocos2d::CCSprite *v36; // x0
CCMenuItemSpriteExtra *v37; // x0
CCMenuItemSpriteExtra_vtbl *v38; // x2
CCMenuItemSpriteExtra *v39; // x20
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v41)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
const char *v42; // x1
char *v43; // x0
int v44; // w20
cocos2d::CCSprite *v45; // x0
CCMenuItemSpriteExtra *v46; // x0
cocos2d::CCMenu_vtbl *v47; // x2
CCMenuItemSpriteExtra *m_nextFloorButton; // x24
void (__fastcall *v49)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCSprite *v50; // x24
void (__fastcall *v51)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
__int64 v52; // x24
float v53; // s2
cocos2d::CCSprite *v54; // x20
cocos2d::CCSequence *v55; // x24
cocos2d::CCFadeTo *v56; // x0
cocos2d::CCAction *v57; // x0
CCMenuItemSpriteExtra *v58; // x20
void (__fastcall *v59)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCDirector *v60; // x0
float v61; // s0
void (__fastcall *v62)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x20
__int64 v63; // x24
cocos2d::CCMoveBy *v64; // x0
cocos2d::CCEaseInOut *v65; // x20
cocos2d::CCMoveBy *v66; // x0
cocos2d::CCEaseInOut *v67; // x0
cocos2d::CCActionInterval *v68; // x0
cocos2d::CCRepeatForever *v69; // x0
cocos2d::CCSequence *v70; // x20
cocos2d::CCFiniteTimeAction *v71; // x0
cocos2d::CCAction *v72; // x0
CCSpriteGrayscale *v73; // x20
void *v74; // x24
cocos2d::CCSequence *v75; // x21
cocos2d::CCFadeTo *v76; // x0
cocos2d::CCAction *v77; // x0
CCMenuItemSpriteExtra *v78; // x20
void (__fastcall *v79)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x21
cocos2d::CCDirector *v80; // x0
float v81; // s0
float v82; // s8
cocos2d::CCDirector *v83; // x0
float v84; // s0
bool m_enteringLevel; // w0
int i; // w28
GameStatsManager *v87; // x20
const char *CoinKey; // x0
_BOOL4 hasSecretCoin; // w23
const char *v90; // x0
cocos2d::CCSprite *v91; // x20
void (__fastcall *v92)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *v93)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
float v94; // s1
unsigned int *v95; // x1
int v96; // w2
__int64 v97; // x24
float v98; // s2
GameManager *v99; // x0
cocos2d::CCSequence *v100; // x19
cocos2d::CCFiniteTimeAction *v101; // x0
cocos2d::CCAction *v102; // x0
cocos2d::CCScaleTo *v103; // x0
cocos2d::CCActionInterval *v104; // x0
cocos2d::CCEaseExponentialOut *v105; // x0
unsigned int *v106; // x28
int v107; // w0
cocos2d::CCNode *v108; // [xsp+88h] [xbp+88h]
_BOOL4 v109; // [xsp+94h] [xbp+94h]
cocos2d::CCSprite *v110; // [xsp+B0h] [xbp+B0h]
bool v111; // [xsp+B8h] [xbp+B8h]
int v112; // [xsp+BCh] [xbp+BCh]
GJGameLevel *MainLevel; // [xsp+C0h] [xbp+C0h]
__int64 v114; // [xsp+C8h] [xbp+C8h]
float v115; // [xsp+D0h] [xbp+D0h]
float v116; // [xsp+D4h] [xbp+D4h]
const char *v117; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v118; // [xsp+E0h] [xbp+E0h] BYREF
cocos2d::CCPoint v119; // [xsp+E8h] [xbp+E8h] BYREF
cocos2d::CCPoint v120; // [xsp+F0h] [xbp+F0h] BYREF
_BYTE v121[8]; // [xsp+F8h] [xbp+F8h] BYREF
__int64 v122; // [xsp+100h] [xbp+100h] BYREF
__int64 v123; // [xsp+108h] [xbp+108h] BYREF
__int64 v124; // [xsp+110h] [xbp+110h] BYREF
cocos2d::CCPoint v125; // 0:kr08_8.8
cocos2d::CCPoint v126; // 0:kr10_8.8
cocos2d::CCPoint v127; // 0:kr18_8.8
cocos2d::CCPoint v128; // 0:kr20_8.8
cocos2d::SEL_MenuHandler v129; // 0:x2.16
cocos2d::SEL_MenuHandler v130; // 0:x2.16
cocos2d::SEL_MenuHandler v131; // 0:x2.16
cocos2d::SEL_MenuHandler v132; // 0:x2.16
cocos2d::SEL_MenuHandler v133; // 0:x2.16
cocos2d::CCPoint v134; // 0:s0.4,4:s1.4
cocos2d::CCPoint v135; // 0:s0.4,4:s1.4
v109 = a2;
v111 = cocos2d::CCLayer::init(a1);
if ( !v111 )
return v111;
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
v5 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v5, "TowerSheet.png", 0);
v6 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v6, "TowerSheet.plist");
v7 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v7->setOpacity(v7, 0);
v129.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v129.adj = (size_t)LevelAreaInnerLayer::onBack;
v8 = CCMenuItemSpriteExtra::create(v7, nullptr, v129);
CCMenuItemSpriteExtra::setSizeMult(v8, 1.6);
v9 = cocos2d::CCFadeIn::create(0.3);
cocos2d::CCNode::runAction(v7, v9);
v108 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v8, nullptr);
a1->addChild_0(a1, v108, 1);
setPosition = v108->setPosition;
v11 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v11);
v13 = v12;
v14 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v14);
cocos2d::CCPoint::CCPoint(&v120, v13 + 24.0, v15 - 23.0);
setPosition(v108, &v120);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v8);
v16 = cocos2d::CCNode::create();
v17 = 0;
a1->addChild(a1, v16);
v18 = cocos2d::CCMenu::create();
v19 = cocos2d::CCSprite::createWithSpriteFrameName("towerBG_01_001.png");
v16->addChild_0(v16, v19, 1);
v20 = v16->setPosition;
cocos2d::CCPoint::CCPoint(&v120, v115 * 0.5, v116 * 0.5);
v20(v16, &v120);
do
{
v21 = (cocos2d::CCPoint *)&v121[v17];
v17 += 8;
cocos2d::CCPoint::CCPoint(v21);
}
while ( v17 != 32 );
v114 = 0;
v112 = 0;
v22 = 0;
cocos2d::CCPoint::CCPoint(&v120, -95.5, -89.25);
cocos2d::CCPoint::operator=(v121, v23, v24);
cocos2d::CCPoint::CCPoint(&v120, 103.75, -33.5);
cocos2d::CCPoint::operator=(&v122, v25, v26);
cocos2d::CCPoint::CCPoint(&v120, -95.5, 21.25);
cocos2d::CCPoint::operator=(&v123, v27, v28);
cocos2d::CCPoint::CCPoint(&v120, 57.5, 75.5);
cocos2d::CCPoint::operator=(&v124, v29, v30);
do
{
v31 = GameLevelManager::sharedState();
MainLevel = GameLevelManager::getMainLevel(v31, v22 + 5001, 1);
v32 = GameStatsManager::sharedState();
hasCompletedMainLevel = GameStatsManager::hasCompletedMainLevel(v32, v22 + 5001);
if ( !v22 )
{
if ( hasCompletedMainLevel )
{
v35 = 1;
LABEL_10:
++v112;
sub_D153B8((int)&v117, "towerDoor_locked_001.png");
sub_D1798C(&v117, "towerDoor_open_001.png", 22);
goto LABEL_11;
}
sub_D153B8((int)&v117, "towerDoor_locked_001.png");
LABEL_27:
sub_D1798C(&v117, "towerDoor_unlocked_001.png", 26);
v35 = 1;
goto LABEL_11;
}
v34 = GameStatsManager::sharedState();
v35 = GameStatsManager::hasCompletedMainLevel(v34, v22 + 5000);
if ( hasCompletedMainLevel )
goto LABEL_10;
sub_D153B8((int)&v117, "towerDoor_locked_001.png");
if ( v35 )
goto LABEL_27;
LABEL_11:
v36 = cocos2d::CCSprite::createWithSpriteFrameName(v117);
v130.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v110 = v36;
v130.adj = (size_t)LevelAreaInnerLayer::onDoor;
v37 = CCMenuItemSpriteExtra::create(v36, nullptr, v130);
v38 = v37->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v37->m_colorEnabled = 1;
v37->m_animationEnabled = 0;
v39 = v37;
v38->setTag(v37, v22 + 5001);
v18->addChild(v18, v39);
if ( hasCompletedMainLevel < !v35 )
{
setColor = v110->setColor;
LOWORD(v120.x) = -6703;
BYTE2(v120.x) = -1;
setColor(v110, (const cocos2d::ccColor3B *)&v120);
v39->setEnabled(v39, 0);
}
v41 = v39->setPosition;
v125 = cocos2d::CCNode::convertToNodeSpace(v18, (const cocos2d::CCPoint *)&v121[v114]);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v41)(v39, &v120, v125.x, v125.y);
if ( !hasCompletedMainLevel )
{
v42 = v117;
v43 = (char *)(v117 - 24);
if ( v117 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_15;
LABEL_37:
if ( &pthread_create )
{
v95 = (unsigned int *)(v42 - 8);
do
v96 = __ldaxr(v95);
while ( __stlxr(v96 - 1, v95) );
}
else
{
v96 = *((_DWORD *)v42 - 2);
*((_DWORD *)v42 - 2) = v96 - 1;
}
if ( v96 <= 0 )
operator delete(v43);
goto LABEL_15;
}
cocos2d::CCPoint::CCPoint(&v120, 0.0, 32.0);
cocos2d::CCPoint::operator+(&v118, &v121[v114], &v120);
for ( i = 1; i != 4; ++i )
{
v87 = GameStatsManager::sharedState();
CoinKey = GJGameLevel::getCoinKey(MainLevel, i);
hasSecretCoin = GameStatsManager::hasSecretCoin(v87, CoinKey);
v90 = "GJ_coinsIcon_001.png";
if ( !hasSecretCoin )
v90 = "GJ_coinsIcon_gray_001.png";
v91 = cocos2d::CCSprite::createWithSpriteFrameName(v90);
v92 = v91->setColor;
if ( hasSecretCoin )
{
LOBYTE(v120.x) = -1;
*(_WORD *)((char *)&v120.x + 1) = -1;
}
else
{
LOWORD(v120.x) = -7711;
BYTE2(v120.x) = -31;
}
v92(v91, (const cocos2d::ccColor3B *)&v120);
v91->setScale(v91, 0.7);
v16->addChild_0(v16, v91, 10);
v93 = v91->setPosition;
if ( i == 2 )
v94 = 8.0;
else
v94 = 0.0;
cocos2d::CCPoint::CCPoint(&v119, (float)(i - 2) * 20.0, v94);
cocos2d::CCPoint::operator+(&v120, &v118, &v119);
v93(v91, &v120);
}
v42 = v117;
v43 = (char *)(v117 - 24);
if ( v117 - 24 != (const char *)&qword_124B6B0 )
goto LABEL_37;
LABEL_15:
++v22;
v114 += 8;
}
while ( v22 != 4 );
v44 = 1;
v45 = cocos2d::CCSprite::createWithSpriteFrameName("towerLockedArrow_001.png");
v131.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v131.adj = (size_t)LevelAreaInnerLayer::onNextFloor;
v46 = CCMenuItemSpriteExtra::create(v45, nullptr, v131);
v47 = v18->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_nextFloorButton = v46;
((void (__fastcall *)(cocos2d::CCMenu *))v47->addChild)(v18);
m_nextFloorButton = a1->m_nextFloorButton;
v49 = m_nextFloorButton->setPosition;
cocos2d::CCPoint::CCPoint(&v119, -96.0, 108.0);
v126 = cocos2d::CCNode::convertToNodeSpace(v18, &v119);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v49)(
m_nextFloorButton,
&v120,
v126.x,
v126.y);
v16->addChild_0(v16, v18, 2);
while ( 1 )
{
v50 = cocos2d::CCSprite::createWithSpriteFrameName("towerTorchInner_001.png");
v16->addChild_0(v16, v50, 4);
v51 = v50->setPosition;
if ( v44 != 1 )
break;
cocos2d::CCPoint::CCPoint(&v120, -195.0, 4.0);
v51(v50, &v120);
v97 = (__int64)v50->getPosition(v50);
cocos2d::CCPoint::CCPoint(&v119, 0.0, 33.0);
cocos2d::CCPoint::operator+(&v120, v97, &v119);
v135.x = 1.0;
LevelAreaLayer::addTorch(v16, v135, (int)&v120, v98, 2, 4, 1, nullptr);
LABEL_44:
++v44;
}
cocos2d::CCPoint::CCPoint(&v120, 195.0, 4.0);
v51(v50, &v120);
v52 = (__int64)v50->getPosition(v50);
cocos2d::CCPoint::CCPoint(&v119, 0.0, 33.0);
cocos2d::CCPoint::operator+(&v120, v52, &v119);
v134.x = 1.0;
LevelAreaLayer::addTorch(v16, v134, (int)&v120, v53, 2, 4, 1, nullptr);
if ( v44 != 2 )
goto LABEL_44;
if ( !v109 )
{
v103 = (cocos2d::CCScaleTo *)((__int64 (__fastcall *)(cocos2d::CCNode *, float))v16->setScale)(v16, 0.2);
v104 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create(v103, 1.0, 1.0);
v105 = cocos2d::CCEaseExponentialOut::create(v104);
cocos2d::CCNode::runAction(v16, v105);
}
v54 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_secretLock4_small_001.png");
v54->setOpacity(v54, 0);
v55 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.5);
v56 = cocos2d::CCFadeTo::create(2.0, 0xC8u);
v57 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v55, v56, 0);
cocos2d::CCNode::runAction(v54, v57);
v132.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v132.adj = (size_t)LevelAreaInnerLayer::onOnlineVault;
v58 = CCMenuItemSpriteExtra::create(v54, nullptr, v132);
v108->addChild(v108, v58);
v59 = v58->setPosition;
v60 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenRight(v60);
cocos2d::CCPoint::CCPoint(&v119, v61 - 22.0, 23.0);
v127 = cocos2d::CCNode::convertToNodeSpace(v108, &v119);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v59)(v58, &v120, v127.x, v127.y);
v62 = v16->setPosition;
v63 = (__int64)v16->getPosition(v16);
cocos2d::CCPoint::CCPoint(&v119, 0.0, -2.0);
cocos2d::CCPoint::operator+(&v120, v63, &v119);
v62(v16, &v120);
cocos2d::CCPoint::CCPoint(&v120, 0.0, 4.0);
v64 = cocos2d::CCMoveBy::create(2.0, &v120);
v65 = cocos2d::CCEaseInOut::create(v64, 2.0);
cocos2d::CCPoint::CCPoint(&v120, 0.0, -4.0);
v66 = cocos2d::CCMoveBy::create(2.0, &v120);
v67 = cocos2d::CCEaseInOut::create(v66, 2.0);
v68 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v65, v67, 0);
v69 = cocos2d::CCRepeatForever::create(v68);
cocos2d::CCNode::runAction(v16, v69);
v70 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.0);
v71 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, LevelAreaInnerLayer::tryResumeTowerMusic, 0);
v72 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v70, v71, 0);
cocos2d::CCNode::runAction(a1, v72);
sub_D153B8((int)&v120, "GJ_infoIcon_001.png");
v73 = CCSpriteGrayscale::createWithSpriteFrameName((const char **)&v120);
v74 = (void *)(*(_QWORD *)&v120 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v120 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v106 = (unsigned int *)(*(_QWORD *)&v120 - 8LL);
do
v107 = __ldaxr(v106);
while ( __stlxr(v107 - 1, v106) );
}
else
{
v107 = *(_DWORD *)(*(_QWORD *)&v120 - 8LL);
*(_DWORD *)(*(_QWORD *)&v120 - 8LL) = v107 - 1;
}
if ( v107 <= 0 )
operator delete(v74);
}
v73->setOpacity(v73, 0);
v73->setScale(v73, 0.8);
v75 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.1);
v76 = cocos2d::CCFadeTo::create(1.0, 0xC8u);
v77 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v75, v76, 0);
cocos2d::CCNode::runAction(v73, v77);
v133.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v133.adj = (size_t)LevelAreaInnerLayer::onInfo;
v78 = CCMenuItemSpriteExtra::create(v73, nullptr, v133);
v108->addChild(v108, v78);
v79 = v78->setPosition;
v80 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenRight(v80);
v82 = v81;
v83 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v83);
cocos2d::CCPoint::CCPoint(&v119, v82 - 20.0, v84 - 20.0);
v128 = cocos2d::CCNode::convertToNodeSpace(v108, &v119);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v79)(v78, &v120, v128.x, v128.y);
CCMenuItemSpriteExtra::setSizeMult(v78, 1.2);
if ( v112 == 4 )
{
v99 = GameManager::sharedState();
if ( !GameManager::getUGV(v99, "33") )
{
a1->m_enteringLevel = (unsigned __int8)&dword_0 + 1;
v100 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(1.0);
v101 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(
a1,
LevelAreaInnerLayer::showFloor1CompleteDialog,
0);
v102 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v100, v101, 0);
cocos2d::CCNode::runAction(a1, v102);
goto LABEL_47;
}
LABEL_24:
m_enteringLevel = a1->m_enteringLevel;
if ( m_enteringLevel )
return m_enteringLevel;
LABEL_48:
GameManager::sharedState()->m_somethingInMenuLayer = 0;
}
else
{
if ( v112 > 3 )
goto LABEL_24;
LABEL_47:
a1->m_nextFloorButton->setEnabled(a1->m_nextFloorButton, 0);
a1->m_nextFloorButton->setVisible(a1->m_nextFloorButton, 0);
m_enteringLevel = a1->m_enteringLevel;
if ( !m_enteringLevel )
goto LABEL_48;
return m_enteringLevel;
}
return v111;
}