//
// GJMGLayer::init from 0x435004 to 0x435256 (594 bytes)
//
// 1 xrefs:
// > GJMGLayer::create @ 0x4352fc
//
// 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 GJMGLayer::init(GJMGLayer *a1, int a2)
{
_BOOL4 v4; // r9
cocos2d::CCDirector *v5; // r0
GameManager *v6; // r0
char *MGTexture; // r0
cocos2d::CCSpriteBatchNode *v8; // r0
cocos2d::CCSpriteBatchNode *v9; // r0
GJMGLayer_vtbl *v10; // r3
cocos2d::CCTexture2D *v11; // r0
float width; // s14
float v13; // s15
cocos2d::CCTexture2D *v14; // r0
cocos2d::CCSprite *v15; // r0
cocos2d::CCSprite *v16; // r6
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r11
cocos2d::CCString *v18; // r0
const char *CString; // r0
cocos2d::CCSpriteBatchNode *v20; // r0
GJMGLayer_vtbl *v21; // r3
cocos2d::CCTexture2D *v22; // r0
float v23; // s16
cocos2d::CCTexture2D *v24; // r0
float v25; // s16
cocos2d::CCTexture2D *v26; // r0
cocos2d::CCSprite *v27; // r0
cocos2d::CCSprite *v28; // r6
void (__fastcall *v29)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCSpriteBatchNode *m_mg2BatchNode; // r6
void (__fastcall *v31)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
int v33; // [sp+4h] [bp-38h]
int v34; // [sp+Ch] [bp-30h] BYREF
cocos2d::CCSpriteBatchNode *v35; // [sp+10h] [bp-2Ch] BYREF
cocos2d::CCSize v36; // [sp+14h] [bp-28h] BYREF
cocos2d::CCSize v37; // [sp+1Ch] [bp-20h] BYREF
char v38; // [sp+24h] [bp-18h] BYREF
float v39; // [sp+28h] [bp-14h]
cocos2d::CCPoint v40; // [sp+2Ch] [bp-10h] BYREF
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
a1->setContentSize(a1, &stru_AC6524);
v5 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v36, v5);
a1->m_ground2Offset = GJMGLayer::defaultYOffsetForBG2(a2);
v6 = GameManager::sharedState();
MGTexture = (char *)GameManager::getMGTexture(v6, a2);
sub_776584((int)&v35, MGTexture);
v8 = v35;
a1->m_showGround = 0;
LOWORD(v34) = 26112;
BYTE2(v34) = -1;
v9 = cocos2d::CCSpriteBatchNode::create((const char *)v8, (unsigned int)&dword_1C + 1);
v10 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mg1BatchNode = v9;
v10->addChild_0(a1, v9, 2);
v11 = a1->m_mg1BatchNode->getTexture(a1->m_mg1BatchNode);
v11->getContentSize(&v37, v11);
width = v36.width;
v13 = v37.width;
a1->m_textureWidth = v37.width;
v33 = (int)(ceilf(width / v13) + 1.0);
v14 = a1->m_mg1BatchNode->getTexture(a1->m_mg1BatchNode);
v15 = cocos2d::CCSprite::createWithTexture(v14);
a1->m_ground1Sprite = v15;
v15->m_bDontDraw = 1;
v16 = v15;
setPosition = v15->setPosition;
cocos2d::CCPoint::CCPoint(&v40, 0.0, 0.0);
setPosition(v16, &v40);
a1->m_ground1Sprite->setColor(a1->m_ground1Sprite, (const cocos2d::ccColor3B *)&v34);
a1->m_mg1BatchNode->addChild(a1->m_mg1BatchNode, a1->m_ground1Sprite);
GJMGLayer::loadGroundSprites(a1, v33, 1);
GJMGLayer::updateGroundColor(a1, (cocos2d::ccColor3B)v34, 1);
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"fg_%02d_2_001.png",
(const char *)a2);
CString = cocos2d::CCString::getCString(v18);
v20 = cocos2d::CCSpriteBatchNode::create(CString, (unsigned int)&dword_1C + 1);
v21 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_mg2BatchNode = v20;
v21->addChild_0(a1, v20, 3);
v22 = a1->m_mg1BatchNode->getTexture(a1->m_mg1BatchNode);
v22->getContentSize((cocos2d::CCSize *)&v38, v22);
v23 = v39;
v24 = a1->m_mg2BatchNode->getTexture(a1->m_mg2BatchNode);
v24->getContentSize((cocos2d::CCSize *)&v40, v24);
v25 = v23 - v40.y;
v26 = a1->m_mg2BatchNode->getTexture(a1->m_mg2BatchNode);
v27 = cocos2d::CCSprite::createWithTexture(v26);
a1->m_ground2Sprite = v27;
v27->m_bDontDraw = 1;
v28 = v27;
v29 = v27->setPosition;
cocos2d::CCPoint::CCPoint(&v40, 0.0, 0.0);
v29(v28, &v40);
a1->m_ground2Sprite->setColor(a1->m_ground2Sprite, (const cocos2d::ccColor3B *)&v34);
a1->m_mg2BatchNode->addChild(a1->m_mg2BatchNode, a1->m_ground2Sprite);
m_mg2BatchNode = a1->m_mg2BatchNode;
v31 = m_mg2BatchNode->setPosition;
cocos2d::CCPoint::CCPoint(&v40, 0.0, v25);
v31(m_mg2BatchNode, &v40);
GJMGLayer::loadGroundSprites(a1, v33, 0);
GJMGLayer::updateGroundColor(a1, (cocos2d::ccColor3B)v34, 0);
sub_774008(&v35);
}
return v4;
}