//
// GJGroundLayer::init from 0x140386d80 to 0x140387312 (1426 bytes)
//
// 2 xrefs:
// > GJGroundLayer::create @ 0x140386d3a
// > ??> @ 0x140922ad8
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:31:08 +0000
//
// Hidden C++ exception states: #wind=1
bool __fastcall GJGroundLayer::init(__int64 a1, int a2, unsigned int a3)
{
bool result; // al
__int64 v7; // rcx
__int64 v8; // rax
__int64 v9; // rcx
int v10; // eax
int v11; // ebx
cocos2d::CCString *v12; // rax
const char *CString; // r14
struct cocos2d::CCSprite *v14; // rsi
__int64 v15; // rbx
__int64 v16; // rax
__int64 v17; // rbx
__int64 v18; // rcx
cocos2d::CCDirector *v19; // rax
float v20; // xmm0_4
__int64 v21; // rax
struct cocos2d::CCSprite *v22; // rdi
__int64 v23; // rbx
__int64 v24; // rax
__int64 v25; // rbx
__int64 v26; // rcx
cocos2d::CCDirector *v27; // rax
float v28; // xmm0_4
__int64 v29; // rax
__int64 v30; // rdx
__int64 v31; // rdx
struct cocos2d::CCSpriteBatchNode *v32; // rsi
__int64 v33; // rax
float v34; // xmm1_4
struct cocos2d::CCTexture2D *v35; // rax
struct cocos2d::CCSprite *v36; // rax
__int64 v37; // rdi
__int64 v38; // rbx
__int64 v39; // rax
unsigned int v40; // r15d
__int64 v41; // r8
unsigned int v42; // r14d
cocos2d::CCArray *v43; // rax
cocos2d::CCArray *v44; // rdi
unsigned int v45; // ebx
struct cocos2d::CCObject *v46; // rax
cocos2d::CCString *v47; // rax
const char *v48; // rax
struct cocos2d::CCSpriteBatchNode *v49; // rsi
struct cocos2d::CCTexture2D *v50; // rax
struct cocos2d::CCSprite *v51; // rax
__int64 v52; // rdi
__int64 v53; // rbx
__int64 v54; // rax
cocos2d::CCArray *v55; // rax
cocos2d::CCArray *v56; // rbx
struct cocos2d::CCObject *v57; // rax
__int16 v58; // [rsp+20h] [rbp-40h] BYREF
char v59; // [rsp+22h] [rbp-3Eh]
__int64 v60; // [rsp+30h] [rbp-30h]
_DWORD v61[2]; // [rsp+38h] [rbp-28h] BYREF
__int64 v62; // [rsp+40h] [rbp-20h] BYREF
float v63; // [rsp+48h] [rbp-18h] BYREF
__int16 v64; // [rsp+A8h] [rbp+48h] BYREF
char v65; // [rsp+AAh] [rbp+4Ah]
result = cocos2d::CCLayer::init((cocos2d::CCLayer *)a1);
if ( result )
{
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)a1 + 312LL))(a1, &unk_14090AB88);
v8 = cocos2d::CCDirector::sharedDirector(v7);
cocos2d::CCDirector::getWinSize(v8, &v63);
v9 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v62 = (__int64)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v62);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v9 = qword_14090BFD0;
}
v10 = 22;
if ( a2 < 22 )
v10 = a2;
v11 = 1;
if ( v10 > 1 )
v11 = v10;
GameManager::loadGround(v9, v11);
v12 = cocos2d::CCString::createWithFormat("groundSquare_%02d_001.png", v11);
CString = cocos2d::CCString::getCString(v12);
*(_BYTE *)(a1 + 441) = 1;
GJGroundLayer::createLine(a1, a3);
v14 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v15 = *(_QWORD *)v14;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, 0.0, 1.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v15 + 288))(v14, v16);
v17 = *(_QWORD *)v14;
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
v20 = cocos2d::CCDirector::getScreenLeft(v19) - 1.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v20, 0.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v17 + 184))(v14, v21);
(*(void (__fastcall **)(__int64, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v14, 6);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, _QWORD))(*(_QWORD *)v14 + 64LL))(v14, 0);
v22 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
v23 = *(_QWORD *)v22;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, 1.0, 1.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v23 + 288))(v22, v24);
v25 = *(_QWORD *)v22;
v27 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v26);
v28 = cocos2d::CCDirector::getScreenRight(v27) + 1.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v28, 0.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v25 + 184))(v22, v29);
(*(void (__fastcall **)(__int64, struct cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v22, 6);
cocos2d::CCSprite::setFlipX(v22, 1);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(*(_QWORD *)v22 + 64LL))(v22, 1);
LOBYTE(v30) = 100;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v14 + 40) + 40LL))((__int64)v14 + 320, v30);
LOBYTE(v31) = 100;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v22 + 40) + 40LL))((__int64)v22 + 320, v31);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v14 + 120LL))(v14);
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v22 + 120LL))(v22);
v60 = 0x30300000306LL;
(**((void (__fastcall ***)(__int64, __int64))v14 + 43))((__int64)v14 + 344, 0x30300000306LL);
(**((void (__fastcall ***)(__int64, __int64))v22 + 43))((__int64)v22 + 344, 0x30300000306LL);
*(_BYTE *)(a1 + 440) = 0;
v58 = 26112;
v64 = 26112;
v65 = -1;
v32 = cocos2d::CCSpriteBatchNode::create(CString);
(*(void (__fastcall **)(__int64, struct cocos2d::CCSpriteBatchNode *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v32, 2);
v33 = (*(__int64 (__fastcall **)(__int64))(*((_QWORD *)v32 + 40) + 16LL))((__int64)v32 + 320);
(*(void (__fastcall **)(__int64, _DWORD *))(*(_QWORD *)v33 + 136LL))(v33, v61);
v34 = *(float *)v61;
*(_DWORD *)(a1 + 424) = v61[0];
LODWORD(v60) = (int)(float)(ceilf(v63 / v34) + 1.0);
*(float *)(a1 + 444) = 128.0 - *(float *)&v61[1];
v35 = (struct cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(__int64))(*((_QWORD *)v32 + 40) + 16LL))((__int64)v32 + 320);
v36 = cocos2d::CCSprite::createWithTexture(v35, (const struct cocos2d::CCRect *)&unk_14090AB78);
*(_QWORD *)(a1 + 408) = v36;
*((_BYTE *)v36 + 559) = 1;
v37 = **(_QWORD **)(a1 + 408);
v38 = *(_QWORD *)(a1 + 408);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, 0.0, 0.0);
(*(void (__fastcall **)(__int64, __int64))(v37 + 184))(v38, v39);
(**(void (__fastcall ***)(__int64, __int16 *))(*(_QWORD *)(a1 + 408) + 320LL))(*(_QWORD *)(a1 + 408) + 320LL, &v64);
(*(void (__fastcall **)(struct cocos2d::CCSpriteBatchNode *, _QWORD))(*(_QWORD *)v32 + 464LL))(
v32,
*(_QWORD *)(a1 + 408));
v62 = 1;
v40 = 0;
(**((void (__fastcall ***)(__int64, __int64))v32 + 40))((__int64)v32 + 320, 1);
LOBYTE(v41) = 1;
v42 = v60;
GJGroundLayer::loadGroundSprites(a1, (unsigned int)v60, v41);
v58 = v64;
v59 = v65;
v43 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 408) + 480LL))(*(_QWORD *)(a1 + 408));
v44 = v43;
if ( v43 )
{
v45 = 0;
if ( cocos2d::CCArray::count(v43) )
{
do
{
v46 = cocos2d::CCArray::objectAtIndex(v44, v45);
(**((void (__fastcall ***)(__int64, __int16 *))v46 + 40))((__int64)v46 + 320, &v58);
++v45;
}
while ( v45 < cocos2d::CCArray::count(v44) );
}
}
if ( a2 >= 8 )
{
v47 = cocos2d::CCString::createWithFormat("groundSquare_%02d_2_001.png", a2);
v48 = cocos2d::CCString::getCString(v47);
v49 = cocos2d::CCSpriteBatchNode::create(v48);
(*(void (__fastcall **)(__int64, struct cocos2d::CCSpriteBatchNode *, __int64))(*(_QWORD *)a1 + 456LL))(
a1,
v49,
3);
v50 = (struct cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(__int64))(*((_QWORD *)v49 + 40) + 16LL))((__int64)v49 + 320);
v51 = cocos2d::CCSprite::createWithTexture(v50, (const struct cocos2d::CCRect *)&unk_14090AB78);
*(_QWORD *)(a1 + 416) = v51;
*((_BYTE *)v51 + 559) = 1;
v52 = **(_QWORD **)(a1 + 416);
v53 = *(_QWORD *)(a1 + 416);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, 0.0, 0.0);
(*(void (__fastcall **)(__int64, __int64))(v52 + 184))(v53, v54);
(**(void (__fastcall ***)(__int64, __int16 *))(*(_QWORD *)(a1 + 416) + 320LL))(
*(_QWORD *)(a1 + 416) + 320LL,
&v64);
(*(void (__fastcall **)(struct cocos2d::CCSpriteBatchNode *, _QWORD))(*(_QWORD *)v49 + 464LL))(
v49,
*(_QWORD *)(a1 + 416));
GJGroundLayer::loadGroundSprites(a1, v42, 0);
v58 = v64;
v59 = v65;
v55 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 408) + 480LL))(*(_QWORD *)(a1 + 408));
v56 = v55;
if ( v55 )
{
if ( cocos2d::CCArray::count(v55) )
{
do
{
v57 = cocos2d::CCArray::objectAtIndex(v56, v40);
(**((void (__fastcall ***)(__int64, __int16 *))v57 + 40))((__int64)v57 + 320, &v58);
++v40;
}
while ( v40 < cocos2d::CCArray::count(v56) );
}
}
}
return 1;
}
return result;
}