//
// GJMGLayer::loadGroundSprites from 0x917874 to 0x917a50 (476 bytes)
//
// 5 xrefs:
// > GJMGLayer::init @ 0x917d78
// > GJMGLayer::init @ 0x917ed4
// > GJMGLayer::updateGroundWidth @ 0x9181c8
// > GJMGLayer::updateGroundWidth @ 0x9181d8
// > ??> @ 0xe8288
//
// 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:20 +0000
//
__int64 __fastcall GJMGLayer::loadGroundSprites(GJMGLayer *this, unsigned int a2, char a3)
{
cocos2d::CCArray *v4; // x20
cocos2d::CCArray *v5; // x0
cocos2d::CCArray *v6; // x19
cocos2d::CCArray *v7; // x0
int v8; // w22
cocos2d::CCSprite *v9; // x0
cocos2d::CCTexture2D *v10; // x1
float *v11; // x19
float v12; // s0
void (__fastcall *v13)(float *, _BYTE *); // x25
void (__fastcall *v14)(float *, _BYTE *); // x25
int v16; // w0
int v17; // w21
__int64 Object; // x0
_BYTE v19[8]; // [xsp+50h] [xbp+50h] BYREF
v4 = *((cocos2d::CCArray **)this + 51);
v5 = *((cocos2d::CCArray **)this + 52);
if ( !a3 )
v4 = v5;
if ( v4 )
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
if ( (*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v4 + 488LL))(v4) )
{
v7 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v4 + 488LL))(v4);
cocos2d::CCArray::addObjectsFromArray(v6, v7);
}
if ( (unsigned int)cocos2d::CCArray::count(v6) != a2 )
{
if ( a2 > (unsigned int)cocos2d::CCArray::count(v6) )
{
v8 = cocos2d::CCArray::count(v6);
if ( (int)a2 > v8 )
{
do
{
v9 = (cocos2d::CCSprite *)(*(__int64 (__fastcall **)(cocos2d::CCArray *))(*(_QWORD *)v4 + 1072LL))(v4);
v11 = (float *)cocos2d::CCSprite::createWithTexture(v9, v10);
(*(void (__fastcall **)(cocos2d::CCArray *, float *))(*(_QWORD *)v4 + 456LL))(v4, v11);
v12 = (float)v8++;
v13 = *(void (__fastcall **)(float *, _BYTE *))(*(_QWORD *)v11 + 184LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v19, v12 * v11[108], 0.0);
v13(v11, v19);
v14 = *(void (__fastcall **)(float *, _BYTE *))(*(_QWORD *)v11 + 296LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v19, 0.0, 0.0);
v14(v11, v19);
(*(void (__fastcall **)(float *, void *))(*(_QWORD *)v11 + 960LL))(v11, &unk_1152A90);
}
while ( v8 != a2 );
}
}
else
{
v16 = cocos2d::CCArray::count(v6);
v17 = v16 - a2;
if ( v17 > 0 )
{
do
{
if ( !(unsigned int)cocos2d::CCArray::count(v6) )
break;
--v17;
Object = cocos2d::CCArray::lastObject(v6);
(*(void (__fastcall **)(cocos2d::CCArray *, __int64, __int64))(*(_QWORD *)v4 + 552LL))(v4, Object, 1);
cocos2d::CCArray::removeLastObject(v6, 1);
}
while ( v17 );
}
}
}
}
return _stack_chk_guard;
}