//
// GJMGLayer::init from 0x10002c8d0 to 0x10002cbf8 (808 bytes)
//
// 1 xrefs:
// > GJMGLayer::create @ 0x10002c884
//
// 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 __fastcall GJMGLayer::init(GJMGLayer *a1, int a2)
{
_BOOL4 v4; // w19
cocos2d::CCDirector *v5; // x0
float v6; // s0
GameManager *v7; // x0
char *MGTexture; // x0
void **v9; // x0
__int64 v10; // x0
float v11; // s8
float v12; // s9
cocos2d::CCTexture2D *v13; // x0
cocos2d::CCSprite *v14; // x21
__n128 v15; // q0
__n128 v16; // q1
cocos2d::CCString *v17; // x0
const char *CString; // x0
__int64 v19; // x0
float v20; // s8
__int64 v21; // x0
float v22; // s9
cocos2d::CCTexture2D *v23; // x0
cocos2d::CCSprite *v24; // x22
__n128 v25; // q0
__n128 v26; // q1
__n128 v27; // q0
__n128 v28; // q1
cocos2d::CCSpriteBatchNode *m_mg2BatchNode; // x22
__int64 v31; // [xsp+14h] [xbp-6Ch] BYREF
__int64 v32; // [xsp+1Ch] [xbp-64h] BYREF
__int64 v33; // [xsp+24h] [xbp-5Ch] BYREF
unsigned __int16 v34; // [xsp+2Ch] [xbp-54h] BYREF
unsigned __int8 v35; // [xsp+2Eh] [xbp-52h]
void *__p[2]; // [xsp+30h] [xbp-50h] BYREF
char v37; // [xsp+47h] [xbp-39h]
float v38; // [xsp+48h] [xbp-38h]
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
((void (__fastcall *)(GJMGLayer *, void *))a1->setContentSize)(a1, &unk_10086A478);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v5);
v6 = 0.0;
if ( (unsigned int)(a2 - 1) <= 2 )
v6 = flt_100635678[a2 - 1];
a1->m_ground2Offset = v6;
v7 = GameManager::sharedState();
MGTexture = (char *)GameManager::getMGTexture(v7, a2);
sub_100009900(__p, MGTexture);
a1->m_showGround = 0;
v35 = -1;
v34 = 26112;
if ( v37 >= 0 )
v9 = __p;
else
v9 = (void **)__p[0];
a1->m_mg1BatchNode = cocos2d::CCSpriteBatchNode::create((const char *)v9, 0x1Du);
((void (__fastcall *)(GJMGLayer *))a1->addChild_0)(a1);
v10 = ((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))a1->m_mg1BatchNode->getTexture)(a1->m_mg1BatchNode);
(*(void (__fastcall **)(__int64 *__return_ptr))(*(_QWORD *)v10 + 144LL))(&v33);
v11 = *(float *)&v33;
LODWORD(a1->m_textureWidth) = v33;
v12 = v38;
v13 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))a1->m_mg1BatchNode->getTexture)(a1->m_mg1BatchNode);
v14 = cocos2d::CCSprite::createWithTexture(v13, &stru_10086A480);
a1->m_ground1Sprite = v14;
v14->m_bDontDraw = 1;
v15.n128_u32[0] = 0;
v16.n128_u32[0] = 0;
sub_100022980(v15, v16, &v32);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v14->setPosition)(v14, &v32);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int16 *))a1->m_ground1Sprite->setColor)(
a1->m_ground1Sprite,
&v34);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))a1->m_mg1BatchNode->addChild)(
a1->m_mg1BatchNode,
a1->m_ground1Sprite);
LODWORD(v14) = (int)(float)(ceilf(v12 / v11) + 1.0);
GJMGLayer::loadGroundSprites(a1, (int)v14, 1);
GJMGLayer::updateGroundColor(a1, (cocos2d::ccColor3B)(v34 | (v35 << 16)), 1);
v17 = (cocos2d::CCString *)sub_100268F4C("fg_%02d_2_001.png", a2);
CString = cocos2d::CCString::getCString(v17);
a1->m_mg2BatchNode = cocos2d::CCSpriteBatchNode::create(CString, 0x1Du);
((void (__fastcall *)(GJMGLayer *))a1->addChild_0)(a1);
v19 = ((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))a1->m_mg1BatchNode->getTexture)(a1->m_mg1BatchNode);
(*(void (__fastcall **)(__int64 *__return_ptr))(*(_QWORD *)v19 + 144LL))(&v32);
v20 = *((float *)&v32 + 1);
v21 = ((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))a1->m_mg2BatchNode->getTexture)(a1->m_mg2BatchNode);
(*(void (__fastcall **)(__int64 *__return_ptr))(*(_QWORD *)v21 + 144LL))(&v31);
v22 = *((float *)&v31 + 1);
v23 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))a1->m_mg2BatchNode->getTexture)(a1->m_mg2BatchNode);
v24 = cocos2d::CCSprite::createWithTexture(v23, &stru_10086A480);
a1->m_ground2Sprite = v24;
v24->m_bDontDraw = 1;
v25.n128_u32[0] = 0;
v26.n128_u32[0] = 0;
sub_100022980(v25, v26, &v32);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v24->setPosition)(v24, &v32);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int16 *))a1->m_ground2Sprite->setColor)(
a1->m_ground2Sprite,
&v34);
v27 = ((__n128 (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))a1->m_mg2BatchNode->addChild)(
a1->m_mg2BatchNode,
a1->m_ground2Sprite);
v28.n128_f32[0] = v20 - v22;
m_mg2BatchNode = a1->m_mg2BatchNode;
v27.n128_u32[0] = 0;
sub_100022980(v27, v28, &v32);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, __int64 *))m_mg2BatchNode->setPosition)(m_mg2BatchNode, &v32);
GJMGLayer::loadGroundSprites(a1, (int)v14, 0);
GJMGLayer::updateGroundColor(a1, (cocos2d::ccColor3B)(v34 | (v35 << 16)), 0);
if ( v37 < 0 )
operator delete(__p[0]);
}
return v4;
}