//
// GJGroundLayer::updateGroundWidth from 0x917164 to 0x917308 (420 bytes)
//
// 2 xrefs:
// > GJGroundLayer::scaleGround @ 0x917518
// > ??> @ 0x842b0
//
// This function is hookable on this platform (idp: arm, 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:57:19 +0000
//
__int64 __fastcall GJGroundLayer::updateGroundWidth(GJGroundLayer *this, unsigned __int8 a2)
{
int v2; // w22
cocos2d::CCDirector *v4; // x0
cocos2d::CCDirector *v5; // x0
__int64 v6; // x1
__int64 v7; // x0
long double v8; // q0
bool v9; // zf
float v10; // s1
float v11; // s2
unsigned int v12; // w20
__int64 v13; // x20
float v14; // s0
void (__fastcall *v15)(__int64, _BYTE *); // x19
__int64 v16; // x0
float v18; // [xsp+40h] [xbp+40h]
float v19; // [xsp+50h] [xbp+50h]
__int64 v20; // [xsp+68h] [xbp+68h] BYREF
_BYTE v21[8]; // [xsp+70h] [xbp+70h] BYREF
v2 = a2;
v4 = (cocos2d::CCDirector *)(*(__int64 (__fastcall **)(GJGroundLayer *))(*(_QWORD *)this + 512LL))(this);
if ( v4 )
{
v5 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v4);
cocos2d::CCDirector::getWinSize(&v20, v5);
v6 = *(_QWORD *)this;
if ( v2 )
{
(*(void (__fastcall **)(GJGroundLayer *))(v6 + 136))(this);
}
else
{
v7 = (*(__int64 (__fastcall **)(GJGroundLayer *))(v6 + 512))(this);
v8 = ((long double (__fastcall *)(__int64))*(_QWORD *)(*(_QWORD *)v7 + 168LL))(v7);
}
v9 = *((_BYTE *)this + 464) == 0;
v10 = *((float *)this + 106);
v19 = *(float *)&v8;
v11 = (float)(*(float *)&v20 / *(float *)&v8) + 10.0;
*((float *)this + 113) = v11;
v12 = (int)(float)(ceilf(v11 / v10) + 1.0);
if ( !v9 )
++v12;
GJGroundLayer::loadGroundSprites(this, v12, 1u);
GJGroundLayer::loadGroundSprites(this, v12, 0);
if ( *((int *)this + 112) <= 1 )
{
if ( v2 )
(*(void (__fastcall **)(_QWORD, float))(**((_QWORD **)this + 54) + 128LL))(*((_QWORD *)this + 54), 1.0 / v19);
}
else
{
(*(void (__fastcall **)(_QWORD, float))(**((_QWORD **)this + 54) + 128LL))(
*((_QWORD *)this + 54),
(float)((float)(*(float *)&v20 + 10.0) / v19) / *(float *)(*((_QWORD *)this + 54) + 432LL));
}
v13 = *((_QWORD *)this + 54);
v14 = (float)(*((float *)this + 113) * 0.5) + -5.0;
v15 = *(void (__fastcall **)(__int64, _BYTE *))(*(_QWORD *)v13 + 184LL);
v18 = v14;
v16 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 192LL))(v13);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v21, v18, *(float *)(v16 + 4));
v15(v13, v21);
}
return _stack_chk_guard;
}