//
// GJGroundLayer::loadGroundSprites from 0x1005eb130 to 0x1005eb38a (602 bytes)
//
// 4 xrefs:
// > GJGroundLayer::init @ 0x1005eadc0
// > GJGroundLayer::init @ 0x1005eaef0
// > GJGroundLayer::updateGroundWidth @ 0x1005eb720
// > GJGroundLayer::updateGroundWidth @ 0x1005eb72d
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall GJGroundLayer::loadGroundSprites(GJGroundLayer *a1, int a2, bool a3)
{
__int64 v4; // rbx
__int64 v6; // r13
__int64 v7; // rsi
int v8; // r15d
cocos2d::CCTexture2D *v9; // rax
cocos2d::CCSprite *v10; // r13
int v11; // r15d
int v12; // r15d
__int64 v13; // rax
cocos2d::CCTexture2D *v14; // rax
cocos2d::CCSprite *v15; // r13
float v16; // [rsp+0h] [rbp-40h] BYREF
GJGroundLayer *v17; // [rsp+8h] [rbp-38h]
unsigned int v18; // [rsp+14h] [rbp-2Ch]
v17 = a1;
v4 = *((_QWORD *)&a1->m_ground1Sprite + !a3);
if ( v4 )
{
v6 = sub_10071F9E0(a1, *(_QWORD *)&a2);
if ( (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v4 + 472LL))(v4) )
{
v7 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v4 + 472LL))(v4);
sub_100720050(v6, v7);
}
if ( (unsigned int)sub_100720070(v6) != a2 )
{
v18 = sub_100720070(v6);
v8 = sub_100720070(v6);
if ( v18 >= a2 )
{
v11 = v8 - a2;
if ( v11 > 0 )
{
v12 = v11 + 1;
do
{
if ( !(unsigned int)sub_100720070(v6) )
break;
v13 = sub_1007200E0(v6);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v4 + 536LL))(v4, v13, 1);
sub_100720200(v6, 1);
--v12;
}
while ( v12 > 1 );
}
}
else if ( v8 < a2 )
{
if ( a3 )
{
do
{
v9 = (cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v4 + 1056LL))(v4);
v10 = cocos2d::CCSprite::createWithTexture_1(v9);
(*(void (__fastcall **)(__int64, cocos2d::CCSprite *))(*(_QWORD *)v4 + 440LL))(v4, v10);
sub_10028CBE0(&v16, (float)v8 * v10->m_obRect.size.width, -v17->m_ground1Offset);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v10->setPosition)(v10, &v16);
sub_10028CBE0(&v16, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v10->setAnchorPoint)(v10, &v16);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v10->setColor)(v10, &unk_1008219C8);
++v8;
}
while ( a2 != v8 );
}
else
{
do
{
v14 = (cocos2d::CCTexture2D *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v4 + 1056LL))(v4);
v15 = cocos2d::CCSprite::createWithTexture_1(v14);
(*(void (__fastcall **)(__int64, cocos2d::CCSprite *))(*(_QWORD *)v4 + 440LL))(v4, v15);
sub_10028CBE0(&v16, (float)v8 * v15->m_obRect.size.width, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v15->setPosition)(v15, &v16);
sub_10028CBE0(&v16, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v15->setAnchorPoint)(v15, &v16);
((void (__fastcall *)(cocos2d::CCSprite *, void *))v15->setColor)(v15, &unk_1008219C8);
++v8;
}
while ( a2 != v8 );
}
}
}
}
}