//
// GJBaseGameLayer::updateCameraBGArt from 0x477220 to 0x4777cc (1452 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::updateEditor @ 0x3763c8
// > GJBaseGameLayer::updateCamera @ 0x48745a
//
// 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 GJBaseGameLayer::updateCameraBGArt(GJBaseGameLayer *a1, cocos2d::CCPoint a2, float a3)
{
float v4; // r9
float y; // s17
cocos2d::CCDirector *v6; // r0
_BOOL4 m_isEditor; // r6
float m_unkFloat4; // s15
float v9; // s16
float v10; // s18
float v11; // s15
int v12; // r2
bool v13; // r3
int v14; // r2
float m_levelFlipping; // s18
bool v16; // cc
const cocos2d::CCPoint *v17; // r0
float v18; // s15
float v19; // s16
const cocos2d::CCPoint *v20; // r0
float v21; // r0
GJMGLayer *m_middleground; // r3
float m_groundScale; // s21
float m_ground2Offset; // s20
float m_unkFloat8; // s22
float v26; // s23
float m_middleGroundOffsetY; // s25
float v28; // s24
float v29; // r0
float v30; // s14
GJMGLayer *v31; // r0
float v32; // s16
float v33; // s12
float v34; // s17
float v35; // s20
cocos2d::CCDirector *v36; // r0
GJMGLayer *v37; // r6
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
float v39; // s15
const cocos2d::CCPoint *v40; // r0
GJMGLayer *v41; // r6
float v42; // s15
float i; // s14
float m_cameraAngle; // s13
cocos2d::CCPoint v45; // r1
float v46; // s17
const cocos2d::CCPoint *v47; // r0
float v48; // s16
const cocos2d::CCPoint *v49; // r0
GJGroundLayer *m_groundLayer; // r6
float v51; // s15
float j; // s14
float v53; // s13
cocos2d::CCPoint v54; // r1
GJGroundLayer *m_groundLayer2; // r6
cocos2d::CCPoint v56; // r1
float height; // s17
float v58; // s16
const cocos2d::CCPoint *v59; // r0
GJGroundLayer *v60; // r6
float m_unkFloat9; // s12
void (__fastcall *v62)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
float v63; // s16
float v64; // s17
float v65; // s19
float v66; // s15
float v67; // r2
GJGroundLayer *v68; // r6
void (__fastcall *v69)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
GJGroundLayer *v70; // r5
bool v71; // r1
GJGroundLayer *v72; // r5
bool v73; // r1
cocos2d::CCSize v74; // [sp+4h] [bp-40h] BYREF
_BYTE v75[8]; // [sp+Ch] [bp-38h] BYREF
_BYTE v76[8]; // [sp+14h] [bp-30h] BYREF
float v77[2]; // [sp+1Ch] [bp-28h] BYREF
cocos2d::CCPoint x; // [sp+24h] [bp-20h] BYREF
cocos2d::CCPoint v79; // [sp+2Ch] [bp-18h] BYREF
cocos2d::CCPoint v80; // [sp+34h] [bp-10h] BYREF
v4 = a2.x;
y = a2.y;
v6 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v74, v6);
m_isEditor = a1->m_isEditor;
if ( a1->m_isEditor )
m_isEditor = !a1->m_started;
m_unkFloat4 = a1->m_gameState.m_unkFloat4;
v9 = v74.height / m_unkFloat4;
v10 = v74.width / m_unkFloat4;
cocos2d::CCPoint::CCPoint(
&v80,
(float)(v74.width / a1->m_gameState.m_cameraZoom) * 0.5,
(float)(v74.height / a1->m_gameState.m_cameraZoom) * 0.5);
cocos2d::CCPoint::operator+(v75, LODWORD(v4), &v80);
v11 = v9 * 0.5;
cocos2d::CCPoint::CCPoint(&v80, v10 * 0.5, v9 * 0.5);
cocos2d::CCPoint::operator+(v76, &a1->m_gameState.m_cameraPosition2, &v80);
cocos2d::CCPoint::operator-(v77, v76, v75);
cocos2d::CCPoint::operator=((PlayerObject *)&a1->m_gameState.m_cameraStepDiff, COERCE_FLOAT(v77), v12, v13);
if ( a1->m_skipArtReload )
cocos2d::CCPoint::operator=((PlayerObject *)v77, COERCE_FLOAT(&stru_AC68C0), v14, a1->m_skipArtReload);
m_levelFlipping = a1->m_gameState.m_levelFlipping;
v16 = m_levelFlipping > 0.5;
if ( m_levelFlipping <= 0.5 )
m_levelFlipping = m_levelFlipping + m_levelFlipping;
else
v11 = 0.5;
if ( v16 )
m_levelFlipping = m_levelFlipping - v11;
else
v11 = 1.0;
if ( v16 )
v11 = -2.0;
else
m_levelFlipping = v11 - m_levelFlipping;
if ( v16 )
m_levelFlipping = m_levelFlipping * v11;
v17 = a1->m_background->getPosition(a1->m_background);
v18 = (float)(v77[0] * a1->m_gameState.m_unkFloat5) * y;
v19 = v17->x;
v20 = a1->m_background->getPosition(a1->m_background);
cocos2d::CCPoint::CCPoint(
&x,
v19 + (float)(v18 * m_levelFlipping),
v20->y + (float)((float)(v77[1] * a1->m_gameState.m_unkFloat6) * y));
if ( a1->m_gameState.m_unkFloat10 != 0.0 )
{
v21 = fmodf(x.x, a1->m_gameState.m_unkFloat10);
x.x = v21;
if ( v21 > 0.0 )
x.x = v21 - a1->m_gameState.m_unkFloat10;
}
a1->m_background->setPosition(a1->m_background, &x);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
m_groundScale = m_middleground->m_groundScale;
m_ground2Offset = m_middleground->m_ground2Offset;
m_unkFloat8 = a1->m_gameState.m_unkFloat8;
v26 = *(float *)(LODWORD(v4) + 4);
m_middleGroundOffsetY = a1->m_gameState.m_middleGroundOffsetY;
v28 = COERCE_FLOAT(((int (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer));
v29 = COERCE_FLOAT(((int (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleX)(a1->m_objectLayer));
if ( m_isEditor )
v30 = COERCE_FLOAT(((int (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer));
else
v30 = 1.0 - (1.0 - fabsf(v29)) * 0.300000012;
v31 = a1->m_middleground;
v32 = v30 * 1.2;
if ( v31->m_groundScale == (float)(v30 * 1.2) )
v33 = 0.0;
else
v33 = GJMGLayer::scaleGround(v31, v30 * 1.2);
v34 = (float)((float)((float)(v77[0] * a1->m_gameState.m_unkFloat7) * (float)(y / v32)) * m_levelFlipping)
+ v33 * 0.5;
if ( m_groundScale == 0.0 )
m_groundScale = v30 * 1.2;
if ( m_isEditor )
{
v35 = a1->m_objectLayer->getPosition(a1->m_objectLayer)->y
+ (float)((float)(a1->m_middleground->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY) * v32);
if ( a1->m_gameState.m_unkFloat4 != a1->m_gameState.m_cameraZoom )
{
v36 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCSize *)&v80, v36);
v34 = (float)((float)(v80.x / v32) - (float)(v80.x / m_groundScale)) * 0.5;
}
}
else
{
v35 = (float)((float)(m_ground2Offset + m_middleGroundOffsetY)
* (float)((float)(1.0 - m_unkFloat8) + (float)(v28 * m_unkFloat8)))
- (float)(v26 * m_unkFloat8);
}
v37 = a1->m_middleground;
setPosition = v37->setPosition;
cocos2d::CCPoint::CCPoint(&v80, 0.0, v35);
setPosition(v37, &v80);
v39 = a1->m_middleground->m_ground1Sprite->getPosition(a1->m_middleground->m_ground1Sprite)->x;
v40 = a1->m_middleground->m_ground1Sprite->getPosition(a1->m_middleground->m_ground1Sprite);
cocos2d::CCPoint::CCPoint(&v79, v34 + v39, v40->y);
v41 = a1->m_middleground;
v42 = v79.x;
for ( i = v41->m_textureWidth; v42 < (float)-i; v42 = v42 + i )
;
while ( v42 > 0.0 )
v42 = v42 - i;
m_cameraAngle = a1->m_gameState.m_cameraAngle;
v79.x = v42;
if ( m_cameraAngle != 0.0 )
v79.x = v42 - i;
cocos2d::CCPoint::CCPoint(&v80, &v79);
LODWORD(v45.x) = &v80;
GJMGLayer::updateGroundPos(v41, v45);
}
if ( a1->m_gameState.m_unkFloat4 == a1->m_gameState.m_cameraZoom )
{
v46 = 0.0;
}
else
{
v46 = GJGroundLayer::scaleGround(a1->m_groundLayer, a1->m_gameState.m_cameraZoom);
GJGroundLayer::scaleGround(a1->m_groundLayer2, a1->m_gameState.m_cameraZoom);
}
v47 = a1->m_groundLayer->m_ground1Sprite->getPosition(a1->m_groundLayer->m_ground1Sprite);
v48 = v47->x + (float)(m_levelFlipping * v77[0]);
v49 = a1->m_groundLayer->m_ground1Sprite->getPosition(a1->m_groundLayer->m_ground1Sprite);
cocos2d::CCPoint::CCPoint(&v79, v48 + (float)(v46 * 0.5), v49->y);
m_groundLayer = a1->m_groundLayer;
v51 = v79.x;
for ( j = m_groundLayer->m_textureWidth; v51 < (float)-j; v51 = v51 + j )
;
while ( v51 > 0.0 )
v51 = v51 - j;
v53 = a1->m_gameState.m_cameraAngle;
v79.x = v51;
if ( v53 != 0.0 )
v79.x = v51 - j;
cocos2d::CCPoint::CCPoint(&v80, &v79);
LODWORD(v54.x) = &v80;
GJGroundLayer::updateGroundPos(m_groundLayer, v54);
m_groundLayer2 = a1->m_groundLayer2;
cocos2d::CCPoint::CCPoint(&v80, &v79);
LODWORD(v56.x) = &v80;
GJGroundLayer::updateGroundPos(m_groundLayer2, v56);
height = v74.height;
v58 = a1->m_cameraUnzoomedHeightOffset * a1->m_gameState.m_cameraZoom;
v59 = a1->m_objectLayer->getPosition(a1->m_objectLayer);
v60 = a1->m_groundLayer;
m_unkFloat9 = a1->m_gameState.m_unkFloat9;
v62 = v60->setPosition;
v63 = v58 * 0.5;
v64 = v63 + height;
v65 = *(float *)&a1->m_gameState.m_unkInt11 * 0.5;
v66 = v64 - (float)((float)(v74.height * 0.5) + (float)(v65 - 1.0));
if ( (float)((float)((float)((float)((float)(v74.height * 0.5) + (float)(1.0 - v65)) + v63) * m_unkFloat9) - v63) <= (float)(v59->y + (float)(a1->m_gameState.m_cameraZoom * 91.0)) )
v67 = v59->y + (float)(a1->m_gameState.m_cameraZoom * 91.0);
else
v67 = (float)((float)((float)((float)(v74.height * 0.5) + (float)(1.0 - v65)) + v63) * m_unkFloat9) - v63;
cocos2d::CCPoint::CCPoint(&v80, 0.0, v67);
v62(v60, &v80);
v68 = a1->m_groundLayer2;
v69 = v68->setPosition;
cocos2d::CCPoint::CCPoint(&v80, 0.0, v64 - (float)(v66 * m_unkFloat9));
v69(v68, &v80);
v70 = a1->m_groundLayer;
v71 = !a1->m_hideGround && v70->getPosition(a1->m_groundLayer)->y > (float)-v63;
GJGroundLayer::toggleVisible01(v70, v71);
v72 = a1->m_groundLayer2;
v73 = !a1->m_hideGround && v72->getPosition(a1->m_groundLayer2)->y < v64;
GJGroundLayer::toggleVisible01(v72, v73);
}