//
// GJGroundLayer::loadGroundSprites from 0x1006be1c0 to 0x1006be41a (602 bytes)
//
// 4 xrefs:
// > GJGroundLayer::init @ 0x1006bde50
// > GJGroundLayer::init @ 0x1006bdf80
// > GJGroundLayer::updateGroundWidth @ 0x1006be7b0
// > GJGroundLayer::updateGroundWidth @ 0x1006be7bd
//
// 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 12:35:30 +0000
//
__int64 __fastcall GJGroundLayer::loadGroundSprites(__int64 a1, int a2, unsigned __int8 a3)
{
__int64 result; // rax
__int64 v5; // rbx
__int64 v7; // r13
__int64 v8; // rsi
int v9; // r15d
__int64 v10; // rax
float *v11; // r13
int v12; // r15d
__int64 v13; // rax
__int64 v14; // rax
float *v15; // r13
float v16; // [rsp+0h] [rbp-40h] BYREF
__int64 v17; // [rsp+8h] [rbp-38h]
unsigned int v18; // [rsp+14h] [rbp-2Ch]
result = a3 ^ 1u;
v17 = a1;
v5 = *(_QWORD *)(a1 + 8 * result + 408);
if ( v5 )
{
v7 = sub_1007FE900(a1);
if ( (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 488LL))(v5) )
{
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 488LL))(v5);
sub_1007FEF70(v7, v8);
}
result = sub_1007FEF90(v7);
if ( (_DWORD)result != a2 )
{
v18 = sub_1007FEF90(v7);
result = sub_1007FEF90(v7);
v9 = result;
if ( v18 >= a2 )
{
if ( (int)result - a2 > 0 )
{
v12 = result - a2 + 1;
do
{
result = sub_1007FEF90(v7);
if ( !(_DWORD)result )
break;
v13 = sub_1007FF000(v7);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v5 + 552LL))(v5, v13, 1);
result = sub_1007FF120(v7, 1);
--v12;
}
while ( v12 > 1 );
}
}
else if ( (int)result < a2 )
{
if ( a3 )
{
do
{
v10 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 1072LL))(v5);
v11 = (float *)cocos2d::CCSprite::createWithTexture_1(v10);
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v5 + 456LL))(v5, v11);
sub_100278250(&v16, (float)v9 * v11[108], -*(float *)(v17 + 444));
(*(void (__fastcall **)(float *, float *))(*(_QWORD *)v11 + 184LL))(v11, &v16);
sub_100278250(&v16, 0.0, 1.0);
(*(void (__fastcall **)(float *, float *))(*(_QWORD *)v11 + 296LL))(v11, &v16);
result = (*(__int64 (__fastcall **)(float *, void *))(*(_QWORD *)v11 + 960LL))(v11, &unk_100A108C8);
++v9;
}
while ( a2 != v9 );
}
else
{
do
{
v14 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 1072LL))(v5);
v15 = (float *)cocos2d::CCSprite::createWithTexture_1(v14);
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v5 + 456LL))(v5, v15);
sub_100278250(&v16, (float)v9 * v15[108], 0.0);
(*(void (__fastcall **)(float *, float *))(*(_QWORD *)v15 + 184LL))(v15, &v16);
sub_100278250(&v16, 0.0, 1.0);
(*(void (__fastcall **)(float *, float *))(*(_QWORD *)v15 + 296LL))(v15, &v16);
result = (*(__int64 (__fastcall **)(float *, void *))(*(_QWORD *)v15 + 960LL))(v15, &unk_100A108C8);
++v9;
}
while ( a2 != v9 );
}
}
}
}
return result;
}