//
// GJGroundLayer::loadGroundSprites from 0x7eb814 to 0x7eba08 (500 bytes)
//
// 5 xrefs:
// > GJGroundLayer::init @ 0x7ec14c
// > GJGroundLayer::init @ 0x7ec21c
// > GJGroundLayer::updateGroundWidth @ 0x7ec3f4
// > GJGroundLayer::updateGroundWidth @ 0x7ec404
// > ??> @ 0x82020
//
// 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
//
void GJGroundLayer::loadGroundSprites(GJGroundLayer *a1, int a2, bool a3)
{
_BOOL4 v3; // w24
cocos2d::CCSprite *m_ground1Sprite; // x0
cocos2d::CCSprite *m_ground2Sprite; // 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 *, cocos2d::CCPoint *); // x28
float v16; // s0
void (__fastcall *v17)(float *, cocos2d::CCPoint *); // x28
int v18; // w0
int v19; // w21
__int64 Object; // x0
cocos2d::CCPoint v21; // [xsp+60h] [xbp+60h] BYREF
v3 = a3;
m_ground1Sprite = a1->m_ground1Sprite;
m_ground2Sprite = a1->m_ground2Sprite;
if ( a3 )
m_ground2Sprite = m_ground1Sprite;
if ( m_ground2Sprite )
{
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)m_ground1Sprite);
if ( m_ground2Sprite->getChildren(m_ground2Sprite) )
{
v9 = m_ground2Sprite->getChildren(m_ground2Sprite);
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 ( a2 > v10 )
{
do
{
v11 = (cocos2d::CCSprite *)m_ground2Sprite->getTexture(m_ground2Sprite);
v13 = (float *)cocos2d::CCSprite::createWithTexture(v11, v12);
m_ground2Sprite->addChild(m_ground2Sprite, (cocos2d::CCNode *)v13);
v14 = 0.0;
v15 = *(void (__fastcall **)(float *, cocos2d::CCPoint *))(*(_QWORD *)v13 + 184LL);
v16 = (float)v10 * v13[108];
if ( v3 )
v14 = -a1->m_ground1Offset;
++v10;
cocos2d::CCPoint::CCPoint(&v21, v16, v14);
v15(v13, &v21);
v17 = *(void (__fastcall **)(float *, cocos2d::CCPoint *))(*(_QWORD *)v13 + 280LL);
cocos2d::CCPoint::CCPoint(&v21, 0.0, 1.0);
v17(v13, &v21);
(*(void (__fastcall **)(float *, void *))(*(_QWORD *)v13 + 944LL))(v13, &unk_ED4710);
}
while ( v10 != a2 );
}
}
else
{
v18 = cocos2d::CCArray::count(v8);
v19 = v18 - a2;
if ( v19 > 0 )
{
do
{
if ( !(unsigned int)cocos2d::CCArray::count(v8) )
break;
--v19;
Object = cocos2d::CCArray::lastObject(v8);
m_ground2Sprite->removeChild_0(m_ground2Sprite, (cocos2d::CCNode *)Object, 1);
cocos2d::CCArray::removeLastObject(v8, 1);
}
while ( v19 );
}
}
}
}
}