//
// GJGroundLayer::loadGroundSprites from 0x916634 to 0x916828 (500 bytes)
//
// 5 xrefs:
// > GJGroundLayer::init @ 0x916f68
// > GJGroundLayer::init @ 0x91703c
// > GJGroundLayer::updateGroundWidth @ 0x917214
// > GJGroundLayer::updateGroundWidth @ 0x917224
// > ??> @ 0xace70
//
// This function is hookable on this platform (idp: arm, 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 12:57:19 +0000
//
__int64 __fastcall GJGroundLayer::loadGroundSprites(GJGroundLayer *this, unsigned int a2, unsigned __int8 a3)
{
int v3; // w24
cocos2d::CCArray *v6; // x0
cocos2d::CCArray *v7; // x20
cocos2d::CCArray *v8; // x19
cocos2d::CCArray *v9; // x0
int v10; // w27
cocos2d::CCSprite *v11; // x0
cocos2d::CCTexture2D *v12; // x1
float *v13; // x19
float v14; // s1
void (__fastcall *v15)(float *, _BYTE *); // x28
float v16; // s0
void (__fastcall *v17)(float *, _BYTE *); // x28
int v19; // w0
int v20; // w21
__int64 Object; // x0
_BYTE v22[8]; // [xsp+60h] [xbp+60h] BYREF
v3 = a3;
v6 = *((cocos2d::CCArray **)this + 51);
v7 = *((cocos2d::CCArray **)this + 52);
if ( a3 )
v7 = v6;
if ( v7 )
{
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
if ( (*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v7 + 488LL))(v7) )
{
v9 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v7 + 488LL))(v7);
cocos2d::CCArray::addObjectsFromArray(v8, v9);
}
if ( (unsigned int)cocos2d::CCArray::count(v8) != a2 )
{
if ( a2 > (unsigned int)cocos2d::CCArray::count(v8) )
{
v10 = cocos2d::CCArray::count(v8);
if ( (int)a2 > v10 )
{
do
{
v11 = (cocos2d::CCSprite *)(*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v7 + 1072LL))(v7);
v13 = (float *)cocos2d::CCSprite::createWithTexture(v11, v12);
(*(void (__fastcall **)(cocos2d::CCArray *, float *))(*(_QWORD *)v7 + 456LL))(v7, v13);
v14 = 0.0;
v15 = *(void (__fastcall **)(float *, _BYTE *))(*(_QWORD *)v13 + 184LL);
v16 = (float)v10 * v13[108];
if ( v3 )
v14 = -*((float *)this + 111);
++v10;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v22, v16, v14);
v15(v13, v22);
v17 = *(void (__fastcall **)(float *, _BYTE *))(*(_QWORD *)v13 + 296LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v22, 0.0, 1.0);
v17(v13, v22);
(*(void (__fastcall **)(float *, void *))(*(_QWORD *)v13 + 960LL))(v13, &unk_1152A90);
}
while ( v10 != a2 );
}
}
else
{
v19 = cocos2d::CCArray::count(v8);
v20 = v19 - a2;
if ( v20 > 0 )
{
do
{
if ( !(unsigned int)cocos2d::CCArray::count(v8) )
break;
--v20;
Object = cocos2d::CCArray::lastObject(v8);
(*(void (__fastcall **)(cocos2d::CCArray *, __int64, __int64))(*(_QWORD *)v7 + 552LL))(v7, Object, 1);
cocos2d::CCArray::removeLastObject(v8, 1);
}
while ( v20 );
}
}
}
}
return _stack_chk_guard;
}