//
// MapSelectLayer::init from 0xac3fe8 to 0xac4618 (1584 bytes)
//
// 2 xrefs:
// > ??> @ 0x91a68
// > ??> @ 0x14aadc0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:01:06 +0000
//
__int64 __fastcall MapSelectLayer::init(GJBigSprite **this)
{
cocos2d::CCArray *v2; // x0
unsigned int v3; // w24
cocos2d::CCObject *v5; // x0
const char *v6; // x1
__int64 v7; // x0
cocos2d::CCMenu *v8; // x19
cocos2d::CCDirector **v9; // x19
__int64 (__fastcall *v10)(cocos2d::CCDirector **, __int16 *); // x21
cocos2d::CCDirector *v11; // x0
cocos2d::CCDirector *ScreenLeft; // x0
float v13; // s0
float v14; // s8
cocos2d::CCDirector *v15; // x0
float v16; // s0
GameManager *v17; // x0
GJBigSprite *v18; // x0
__int64 v19; // x19
void (__fastcall *v20)(__int64, __int16 *); // x21
cocos2d::CCNode *v21; // x0
__int64 v22; // x0
GameManager *v23; // x0
__int64 v24; // x0
__int64 v25; // x0
cocos2d::CCNode *v26; // x1
float *v27; // x19
GameManager *v28; // x0
__int64 v29; // x21
GameManager *v30; // x0
SimplePlayer *v31; // x21
GameManager *v32; // x25
__int64 v33; // x0
int v34; // w0
GameManager *v35; // x25
__int64 v36; // x0
unsigned __int64 v37; // x0
GameManager *v38; // x0
__int64 v39; // x0
GameManager *v40; // x0
__int64 v41; // x21
GameManager *v42; // x25
__int64 v43; // x0
unsigned __int64 v44; // x0
int v45; // w21
float *Monster; // x25
int v47; // w19
int v48; // w0
cocos2d::CCNode *v49; // x19
GameLevelManager *v50; // x0
__int64 v51; // x19
GameLevelManager **LocalLevelByName; // x19
GameLevelManager *v53; // x0
LevelEditorLayer *v54; // x0
GameLevelManager *v55; // x0
__int64 *v56; // x0
__int16 v57; // [xsp+80h] [xbp+80h] BYREF
char v58; // [xsp+82h] [xbp+82h]
__int16 v59; // [xsp+88h] [xbp+88h] BYREF
char v60; // [xsp+8Ah] [xbp+8Ah]
GameLevelManager *v61; // [xsp+90h] [xbp+90h] BYREF
size_t v62; // [xsp+98h] [xbp+98h]
void *v63; // [xsp+A0h] [xbp+A0h]
v2 = (cocos2d::CCArray *)(unsigned __int8)cocos2d::CCLayer::init((cocos2d::CCLayer *)this);
v3 = (unsigned __int8)v2;
if ( (_BYTE)v2 )
{
v5 = (cocos2d::CCObject *)cocos2d::CCArray::create(v2);
*(this + 59) = v5;
cocos2d::CCObject::retain(v5);
v7 = cocos2d::CCSprite::createWithSpriteFrameName((cocos2d::CCSprite *)"GJ_arrow_01_001.png", v6);
v8 = (cocos2d::CCMenu *)CCMenuItemSpriteExtra::create(v7, 0, (__int64)this, (__int64)MapSelectLayer::onBack, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v8, 1.6);
v9 = (cocos2d::CCDirector **)cocos2d::CCMenu::create(v8, nullptr);
(*((void (__fastcall **)(GJBigSprite **, cocos2d::CCDirector **, __int64))*this + 58))(this, v9, 1);
v10 = *((__int64 (__fastcall **)(cocos2d::CCDirector **, __int16 *))*v9 + 23);
v11 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(*v9);
ScreenLeft = (cocos2d::CCDirector *)cocos2d::CCDirector::getScreenLeft(v11);
v14 = v13;
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(ScreenLeft);
cocos2d::CCDirector::getScreenTop(v15);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59, v14 + 25.0, v16 - 22.0);
v17 = (GameManager *)v10(v9, &v59);
v18 = (GJBigSprite *)GameManager::sharedState(v17);
*((_BYTE *)v18 + 1064) = 0;
v19 = GJBigSprite::create(v18);
*(this + 51) = (GJBigSprite *)v19;
v20 = *(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v19 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59, -165.0, -800.0);
v20(v19, &v59);
GJBigSprite::updateSpriteVisibility(*(this + 51));
v21 = *(this + 51);
*((_BYTE *)v21 + 360) = 1;
v22 = cocos2d::CCNode::create(v21);
*(this + 53) = (GJBigSprite *)v22;
v23 = (GameManager *)(*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(*(_QWORD *)*(this + 51) + 464LL))(
*(this + 51),
v22,
20);
v24 = GameManager::sharedState(v23);
v25 = SimplePlayer::create((SimplePlayer *)(unsigned int)(*(_DWORD *)(v24 + 716) - *(_DWORD *)(v24 + 720)));
*(this + 52) = (GJBigSprite *)v25;
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v25 + 160LL))(v25, 0.5);
v27 = (float *)GJMapObject::create(*(this + 52), v26);
(*(void (__fastcall **)(_QWORD, float *, _QWORD))(*(_QWORD *)*(this + 53) + 464LL))(*(this + 53), v27, 0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59, 462.0, 950.0);
v28 = (GameManager *)GJMapObject::setObjectOrigin(v27, (__int64)&v59, 0.0);
v29 = (__int64)*(this + 52);
v30 = (GameManager *)*(unsigned __int8 *)(GameManager::sharedState(v28) + 912);
*(_BYTE *)(v29 + 660) = (_BYTE)v30;
v31 = *(this + 52);
v32 = (GameManager *)GameManager::sharedState(v30);
v33 = GameManager::sharedState(v32);
v34 = GameManager::colorForIdx(v32, *(_DWORD *)(v33 + 812) - *(_DWORD *)(v33 + 816));
v58 = BYTE2(v34);
v57 = v34;
v35 = (GameManager *)GameManager::sharedState((GameManager *)v34);
v36 = GameManager::sharedState(v35);
v37 = GameManager::colorForIdx(v35, *(_DWORD *)(v36 + 824) - *(_DWORD *)(v36 + 828));
v59 = v37;
v60 = BYTE2(v37);
v38 = (GameManager *)SimplePlayer::setColors(v31, (__int64)&v57, (__int64)&v59);
v39 = GameManager::sharedState(v38);
v40 = (GameManager *)(unsigned int)(*(_DWORD *)(v39 + 836) - *(_DWORD *)(v39 + 840));
if ( ((unsigned int)v40 & 0x80000000) != 0 )
{
SimplePlayer::disableCustomGlowColor((__int64)*(this + 52));
}
else
{
v41 = (__int64)*(this + 52);
v42 = (GameManager *)GameManager::sharedState(v40);
v43 = GameManager::sharedState(v42);
v44 = GameManager::colorForIdx(v42, *(_DWORD *)(v43 + 836) - *(_DWORD *)(v43 + 840));
v59 = v44;
v60 = BYTE2(v44);
SimplePlayer::enableCustomGlowColor(v41, (__int64)&v59);
}
v45 = 10;
SimplePlayer::updateColors(*(this + 52));
GJMapObject::startPlayerJumpLoop((GJMapObject *)v27);
do
{
Monster = (float *)GJMapObject::createMonster((GJMapObject *)((char *)&elf_hash_bucket[103] + 2));
(*(void (__fastcall **)(_QWORD, float *, _QWORD))(*(_QWORD *)*(this + 53) + 464LL))(*(this + 53), Monster, 0);
v47 = rand();
v48 = rand();
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v59,
(float)((float)((float)((float)((float)v47 * 4.6566e-10) * 2.0) + -1.0) * 100.0) + 600.0,
(float)((float)((float)((float)((float)v48 * 4.6566e-10) * 2.0) + -1.0) * 100.0) + 600.0);
GJMapObject::setObjectOrigin(Monster, (__int64)&v59, 50.0);
cocos2d::CCArray::addObject(*(this + 59), (cocos2d::CCObject *)Monster);
--v45;
}
while ( v45 );
v49 = GJMapObject::createMonster((GJMapObject *)((char *)&elf_hash_bucket[205] + 3));
(*(void (__fastcall **)(_QWORD, cocos2d::CCNode *, _QWORD))(*(_QWORD *)*(this + 53) + 464LL))(*(this + 53), v49, 0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v59, 436.0, 776.0);
GJMapObject::setObjectOrigin((float *)v49, (__int64)&v59, 50.0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)v49 + 42) + 344LL))(*((_QWORD *)v49 + 42), 0);
v50 = (GameLevelManager *)cocos2d::CCArray::addObject(*(this + 59), v49);
*((_BYTE *)this + 448) = 0;
v51 = GameLevelManager::sharedState(v50);
v61 = nullptr;
v62 = 0;
v63 = nullptr;
std::string::__init((__int64 *)&v61, "gamemap", 7u);
LocalLevelByName = (GameLevelManager **)GameLevelManager::getLocalLevelByName(v51, (__int64)&v61);
v53 = (GameLevelManager *)(unsigned __int8)v61;
if ( ((unsigned __int8)v61 & 1) != 0 )
operator delete(v63);
if ( !LocalLevelByName )
{
v55 = (GameLevelManager *)GameLevelManager::sharedState(v53);
LocalLevelByName = (GameLevelManager **)GameLevelManager::createNewLevel(v55);
v61 = nullptr;
v62 = 0;
v63 = nullptr;
std::string::__init((__int64 *)&v61, "gamemap", 7u);
v56 = (__int64 *)(LocalLevelByName + 43);
if ( LocalLevelByName + 43 != &v61 )
{
if ( ((unsigned __int8)v61 & 1) != 0 )
std::string::assign(v56, v63, v62);
else
std::string::assign(v56, (char *)&v61 + 1, (unsigned __int8)v61 >> 1);
}
if ( ((unsigned __int8)v61 & 1) != 0 )
operator delete(v63);
}
v54 = (LevelEditorLayer *)LevelEditorLayer::create(
(LevelEditorLayer *)LocalLevelByName,
(GJGameLevel *)(*((unsigned __int8 *)this + 448) ^ 1u));
*(this + 60) = v54;
LevelEditorLayer::toggleBackground(v54, 0);
LevelEditorLayer::toggleGround(*(this + 60), 0);
if ( *((_BYTE *)this + 448) )
{
(*((void (__fastcall **)(GJBigSprite **, _QWORD))*this + 57))(this, *(this + 60));
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(*(_QWORD *)*(this + 60) + 464LL))(
*(this + 60),
*(this + 51),
4294967196LL);
}
else
{
*((_BYTE *)*(this + 60) + 14016) = 1;
LevelEditorLayer::updatePreviewParticles((cocos2d::CCArray **)*(this + 60));
*((_BYTE *)*(this + 60) + 14298) = 1;
LevelEditorLayer::updateEditorMode(*(this + 60));
(*((void (__fastcall **)(GJBigSprite **, _QWORD))*this + 57))(this, *(this + 51));
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(*(_QWORD *)*(this + 53) + 464LL))(
*(this + 53),
*(this + 60),
100);
(*((void (__fastcall **)(GJBigSprite **, __int64))*this + 134))(this, 1);
(*((void (__fastcall **)(GJBigSprite **, __int64))*this + 136))(this, 1);
(*((void (__fastcall **)(GJBigSprite **, __int64))*this + 125))(this, 1);
(*((void (__fastcall **)(GJBigSprite **, __int64))*this + 138))(this, 1);
}
cocos2d::CCNode::scheduleUpdate((cocos2d::CCNode *)this);
}
return v3;
}