//
// GJGroundLayer::init from 0x10002ba0c to 0x10002be6c (1120 bytes)
//
// 1 xrefs:
// > GJGroundLayer::create @ 0x10002b9bc
//
// 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 GJGroundLayer::init(GJGroundLayer *a1, int a2, int a3)
{
_BOOL4 v6; // w19
cocos2d::CCDirector *v7; // x0
GameManager *v8; // x0
const char *GTexture; // x22
cocos2d::CCSprite *v10; // x23
__n128 v11; // q0
__n128 v12; // q1
cocos2d::CCDirector *v13; // x0
__n128 v14; // q0
__n128 v15; // q1
cocos2d::CCSprite *v16; // x24
__n128 v17; // q0
__n128 v18; // q1
cocos2d::CCDirector *v19; // x0
__n128 v20; // q0
__n128 v21; // q1
cocos2d::CCSpriteBatchNode *v22; // x23
__int64 v23; // x0
float v24; // s2
int v25; // w22
cocos2d::CCTexture2D *v26; // x0
cocos2d::CCSprite *v27; // x24
__n128 v28; // q0
__n128 v29; // q1
cocos2d::CCString *v30; // x0
const char *CString; // x0
cocos2d::CCSpriteBatchNode *v32; // x21
cocos2d::CCTexture2D *v33; // x0
cocos2d::CCSprite *v34; // x23
__n128 v35; // q0
__n128 v36; // q1
int v38; // [xsp+14h] [xbp-6Ch] BYREF
unsigned __int16 v39; // [xsp+1Ch] [xbp-64h] BYREF
unsigned __int8 v40; // [xsp+1Eh] [xbp-62h]
__int64 v41; // [xsp+20h] [xbp-60h] BYREF
float v42; // [xsp+28h] [xbp-58h]
v6 = cocos2d::CCLayer::init(a1);
if ( v6 )
{
((void (__fastcall *)(GJGroundLayer *, void *))a1->setContentSize)(a1, &unk_10086A478);
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v7);
v8 = GameManager::sharedState();
GTexture = GameManager::getGTexture(v8, a2);
a1->m_blendLine = 1;
GJGroundLayer::createLine(a1, a3);
v10 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v11.n128_u32[0] = 0;
v12.n128_u32[0] = 1.0;
sub_100022980(v11, v12, &v41);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v10->setAnchorPoint)(v10, &v41);
v13 = cocos2d::CCDirector::sharedDirector();
v14.n128_f32[0] = sub_1001768D8(v13) + -1.0;
v15.n128_u32[0] = 0;
sub_100022980(v14, v15, &v41);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v10->setPosition)(v10, &v41);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v10, 6);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v10->setTag)(v10, 0);
v16 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v17.n128_u32[0] = 1.0;
v18.n128_u32[0] = 1.0;
sub_100022980(v17, v18, &v41);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v16->setAnchorPoint)(v16, &v41);
v19 = cocos2d::CCDirector::sharedDirector();
v20.n128_f32[0] = sub_1001768E0(v19) + 1.0;
v21.n128_u32[0] = 0;
sub_100022980(v20, v21, &v41);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *))v16->setPosition)(v16, &v41);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v16, 6);
cocos2d::CCSprite::setFlipX(v16, 1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v16->setTag)(v16, 1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setOpacity)(v10, 100);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v16->setOpacity)(v16, 100);
((void (__fastcall *)(cocos2d::CCSprite *, float))v10->setScaleX)(v10, 0.7);
((void (__fastcall *)(cocos2d::CCSprite *, float))v16->setScaleX)(v16, 0.7);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setBlendFunc)(v10, 0x30300000306LL);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v16->setBlendFunc)(v16, 0x30300000306LL);
a1->m_showGround = 0;
v40 = -1;
v39 = 26112;
v22 = cocos2d::CCSpriteBatchNode::create(GTexture, 0x1Du);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSpriteBatchNode *, __int64))a1->addChild_0)(a1, v22, 2);
v23 = ((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v22->getTexture)(v22);
(*(void (__fastcall **)(__int64 *__return_ptr))(*(_QWORD *)v23 + 144LL))(&v41);
v24 = *((float *)&v41 + 1);
v25 = (int)(float)(ceilf(v42 / *(float *)&v41) + 1.0);
LODWORD(a1->m_textureWidth) = v41;
a1->m_ground1Offset = 128.0 - v24;
v26 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v22->getTexture)(v22);
v27 = cocos2d::CCSprite::createWithTexture(v26, &stru_10086A480);
a1->m_ground1Sprite = v27;
v27->m_bDontDraw = 1;
v28.n128_u32[0] = 0;
v29.n128_u32[0] = 0;
sub_100022980(v28, v29, &v38);
((void (__fastcall *)(cocos2d::CCSprite *, int *))v27->setPosition)(v27, &v38);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int16 *))a1->m_ground1Sprite->setColor)(
a1->m_ground1Sprite,
&v39);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))v22->addChild)(v22, a1->m_ground1Sprite);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, __int64))v22->setBlendFunc)(v22, 1);
GJGroundLayer::loadGroundSprites(a1, v25, 1);
GJGroundLayer::updateGround01Color(a1, (cocos2d::ccColor3B)(v39 | (v40 << 16)));
if ( a2 >= 8 )
{
v30 = (cocos2d::CCString *)sub_100268F4C("groundSquare_%02d_2_001.png", a2);
CString = cocos2d::CCString::getCString(v30);
v32 = cocos2d::CCSpriteBatchNode::create(CString, 0x1Du);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSpriteBatchNode *, __int64))a1->addChild_0)(a1, v32, 3);
v33 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v32->getTexture)(v32);
v34 = cocos2d::CCSprite::createWithTexture(v33, &stru_10086A480);
a1->m_ground2Sprite = v34;
v34->m_bDontDraw = 1;
v35.n128_u32[0] = 0;
v36.n128_u32[0] = 0;
sub_100022980(v35, v36, &v38);
((void (__fastcall *)(cocos2d::CCSprite *, int *))v34->setPosition)(v34, &v38);
((void (__fastcall *)(cocos2d::CCSprite *, unsigned __int16 *))a1->m_ground2Sprite->setColor)(
a1->m_ground2Sprite,
&v39);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))v32->addChild)(v32, a1->m_ground2Sprite);
GJGroundLayer::loadGroundSprites(a1, v25, 0);
GJGroundLayer::updateGround01Color(a1, (cocos2d::ccColor3B)(v39 | (v40 << 16)));
}
}
return v6;
}