//
// GJGroundLayer::updateGroundWidth from 0x10002c414 to 0x10002c57c (360 bytes)
//
// 1 xrefs:
// > GJGroundLayer::scaleGround @ 0x10002c3ec
//
// 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 __fastcall GJGroundLayer::updateGroundWidth(GJGroundLayer *a1, bool a2)
{
_BOOL4 v2; // w20
cocos2d::CCDirector *v4; // x0
GJGroundLayer_vtbl *v5; // x8
float (__fastcall **p_getScaleX)(GJGroundLayer *, __n128, __n128); // x8
GJGroundLayer *v7; // x0
float v8; // s8
float v9; // s0
int v10; // w21
_BOOL4 m_cameraRotated; // w22
__n128 v12; // q0
cocos2d::CCSprite *v13; // x0
cocos2d::CCSprite *m_lineSprite; // x20
float v15; // s8
__n128 v16; // q1
__n128 v17; // q0
__n128 v18; // q0
__n128 v19; // q1
int v20; // [xsp+0h] [xbp-40h] BYREF
float v21; // [xsp+8h] [xbp-38h]
cocos2d::CCSize WinSize; // 0:kr00_8.8
v2 = a2;
if ( ((__int64 (__fastcall *)(GJGroundLayer *))a1->getParent)(a1) )
{
v4 = cocos2d::CCDirector::sharedDirector();
WinSize = cocos2d::CCDirector::getWinSize(v4);
v18.n128_u32[0] = LODWORD(WinSize.width);
v19.n128_u32[0] = LODWORD(WinSize.height);
v5 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v2 )
{
p_getScaleX = (float (__fastcall **)(GJGroundLayer *, __n128, __n128))&v5->getScaleX;
v7 = a1;
}
else
{
v7 = (GJGroundLayer *)((__int64 (__fastcall *)(GJGroundLayer *, float, float))v5->getParent)(
a1,
WinSize.width,
WinSize.height);
p_getScaleX = (float (__fastcall **)(GJGroundLayer *, __n128, __n128))&v7->getScale;
}
v8 = (*p_getScaleX)(v7, v18, v19);
v9 = (float)(v21 / v8) + 10.0;
a1->m_groundWidth = v9;
v10 = (int)(float)(ceilf(v9 / a1->m_textureWidth) + 1.0);
m_cameraRotated = a1->m_cameraRotated;
GJGroundLayer::loadGroundSprites(a1, v10 + m_cameraRotated, 1);
GJGroundLayer::loadGroundSprites(a1, v10 + m_cameraRotated, 0);
if ( a1->m_lineType < 2 )
{
if ( !v2 )
{
LABEL_10:
m_lineSprite = a1->m_lineSprite;
v15 = (float)(a1->m_groundWidth * 0.5) + -5.0;
v16.n128_u32[0] = *(_DWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))m_lineSprite->getPosition)(m_lineSprite)
+ 4);
v17.n128_f32[0] = v15;
sub_100022980(v17, v16, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, int *))m_lineSprite->setPosition)(m_lineSprite, &v20);
return;
}
v13 = a1->m_lineSprite;
v12.n128_f32[0] = 1.0 / v8;
}
else
{
v13 = a1->m_lineSprite;
v12.n128_f32[0] = (float)((float)(v21 + 10.0) / v8) / v13->m_obRect.size.width;
}
((void (__fastcall *)(cocos2d::CCSprite *, __n128))v13->setScaleX)(v13, v12);
goto LABEL_10;
}
}