//
// GJBaseGameLayer::updateCameraBGArt from 0x866d80 to 0x8674ac (1836 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateEditor @ 0x67c0ac
// > GJBaseGameLayer::updateCamera @ 0x87e5c0
// > ??> @ 0x2ce08
//
// 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)
{
__int64 v3; // x1
float *v4; // x21
__int64 v6; // x24
float v7; // s11
int v8; // w22
cocos2d::CCDirector *v9; // x0
float m_unkFloat4; // s9
float v11; // s0
float v12; // s1
float v13; // s0
float v14; // s1
float m_levelFlipping; // s0
float v16; // s10
float v17; // s1
const cocos2d::CCPoint *v18; // x0
float m_unkFloat10; // s1
GJMGLayer *m_middleground; // x1
float m_groundScale; // s14
float m_unkFloat8; // s13
float v23; // s12
float m_ground2Offset; // w25
float m_middleGroundOffsetY; // w26
float v26; // s15
float v27; // s0
GJMGLayer *v28; // x0
double v29; // d2
float v30; // s0
float v31; // s9
float v32; // s8
GJMGLayer *v33; // x24
float v34; // s1
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
const cocos2d::CCPoint *v36; // x0
GJMGLayer *v37; // x24
float v38; // s0
float m_textureWidth; // s2
float v40; // s1
float m_cameraZoom; // s0
float v42; // s8
const cocos2d::CCPoint *v43; // x0
const cocos2d::CCPoint *v44; // x0
GJGroundLayer *m_groundLayer; // x24
float v46; // s0
float v47; // s1
GJGroundLayer *m_groundLayer2; // x24
float v49; // s8
float v50; // s9
const cocos2d::CCPoint *v51; // x0
float v52; // s3
float v53; // s2
float m_unkFloat9; // s5
float v55; // s1
GJGroundLayer *v56; // x22
void (__fastcall *v57)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
float v58; // s10
GJGroundLayer *v59; // x22
void (__fastcall *v60)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
GJGroundLayer *v61; // x20
bool v62; // w1
GJGroundLayer *v63; // x19
bool v64; // w1
float v65; // s0
float v66; // s0
const cocos2d::CCPoint *v67; // x0
cocos2d::CCDirector *v68; // x0
float v69; // [xsp+A0h] [xbp+A0h]
float v70; // [xsp+A0h] [xbp+A0h]
float v71; // [xsp+A0h] [xbp+A0h]
float v72; // [xsp+A0h] [xbp+A0h]
float v73; // [xsp+B0h] [xbp+B0h]
float v74; // [xsp+B4h] [xbp+B4h]
__int64 v75; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v76; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v77; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint x; // [xsp+D0h] [xbp+D0h] BYREF
cocos2d::CCPoint v79; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v80; // [xsp+E0h] [xbp+E0h] BYREF
cocos2d::CCPoint v81; // 0:s0.4,4:s1.4
cocos2d::CCPoint v82; // 0:s0.4,4:s1.4
cocos2d::CCPoint v83; // 0:s0.4,4:s1.4
v4 = &a1->m_varianceValues.__elems_[1975];
v6 = v3;
v7 = a2.x;
v8 = 0;
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
if ( *((_BYTE *)v4 + 268) )
v8 = *((unsigned __int8 *)v4 + 696) ^ 1;
m_unkFloat4 = a1->m_gameState.m_unkFloat4;
cocos2d::CCPoint::CCPoint(
&v80,
(float)(v73 / a1->m_gameState.m_cameraZoom) * 0.5,
(float)(v74 / a1->m_gameState.m_cameraZoom) * 0.5);
cocos2d::CCPoint::operator+(&v75, v6, &v80);
cocos2d::CCPoint::CCPoint(&v80, (float)(v73 / m_unkFloat4) * 0.5, (float)(v74 / m_unkFloat4) * 0.5);
cocos2d::CCPoint::operator+(&v76, &a1->m_gameState.m_cameraPosition2, &v80);
cocos2d::CCPoint::operator-(&v77, &v76, &v75);
cocos2d::CCPoint::operator=(&a1->m_gameState.m_cameraStepDiff, v11, v12);
if ( *((_BYTE *)v4 + 645) )
cocos2d::CCPoint::operator=(&v77, v13, v14);
m_levelFlipping = a1->m_gameState.m_levelFlipping;
if ( m_levelFlipping > 0.5 )
v16 = (float)(m_levelFlipping - 0.5) * -2.0;
else
v16 = 1.0 - (float)(m_levelFlipping * 2.0);
v17 = a1->m_background->getPosition(a1->m_background)->x;
v69 = v17 + (float)((float)((float)(*(float *)&v77 * a1->m_gameState.m_unkFloat5) * v7) * v16);
v18 = a1->m_background->getPosition(a1->m_background);
cocos2d::CCPoint::CCPoint(&x, v69, v18->y + (float)((float)(*((float *)&v77 + 1) * a1->m_gameState.m_unkFloat6) * v7));
m_unkFloat10 = a1->m_gameState.m_unkFloat10;
if ( m_unkFloat10 != 0.0 )
{
v66 = fmodf(x.x, m_unkFloat10);
x.x = v66;
if ( v66 > 0.0 )
x.x = v66 - a1->m_gameState.m_unkFloat10;
}
a1->m_background->setPosition(a1->m_background, &x);
m_middleground = a1->m_middleground;
if ( !m_middleground )
{
m_cameraZoom = a1->m_gameState.m_cameraZoom;
v42 = 0.0;
if ( a1->m_gameState.m_unkFloat4 == m_cameraZoom )
goto LABEL_24;
goto LABEL_43;
}
m_groundScale = m_middleground->m_groundScale;
m_unkFloat8 = a1->m_gameState.m_unkFloat8;
v23 = *(float *)(v6 + 4);
m_ground2Offset = m_middleground->m_ground2Offset;
m_middleGroundOffsetY = a1->m_gameState.m_middleGroundOffsetY;
v26 = a1->m_objectLayer->getScaleY(a1->m_objectLayer);
a1->m_objectLayer->getScaleX(a1->m_objectLayer);
if ( v8 )
{
v65 = a1->m_objectLayer->getScaleY(a1->m_objectLayer);
v28 = a1->m_middleground;
v29 = 0.0;
v31 = v65 * 1.2;
if ( v28->m_groundScale == (float)(v65 * 1.2) )
goto LABEL_11;
}
else
{
v28 = a1->m_middleground;
v29 = 0.0;
v30 = 1.0 - (1.0 - fabsf(v27)) * 0.300000012;
v31 = v30 * 1.2;
if ( v28->m_groundScale == (float)(v30 * 1.2) )
goto LABEL_11;
}
v29 = GJMGLayer::scaleGround(v28, v31) * 0.5;
LABEL_11:
if ( m_groundScale == 0.0 )
m_groundScale = v31;
v32 = (float)((float)((float)(*(float *)&v77 * a1->m_gameState.m_unkFloat7) * (float)(v7 / v31)) * v16) + v29;
if ( v8 )
{
v67 = a1->m_objectLayer->getPosition(a1->m_objectLayer);
v33 = a1->m_middleground;
v34 = v67->y + (float)((float)(v33->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY) * v31);
if ( a1->m_gameState.m_unkFloat4 != a1->m_gameState.m_cameraZoom )
{
v72 = v67->y + (float)((float)(v33->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY) * v31);
v68 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v68);
v33 = a1->m_middleground;
v34 = v72;
v32 = (float)((float)(v80.x / v31) - (float)(v80.x / m_groundScale)) * 0.5;
}
}
else
{
v33 = a1->m_middleground;
v34 = (float)((float)-v23 * m_unkFloat8)
+ (float)((float)(m_ground2Offset + m_middleGroundOffsetY)
* (float)((float)(1.0 - m_unkFloat8) + (float)(m_unkFloat8 * v26)));
}
setPosition = v33->setPosition;
cocos2d::CCPoint::CCPoint(&v80, 0.0, v34);
setPosition(v33, &v80);
v70 = v32 + a1->m_middleground->m_ground1Sprite->getPosition(a1->m_middleground->m_ground1Sprite)->x;
v36 = a1->m_middleground->m_ground1Sprite->getPosition(a1->m_middleground->m_ground1Sprite);
cocos2d::CCPoint::CCPoint(&v79, v70, v36->y);
v37 = a1->m_middleground;
v38 = v79.x;
m_textureWidth = v37->m_textureWidth;
if ( v79.x >= (float)-m_textureWidth )
{
v40 = v79.x;
}
else
{
do
v38 = v38 + m_textureWidth;
while ( v38 < (float)-m_textureWidth );
v40 = v38;
v79.x = v38;
}
if ( v38 > 0.0 )
{
do
v40 = v40 - m_textureWidth;
while ( v40 > 0.0 );
v79.x = v40;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
v79.x = v40 - m_textureWidth;
cocos2d::CCPoint::CCPoint(&v80, &v79);
GJMGLayer::updateGroundPos(v37, v81);
m_cameraZoom = a1->m_gameState.m_cameraZoom;
v42 = 0.0;
if ( a1->m_gameState.m_unkFloat4 != m_cameraZoom )
{
LABEL_43:
v42 = GJGroundLayer::scaleGround(a1->m_groundLayer, m_cameraZoom);
GJGroundLayer::scaleGround(a1->m_groundLayer2, a1->m_gameState.m_cameraZoom);
}
LABEL_24:
v43 = a1->m_groundLayer->m_ground1Sprite->getPosition(a1->m_groundLayer->m_ground1Sprite);
v71 = (float)(v43->x + (float)(*(float *)&v77 * v16)) + (float)(v42 * 0.5);
v44 = a1->m_groundLayer->m_ground1Sprite->getPosition(a1->m_groundLayer->m_ground1Sprite);
cocos2d::CCPoint::CCPoint(&v79, v71, v44->y);
m_groundLayer = a1->m_groundLayer;
v46 = v79.x;
v47 = m_groundLayer->m_textureWidth;
if ( (float)-v47 > v79.x )
{
do
v46 = v46 + v47;
while ( v46 < (float)-v47 );
v79.x = v46;
}
if ( v46 > 0.0 )
{
do
v46 = v46 - v47;
while ( v46 > 0.0 );
v79.x = v46;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
v79.x = v46 - v47;
cocos2d::CCPoint::CCPoint(&v80, &v79);
GJGroundLayer::updateGroundPos(m_groundLayer, v82);
m_groundLayer2 = a1->m_groundLayer2;
cocos2d::CCPoint::CCPoint(&v80, &v79);
GJGroundLayer::updateGroundPos(m_groundLayer2, v83);
v49 = (float)(a1->m_cameraUnzoomedHeightOffset * a1->m_gameState.m_cameraZoom) * 0.5;
v50 = v49 + v74;
v51 = a1->m_objectLayer->getPosition(a1->m_objectLayer);
v52 = *(float *)&a1->m_gameState.m_unkInt11 * 0.5;
v53 = v74 * 0.5;
m_unkFloat9 = a1->m_gameState.m_unkFloat9;
v55 = v51->y + (float)(a1->m_gameState.m_cameraZoom * 91.0);
if ( v55 < (float)-(float)(v49 - (float)((float)(v49 + (float)((float)(v74 * 0.5) + (float)(1.0 - v52))) * m_unkFloat9)) )
v55 = -(float)(v49 - (float)((float)(v49 + (float)(v53 + (float)(1.0 - v52))) * m_unkFloat9));
v56 = a1->m_groundLayer;
v57 = v56->setPosition;
v58 = v50 - (float)(m_unkFloat9 * (float)(v50 - (float)(v53 + (float)(v52 - 1.0))));
cocos2d::CCPoint::CCPoint(&v80, 0.0, v55);
v57(v56, &v80);
v59 = a1->m_groundLayer2;
v60 = v59->setPosition;
cocos2d::CCPoint::CCPoint(&v80, 0.0, v58);
v60(v59, &v80);
v61 = a1->m_groundLayer;
v62 = 0;
if ( !*((_BYTE *)v4 + 1184) )
v62 = (float)-v49 < v61->getPosition(a1->m_groundLayer)->y;
GJGroundLayer::toggleVisible01(v61, v62);
v63 = a1->m_groundLayer2;
v64 = 0;
if ( !*((_BYTE *)v4 + 1184) )
v64 = v50 > v63->getPosition(v63)->y;
GJGroundLayer::toggleVisible01(v63, v64);
}