//
// GJGroundLayer::loadGroundSprites from 0x140387320 to 0x1403875d6 (694 bytes)
//
// 9 xrefs:
// > GJGroundLayer::init @ 0x14038713b
// > GJGroundLayer::init @ 0x14038727f
// > GJGroundLayer::scaleGround @ 0x1403878a3
// > GJGroundLayer::scaleGround @ 0x1403878b0
// > ??> @ 0x1408bd85c
// > ??> @ 0x1408bd8dc
// > ??> @ 0x1408bd8f8
// > ??> @ 0x1408bd90c
// > ??> @ 0x140922ae4
//
// 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
//
void __fastcall GJGroundLayer::loadGroundSprites(__int64 a1, int a2, unsigned __int8 a3)
{
_QWORD *v6; // rsi
cocos2d::CCArray *v7; // rbx
struct cocos2d::CCArray *v8; // rax
int v9; // ebp
struct cocos2d::CCTexture2D *v10; // rax
struct cocos2d::CCSprite *v11; // rdi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // rbx
__int64 v15; // rax
struct cocos2d::CCTexture2D *v16; // rax
struct cocos2d::CCSprite *v17; // rdi
void (__fastcall *v18)(struct cocos2d::CCSprite *, __int64); // rbx
__int64 v19; // rax
__int64 v20; // rbx
__int64 v21; // rax
int v22; // edi
struct cocos2d::CCObject *Object; // rax
__int64 v24; // r8
_BYTE v25[16]; // [rsp+20h] [rbp-58h] BYREF
char v26; // [rsp+98h] [rbp+20h] BYREF
v6 = *(_QWORD **)(a1 + 8 * (a3 ^ 1LL) + 408);
if ( v6 )
{
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
if ( (*(__int64 (__fastcall **)(_QWORD *))(*v6 + 480LL))(v6) )
{
v8 = (struct cocos2d::CCArray *)(*(__int64 (__fastcall **)(_QWORD *))(*v6 + 480LL))(v6);
cocos2d::CCArray::addObjectsFromArray(v7, v8);
}
if ( cocos2d::CCArray::count(v7) != a2 )
{
if ( cocos2d::CCArray::count(v7) >= a2 )
{
v22 = cocos2d::CCArray::count(v7) - a2;
while ( v22 > 0 )
{
if ( !cocos2d::CCArray::count(v7) )
break;
--v22;
Object = cocos2d::CCArray::lastObject(v7);
LOBYTE(v24) = 1;
(*(void (__fastcall **)(_QWORD *, struct cocos2d::CCObject *, __int64))(*v6 + 536LL))(v6, Object, v24);
cocos2d::CCArray::removeLastObject(v7, 1);
}
}
else
{
v9 = cocos2d::CCArray::count(v7);
if ( v9 < a2 )
{
if ( a3 )
{
do
{
v10 = (struct cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(_QWORD *))(v6[43] + 16LL))(v6 + 43);
v11 = cocos2d::CCSprite::createWithTexture(v10);
(*(void (__fastcall **)(_QWORD *, struct cocos2d::CCSprite *))(*v6 + 464LL))(v6, v11);
v12 = *(_QWORD *)v11;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v26,
(float)v9 * *((float *)v11 + 108),
-*(float *)(a1 + 444));
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v12 + 184))(v11, v13);
v14 = *(_QWORD *)v11;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v25, 0.0, 1.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v14 + 288))(v11, v15);
(**((void (__fastcall ***)(__int64, void *))v11 + 40))((__int64)v11 + 320, &unk_140703478);
++v9;
}
while ( v9 < a2 );
}
else
{
do
{
v16 = (struct cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(_QWORD *))(v6[43] + 16LL))(v6 + 43);
v17 = cocos2d::CCSprite::createWithTexture(v16);
(*(void (__fastcall **)(_QWORD *, struct cocos2d::CCSprite *))(*v6 + 464LL))(v6, v17);
v18 = *(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(*(_QWORD *)v17 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v26, (float)v9 * *((float *)v17 + 108), 0.0);
v18(v17, v19);
v20 = *(_QWORD *)v17;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v25, 0.0, 1.0);
(*(void (__fastcall **)(struct cocos2d::CCSprite *, __int64))(v20 + 288))(v17, v21);
(**((void (__fastcall ***)(__int64, void *))v17 + 40))((__int64)v17 + 320, &unk_140703478);
++v9;
}
while ( v9 < a2 );
}
}
}
}
}
}