//
// GJMGLayer::loadGroundSprites from 0x434e6c to 0x434f90 (292 bytes)
//
// 4 xrefs:
// > GJMGLayer::init @ 0x43513c
// > GJMGLayer::init @ 0x435220
// > GJMGLayer::updateGroundWidth @ 0x435406
// > GJMGLayer::updateGroundWidth @ 0x435410
//
// 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 GJMGLayer::loadGroundSprites(GJMGLayer *a1, int a2, bool a3)
{
cocos2d::CCSprite *m_ground1Sprite; // r4
cocos2d::CCArray *v5; // r5
cocos2d::CCArray *v6; // r0
int v7; // r7
__int64 v8; // r0
float *v9; // r5
float v10; // s14
void (__fastcall *v11)(float *, cocos2d::CCPoint *); // r11
void (__fastcall *v12)(float *, cocos2d::CCPoint *); // r11
int v13; // r6
cocos2d::CCNode *Object; // r0
cocos2d::CCPoint v15; // [sp+4h] [bp-10h] BYREF
m_ground1Sprite = a1->m_ground1Sprite;
if ( !a3 )
m_ground1Sprite = a1->m_ground2Sprite;
if ( m_ground1Sprite )
{
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)a1);
if ( m_ground1Sprite->getChildren(m_ground1Sprite) )
{
v6 = m_ground1Sprite->getChildren(m_ground1Sprite);
cocos2d::CCArray::addObjectsFromArray(v5, v6);
}
if ( cocos2d::CCArray::count(v5) != a2 )
{
if ( cocos2d::CCArray::count(v5) >= (unsigned int)a2 )
{
v13 = cocos2d::CCArray::count(v5) - a2;
while ( v13 > 0 && cocos2d::CCArray::count(v5) )
{
--v13;
Object = (cocos2d::CCNode *)cocos2d::CCArray::lastObject(v5);
m_ground1Sprite->removeChild_0(m_ground1Sprite, Object, 1);
cocos2d::CCArray::removeLastObject(v5, 1);
}
}
else
{
v7 = cocos2d::CCArray::count(v5);
while ( v7 < a2 )
{
v8 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))m_ground1Sprite->getTexture)(m_ground1Sprite);
v9 = (float *)cocos2d::CCSprite::createWithTexture(
(cocos2d::CCSprite *)v8,
(cocos2d::CCTexture2D *)HIDWORD(v8));
m_ground1Sprite->addChild(m_ground1Sprite, (cocos2d::CCNode *)v9);
v10 = (float)v7++;
v11 = *(void (__fastcall **)(float *, cocos2d::CCPoint *))(*(_DWORD *)v9 + 92);
cocos2d::CCPoint::CCPoint(&v15, v10 * v9[86], 0.0);
v11(v9, &v15);
v12 = *(void (__fastcall **)(float *, cocos2d::CCPoint *))(*(_DWORD *)v9 + 140);
cocos2d::CCPoint::CCPoint(&v15, 0.0, 0.0);
v12(v9, &v15);
(*(void (__fastcall **)(float *, _UNKNOWN **))(*(_DWORD *)v9 + 472))(v9, &off_9AB688);
}
}
}
}
}