//
// GJBaseGameLayer::updateCameraBGArt from 0x14023e450 to 0x14023ee35 (2533 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::updateCamera @ 0x14023e30c
// > LevelEditorLayer::updateEditor @ 0x1402d8d7b
// > ??> @ 0x140681950
// > ??> @ 0x140681a30
// > ??> @ 0x1406ce2bc
//
// 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)
{
cocos2d::CCDirector *v6; // rax
bool v7; // r14
float m_unkFloat4; // xmm0_4
float v9; // xmm7_4
double v10; // xmm0_8
float m_levelFlipping; // xmm0_4
float v12; // xmm8_4
const cocos2d::CCPoint *v13; // rax
float m_unkFloat10; // xmm6_4
float v15; // xmm0_4
GJMGLayer *m_middleground; // rax
float m_groundScale; // xmm13_4
float v18; // xmm6_4
double v19; // xmm0_8
GJMGLayer *v20; // rdi
float v21; // xmm2_4
float v22; // xmm6_4
GJMGLayer_vtbl *v23; // rax
GJMGLayer *v24; // rcx
float m_groundWidth; // xmm7_4
__int64 v26; // rcx
cocos2d::CCDirector *v27; // rax
__int64 v28; // rax
GJMGLayer_vtbl *v29; // rdx
__int64 v30; // rax
float v31; // xmm0_4
float v32; // xmm1_4
int v33; // eax
int v34; // ebx
double v35; // xmm0_8
float v36; // xmm7_4
cocos2d::CCDirector *v37; // rax
GJMGLayer_vtbl *v38; // rbx
double v39; // xmm0_8
const cocos2d::CCPoint *v40; // rax
cocos2d::CCSprite *m_ground1Sprite; // rbx
float *v42; // rax
float v43; // xmm1_4
float m_textureWidth; // xmm2_4
GJMGLayer *v45; // rbx
const cocos2d::CCPoint *v46; // rax
const cocos2d::CCPoint *v47; // rdi
cocos2d::CCSprite *m_ground2Sprite; // rcx
float m_cameraZoom; // xmm1_4
float v50; // xmm7_4
float v51; // xmm0_4
GJGroundLayer **p_m_groundLayer; // rdi
cocos2d::CCSprite *v53; // rbx
float *v54; // rax
float v55; // xmm1_4
float v56; // xmm2_4
GJGroundLayer *v57; // rbx
const cocos2d::CCPoint *v58; // rax
const cocos2d::CCPoint *v59; // r14
cocos2d::CCSprite *v60; // rcx
GJGroundLayer **v61; // r12
GJGroundLayer **p_m_groundLayer2; // r14
GJGroundLayer *m_groundLayer2; // rbx
const cocos2d::CCPoint *v64; // rax
const cocos2d::CCPoint *v65; // r13
cocos2d::CCSprite *v66; // rcx
GJGroundLayer **v67; // r15
float v68; // xmm11_4
float v69; // xmm10_4
float v70; // xmm11_4
const cocos2d::CCPoint *v71; // rax
float m_unkFloat9; // xmm7_4
GJGroundLayer *v73; // rbx
float v74; // xmm8_4
GJGroundLayer_vtbl *v75; // rdi
float v76; // xmm6_4
const cocos2d::CCPoint *v77; // rax
GJGroundLayer *v78; // rbx
GJGroundLayer_vtbl *v79; // rdi
const cocos2d::CCPoint *v80; // rax
_BOOL8 v81; // rdx
bool v82; // al
GJGroundLayer *v83; // rcx
GJGroundLayer **v84; // rbx
bool v85; // al
GJGroundLayer *v86; // rcx
float v87; // [rsp+28h] [rbp-E0h]
float X; // [rsp+30h] [rbp-D8h] BYREF
float v89; // [rsp+38h] [rbp-D0h]
float v90; // [rsp+3Ch] [rbp-CCh]
char v91[8]; // [rsp+40h] [rbp-C8h] BYREF
int v92; // [rsp+48h] [rbp-C0h] BYREF
__int128 v93; // [rsp+50h] [rbp-B8h] BYREF
float v94; // [rsp+138h] [rbp+30h] BYREF
float v95; // [rsp+150h] [rbp+48h]
v6 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v6);
v7 = a1->m_isEditor && !a1->m_started;
m_unkFloat4 = a1->m_gameState.m_unkFloat4;
v9 = v89 / m_unkFloat4;
cocos2d::CCPoint::CCPoint(m_unkFloat4, (float)(v89 / a1->m_gameState.m_cameraZoom) * 0.5);
v10 = ((double (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator+)(a2, v91);
cocos2d::CCPoint::CCPoint(*(float *)&v10, v9 * 0.5);
cocos2d::CCPoint::operator+(&a1->m_gameState.m_cameraPosition2, &v92);
cocos2d::CCPoint::operator-(&v92, &v94, v91);
cocos2d::CCPoint::operator=(&a1->m_gameState.m_cameraStepDiff, &v94);
if ( a1->m_skipArtReload )
cocos2d::CCPoint::operator=(&v94, &dword_1406C1D28);
m_levelFlipping = a1->m_gameState.m_levelFlipping;
if ( m_levelFlipping > 0.5 )
{
v12 = (float)(m_levelFlipping - 0.5) * -2.0;
}
else
{
m_levelFlipping = m_levelFlipping + m_levelFlipping;
v12 = 1.0 - m_levelFlipping;
}
a1->m_background->getPosition_0(a1->m_background);
v13 = a1->m_background->getPosition_0(a1->m_background);
cocos2d::CCPoint::CCPoint(
m_levelFlipping,
(float)((float)((float)(v94 * a1->m_gameState.m_unkFloat5) * a3) * v12) + v13->x);
m_unkFloat10 = a1->m_gameState.m_unkFloat10;
if ( m_unkFloat10 != 0.0 )
{
v15 = fmodf(X, a1->m_gameState.m_unkFloat10);
X = v15;
if ( v15 > 0.0 )
X = v15 - m_unkFloat10;
}
a1->m_background->setPosition_0(a1->m_background, (const cocos2d::CCPoint *)&X);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
m_groundScale = m_middleground->m_groundScale;
a1->m_objectLayer->getScaleY(a1->m_objectLayer);
v18 = 1.0
- (float)((float)(1.0
- fabs(COERCE_FLOAT(COERCE_UNSIGNED_INT64(((double (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleX)(a1->m_objectLayer)))))
* 0.30000001);
if ( v7 )
{
v19 = ((double (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer);
v18 = *(float *)&v19;
}
v20 = a1->m_middleground;
v21 = 0.0;
v22 = v18 * 1.2;
if ( v20->m_groundScale != v22 )
{
v23 = v20->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v24 = a1->m_middleground;
v20->m_groundScale = v22;
((void (__fastcall *)(GJMGLayer *))v23->setScaleX)(v24);
v20->getScaleY(v20);
((void (__fastcall *)(GJMGLayer *))v20->setScaleY)(v20);
m_groundWidth = v20->m_groundWidth;
if ( v20->getParent(v20) )
{
v27 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v26);
cocos2d::CCDirector::getWinSize(v27);
v28 = (__int64)v20->getParent(v20);
v29 = v20->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v28 )
{
v29->getScaleX(v20);
}
else
{
v30 = (__int64)v29->getParent(v20);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v30 + 168LL))(v30);
}
v31 = v20->getScaleX(v20);
v32 = (float)(*(float *)&v93 / v31) + 10.0;
v20->m_groundWidth = v32;
v33 = (int)(float)(ceilf(v32 / v20->m_textureWidth) + 1.0);
v34 = v33 + 1;
if ( !v20->m_cameraRotated )
v34 = v33;
GJMGLayer::loadGroundSprites(v20, v34, 1);
GJMGLayer::loadGroundSprites(v20, v34, 0);
}
v21 = v20->m_groundWidth - m_groundWidth;
}
if ( m_groundScale == 0.0 )
m_groundScale = v22;
v35 = v21 * 0.5;
v36 = (float)((float)((float)(v94 * a1->m_gameState.m_unkFloat7) * (float)(a3 / v22)) * v12) + v35;
if ( v7 )
{
a1->m_objectLayer->getPosition_0(a1->m_objectLayer);
*(float *)&v35 = a1->m_gameState.m_unkFloat4;
if ( *(float *)&v35 != a1->m_gameState.m_cameraZoom )
{
v37 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1->m_middleground);
cocos2d::CCDirector::getWinSize(v37);
*(float *)&v35 = *(float *)&v93 / m_groundScale;
v36 = (float)((float)(*(float *)&v93 / v22) - (float)(*(float *)&v93 / m_groundScale)) * 0.5;
}
}
v38 = a1->m_middleground->__vftable;
v39 = cocos2d::CCPoint::CCPoint(*(float *)&v35, 0.0);
v38->setPosition_0(a1->m_middleground, v40);
m_ground1Sprite = a1->m_middleground->m_ground1Sprite;
m_ground1Sprite->getPosition_0(m_ground1Sprite);
v42 = (float *)m_ground1Sprite->getPosition_0(m_ground1Sprite);
cocos2d::CCPoint::CCPoint(*(float *)&v39, v36 + *v42);
v43 = v87;
m_textureWidth = a1->m_middleground->m_textureWidth;
if ( (float)-m_textureWidth > v87 )
{
do
v43 = v43 + m_textureWidth;
while ( (float)-m_textureWidth > v43 );
}
for ( ; v43 > 0.0; v43 = v43 - m_textureWidth )
;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v93);
v45 = a1->m_middleground;
v47 = v46;
v45->m_ground1Sprite->setPosition_0(v45->m_ground1Sprite, v46);
m_ground2Sprite = v45->m_ground2Sprite;
if ( m_ground2Sprite )
m_ground2Sprite->setPosition_0(m_ground2Sprite, v47);
}
m_cameraZoom = a1->m_gameState.m_cameraZoom;
v50 = 0.0;
v51 = a1->m_gameState.m_unkFloat4;
p_m_groundLayer = &a1->m_groundLayer;
if ( v51 != m_cameraZoom )
{
v50 = GJGroundLayer::scaleGround(a1->m_groundLayer, m_cameraZoom);
v51 = GJGroundLayer::scaleGround(a1->m_groundLayer2, a1->m_gameState.m_cameraZoom);
}
v53 = (*p_m_groundLayer)->m_ground1Sprite;
v53->getPosition_0(v53);
v54 = (float *)v53->getPosition_0(v53);
cocos2d::CCPoint::CCPoint(v51, (float)((float)(v94 * v12) + *v54) + (float)(v50 * 0.5));
v55 = v95;
v56 = (*p_m_groundLayer)->m_textureWidth;
if ( (float)-v56 > v95 )
{
do
v55 = v55 + v56;
while ( (float)-v56 > v55 );
v95 = v55;
p_m_groundLayer = &a1->m_groundLayer;
}
if ( v55 > 0.0 )
{
do
v55 = v55 - v56;
while ( v55 > 0.0 );
v95 = v55;
p_m_groundLayer = &a1->m_groundLayer;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
v95 = v55 - v56;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v93);
v57 = *p_m_groundLayer;
v59 = v58;
(*p_m_groundLayer)->m_ground1Sprite->setPosition_0((*p_m_groundLayer)->m_ground1Sprite, v58);
v60 = v57->m_ground2Sprite;
v61 = p_m_groundLayer;
if ( v60 )
{
v60->setPosition_0(v60, v59);
v61 = &a1->m_groundLayer;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v93);
p_m_groundLayer2 = &a1->m_groundLayer2;
m_groundLayer2 = a1->m_groundLayer2;
v65 = v64;
m_groundLayer2->m_ground1Sprite->setPosition_0(m_groundLayer2->m_ground1Sprite, v64);
v66 = m_groundLayer2->m_ground2Sprite;
v67 = p_m_groundLayer;
if ( v66 )
{
v66->setPosition_0(v66, v65);
v67 = v61;
}
v68 = (float)(a1->m_cameraUnzoomedHeightOffset * a1->m_gameState.m_cameraZoom) * 0.5;
v69 = v68 + v90;
v70 = -v68;
v71 = a1->m_objectLayer->getPosition_0(a1->m_objectLayer);
m_unkFloat9 = a1->m_gameState.m_unkFloat9;
v73 = *p_m_groundLayer;
v74 = *(float *)&a1->m_gameState.m_unkInt11 * 0.5;
v75 = (*p_m_groundLayer)->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v76 = v90 * 0.5;
cocos2d::CCPoint::CCPoint((float)(a1->m_gameState.m_cameraZoom * 91.0) + v71->y, 0.0);
v75->setPosition_0(v73, v77);
v78 = *p_m_groundLayer2;
v79 = (*p_m_groundLayer2)->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint((float)(v69 - (float)((float)(v74 - 1.0) + v76)) * m_unkFloat9, 0.0);
v79->setPosition_0(v78, v80);
v82 = false;
if ( !a1->m_hideGround )
{
p_m_groundLayer2 = &a1->m_groundLayer2;
if ( (*v67)->getPosition_0(*v67)->y > v70 )
v82 = true;
}
v83 = *v67;
v84 = p_m_groundLayer2;
if ( (*v67)->m_showGround1 != v82 )
{
v83->m_showGround1 = v82;
if ( v82 && v83->m_showGround2 )
LOBYTE(v81) = 1;
else
v81 = 0;
v83->setVisible(v83, v81);
v84 = &a1->m_groundLayer2;
}
v85 = !a1->m_hideGround && v69 > (*p_m_groundLayer2)->getPosition_0(*p_m_groundLayer2)->y;
v86 = *v84;
if ( (*v84)->m_showGround1 != v85 )
{
v86->m_showGround1 = v85;
if ( v85 && v86->m_showGround2 )
{
LOBYTE(v81) = 1;
v86->setVisible(v86, v81);
}
else
{
v86->setVisible(v86, 0);
}
}
}