//
// GJBaseGameLayer::updateShaderLayer from 0x85f1d8 to 0x85fc2c (2644 bytes)
//
// 8 xrefs:
// > PlayLayer::resetLevel @ 0x5e5660
// > PlayLayer::resetLevel @ 0x5e5a98
// > LevelEditorLayer::onPlaytest @ 0x664450
// > LevelEditorLayer::updateGameObjects @ 0x67bad4
// > GJBaseGameLayer::resetLevelVariables @ 0x88ac58
// > GJBaseGameLayer::update @ 0x89d8dc
// > GJBaseGameLayer::update @ 0x89e518
// > ??> @ 0x39300
//
// 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::updateShaderLayer(GJBaseGameLayer *a1, float a2)
{
ShaderLayer *m_shaderLayer; // x2
int m_grayscaleTintChannel; // w1
ShaderLayer *v6; // x20
int m_blurRefChannel; // w1
ShaderLayer *v8; // x21
GJShaderState *p_m_state; // 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
GLubyte b; // w20
GLubyte r; // w24
GLubyte g; // w23
bool shouldBlend; // w0
bool v22; // w3
float v23; // s0
ShaderLayer *v24; // x0
GJShaderState *v25; // x2
int m_motionBlurTargetIDX; // w1
int m_motionBlurTargetIDY; // w1
float v28; // s10
ShaderLayer *v29; // x0
__int64 v30; // x0
ShaderLayer *v31; // x2
GJShaderState *v32; // x0
int m_minBlendingLayer; // w20
int m_maxBlendingLayer; // w21
cocos2d::CCNode *m_objectParent; // x1
cocos2d::CCNode *m_inShaderParent; // x1
cocos2d::CCNode *v37; // x2
GJMGLayer *m_middleground; // x1
cocos2d::CCNode *v39; // x2
cocos2d::CCNode *m_aboveShaderParent; // x23
GJGroundLayer *m_groundLayer; // x1
GJGroundLayer *m_groundLayer2; // x1
cocos2d::CCNode *v43; // x2
int v44; // w24
int v45; // w26
cocos2d::CCLayer *m_noPlayerParticles; // x0
cocos2d::CCLayer *m_objectLayer; // x27
cocos2d::CCLayer *m_aboveShaderObjectLayer; // x28
cocos2d::CCArray *v49; // x20
cocos2d::CCArray *v50; // x0
cocos2d::CCArray *v51; // x0
cocos2d::CCArray *v52; // x20
cocos2d::CCArray *v53; // x0
cocos2d::CCArray *v54; // x0
cocos2d::CCArray *v55; // x20
cocos2d::CCArray *v56; // x0
int v57; // w23
int j; // w25
cocos2d::CCArray *v59; // x0
cocos2d::ccArray *v60; // x0
cocos2d::CCNode **v61; // x20
cocos2d::CCNode **v62; // x21
int v63; // w0
cocos2d::CCNode *v64; // x2
int v65; // w0
ShaderLayer *v66; // x2
cocos2d::CCNode *v67; // x20
void (__fastcall *setVisible)(cocos2d::CCNode *__hidden, bool); // x21
cocos2d::CCNode *v69; // x20
void (__fastcall *v70)(cocos2d::CCNode *__hidden, bool); // x21
const cocos2d::ccColor3B *v71; // x0
int v72; // w23
cocos2d::CCArray *v73; // x0
cocos2d::CCLayer *m_inShaderObjectLayer; // x24
cocos2d::CCArray *v75; // x1
cocos2d::CCArray *v76; // x20
cocos2d::ccArray *data; // x0
cocos2d::CCNode **arr; // x20
cocos2d::CCNode **i; // x21
cocos2d::CCNode *v80; // x1
int v81; // w21
cocos2d::CCArray *v82; // x0
cocos2d::CCArray *v83; // x1
cocos2d::CCArray *v84; // x20
cocos2d::ccArray *v85; // x0
cocos2d::CCNode **v86; // x20
cocos2d::CCNode **v87; // x23
cocos2d::CCNode *v88; // x1
cocos2d::CCArray *v89; // [xsp+80h] [xbp+80h]
cocos2d::CCArray *v90; // [xsp+88h] [xbp+88h]
unsigned int v91; // [xsp+94h] [xbp+94h]
cocos2d::CCArray *v92; // [xsp+98h] [xbp+98h]
cocos2d::CCNode *v93; // [xsp+A0h] [xbp+A0h]
cocos2d::CCArray *v94; // [xsp+A0h] [xbp+A0h]
cocos2d::CCArray *v95; // [xsp+A0h] [xbp+A0h]
float v96; // [xsp+A0h] [xbp+A0h]
float v97; // [xsp+C0h] [xbp+C0h]
float v98; // [xsp+C4h] [xbp+C4h]
cocos2d::ccColor3B v99; // 0:w0.3
cocos2d::CCPoint v100; // 0:kr00_8.8
cocos2d::CCPoint v101; // 0:kr28_8.8
cocos2d::CCPoint v102; // 0:kr30_8.8
cocos2d::CCPoint v103; // 0:s0.4,4:s1.4
cocos2d::CCPoint v104; // 0:s0.4,4:s1.4
m_shaderLayer = a1->m_shaderLayer;
if ( !m_shaderLayer )
goto LABEL_79;
m_grayscaleTintChannel = m_shaderLayer->m_state.m_grayscaleTintChannel;
if ( m_grayscaleTintChannel <= 0 )
{
m_shaderLayer->m_state.m_grayscaleTint.b = -1;
m_shaderLayer->m_state.m_grayscaleTint.g = -1;
m_shaderLayer->m_state.m_grayscaleTint.r = -1;
v6 = a1->m_shaderLayer;
m_blurRefChannel = v6->m_state.m_blurRefChannel;
if ( m_blurRefChannel > 0 )
goto LABEL_4;
LABEL_85:
v71 = a1->m_background->getColor(a1->m_background);
*(_WORD *)&v6->m_state.m_blurRefColor.r = *(_WORD *)&v71->r;
v6->m_state.m_blurRefColor.b = v71->b;
goto LABEL_5;
}
a1->m_shaderLayer->m_state.m_grayscaleTint = GJEffectManager::activeColorForIndex(
a1->m_effectManager,
m_grayscaleTintChannel);
v6 = a1->m_shaderLayer;
m_blurRefChannel = v6->m_state.m_blurRefChannel;
if ( m_blurRefChannel <= 0 )
goto LABEL_85;
LABEL_4:
v6->m_state.m_blurRefColor = GJEffectManager::activeColorForIndex(a1->m_effectManager, m_blurRefChannel);
LABEL_5:
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
if ( v8->m_state.m_radialBlurTarget )
{
m_radialBlurTargetID = v8->m_state.m_radialBlurTargetID;
if ( m_radialBlurTargetID )
{
v100 = GJBaseGameLayer::positionForShaderTarget(a1, m_radialBlurTargetID);
cocos2d::CCPoint::operator=(&v8->m_state.m_radialBlurCenter, v100.x, v100.y);
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
}
}
if ( p_m_state->m_pinchTargetEnabledX )
{
m_pinchTargetIDX = p_m_state->m_pinchTargetIDX;
if ( m_pinchTargetIDX )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_pinchTargetIDX);
v8 = a1->m_shaderLayer;
p_m_state->m_pinchCenter.x = v97;
p_m_state = &v8->m_state;
}
}
if ( p_m_state->m_pinchTargetEnabledY )
{
m_pinchTargetIDY = p_m_state->m_pinchTargetIDY;
if ( m_pinchTargetIDY )
{
GJBaseGameLayer::positionForShaderTarget(a1, m_pinchTargetIDY);
v8 = a1->m_shaderLayer;
p_m_state->m_pinchCenter.y = v98;
p_m_state = &v8->m_state;
}
}
m_shockWaveTargetID = p_m_state->m_shockWaveTargetID;
if ( m_shockWaveTargetID )
{
v104 = GJBaseGameLayer::positionForShaderTarget(a1, m_shockWaveTargetID);
ShaderLayer::updateShockWaveCenter(v8, v104);
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
}
m_shockLineTargetID = p_m_state->m_shockLineTargetID;
if ( m_shockLineTargetID )
{
v103 = GJBaseGameLayer::positionForShaderTarget(a1, m_shockLineTargetID);
ShaderLayer::updateShockLineCenter(v8, v103);
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
}
m_lensCircleTargetID = p_m_state->m_lensCircleTargetID;
if ( m_lensCircleTargetID )
{
v102 = GJBaseGameLayer::positionForShaderTarget(a1, m_lensCircleTargetID);
cocos2d::CCPoint::operator=(&v8->m_state.m_lensCircleCenter, v102.x, v102.y);
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
}
m_bulgeTargetID = p_m_state->m_bulgeTargetID;
if ( m_bulgeTargetID )
{
v101 = GJBaseGameLayer::positionForShaderTarget(a1, m_bulgeTargetID);
cocos2d::CCPoint::operator=(&v8->m_state.m_bulgeCenter, v101.x, v101.y);
v8 = a1->m_shaderLayer;
p_m_state = &v8->m_state;
}
m_lensCircleTintChannel = p_m_state->m_lensCircleTintChannel;
if ( m_lensCircleTintChannel <= 0 )
{
b = 0;
g = 0;
r = 0;
v22 = 0;
}
else
{
v99 = GJEffectManager::activeColorForIndex(a1->m_effectManager, m_lensCircleTintChannel);
b = v99.b;
r = v99.r;
g = v99.g;
shouldBlend = GJEffectManager::shouldBlend(a1->m_effectManager, a1->m_shaderLayer->m_state.m_lensCircleTintChannel);
v8 = a1->m_shaderLayer;
v22 = shouldBlend;
}
v8->m_state.m_lensCircleTint.r = r;
v8->m_state.m_lensCircleTint.g = g;
v8->m_state.m_lensCircleTint.b = b;
v23 = 0.0;
v24 = a1->m_shaderLayer;
v25 = &v24->m_state;
m_motionBlurTargetIDX = v24->m_state.m_motionBlurTargetIDX;
v24->m_state.m_lensCircleAdditive = v22;
if ( m_motionBlurTargetIDX )
{
GJBaseGameLayer::speedForShaderTarget(a1, m_motionBlurTargetIDX);
v24 = a1->m_shaderLayer;
v23 = v97;
v25 = &v24->m_state;
}
m_motionBlurTargetIDY = v25->m_motionBlurTargetIDY;
v28 = 0.0;
if ( m_motionBlurTargetIDY )
{
v96 = v23;
GJBaseGameLayer::speedForShaderTarget(a1, m_motionBlurTargetIDY);
v24 = a1->m_shaderLayer;
v28 = v98;
v23 = v96;
}
ShaderLayer::updateMotionBlurSpeedX(v24, v23, a2 * 60.0);
ShaderLayer::updateMotionBlurSpeedY(a1->m_shaderLayer, v28, a2 * 60.0);
a1->m_shaderLayer->update(a1->m_shaderLayer, a2);
ShaderLayer::performCalculations(a1->m_shaderLayer);
v29 = a1->m_shaderLayer;
if ( !v29->m_state.m_usesShaders )
{
v72 = 1;
if ( !v29->getParent(v29) )
goto LABEL_109;
while ( v72 == 1 )
{
v73 = a1->m_inShaderParent->getChildren(a1->m_inShaderParent);
m_inShaderObjectLayer = a1->m_inShaderObjectLayer;
v75 = v73;
if ( v73 )
{
LABEL_89:
v94 = v75;
v76 = (cocos2d::CCArray *)cocos2d::CCArray::create(v73);
cocos2d::CCArray::addObjectsFromArray(v76, v94);
if ( v76 )
{
data = v76->data;
if ( data->num )
{
arr = (cocos2d::CCNode **)data->arr;
for ( i = &arr[data->num - 1]; i >= arr; ++arr )
{
v80 = *arr;
if ( !*arr )
break;
if ( v80 != m_inShaderObjectLayer )
GJBaseGameLayer::reparentObject(a1, v80, a1->m_objectParent);
}
}
}
LABEL_96:
if ( v72 == 2 )
{
v81 = 1;
while ( v81 == 1 )
{
v82 = a1->m_inShaderObjectLayer->getChildren(a1->m_inShaderObjectLayer);
v83 = v82;
if ( v82 )
{
LABEL_101:
v95 = v83;
v84 = (cocos2d::CCArray *)cocos2d::CCArray::create(v82);
cocos2d::CCArray::addObjectsFromArray(v84, v95);
if ( v84 )
{
v85 = v84->data;
if ( v85->num )
{
v86 = (cocos2d::CCNode **)v85->arr;
v87 = &v86[v85->num - 1];
while ( v87 >= v86 )
{
v88 = *v86;
if ( !*v86 )
break;
++v86;
GJBaseGameLayer::reparentObject(a1, v88, a1->m_objectLayer);
}
}
}
LABEL_106:
if ( v81 == 2 )
{
GJBaseGameLayer::reparentObject(a1, a1->m_objectParent, a1);
GJBaseGameLayer::reparentObject(a1, a1->m_inShaderParent, a1);
a1->m_shaderLayer->removeFromParentAndCleanup(a1->m_shaderLayer, 0);
LABEL_109:
v66 = a1->m_shaderLayer;
LABEL_110:
v66->m_state.m_zLayerDirty = 0;
goto LABEL_79;
}
++v81;
}
else
{
v81 = 2;
}
}
v82 = a1->m_aboveShaderObjectLayer->getChildren(a1->m_aboveShaderObjectLayer);
v83 = v82;
if ( !v82 )
goto LABEL_106;
goto LABEL_101;
}
++v72;
}
else
{
v72 = 2;
}
}
v73 = a1->m_aboveShaderParent->getChildren(a1->m_aboveShaderParent);
m_inShaderObjectLayer = a1->m_aboveShaderObjectLayer;
v75 = v73;
if ( !v73 )
goto LABEL_96;
goto LABEL_89;
}
v30 = (__int64)v29->getParent(v29);
v31 = a1->m_shaderLayer;
if ( v30 )
{
v32 = &v31->m_state;
if ( !v31->m_state.m_zLayerDirty )
goto LABEL_78;
}
else
{
v32 = &v31->m_state;
}
m_minBlendingLayer = v32->m_minBlendingLayer;
m_maxBlendingLayer = v32->m_maxBlendingLayer;
m_objectParent = a1->m_objectParent;
if ( m_minBlendingLayer <= 1 )
{
GJBaseGameLayer::reparentObject(a1, m_objectParent, v31);
m_inShaderParent = a1->m_inShaderParent;
v37 = a1;
}
else
{
GJBaseGameLayer::reparentObject(a1, m_objectParent, a1);
m_inShaderParent = a1->m_inShaderParent;
v37 = a1->m_shaderLayer;
}
GJBaseGameLayer::reparentObject(a1, m_inShaderParent, v37);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
v39 = a1->m_inShaderParent;
if ( m_maxBlendingLayer <= 1 || m_minBlendingLayer != 2 )
v39 = a1->m_objectParent;
GJBaseGameLayer::reparentObject(a1, m_middleground, v39);
}
m_aboveShaderParent = a1->m_objectParent;
v91 = m_minBlendingLayer > 1;
if ( m_maxBlendingLayer > 12 || m_minBlendingLayer <= 1 )
{
if ( m_minBlendingLayer > 1 || m_maxBlendingLayer > 12 )
{
if ( m_minBlendingLayer <= 13 && m_minBlendingLayer > 1 && m_maxBlendingLayer > 12 )
m_aboveShaderParent = a1->m_inShaderParent;
}
else
{
m_aboveShaderParent = a1->m_inShaderParent;
}
}
else
{
m_aboveShaderParent = a1->m_aboveShaderParent;
}
m_groundLayer = a1->m_groundLayer;
if ( m_groundLayer )
GJBaseGameLayer::reparentObject(a1, m_groundLayer, m_aboveShaderParent);
m_groundLayer2 = a1->m_groundLayer2;
if ( m_groundLayer2 )
GJBaseGameLayer::reparentObject(a1, m_groundLayer2, m_aboveShaderParent);
v43 = a1->m_objectParent;
if ( m_maxBlendingLayer > 13 || m_minBlendingLayer <= 1 )
{
if ( m_minBlendingLayer > 1 || m_maxBlendingLayer > 13 )
{
if ( m_minBlendingLayer <= 14 && m_minBlendingLayer > 1 && m_maxBlendingLayer > 13 )
v43 = a1->m_inShaderParent;
}
else
{
v43 = a1->m_inShaderParent;
}
}
else
{
v43 = a1->m_aboveShaderParent;
}
GJBaseGameLayer::reparentObject(a1, a1->m_uiTriggerUI, v43);
v44 = GJBaseGameLayer::minZOrderForShaderZ(a1, m_minBlendingLayer);
v45 = GJBaseGameLayer::maxZOrderForShaderZ(a1, m_maxBlendingLayer);
m_noPlayerParticles = (cocos2d::CCLayer *)a1->m_shaderLayer->m_state.m_noPlayerParticles;
if ( !a1->m_shaderLayer->m_state.m_noPlayerParticles )
goto LABEL_51;
if ( m_minBlendingLayer != 8 )
{
if ( m_maxBlendingLayer == 8 )
v45 = 60;
LABEL_51:
m_objectLayer = a1->m_inShaderObjectLayer;
m_aboveShaderObjectLayer = a1->m_aboveShaderObjectLayer;
m_noPlayerParticles = a1->m_objectLayer;
if ( m_minBlendingLayer <= 1 )
{
m_aboveShaderObjectLayer = a1->m_inShaderObjectLayer;
m_objectLayer = a1->m_objectLayer;
}
goto LABEL_53;
}
m_objectLayer = a1->m_inShaderObjectLayer;
if ( m_maxBlendingLayer == 8 )
{
v45 = 60;
m_aboveShaderObjectLayer = a1->m_aboveShaderObjectLayer;
v44 = 40;
}
else
{
v44 = 40;
m_aboveShaderObjectLayer = a1->m_aboveShaderObjectLayer;
}
LABEL_53:
v49 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)m_noPlayerParticles);
v90 = v49;
v50 = a1->m_objectLayer->getChildren(a1->m_objectLayer);
if ( v50 )
{
v51 = a1->m_objectLayer->getChildren(a1->m_objectLayer);
v50 = (cocos2d::CCArray *)cocos2d::CCArray::addObjectsFromArray(v49, v51);
}
v52 = (cocos2d::CCArray *)cocos2d::CCArray::create(v50);
v89 = v52;
v53 = a1->m_inShaderObjectLayer->getChildren(a1->m_inShaderObjectLayer);
if ( v53 )
{
v54 = a1->m_inShaderObjectLayer->getChildren(a1->m_inShaderObjectLayer);
v53 = (cocos2d::CCArray *)cocos2d::CCArray::addObjectsFromArray(v52, v54);
}
v55 = (cocos2d::CCArray *)cocos2d::CCArray::create(v53);
v92 = v55;
if ( a1->m_aboveShaderObjectLayer->getChildren(a1->m_aboveShaderObjectLayer) )
{
v56 = a1->m_aboveShaderObjectLayer->getChildren(a1->m_aboveShaderObjectLayer);
cocos2d::CCArray::addObjectsFromArray(v55, v56);
}
v57 = 1;
for ( j = 0; ; ++j )
{
if ( !j )
{
v59 = v90;
if ( v90 )
goto LABEL_63;
goto LABEL_74;
}
if ( j != 1 )
break;
v59 = v89;
if ( v89 )
goto LABEL_63;
LABEL_74:
++v57;
}
v59 = v92;
if ( !v92 )
goto LABEL_73;
LABEL_63:
v60 = v59->data;
if ( v60->num )
{
v61 = (cocos2d::CCNode **)v60->arr;
v62 = &v61[v60->num - 1];
if ( v61 <= v62 )
{
while ( *v61 )
{
v93 = *v61;
v63 = (*v61)->getZOrder(*v61);
if ( v44 > v63 )
{
++v61;
GJBaseGameLayer::reparentObject(a1, v93, a1->m_objectLayer);
if ( v62 < v61 )
break;
}
else
{
if ( v45 >= v63 )
v64 = m_objectLayer;
else
v64 = m_aboveShaderObjectLayer;
++v61;
GJBaseGameLayer::reparentObject(a1, v93, v64);
if ( v62 < v61 )
break;
}
}
}
}
LABEL_73:
if ( v57 != 3 )
goto LABEL_74;
if ( !a1->m_shaderLayer->getParent(a1->m_shaderLayer) )
{
a1->addChild_0(a1, a1->m_shaderLayer, v91);
a1->m_shaderLayer->m_state.m_zLayerDirty = 0;
goto LABEL_79;
}
v65 = a1->m_shaderLayer->getZOrder(a1->m_shaderLayer);
v66 = a1->m_shaderLayer;
if ( v91 == v65 )
goto LABEL_110;
v66->setZOrder(a1->m_shaderLayer, v91);
v32 = &a1->m_shaderLayer->m_state;
LABEL_78:
v32->m_zLayerDirty = 0;
LABEL_79:
v67 = a1->m_inShaderParent;
setVisible = v67->setVisible;
if ( v67->getChildrenCount(v67) <= 1 )
((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_inShaderObjectLayer->getChildrenCount)(a1->m_inShaderObjectLayer);
((void (__fastcall *)(cocos2d::CCNode *))setVisible)(v67);
v69 = a1->m_aboveShaderParent;
v70 = v69->setVisible;
if ( v69->getChildrenCount(v69) <= 1 )
((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_aboveShaderObjectLayer->getChildrenCount)(a1->m_aboveShaderObjectLayer);
((void (__fastcall *)(cocos2d::CCNode *))v70)(v69);
}