//
// GJBaseGameLayer::updateCameraBGArt from 0x1002035b0 to 0x100203c0c (1628 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::updateCamera @ 0x100200d24
// > LevelEditorLayer::updateEditor @ 0x100358538
//
// 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 GJBaseGameLayer::updateCameraBGArt(GJBaseGameLayer *a1, cocos2d::CCPoint a2, float a3)
{
float32x2_t *v3; // x1
float x; // s8
float32x2_t *v5; // x20
bool *p_m_isEditor; // x21
cocos2d::CCDirector *v8; // x0
__n128 v9; // q0
__n128 v10; // q1
bool v11; // w22
float v12; // s4
float m_unkFloat4; // s5
float v14; // s10
float v15; // s11
__n128 v16; // q0
__n128 v17; // q1
float m_levelFlipping; // s0
float v19; // s11
float *v20; // x0
float v21; // s9
__int64 v22; // x0
__n128 v23; // q1
__n128 v24; // q0
float m_unkFloat10; // s9
float v26; // s0
GJMGLayer *m_middleground; // x8
float m_groundScale; // s13
float m_unkFloat8; // s12
float v30; // s9
__n128 v31; // q0
__n128 v32; // q1
float v33; // s10
GJMGLayer *v34; // x0
float v35; // s14
float v36; // s13
float v37; // s8
cocos2d::CCDirector *v38; // x0
GJMGLayer *v39; // x20
float v40; // s8
__n128 v41; // q1
__n128 v42; // q0
GJMGLayer *v43; // x20
float m_textureWidth; // s0
float v45; // s1
float m_cameraZoom; // s0
float v47; // s8
float v48; // s8
float *v49; // x0
float v50; // s8
__n128 v51; // q1
__n128 v52; // q0
GJGroundLayer *m_groundLayer; // x20
float v54; // s0
float v55; // s1
GJGroundLayer *m_groundLayer2; // x20
float v57; // s10
float v58; // s9
__int64 v59; // x0
__n128 v60; // q0
float v61; // s3
float m_unkFloat9; // s4
__n128 v63; // q1
float v64; // s8
GJGroundLayer *v65; // x20
__n128 v66; // q0
GJGroundLayer *v67; // x20
__n128 v68; // q1
GJGroundLayer *v69; // x20
bool v70; // w1
GJGroundLayer *v71; // x19
bool v72; // w1
float m_middleGroundOffsetY; // [xsp+Ch] [xbp-A4h]
float m_ground2Offset; // [xsp+10h] [xbp-A0h]
float v75; // [xsp+14h] [xbp-9Ch]
__int64 v76; // [xsp+18h] [xbp-98h] BYREF
__int64 v77; // [xsp+20h] [xbp-90h] BYREF
float v78; // [xsp+28h] [xbp-88h] BYREF
float32x2_t v79; // [xsp+30h] [xbp-80h] BYREF
float32x2_t v80; // [xsp+38h] [xbp-78h] BYREF
float32x2_t v81; // [xsp+40h] [xbp-70h] BYREF
float v82; // [xsp+48h] [xbp-68h]
float v83; // [xsp+4Ch] [xbp-64h]
cocos2d::CCPoint v84; // 0:s0.4,4:s1.4
cocos2d::CCPoint v85; // 0:s0.4,4:s1.4
cocos2d::CCPoint v86; // 0:s0.4,4:s1.4
x = a2.x;
v5 = v3;
p_m_isEditor = &a1->m_isEditor;
v8 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v8);
v11 = *p_m_isEditor && !p_m_isEditor[396];
v9.n128_u32[0] = LODWORD(a1->m_gameState.m_cameraZoom);
v12 = v83 / v9.n128_f32[0];
m_unkFloat4 = a1->m_gameState.m_unkFloat4;
v14 = v82 / m_unkFloat4;
v9.n128_f32[0] = (float)(v82 / v9.n128_f32[0]) * 0.5;
v10.n128_f32[0] = v12 * 0.5;
v15 = v83 / m_unkFloat4;
sub_100022980(v9, v10, &v80);
v16.n128_f32[1] = sub_1000229DC(v5, &v80, &v81).f32[1];
v16.n128_f32[0] = v14 * 0.5;
v17.n128_f32[0] = v15 * 0.5;
sub_100022980(v16, v17, &v79);
sub_1000229DC((float32x2_t *)&a1->m_gameState.m_cameraPosition2, &v79, &v80);
sub_1000229F0(&v80, &v81, &v79);
sub_1000229D0(&a1->m_gameState.m_cameraStepDiff, (double *)&v79);
if ( p_m_isEditor[345] )
sub_1000229D0(&v79, (double *)&qword_10086C9A0);
m_levelFlipping = a1->m_gameState.m_levelFlipping;
if ( m_levelFlipping <= 0.5 )
v19 = (float)(m_levelFlipping * -2.0) + 1.0;
else
v19 = (float)(m_levelFlipping + -0.5) * -2.0;
v20 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getPosition)(a1->m_background);
v21 = *v20 + (float)((float)((float)(v79.f32[0] * a1->m_gameState.m_unkFloat5) * x) * v19);
v22 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getPosition)(a1->m_background);
v23.n128_f32[0] = *(float *)(v22 + 4) + (float)((float)(v79.f32[1] * a1->m_gameState.m_unkFloat6) * x);
v24.n128_f32[0] = v21;
sub_100022980(v24, v23, &v78);
m_unkFloat10 = a1->m_gameState.m_unkFloat10;
if ( m_unkFloat10 != 0.0 )
{
v26 = fmodf(v78, a1->m_gameState.m_unkFloat10);
v78 = v26;
if ( v26 > 0.0 )
v78 = v26 - m_unkFloat10;
}
((void (__fastcall *)(cocos2d::CCSprite *, float *))a1->m_background->setPosition)(a1->m_background, &v78);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
m_groundScale = m_middleground->m_groundScale;
m_unkFloat8 = a1->m_gameState.m_unkFloat8;
m_ground2Offset = m_middleground->m_ground2Offset;
v75 = v5->f32[1];
m_middleGroundOffsetY = a1->m_gameState.m_middleGroundOffsetY;
v30 = ((float (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer);
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleX)(a1->m_objectLayer);
if ( v11 )
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer);
else
v31.n128_f32[0] = (float)((float)(1.0 - fabsf(v31.n128_f32[0])) * -0.3) + 1.0;
v33 = v31.n128_f32[0] * 1.2;
v34 = a1->m_middleground;
if ( v34->m_groundScale == (float)(v31.n128_f32[0] * 1.2) )
v31.n128_u64[0] = 0;
else
v31.n128_f64[0] = GJMGLayer::scaleGround(v34, v33) * 0.5;
if ( m_groundScale == 0.0 )
v35 = v33;
else
v35 = m_groundScale;
v32.n128_f64[0] = (float)(v19 * (float)((float)(x / v33) * (float)(v79.f32[0] * a1->m_gameState.m_unkFloat7)));
v31.n128_f64[0] = v31.n128_f64[0] + v32.n128_f64[0];
v36 = v31.n128_f64[0];
if ( v11 )
{
v37 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getPosition)(a1->m_objectLayer)
+ 4)
+ (float)((float)(a1->m_middleground->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY) * v33);
if ( a1->m_gameState.m_unkFloat4 != a1->m_gameState.m_cameraZoom )
{
v38 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v38);
v36 = (float)((float)(*(float *)&v77 / v33) - (float)(*(float *)&v77 / v35)) * 0.5;
}
}
else
{
v37 = (float)((float)(m_ground2Offset + m_middleGroundOffsetY)
* (float)((float)(1.0 - m_unkFloat8) + (float)(v30 * m_unkFloat8)))
- (float)(v75 * m_unkFloat8);
}
v39 = a1->m_middleground;
v31.n128_u32[0] = 0;
v32.n128_f32[0] = v37;
sub_100022980(v31, v32, &v77);
((void (__fastcall *)(GJMGLayer *, __int64 *))v39->setPosition)(v39, &v77);
v40 = v36
+ *(float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_middleground->m_ground1Sprite->getPosition)(a1->m_middleground->m_ground1Sprite);
v41.n128_u32[0] = *(_DWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_middleground->m_ground1Sprite->getPosition)(a1->m_middleground->m_ground1Sprite)
+ 4);
v42.n128_f32[0] = v40;
sub_100022980(v42, v41, &v77);
v43 = a1->m_middleground;
m_textureWidth = v43->m_textureWidth;
v45 = *(float *)&v77;
if ( *(float *)&v77 < (float)-m_textureWidth )
{
do
v45 = m_textureWidth + v45;
while ( v45 < (float)-m_textureWidth );
*(float *)&v77 = v45;
}
if ( v45 > 0.0 )
{
do
v45 = v45 - m_textureWidth;
while ( v45 > 0.0 );
*(float *)&v77 = v45;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
*(float *)&v77 = v45 - m_textureWidth;
v84.x = sub_1000229B8(&v76, &v77);
GJMGLayer::updateGroundPos(v43, v84);
}
m_cameraZoom = a1->m_gameState.m_cameraZoom;
if ( a1->m_gameState.m_unkFloat4 == m_cameraZoom )
{
v48 = 0.0;
}
else
{
v47 = GJGroundLayer::scaleGround(a1->m_groundLayer, m_cameraZoom);
GJGroundLayer::scaleGround(a1->m_groundLayer2, a1->m_gameState.m_cameraZoom);
v48 = v47 * 0.5;
}
v49 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_groundLayer->m_ground1Sprite->getPosition)(a1->m_groundLayer->m_ground1Sprite);
v50 = v48 + (float)(*v49 + (float)(v79.f32[0] * v19));
v51.n128_u32[0] = *(_DWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_groundLayer->m_ground1Sprite->getPosition)(a1->m_groundLayer->m_ground1Sprite)
+ 4);
v52.n128_f32[0] = v50;
sub_100022980(v52, v51, &v77);
m_groundLayer = a1->m_groundLayer;
v54 = m_groundLayer->m_textureWidth;
v55 = *(float *)&v77;
if ( *(float *)&v77 < (float)-v54 )
{
do
v55 = v54 + v55;
while ( v55 < (float)-v54 );
*(float *)&v77 = v55;
}
if ( v55 > 0.0 )
{
do
v55 = v55 - v54;
while ( v55 > 0.0 );
*(float *)&v77 = v55;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
*(float *)&v77 = v55 - v54;
v85.x = sub_1000229B8(&v76, &v77);
GJGroundLayer::updateGroundPos(m_groundLayer, v85);
m_groundLayer2 = a1->m_groundLayer2;
v86.x = sub_1000229B8(&v76, &v77);
GJGroundLayer::updateGroundPos(m_groundLayer2, v86);
v57 = a1->m_cameraUnzoomedHeightOffset * a1->m_gameState.m_cameraZoom;
v58 = v83 + (float)(v57 * 0.5);
v59 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getPosition)(a1->m_objectLayer);
v61 = *(float *)&a1->m_gameState.m_unkInt11 * 0.5;
m_unkFloat9 = a1->m_gameState.m_unkFloat9;
v63.n128_f32[0] = -(float)((float)(v57 * 0.5)
- (float)((float)((float)(v57 * 0.5) + (float)((float)(v83 * 0.5) + (float)(1.0 - v61)))
* m_unkFloat9));
if ( v63.n128_f32[0] <= (float)(*(float *)(v59 + 4) + (float)(a1->m_gameState.m_cameraZoom * 91.0)) )
v63.n128_f32[0] = *(float *)(v59 + 4) + (float)(a1->m_gameState.m_cameraZoom * 91.0);
v64 = v58 - (float)((float)(v58 - (float)((float)(v83 * 0.5) + (float)(v61 + -1.0))) * m_unkFloat9);
v65 = a1->m_groundLayer;
v60.n128_u32[0] = 0;
sub_100022980(v60, v63, &v76);
v66 = ((__n128 (__fastcall *)(GJGroundLayer *, __int64 *))v65->setPosition)(v65, &v76);
v67 = a1->m_groundLayer2;
v66.n128_u32[0] = 0;
v68.n128_f32[0] = v64;
sub_100022980(v66, v68, &v76);
((void (__fastcall *)(GJGroundLayer *, __int64 *))v67->setPosition)(v67, &v76);
v69 = a1->m_groundLayer;
v70 = !p_m_isEditor[900]
&& *(float *)(((__int64 (__fastcall *)(GJGroundLayer *))v69->getPosition)(a1->m_groundLayer) + 4) > (float)-(float)(v57 * 0.5);
GJGroundLayer::toggleVisible01(v69, v70);
v71 = a1->m_groundLayer2;
v72 = !p_m_isEditor[900] && *(float *)(((__int64 (__fastcall *)(GJGroundLayer *))v71->getPosition)(v71) + 4) < v58;
GJGroundLayer::toggleVisible01(v71, v72);
}