//
// GJBaseGameLayer::updateCameraBGArt from 0x10015b270 to 0x10015bb16 (2214 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::updateEditor @ 0x1000dd8ab
// > GJBaseGameLayer::updateCamera @ 0x100155c6a
//
// 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)
{
__int64 v3; // rsi
float m_cameraZoom; // xmm2_4
float m_unkFloat4; // xmm3_4
__int64 *v7; // rsi
__m128 m_levelFlipping_low; // xmm3
__m128 v9; // xmm1
__m128 v10; // xmm2
__m128 v11; // rt1
__m128 v12; // xmm3
float *v13; // rax
__int64 v14; // rax
float m_unkFloat10; // xmm1_4
float v16; // xmm0_4
float *v17; // rsi
GJMGLayer *m_middleground; // rax
__int8 v19; // r14
float m_unkFloat8; // xmm1_4
cocos2d::CCLayer *m_objectLayer; // rdi
cocos2d::CCLayer_vtbl *v22; // rax
__m128 v23; // xmm0
__m128 v24; // xmm3
GJMGLayer *v25; // rdi
float m_groundScale; // xmm0_4
float v27; // xmm0_4
double v28; // xmm0_8
double v29; // xmm1_8
__m128 v30; // xmm0
__int64 v31; // rax
float v32; // xmm1_4
__m128 v33; // xmm4
__m128 v34; // xmm2
GJMGLayer *v35; // r14
float *v36; // rax
__m128 v37; // xmm0
__int64 v38; // rax
GJMGLayer *v39; // r14
float m_textureWidth; // xmm0_4
float v41; // xmm1_4
cocos2d::CCPoint v42; // xmm0_8
float v43; // xmm0_4
float v44; // xmm0_4
float *v45; // rax
__m128 v46; // xmm0
__int64 v47; // rax
GJGroundLayer *m_groundLayer; // r14
float v49; // xmm0_4
float v50; // xmm1_4
cocos2d::CCPoint v51; // xmm0_8
GJGroundLayer *m_groundLayer2; // r14
cocos2d::CCPoint v53; // xmm0_8
__m128 m_cameraUnzoomedHeightOffset_low; // xmm1
__int64 v55; // rax
float v56; // xmm2_4
__m128 v57; // xmm3
__m128 v58; // xmm1
GJGroundLayer *v59; // r14
GJGroundLayer *v60; // r14
GJGroundLayer *v61; // r14
bool v62; // al
__int64 v63; // rax
GJGroundLayer *v64; // r14
bool v65; // al
__int64 v66; // rax
char v67[8]; // [rsp+8h] [rbp-D8h] BYREF
__m128 m_groundScale_low; // [rsp+10h] [rbp-D0h]
char v69[8]; // [rsp+28h] [rbp-B8h] BYREF
__m128 v70; // [rsp+30h] [rbp-B0h]
float v71; // [rsp+48h] [rbp-98h]
float v72; // [rsp+4Ch] [rbp-94h]
__int64 v73; // [rsp+50h] [rbp-90h]
float v74; // [rsp+58h] [rbp-88h] BYREF
float v75; // [rsp+5Ch] [rbp-84h]
float v76; // [rsp+60h] [rbp-80h] BYREF
char v77[8]; // [rsp+68h] [rbp-78h] BYREF
__m128 v78; // [rsp+70h] [rbp-70h]
__m128 v79; // [rsp+80h] [rbp-60h]
float v80[2]; // [rsp+94h] [rbp-4Ch] BYREF
float v81; // [rsp+9Ch] [rbp-44h]
__m128 v82; // [rsp+A0h] [rbp-40h]
float v83[12]; // [rsp+B0h] [rbp-30h] BYREF
v82.i32[0] = LODWORD(a2.x);
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v74);
v70.i32[0] = a1->m_isEditor && !a1->m_started;
m_cameraZoom = a1->m_gameState.m_cameraZoom;
m_unkFloat4 = a1->m_gameState.m_unkFloat4;
v78.f32[0] = v74 / m_unkFloat4;
v79.f32[0] = v75 / m_unkFloat4;
sub_10028CBE0(v69, (float)(v74 / m_cameraZoom) * 0.5, (float)(v75 / m_cameraZoom) * 0.5);
v73 = v3;
sub_10028CCE0(v67, v3);
sub_10028CBE0(v80, v78.f32[0] * 0.5, v79.f32[0] * 0.5);
sub_10028CCE0(v69, &a1->m_gameState.m_cameraPosition2);
sub_10028CD00(v80, v69, v67);
v7 = (__int64 *)v80;
sub_10028CC90();
if ( a1->m_skipArtReload )
{
v7 = &qword_10099EFF0;
sub_10028CC90();
}
m_levelFlipping_low = (__m128)LODWORD(a1->m_gameState.m_levelFlipping);
v9 = (__m128)0x3F800000u;
v10 = (__m128)0xBF000000;
v10.f32[0] = (float)(m_levelFlipping_low.f32[0] + -0.5) * -2.0;
v9.f32[0] = 1.0 - (float)(m_levelFlipping_low.f32[0] + m_levelFlipping_low.f32[0]);
v11.i32[0] = 1056964608;
v12 = _mm_cmpgt_ss(m_levelFlipping_low, v11);
v78 = _mm_or_ps(_mm_andnot_ps(v12, v9), _mm_and_ps(v10, v12));
v13 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *, __int64 *))a1->m_background->getPosition)(
a1->m_background,
v7);
v79.f32[0] = (float)((float)((float)(v80[0] * a1->m_gameState.m_unkFloat5) * v82.f32[0]) * v78.f32[0]) + *v13;
v14 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getPosition)(a1->m_background);
sub_10028CBE0(
&v76,
v79.f32[0],
(float)((float)(v80[1] * a1->m_gameState.m_unkFloat6) * v82.f32[0]) + *(float *)(v14 + 4));
m_unkFloat10 = a1->m_gameState.m_unkFloat10;
if ( m_unkFloat10 != 0.0 )
{
v79.i32[0] = LODWORD(a1->m_gameState.m_unkFloat10);
v16 = fmodf(v76, m_unkFloat10);
v76 = v16;
if ( v16 > 0.0 )
v76 = v16 - v79.f32[0];
}
v17 = &v76;
((void (__fastcall *)(cocos2d::CCSprite *, float *))a1->m_background->setPosition)(a1->m_background, &v76);
m_middleground = a1->m_middleground;
v19 = v70.i8[0];
if ( m_middleground )
{
m_groundScale_low = (__m128)LODWORD(m_middleground->m_groundScale);
m_unkFloat8 = a1->m_gameState.m_unkFloat8;
v81 = m_middleground->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY;
m_objectLayer = a1->m_objectLayer;
v22 = m_objectLayer->cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v23 = (__m128)*(unsigned int *)(v73 + 4);
v71 = m_unkFloat8;
*(float *)&v73 = v23.f32[0] * m_unkFloat8;
v23.f32[0] = ((float (__fastcall *)(cocos2d::CCLayer *))v22->getScaleY)(m_objectLayer);
v72 = v23.f32[0];
((void (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleX)(a1->m_objectLayer);
if ( v19 )
{
*(double *)v23.i64 = ((double (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getScaleY)(a1->m_objectLayer);
v24 = v23;
}
else
{
v24 = (__m128)0x3F800000u;
v24.f32[0] = (float)((float)(1.0 - fabs(v23.f32[0])) * -0.30000001) + 1.0;
}
v24.f32[0] = v24.f32[0] * 1.2;
v25 = a1->m_middleground;
m_groundScale = v25->m_groundScale;
v79 = v24;
if ( m_groundScale == v24.f32[0] )
{
v28 = 0.0;
}
else
{
v27 = GJMGLayer::scaleGround(v25, v24.f32[0]);
v24.i32[0] = v79.i32[0];
v28 = v27 * 0.5;
}
v29 = (float)((float)((float)(v80[0] * a1->m_gameState.m_unkFloat7) * (float)(v82.f32[0] / v24.f32[0])) * v78.f32[0])
+ v28;
v30 = 0;
v30.f32[0] = v29;
v82 = v30;
if ( v19 )
{
v31 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getPosition)(a1->m_objectLayer);
v32 = (float)((float)(a1->m_middleground->m_ground2Offset + a1->m_gameState.m_middleGroundOffsetY) * v79.f32[0])
+ *(float *)(v31 + 4);
if ( a1->m_gameState.m_unkFloat4 != a1->m_gameState.m_cameraZoom )
{
v33 = _mm_cmpeq_ss((__m128)0LL, m_groundScale_low);
v82 = _mm_or_ps(_mm_andnot_ps(v33, m_groundScale_low), _mm_and_ps(v33, v79));
v81 = v32;
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v83);
v32 = v81;
v34 = _mm_div_ps(_mm_moveldup_ps((__m128)LODWORD(v83[0])), _mm_insert_ps(v79, (__m128)v82.u32[0], 16));
v34.f32[0] = (float)(v34.f32[0] - _mm_movehdup_ps(v34).f32[0]) * 0.5;
v82 = v34;
}
}
else
{
v32 = (float)(v81 * (float)((float)(v72 * v71) + (float)(1.0 - v71))) - *(float *)&v73;
}
v35 = a1->m_middleground;
sub_10028CBE0(v83, 0.0, v32);
((void (__fastcall *)(GJMGLayer *, float *))v35->setPosition)(v35, v83);
v36 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_middleground->m_ground1Sprite->getPosition)(a1->m_middleground->m_ground1Sprite);
v37 = v82;
v37.f32[0] = v82.f32[0] + *v36;
v82 = v37;
v38 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_middleground->m_ground1Sprite->getPosition)(a1->m_middleground->m_ground1Sprite);
sub_10028CBE0(v83, v82.f32[0], *(float *)(v38 + 4));
v39 = a1->m_middleground;
m_textureWidth = v39->m_textureWidth;
v41 = v83[0];
if ( (float)-m_textureWidth > v83[0] )
{
do
v41 = v41 + m_textureWidth;
while ( (float)-m_textureWidth > v41 );
v83[0] = v41;
}
if ( v41 > 0.0 )
{
do
v41 = v41 - m_textureWidth;
while ( v41 > 0.0 );
v83[0] = v41;
}
if ( a1->m_gameState.m_cameraAngle != 0.0 )
v83[0] = v41 - m_textureWidth;
*(double *)&v42 = sub_10028CC60(v77);
v17 = (float *)v77;
GJMGLayer::updateGroundPos(v39, v42);
}
v43 = a1->m_gameState.m_cameraZoom;
if ( a1->m_gameState.m_unkFloat4 == v43 )
{
v44 = 0.0;
}
else
{
v82.i32[0] = GJGroundLayer::scaleGround(a1->m_groundLayer, v43);
GJGroundLayer::scaleGround(a1->m_groundLayer2, a1->m_gameState.m_cameraZoom);
v44 = v82.f32[0] * 0.5;
}
v82.f32[0] = v44;
v45 = (float *)((__int64 (__fastcall *)(cocos2d::CCSprite *, float *))a1->m_groundLayer->m_ground1Sprite->getPosition)(
a1->m_groundLayer->m_ground1Sprite,
v17);
v46 = v78;
v46.f32[0] = (float)((float)(v78.f32[0] * v80[0]) + *v45) + v82.f32[0];
v78 = v46;
v47 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_groundLayer->m_ground1Sprite->getPosition)(a1->m_groundLayer->m_ground1Sprite);
sub_10028CBE0(v83, v78.f32[0], *(float *)(v47 + 4));
m_groundLayer = a1->m_groundLayer;
v49 = m_groundLayer->m_textureWidth;
v50 = v83[0];
if ( (float)-v49 > v83[0] )
{
do
v50 = v50 + v49;
while ( (float)-v49 > v50 );
v83[0] = v50;
if ( v50 <= 0.0 )
{
LABEL_34:
if ( a1->m_gameState.m_cameraAngle == 0.0 )
goto LABEL_36;
goto LABEL_35;
}
}
else if ( v83[0] <= 0.0 )
{
goto LABEL_34;
}
do
v50 = v50 - v49;
while ( v50 > 0.0 );
v83[0] = v50;
if ( a1->m_gameState.m_cameraAngle != 0.0 )
LABEL_35:
v83[0] = v50 - v49;
LABEL_36:
*(double *)&v51 = sub_10028CC60(v77);
GJGroundLayer::updateGroundPos(m_groundLayer, v51);
m_groundLayer2 = a1->m_groundLayer2;
*(double *)&v53 = sub_10028CC60(v77);
GJGroundLayer::updateGroundPos(m_groundLayer2, v53);
m_cameraUnzoomedHeightOffset_low = (__m128)LODWORD(a1->m_cameraUnzoomedHeightOffset);
m_cameraUnzoomedHeightOffset_low.f32[0] = (float)(m_cameraUnzoomedHeightOffset_low.f32[0]
* a1->m_gameState.m_cameraZoom)
* 0.5;
v70 = m_cameraUnzoomedHeightOffset_low;
v82 = _mm_xor_ps((__m128)xmmword_1008150B0, m_cameraUnzoomedHeightOffset_low);
v78.f32[0] = v75 + m_cameraUnzoomedHeightOffset_low.f32[0];
v55 = ((__int64 (__fastcall *)(cocos2d::CCLayer *, char *))a1->m_objectLayer->getPosition)(a1->m_objectLayer, v77);
v56 = 0.5 * *(float *)&a1->m_gameState.m_unkInt11;
v57 = (__m128)0x3F800000u;
v57.f32[0] = (float)((float)(1.0 - v56) + (float)(v75 * 0.5)) + v70.f32[0];
v58 = _mm_add_ps(
_mm_insert_ps(v82, (__m128)*(unsigned int *)(v55 + 4), 28),
_mm_mul_ps(
_mm_insert_ps(
(__m128)LODWORD(a1->m_gameState.m_unkFloat9),
(__m128)LODWORD(a1->m_gameState.m_cameraZoom),
16),
_mm_blend_ps(v57, (__m128)xmmword_1008169D0, 14)));
v70.f32[0] = v78.f32[0]
- (float)((float)(v78.f32[0] - (float)((float)(v56 + -1.0) + (float)(v75 * 0.5)))
* a1->m_gameState.m_unkFloat9);
v59 = a1->m_groundLayer;
sub_10028CBE0(v77, 0.0, fmaxf(v58.f32[0], _mm_movehdup_ps(v58).f32[0]));
((void (__fastcall *)(GJGroundLayer *, char *))v59->setPosition)(v59, v77);
v60 = a1->m_groundLayer2;
sub_10028CBE0(v77, 0.0, v70.f32[0]);
((void (__fastcall *)(GJGroundLayer *, char *))v60->setPosition)(v60, v77);
v61 = a1->m_groundLayer;
if ( a1->m_hideGround )
{
v62 = 0;
}
else
{
v63 = ((__int64 (__fastcall *)(GJGroundLayer *))v61->getPosition)(a1->m_groundLayer);
v62 = *(float *)(v63 + 4) > v82.f32[0];
}
GJGroundLayer::toggleVisible01(v61, v62);
v64 = a1->m_groundLayer2;
if ( a1->m_hideGround )
{
v65 = 0;
}
else
{
v66 = ((__int64 (__fastcall *)(GJGroundLayer *))v64->getPosition)(a1->m_groundLayer2);
v65 = v78.f32[0] > *(float *)(v66 + 4);
}
GJGroundLayer::toggleVisible01(v64, v65);
}