//
// GJBaseGameLayer::updateShaderLayer from 0x1001f1288 to 0x1001f1ac4 (2108 bytes)
//
// 7 xrefs:
// > PlayLayer::resetLevel @ 0x1001221f0
// > PlayLayer::resetLevel @ 0x100122250
// > GJBaseGameLayer::update @ 0x1001fef78
// > GJBaseGameLayer::update @ 0x1001ff1f0
// > GJBaseGameLayer::resetLevelVariables @ 0x1002024a8
// > LevelEditorLayer::updateGameObjects @ 0x100358dd0
// > LevelEditorLayer::onPlaytest @ 0x100362fa0
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall GJBaseGameLayer::updateShaderLayer(GJBaseGameLayer *a1, float a2)
{
ShaderLayer *m_shaderLayer; // x8
int m_grayscaleTintChannel; // w1
int v6; // w0
int m_blurRefChannel; // w1
__int64 v8; // x0
ShaderLayer *v9; // x8
GLubyte v10; // w9
ShaderLayer *v11; // x20
int m_radialBlurTargetID; // w1
int m_pinchTargetIDX; // w1
int m_pinchTargetIDY; // w1
int m_shockWaveTargetID; // w1
int m_shockLineTargetID; // w1
int m_lensCircleTargetID; // w1
int m_bulgeTargetID; // w1
int m_lensCircleTintChannel; // w1
int v20; // w0
int v21; // w21
bool shouldBlend; // w8
ShaderLayer *v23; // x0
int m_motionBlurTargetIDX; // w1
float v25; // s9
float v26; // s10
int m_motionBlurTargetIDY; // w1
ShaderLayer *v28; // x0
_BOOL4 m_usesShaders; // w20
GJBaseGameLayer *v30; // x0
ShaderLayer *v31; // x2
int m_minBlendingLayer; // w21
int m_maxBlendingLayer; // w22
cocos2d::CCNode *m_objectParent; // x1
GJBaseGameLayer *v35; // x0
cocos2d::CCNode *v36; // x2
char v37; // w8
char v38; // w26
bool v39; // zf
__int64 v40; // x8
__int64 v41; // x21
__int64 v42; // x0
__int64 v43; // x20
cocos2d::CCNode *v44; // x27
__int64 v45; // x21
GJBaseGameLayer *v46; // x0
unsigned int *v47; // x9
__int64 v48; // x8
cocos2d::CCNode **v49; // x20
unsigned __int64 v50; // x21
cocos2d::CCNode *v51; // x1
char v52; // w8
char v53; // w24
__int64 v54; // x8
GJBaseGameLayer *v55; // x0
GJBaseGameLayer *v56; // x20
__int64 v57; // x21
unsigned int *v58; // x9
__int64 v59; // x8
cocos2d::CCNode **v60; // x20
unsigned __int64 v61; // x21
GJBaseGameLayer *v62; // x0
void (*setZOrder)(void); // x8
cocos2d::CCNode **p_m_objectParent; // x25
_BOOL4 v65; // w20
cocos2d::CCNode **p_m_inShaderParent; // x24
GJBaseGameLayer *v67; // x0
GJMGLayer *m_middleground; // x1
cocos2d::CCNode **v70; // x8
cocos2d::CCNode **p_m_aboveShaderParent; // x8
cocos2d::CCNode *v73; // x23
GJGroundLayer *m_groundLayer; // x1
GJGroundLayer *m_groundLayer2; // x1
cocos2d::CCNode *v77; // x2
GJBaseGameLayer *v78; // x0
int v79; // w23
__int64 v80; // x0
int v81; // w10
int v82; // w26
__int64 v83; // x8
__int64 v84; // x9
__int64 v85; // x28
__int64 v86; // x21
__int64 v87; // x0
__int64 v88; // x0
__int64 v89; // x22
__int64 v90; // x0
__int64 v91; // x0
__int64 v92; // x23
__int64 v93; // x0
int v94; // w20
__int64 v95; // x25
__int64 v96; // x27
__int64 v97; // x8
__int64 v98; // x23
unsigned int *v99; // x9
__int64 v100; // x8
cocos2d::CCNode **v101; // x21
unsigned __int64 v102; // x22
cocos2d::CCNode *v103; // x24
GJBaseGameLayer *v104; // x0
cocos2d::CCLayer *m_objectLayer; // x2
__int64 v106; // x0
ShaderLayer *v107; // x1
cocos2d::CCNode *m_inShaderParent; // x20
_BOOL8 v109; // x1
cocos2d::CCNode *m_aboveShaderParent; // x20
_BOOL8 v111; // x1
unsigned int v112; // [xsp+4h] [xbp-8Ch]
__int64 v113; // [xsp+8h] [xbp-88h]
int v114; // [xsp+14h] [xbp-7Ch]
double v115; // [xsp+18h] [xbp-78h] BYREF
cocos2d::CCPoint v116; // 0:s0.4,4:s1.4
cocos2d::CCPoint v117; // 0:s0.4,4:s1.4
m_shaderLayer = a1->m_shaderLayer;
if ( !m_shaderLayer )
goto LABEL_139;
m_grayscaleTintChannel = m_shaderLayer->m_state.m_grayscaleTintChannel;
if ( m_grayscaleTintChannel < 1 )
{
v6 = 0xFFFFFF;
}
else
{
*(cocos2d::ccColor3B *)&v6 = GJEffectManager::activeColorForIndex(a1->m_effectManager, m_grayscaleTintChannel);
m_shaderLayer = a1->m_shaderLayer;
}
*(_WORD *)&m_shaderLayer->m_state.m_grayscaleTint.r = v6;
m_shaderLayer->m_state.m_grayscaleTint.b = BYTE2(v6);
m_blurRefChannel = a1->m_shaderLayer->m_state.m_blurRefChannel;
if ( m_blurRefChannel < 1 )
{
v8 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getColor)(a1->m_background);
v9 = a1->m_shaderLayer;
v10 = *(_BYTE *)(v8 + 2);
*(_WORD *)&v9->m_state.m_blurRefColor.r = *(_WORD *)v8;
v9->m_state.m_blurRefColor.b = v10;
}
else
{
a1->m_shaderLayer->m_state.m_blurRefColor = GJEffectManager::activeColorForIndex(
a1->m_effectManager,
m_blurRefChannel);
}
v11 = a1->m_shaderLayer;
if ( v11->m_state.m_radialBlurTarget )
{
m_radialBlurTargetID = v11->m_state.m_radialBlurTargetID;
if ( m_radialBlurTargetID )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_radialBlurTargetID);
sub_1000229D0(&a1->m_shaderLayer->m_state.m_radialBlurCenter, &v115);
v11 = a1->m_shaderLayer;
}
}
if ( v11->m_state.m_pinchTargetEnabledX )
{
m_pinchTargetIDX = v11->m_state.m_pinchTargetIDX;
if ( m_pinchTargetIDX )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_pinchTargetIDX);
v11 = a1->m_shaderLayer;
v11->m_state.m_pinchCenter.x = *(float *)&v115;
}
}
if ( v11->m_state.m_pinchTargetEnabledY )
{
m_pinchTargetIDY = v11->m_state.m_pinchTargetIDY;
if ( m_pinchTargetIDY )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_pinchTargetIDY);
v11 = a1->m_shaderLayer;
v11->m_state.m_pinchCenter.y = *((float *)&v115 + 1);
}
}
m_shockWaveTargetID = v11->m_state.m_shockWaveTargetID;
if ( m_shockWaveTargetID )
{
v116 = GJBaseGameLayer::positionForShaderTarget(a1, m_shockWaveTargetID);
ShaderLayer::updateShockWaveCenter(v11, v116);
v11 = a1->m_shaderLayer;
}
m_shockLineTargetID = v11->m_state.m_shockLineTargetID;
if ( m_shockLineTargetID )
{
v117 = GJBaseGameLayer::positionForShaderTarget(a1, m_shockLineTargetID);
ShaderLayer::updateShockLineCenter(v11, v117);
v11 = a1->m_shaderLayer;
}
m_lensCircleTargetID = v11->m_state.m_lensCircleTargetID;
if ( m_lensCircleTargetID )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_lensCircleTargetID);
sub_1000229D0(&a1->m_shaderLayer->m_state.m_lensCircleCenter, &v115);
v11 = a1->m_shaderLayer;
}
m_bulgeTargetID = v11->m_state.m_bulgeTargetID;
if ( m_bulgeTargetID )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_bulgeTargetID);
sub_1000229D0(&a1->m_shaderLayer->m_state.m_bulgeCenter, &v115);
v11 = a1->m_shaderLayer;
}
m_lensCircleTintChannel = v11->m_state.m_lensCircleTintChannel;
if ( m_lensCircleTintChannel < 1 )
{
shouldBlend = 0;
v21 = 0;
}
else
{
*(cocos2d::ccColor3B *)&v20 = GJEffectManager::activeColorForIndex(a1->m_effectManager, m_lensCircleTintChannel);
v21 = v20;
shouldBlend = GJEffectManager::shouldBlend(a1->m_effectManager, a1->m_shaderLayer->m_state.m_lensCircleTintChannel);
v11 = a1->m_shaderLayer;
}
*(_WORD *)&v11->m_state.m_lensCircleTint.r = v21;
v11->m_state.m_lensCircleTint.b = BYTE2(v21);
v23 = a1->m_shaderLayer;
v23->m_state.m_lensCircleAdditive = shouldBlend;
m_motionBlurTargetIDX = v23->m_state.m_motionBlurTargetIDX;
v25 = 0.0;
if ( m_motionBlurTargetIDX )
{
GJBaseGameLayer::speedForShaderTarget(a1, m_motionBlurTargetIDX);
v26 = *(float *)&v115;
v23 = a1->m_shaderLayer;
}
else
{
v26 = 0.0;
}
m_motionBlurTargetIDY = v23->m_state.m_motionBlurTargetIDY;
if ( m_motionBlurTargetIDY )
{
GJBaseGameLayer::speedForShaderTarget(a1, m_motionBlurTargetIDY);
v25 = *((float *)&v115 + 1);
v23 = a1->m_shaderLayer;
}
ShaderLayer::updateMotionBlurSpeedX(v23, v26, a2 * 60.0);
ShaderLayer::updateMotionBlurSpeedY(a1->m_shaderLayer, v25, a2 * 60.0);
((void (__fastcall *)(ShaderLayer *, float))a1->m_shaderLayer->update)(a1->m_shaderLayer, a2);
ShaderLayer::performCalculations(a1->m_shaderLayer);
v28 = a1->m_shaderLayer;
m_usesShaders = v28->m_state.m_usesShaders;
v30 = (GJBaseGameLayer *)((__int64 (__fastcall *)(ShaderLayer *))v28->getParent)(v28);
if ( m_usesShaders )
{
v31 = a1->m_shaderLayer;
if ( v30 && !v31->m_state.m_zLayerDirty )
goto LABEL_138;
m_minBlendingLayer = v31->m_state.m_minBlendingLayer;
m_maxBlendingLayer = v31->m_state.m_maxBlendingLayer;
m_objectParent = a1->m_objectParent;
if ( m_minBlendingLayer > 1 )
{
GJBaseGameLayer::reparentObject(v30, m_objectParent, a1);
v36 = a1->m_shaderLayer;
}
else
{
GJBaseGameLayer::reparentObject(v30, m_objectParent, v31);
v36 = a1;
}
p_m_objectParent = &a1->m_objectParent;
v65 = m_minBlendingLayer > 1;
p_m_inShaderParent = &a1->m_inShaderParent;
GJBaseGameLayer::reparentObject(v35, a1->m_inShaderParent, v36);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
if ( m_maxBlendingLayer > 1 && m_minBlendingLayer == 2 )
v70 = &a1->m_inShaderParent;
else
v70 = &a1->m_objectParent;
GJBaseGameLayer::reparentObject(v67, m_middleground, *v70);
}
if ( m_maxBlendingLayer < 13 && m_minBlendingLayer > 1 )
{
p_m_aboveShaderParent = &a1->m_aboveShaderParent;
}
else
{
v73 = *p_m_objectParent;
if ( m_minBlendingLayer > 1 || (p_m_aboveShaderParent = &a1->m_inShaderParent, m_maxBlendingLayer >= 13) )
{
if ( m_minBlendingLayer < 2 == m_minBlendingLayer < 14
|| (p_m_aboveShaderParent = &a1->m_inShaderParent, m_maxBlendingLayer < 13) )
{
LABEL_86:
m_groundLayer = a1->m_groundLayer;
if ( m_groundLayer )
GJBaseGameLayer::reparentObject(v67, m_groundLayer, v73);
m_groundLayer2 = a1->m_groundLayer2;
if ( m_groundLayer2 )
GJBaseGameLayer::reparentObject(v67, m_groundLayer2, v73);
if ( m_maxBlendingLayer < 14 && m_minBlendingLayer > 1 )
{
p_m_inShaderParent = &a1->m_aboveShaderParent;
}
else
{
v77 = *p_m_objectParent;
if ( (m_minBlendingLayer > 1 || m_maxBlendingLayer >= 14)
&& (m_minBlendingLayer < 2 == m_minBlendingLayer < 15 || m_maxBlendingLayer < 14) )
{
LABEL_100:
GJBaseGameLayer::reparentObject(v67, a1->m_uiTriggerUI, v77);
v79 = GJBaseGameLayer::minZOrderForShaderZ(v78, m_minBlendingLayer);
v80 = GJBaseGameLayer::maxZOrderForShaderZ(a1, m_maxBlendingLayer);
if ( a1->m_shaderLayer->m_state.m_noPlayerParticles && m_maxBlendingLayer == 8 )
v81 = 60;
else
v81 = v80;
v114 = v81;
if ( m_minBlendingLayer == 8 && a1->m_shaderLayer->m_state.m_noPlayerParticles )
v82 = 40;
else
v82 = v79;
v83 = 3816;
v84 = 3808;
if ( m_minBlendingLayer >= 2 )
v84 = 3816;
v113 = *(__int64 *)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v84);
if ( m_minBlendingLayer >= 2 )
v83 = 3824;
v85 = *(__int64 *)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v83);
v86 = sub_10024A15C(v80);
v87 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getChildren)(a1->m_objectLayer);
if ( v87 )
{
v88 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_objectLayer->getChildren)(a1->m_objectLayer);
v87 = sub_10024A360(v86, v88);
}
v89 = sub_10024A15C(v87);
v90 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_inShaderObjectLayer->getChildren)(a1->m_inShaderObjectLayer);
if ( v90 )
{
v91 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_inShaderObjectLayer->getChildren)(a1->m_inShaderObjectLayer);
v90 = sub_10024A360(v89, v91);
}
v112 = v65;
v92 = sub_10024A15C(v90);
if ( ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_aboveShaderObjectLayer->getChildren)(a1->m_aboveShaderObjectLayer) )
{
v93 = ((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_aboveShaderObjectLayer->getChildren)(a1->m_aboveShaderObjectLayer);
sub_10024A360(v92, v93);
}
v94 = 0;
do
{
v95 = v89;
v96 = v92;
if ( v94 == 1 )
v97 = v89;
else
v97 = v92;
v98 = v86;
if ( !v94 )
v97 = v86;
if ( v97 )
{
v99 = *(unsigned int **)(v97 + 56);
v100 = *v99;
if ( (_DWORD)v100 )
{
v101 = *((cocos2d::CCNode ***)v99 + 2);
v102 = (unsigned __int64)&v101[v100 - 1];
do
{
v103 = *v101;
if ( !*v101 )
break;
v104 = (GJBaseGameLayer *)((__int64 (__fastcall *)(cocos2d::CCNode *))v103->getZOrder)(*v101);
if ( (int)v104 >= v82 )
m_objectLayer = (cocos2d::CCLayer *)((int)v104 <= v114 ? v113 : v85);
else
m_objectLayer = a1->m_objectLayer;
GJBaseGameLayer::reparentObject(v104, v103, m_objectLayer);
++v101;
}
while ( (unsigned __int64)v101 <= v102 );
}
}
++v94;
v86 = v98;
v89 = v95;
v92 = v96;
}
while ( v94 != 3 );
v106 = ((__int64 (__fastcall *)(ShaderLayer *))a1->m_shaderLayer->getParent)(a1->m_shaderLayer);
v107 = a1->m_shaderLayer;
if ( !v106 )
{
((void (__fastcall *)(GJBaseGameLayer *, ShaderLayer *, _QWORD))a1->addChild_0)(a1, v107, v112);
goto LABEL_138;
}
if ( ((unsigned int (__fastcall *)(ShaderLayer *))v107->getZOrder)(a1->m_shaderLayer) != v112 )
{
setZOrder = (void (*)(void))a1->m_shaderLayer->setZOrder;
LABEL_136:
setZOrder();
goto LABEL_138;
}
goto LABEL_138;
}
}
v77 = *p_m_inShaderParent;
goto LABEL_100;
}
}
}
v73 = *p_m_aboveShaderParent;
goto LABEL_86;
}
if ( v30 )
{
v37 = 1;
do
{
v38 = v37;
v39 = (v37 & 1) == 0;
if ( (v37 & 1) != 0 )
v40 = 3792;
else
v40 = 3800;
if ( v39 )
v41 = 3824;
else
v41 = 3816;
v42 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v40)
+ 472LL))(*(GJBaseGameLayer_vtbl **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v40));
if ( v42 )
{
v43 = v42;
v44 = *(cocos2d::CCNode **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v41);
v45 = sub_10024A15C(v42);
v46 = (GJBaseGameLayer *)sub_10024A360(v45, v43);
if ( v45 )
{
v47 = *(unsigned int **)(v45 + 56);
v48 = *v47;
if ( (_DWORD)v48 )
{
v49 = *((cocos2d::CCNode ***)v47 + 2);
v50 = (unsigned __int64)&v49[v48 - 1];
do
{
v51 = *v49;
if ( !*v49 )
break;
if ( v51 != v44 )
GJBaseGameLayer::reparentObject(v46, v51, a1->m_objectParent);
++v49;
}
while ( (unsigned __int64)v49 <= v50 );
}
}
}
v37 = 0;
}
while ( (v38 & 1) != 0 );
v52 = 1;
do
{
v53 = v52;
if ( (v52 & 1) != 0 )
v54 = 3816;
else
v54 = 3824;
v55 = (GJBaseGameLayer *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v54)
+ 472LL))(*(GJBaseGameLayer_vtbl **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable + v54));
if ( v55 )
{
v56 = v55;
v57 = sub_10024A15C(v55);
v55 = (GJBaseGameLayer *)sub_10024A360(v57, v56);
if ( v57 )
{
v58 = *(unsigned int **)(v57 + 56);
v59 = *v58;
if ( (_DWORD)v59 )
{
v60 = *((cocos2d::CCNode ***)v58 + 2);
v61 = (unsigned __int64)&v60[v59 - 1];
do
{
if ( !*v60 )
break;
GJBaseGameLayer::reparentObject(v55, *v60++, a1->m_objectLayer);
}
while ( (unsigned __int64)v60 <= v61 );
}
}
}
v52 = 0;
}
while ( (v53 & 1) != 0 );
GJBaseGameLayer::reparentObject(v55, a1->m_objectParent, a1);
GJBaseGameLayer::reparentObject(v62, a1->m_inShaderParent, a1);
setZOrder = (void (*)(void))a1->m_shaderLayer->removeFromParentAndCleanup;
goto LABEL_136;
}
LABEL_138:
a1->m_shaderLayer->m_state.m_zLayerDirty = 0;
LABEL_139:
m_inShaderParent = a1->m_inShaderParent;
v109 = ((unsigned int (__fastcall *)(cocos2d::CCNode *, __n128))m_inShaderParent->getChildrenCount)(
m_inShaderParent,
*(__n128 *)&a2) > 1
|| ((unsigned int (__fastcall *)(cocos2d::CCLayer *))a1->m_inShaderObjectLayer->getChildrenCount)(a1->m_inShaderObjectLayer) != 0;
((void (__fastcall *)(cocos2d::CCNode *, _BOOL8))m_inShaderParent->setVisible)(m_inShaderParent, v109);
m_aboveShaderParent = a1->m_aboveShaderParent;
v111 = ((unsigned int (__fastcall *)(cocos2d::CCNode *))m_aboveShaderParent->getChildrenCount)(m_aboveShaderParent) > 1
|| ((unsigned int (__fastcall *)(cocos2d::CCLayer *))a1->m_aboveShaderObjectLayer->getChildrenCount)(a1->m_aboveShaderObjectLayer) != 0;
((void (__fastcall *)(cocos2d::CCNode *, _BOOL8))m_aboveShaderParent->setVisible)(m_aboveShaderParent, v111);
}