//
// GJGroundLayer::init from 0x14027e220 to 0x14027e783 (1379 bytes)
//
// 2 xrefs:
// > GJGroundLayer::create @ 0x14027e1da
// > ??> @ 0x1406d11c0
//
// 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
//
// Hidden C++ exception states: #wind=1
bool GJGroundLayer::init(GJGroundLayer *a1, int a2, int a3)
{
float v3; // xmm0_4
bool result; // al
__int64 v8; // rcx
cocos2d::CCDirector *v9; // rax
GameManager *v10; // rcx
int v11; // eax
int v12; // ebx
cocos2d::CCString *v13; // rax
const char *CString; // r14
struct cocos2d::CCSprite *v15; // rsi
cocos2d::CCSprite_vtbl *v16; // rbx
const cocos2d::CCPoint *v17; // rax
cocos2d::CCSprite_vtbl *v18; // rbx
__int64 v19; // rcx
cocos2d::CCDirector *v20; // rax
float v21; // xmm0_4
double v22; // xmm0_8
const cocos2d::CCPoint *v23; // rax
struct cocos2d::CCSprite *v24; // rdi
cocos2d::CCSprite_vtbl *v25; // rbx
const cocos2d::CCPoint *v26; // rax
cocos2d::CCSprite_vtbl *v27; // rbx
__int64 v28; // rcx
cocos2d::CCDirector *v29; // rax
float v30; // xmm0_4
const cocos2d::CCPoint *v31; // rax
__int64 v32; // rdx
__int64 v33; // rdx
struct cocos2d::CCSpriteBatchNode *v34; // rdi
__int64 v35; // rax
float v36; // xmm1_4
float v37; // xmm0_4
int v38; // r13d
struct cocos2d::CCTexture2D *v39; // rax
struct cocos2d::CCSprite *v40; // rax
cocos2d::CCSprite_vtbl *v41; // rbx
double v42; // xmm0_8
const cocos2d::CCPoint *v43; // rax
unsigned int v44; // r14d
cocos2d::CCArray *v45; // rax
cocos2d::CCArray *v46; // rdi
unsigned int v47; // ebx
struct cocos2d::CCObject *v48; // rax
cocos2d::CCString *v49; // rax
const char *v50; // rax
struct cocos2d::CCSpriteBatchNode *v51; // rdi
struct cocos2d::CCTexture2D *v52; // rax
struct cocos2d::CCSprite *v53; // rax
cocos2d::CCSprite_vtbl *v54; // rbx
const cocos2d::CCPoint *v55; // rax
cocos2d::CCArray *v56; // rax
cocos2d::CCArray *v57; // rbx
struct cocos2d::CCObject *v58; // rax
__int16 v59; // [rsp+20h] [rbp-40h] BYREF
char v60; // [rsp+22h] [rbp-3Eh]
__int64 v61; // [rsp+30h] [rbp-30h]
_DWORD v62[6]; // [rsp+38h] [rbp-28h] BYREF
__int16 v63; // [rsp+A8h] [rbp+48h] BYREF
char v64; // [rsp+AAh] [rbp+4Ah]
result = cocos2d::CCLayer::init(a1);
if ( result )
{
a1->setContentSize(a1, &stru_1406C1E20);
v9 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::getWinSize(v9);
v10 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v61 = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v61);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
v11 = 22;
if ( a2 < 22 )
v11 = a2;
v12 = 1;
if ( v11 > 1 )
v12 = v11;
GameManager::loadGround(v10, v12);
v13 = cocos2d::CCString::createWithFormat("groundSquare_%02d_001.png", v12);
CString = cocos2d::CCString::getCString(v13);
a1->m_blendLine = 1;
GJGroundLayer::createLine(a1, a3);
v15 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v16 = v15->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v3, 0.0);
v16->setAnchorPoint(v15, v17);
v18 = v15->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v19);
v21 = cocos2d::CCDirector::getScreenLeft(v20) - 1.0;
v22 = cocos2d::CCPoint::CCPoint(v21, v21);
v18->setPosition_0(v15, v23);
a1->addChild_0(a1, v15, 6);
v15->setTag(v15, 0);
v24 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v25 = v24->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v22, 1.0);
v25->setAnchorPoint(v24, v26);
v27 = v24->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v29 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v28);
v30 = cocos2d::CCDirector::getScreenRight(v29) + 1.0;
cocos2d::CCPoint::CCPoint(v30, v30);
v27->setPosition_0(v24, v31);
a1->addChild_0(a1, v24, 6);
cocos2d::CCSprite::setFlipX(v24, 1);
v24->setTag(v24, 1);
LOBYTE(v32) = 100;
v15->setOpacity(&v15->cocos2d::CCRGBAProtocol, v32);
LOBYTE(v33) = 100;
v24->setOpacity(&v24->cocos2d::CCRGBAProtocol, v33);
((void (__fastcall *)(struct cocos2d::CCSprite *))v15->setScaleX)(v15);
((void (__fastcall *)(struct cocos2d::CCSprite *))v24->setScaleX)(v24);
v61 = 0x30300000306LL;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v15->setBlendFunc)(
&v15->cocos2d::CCTextureProtocol,
0x30300000306LL);
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v24->setBlendFunc)(
&v24->cocos2d::CCTextureProtocol,
0x30300000306LL);
a1->m_showGround = 0;
v59 = 26112;
v63 = 26112;
v64 = -1;
v34 = cocos2d::CCSpriteBatchNode::create(CString);
a1->addChild_0(a1, v34, 2);
v35 = (__int64)v34->getTexture(&v34->cocos2d::CCTextureProtocol);
(*(void (__fastcall **)(__int64, _DWORD *))(*(_QWORD *)v35 + 136LL))(v35, v62);
v36 = *(float *)v62;
LODWORD(a1->m_textureWidth) = v62[0];
v37 = ceilf(*(float *)&v62[2] / v36) + 1.0;
v38 = (int)v37;
a1->m_ground1Offset = 128.0 - *(float *)&v62[1];
v39 = v34->getTexture(&v34->cocos2d::CCTextureProtocol);
v40 = cocos2d::CCSprite::createWithTexture(v39, &stru_1406C1E10);
a1->m_ground1Sprite = v40;
v40->m_bDontDraw = 1;
v41 = a1->m_ground1Sprite->__vftable;
v42 = cocos2d::CCPoint::CCPoint(v37, 0.0);
v41->setPosition_0(a1->m_ground1Sprite, v43);
a1->m_ground1Sprite->setColor(&a1->m_ground1Sprite->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v63);
v34->addChild_1(v34, a1->m_ground1Sprite);
v61 = 1;
v44 = 0;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v34->setBlendFunc)(&v34->cocos2d::CCTextureProtocol, 1);
GJGroundLayer::loadGroundSprites(a1, v38, 1);
v59 = v63;
v60 = v64;
v45 = a1->m_ground1Sprite->getChildren(a1->m_ground1Sprite);
v46 = v45;
if ( v45 )
{
v47 = 0;
if ( cocos2d::CCArray::count(v45) )
{
do
{
v48 = cocos2d::CCArray::objectAtIndex(v46, v47);
(**(void (__fastcall ***)(__int64, __int16 *))&v48[5].m_unknown2)((__int64)&v48[5].m_unknown2, &v59);
++v47;
}
while ( v47 < cocos2d::CCArray::count(v46) );
}
}
if ( a2 >= 8 )
{
v49 = cocos2d::CCString::createWithFormat("groundSquare_%02d_2_001.png", a2);
v50 = cocos2d::CCString::getCString(v49);
v51 = cocos2d::CCSpriteBatchNode::create(v50);
a1->addChild_0(a1, v51, 3);
v52 = v51->getTexture(&v51->cocos2d::CCTextureProtocol);
v53 = cocos2d::CCSprite::createWithTexture(v52, &stru_1406C1E10);
a1->m_ground2Sprite = v53;
v53->m_bDontDraw = 1;
v54 = a1->m_ground2Sprite->__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v42, 0.0);
v54->setPosition_0(a1->m_ground2Sprite, v55);
a1->m_ground2Sprite->setColor(&a1->m_ground2Sprite->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v63);
v51->addChild_1(v51, a1->m_ground2Sprite);
GJGroundLayer::loadGroundSprites(a1, v38, 0);
v59 = v63;
v60 = v64;
v56 = a1->m_ground1Sprite->getChildren(a1->m_ground1Sprite);
v57 = v56;
if ( v56 )
{
if ( cocos2d::CCArray::count(v56) )
{
do
{
v58 = cocos2d::CCArray::objectAtIndex(v57, v44);
(**(void (__fastcall ***)(__int64, __int16 *))&v58[5].m_unknown2)((__int64)&v58[5].m_unknown2, &v59);
++v44;
}
while ( v44 < cocos2d::CCArray::count(v57) );
}
}
}
return 1;
}
return result;
}