//
// GJBaseGameLayer::createPlayer from 0x5a5330 to 0x5a5640 (784 bytes)
//
// 2 xrefs:
// > PlayLayer::init @ 0x40b160
// > LevelEditorLayer::init @ 0x476278
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:53:20 +0000
//
_DWORD *__fastcall GJBaseGameLayer::createPlayer(PlayerObject **this, bool a2, unsigned int a3, unsigned int a4)
{
GameManager *v5; // r0
PlayerObject *v6; // r5
int v7; // r0
int *v8; // r0
int *v9; // r7
int (__fastcall *v10)(int *, unsigned int *); // r8
GameManager *v11; // r5
int v12; // r0
int v13; // r0
GameManager *v14; // r0
int v15; // r7
GameManager *v16; // r8
int v17; // r0
int v18; // r0
GameManager *v19; // r0
GameManager *v20; // r0
int v21; // r7
GameManager *v22; // r8
int v23; // r0
int v24; // r0
GameManager *v25; // r0
int v26; // r7
GameManager *v27; // r0
char GameVariable; // r0
char v29; // r3
GameManager *v30; // r0
GameManager *v31; // r0
PlayerObject *v32; // r8
int v33; // r0
int *v34; // r0
int *v35; // r8
int (__fastcall *v36)(int *, unsigned int *); // r9
GameManager *v37; // r10
int v38; // r0
int v39; // r0
GameManager *v40; // r0
int v41; // r8
GameManager *v42; // r9
int v43; // r0
int v44; // r0
GameManager *v45; // r0
GameManager *v46; // r0
int v47; // r8
GameManager *v48; // r9
int v49; // r0
int v50; // r0
char v51; // r3
_DWORD *result; // r0
bool v54; // [sp+4h] [bp-Ch]
unsigned int v55[2]; // [sp+8h] [bp-8h] BYREF
v55[0] = a3;
v55[1] = a4;
v5 = (GameManager *)GameManager::sharedState((GameManager *)this);
v6 = (PlayerObject *)(*((_DWORD *)v5 + 129) - *((_DWORD *)v5 + 130));
v7 = GameManager::sharedState(v5);
v8 = PlayerObject::create(
v6,
(const char *)(*(_DWORD *)(v7 + 528) - *(_DWORD *)(v7 + 532)),
(GJBaseGameLayer *)this,
*(this + 609),
(cocos2d::CCLayer *)(*((unsigned __int8 *)this + 10612) ^ 1),
a2);
*(this + 519) = (PlayerObject *)v8;
v9 = v8;
v10 = *(int (__fastcall **)(int *, unsigned int *))(*v8 + 480);
v11 = (GameManager *)GameManager::sharedState((GameManager *)v8);
v12 = GameManager::sharedState(v11);
v13 = GameManager::colorForIdx(v11, *(_DWORD *)(v12 + 612) - *(_DWORD *)(v12 + 616));
LOWORD(v55[0]) = v13;
BYTE2(v55[0]) = BYTE2(v13);
v14 = (GameManager *)v10(v9, v55);
v15 = (int)*(this + 519);
v16 = (GameManager *)GameManager::sharedState(v14);
v17 = GameManager::sharedState(v16);
v18 = GameManager::colorForIdx(v16, *(_DWORD *)(v17 + 624) - *(_DWORD *)(v17 + 628));
LOWORD(v55[0]) = v18;
BYTE2(v55[0]) = BYTE2(v18);
v19 = (GameManager *)PlayerObject::setSecondColor(v15, (unsigned __int8 *)v55);
v20 = (GameManager *)GameManager::sharedState(v19);
if ( *((_DWORD *)v20 + 159) - *((_DWORD *)v20 + 160) >= 0 )
{
v21 = (int)*(this + 519);
v22 = (GameManager *)GameManager::sharedState(v20);
v23 = GameManager::sharedState(v22);
v24 = GameManager::colorForIdx(v22, *(_DWORD *)(v23 + 636) - *(_DWORD *)(v23 + 640));
LOWORD(v55[0]) = v24;
BYTE2(v55[0]) = BYTE2(v24);
PlayerObject::enableCustomGlowColor(v21, (int)v55);
}
PlayerObject::updateGlowColor(*(this + 519));
v25 = (GameManager *)(*(int (__fastcall **)(_DWORD, _DWORD, int))(*(_DWORD *)*(this + 609) + 232))(
*(this + 609),
*(this + 519),
59);
*((_DWORD *)*(this + 519) + 195) = 1;
if ( !*((_BYTE *)this + 10612) )
v25 = (GameManager *)PlayerObject::addAllParticles(*(this + 519));
v26 = (int)*(this + 519);
v27 = (GameManager *)GameManager::sharedState(v25);
GameVariable = GameManager::getGameVariable(v27, "0068");
PlayerObject::updateCheckpointMode(v26, GameVariable);
(*(void (__fastcall **)(_DWORD, int))(*(_DWORD *)*(this + 519) + 172))(
*(this + 519),
*((unsigned __int8 *)this + 10612) ^ 1);
v29 = *((_BYTE *)this + 10612);
if ( v29 )
v29 = *((_BYTE *)this + 1434);
*((_BYTE *)*(this + 519) + 2464) = v29;
v55[0] = *((_DWORD *)*(this + 519) + 195);
v30 = (GameManager *)std::unordered_map::operator[]((int)(this + 2917), v55);
*(_DWORD *)v30 = *(this + 519);
v31 = (GameManager *)GameManager::sharedState(v30);
v32 = (PlayerObject *)(*((_DWORD *)v31 + 129) - *((_DWORD *)v31 + 130));
v33 = GameManager::sharedState(v31);
v34 = PlayerObject::create(
v32,
(const char *)(*(_DWORD *)(v33 + 528) - *(_DWORD *)(v33 + 532)),
(GJBaseGameLayer *)this,
*(this + 609),
(cocos2d::CCLayer *)(*((unsigned __int8 *)this + 10612) ^ 1),
v54);
*(this + 520) = (PlayerObject *)v34;
v35 = v34;
v36 = *(int (__fastcall **)(int *, unsigned int *))(*v34 + 480);
v37 = (GameManager *)GameManager::sharedState((GameManager *)v34);
v38 = GameManager::sharedState(v37);
v39 = GameManager::colorForIdx(v37, *(_DWORD *)(v38 + 624) - *(_DWORD *)(v38 + 628));
LOWORD(v55[0]) = v39;
BYTE2(v55[0]) = BYTE2(v39);
v40 = (GameManager *)v36(v35, v55);
v41 = (int)*(this + 520);
v42 = (GameManager *)GameManager::sharedState(v40);
v43 = GameManager::sharedState(v42);
v44 = GameManager::colorForIdx(v42, *(_DWORD *)(v43 + 612) - *(_DWORD *)(v43 + 616));
LOWORD(v55[0]) = v44;
BYTE2(v55[0]) = BYTE2(v44);
v45 = (GameManager *)PlayerObject::setSecondColor(v41, (unsigned __int8 *)v55);
v46 = (GameManager *)GameManager::sharedState(v45);
if ( *((_DWORD *)v46 + 159) - *((_DWORD *)v46 + 160) >= 0 )
{
v47 = (int)*(this + 520);
v48 = (GameManager *)GameManager::sharedState(v46);
v49 = GameManager::sharedState(v48);
v50 = GameManager::colorForIdx(v48, *(_DWORD *)(v49 + 636) - *(_DWORD *)(v49 + 640));
LOWORD(v55[0]) = v50;
BYTE2(v55[0]) = BYTE2(v50);
PlayerObject::enableCustomGlowColor(v47, (int)v55);
}
PlayerObject::updateGlowColor(*(this + 520));
cocos2d::CCObject::retain(*(this + 520));
*((_BYTE *)*(this + 520) + 2120) = 1;
*((_DWORD *)*(this + 520) + 195) = 2;
(*(void (__fastcall **)(_DWORD, int))(*(_DWORD *)*(this + 520) + 172))(
*(this + 520),
*((unsigned __int8 *)this + 10612) ^ 1);
v51 = *((_BYTE *)this + 10612);
if ( v51 )
v51 = *((_BYTE *)this + 1434);
*((_BYTE *)*(this + 520) + 2464) = v51;
v55[0] = *((_DWORD *)*(this + 520) + 195);
result = std::unordered_map::operator[]((int)(this + 2917), v55);
*result = *(this + 520);
return result;
}