//
// ShaderLayer::setupShader from 0xb2dc54 to 0xb2e0cc (1144 bytes)
//
// 5 xrefs:
// > GameManager::applicationWillEnterForeground @ 0x722690
// > GameManager::applicationWillEnterForeground @ 0x7226c4
// > ShaderLayer::update @ 0xb2e8f4
// > ShaderLayer::init @ 0xb303f0
// > ??> @ 0xe23f0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:01:42 +0000
//
__int64 __fastcall ShaderLayer::setupShader(ShaderLayer *this, unsigned __int8 a2)
{
int v2; // w22
__int64 v4; // x0
cocos2d::CCObject *v5; // x0
cocos2d::CCShaderCache *v6; // x0
cocos2d::CCGLProgram *v7; // x0
__int64 v8; // x0
const cocos2d::CCSize *v9; // x0
float v10; // s9
cocos2d::CCDirector *v11; // x0
cocos2d::CCDirector *v12; // x0
cocos2d::CCDirector *WinSize; // x0
float v14; // s0
cocos2d::CCDirector *v15; // x0
cocos2d::CCDirector *ContentScaleFactor; // x0
float v17; // s0
float v18; // s9
cocos2d::CCDirector *v19; // x0
cocos2d::CCDirector *v20; // x0
cocos2d::CCDirector *v21; // x0
cocos2d::CCDirector *v22; // x0
cocos2d::CCDirector *v23; // x0
float v24; // s0
cocos2d::CCSprite *v25; // x0
__int64 v26; // x0
__int64 v27; // x22
void (__fastcall *v28)(__int64, __int64); // x23
__int64 v29; // x0
__int64 v30; // x0
__int64 v31; // x0
__int64 v32; // x22
void (__fastcall *v33)(__int64, _QWORD *); // x23
GameManager *v34; // x0
GameManager *v35; // x0
char GameVariable; // w0
cocos2d::CCGLProgram *v38; // x22
char *v39; // x2
GameManager *updated; // x0
cocos2d::CCGLProgram *v41; // x22
cocos2d::CCShaderCache *v42; // x0
cocos2d::CCShaderCache *v43; // x0
char *v44; // [xsp+58h] [xbp+58h]
float v45; // [xsp+68h] [xbp+68h] BYREF
float v46; // [xsp+6Ch] [xbp+6Ch]
_QWORD v47[2]; // [xsp+70h] [xbp+70h] BYREF
char *v48[2]; // [xsp+80h] [xbp+80h] BYREF
char *v49; // [xsp+90h] [xbp+90h]
v2 = a2;
v4 = *((_QWORD *)this + 138);
if ( v4 )
{
(*(void (__fastcall **)(__int64))(*(_QWORD *)v4 + 536LL))(v4);
*((_QWORD *)this + 138) = 0;
}
v5 = *((cocos2d::CCObject **)this + 137);
if ( v5 )
{
v5 = (cocos2d::CCObject *)cocos2d::CCObject::release(v5);
*((_QWORD *)this + 137) = 0;
}
v6 = (cocos2d::CCShaderCache *)cocos2d::CCShaderCache::sharedShaderCache(v5);
v7 = (cocos2d::CCGLProgram *)cocos2d::CCShaderCache::programForKey(v6, "custom_program");
*((_QWORD *)this + 136) = v7;
if ( v7 )
{
if ( !v2 )
goto LABEL_7;
cocos2d::CCGLProgram::reset(v7);
}
else
{
v41 = (cocos2d::CCGLProgram *)operator new(0x78u);
v42 = (cocos2d::CCShaderCache *)cocos2d::CCGLProgram::CCGLProgram(v41);
*((_QWORD *)this + 136) = v41;
v43 = (cocos2d::CCShaderCache *)cocos2d::CCShaderCache::sharedShaderCache(v42);
cocos2d::CCShaderCache::addProgram(v43, *((cocos2d::CCGLProgram **)this + 136), "custom_program");
cocos2d::CCObject::release(*((cocos2d::CCObject **)this + 136));
}
v38 = *((cocos2d::CCGLProgram **)this + 136);
v44 = (char *)vertTest();
uberShader(v48);
v39 = (char *)v48 + 1;
if ( ((__int64)v48[0] & 1) != 0 )
v39 = v49;
cocos2d::CCGLProgram::initWithVertexShaderByteArray(v38, v44, v39);
if ( ((__int64)v48[0] & 1) != 0 )
operator delete(v49);
cocos2d::CCGLProgram::addAttribute(*((cocos2d::CCGLProgram **)this + 136), "a_position", 0);
cocos2d::CCGLProgram::addAttribute(*((cocos2d::CCGLProgram **)this + 136), "a_color", 1u);
cocos2d::CCGLProgram::addAttribute(*((cocos2d::CCGLProgram **)this + 136), "a_texCoord", 2u);
cocos2d::CCGLProgram::link(*((cocos2d::CCGLProgram **)this + 136));
updated = (GameManager *)cocos2d::CCGLProgram::updateUniforms(*((cocos2d::CCGLProgram **)this + 136));
v7 = (cocos2d::CCGLProgram *)GameManager::sharedState(updated);
*((_BYTE *)v7 + 1700) = 0;
LABEL_7:
v8 = cocos2d::CCDirector::sharedDirector(v7);
v9 = (const cocos2d::CCSize *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(v8 + 192) + 48LL))(*(_QWORD *)(v8 + 192));
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v45, v9);
cocos2d::CCSize::operator=((char *)this + 1160, &v45);
v10 = v46;
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v11);
WinSize = (cocos2d::CCDirector *)cocos2d::CCDirector::getWinSize(v47, v12);
v14 = 1.0 / (float)(*((float *)this + 291) / *((float *)this + 290));
*((float *)this + 288) = v10 / *((float *)v47 + 1);
*((float *)this + 289) = v14;
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(WinSize);
ContentScaleFactor = (cocos2d::CCDirector *)cocos2d::CCDirector::getContentScaleFactor(v15);
v18 = v17;
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(ContentScaleFactor);
cocos2d::CCDirector::setContentScaleFactor(v19, 1.0);
v20 = (cocos2d::CCDirector *)cocos2d::CCRenderTexture::create((unsigned int)(int)v45, (unsigned int)(int)v46, 0);
*((_QWORD *)this + 137) = v20;
v21 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v20);
v22 = (cocos2d::CCDirector *)cocos2d::CCDirector::setContentScaleFactor(v21, v18);
v23 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v22);
cocos2d::CCDirector::getScreenScaleFactorW(v23);
*((float *)this + 287) = (float)(1.0 / v24) * 1.2019;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v47, 0.0, 0.0);
cocos2d::CCSize::operator=((char *)this + 1184, v47);
v25 = (cocos2d::CCSprite *)cocos2d::CCObject::retain(*((cocos2d::CCObject **)this + 137));
v26 = cocos2d::CCSprite::create(v25);
*((_QWORD *)this + 138) = v26;
v27 = v26;
v28 = *(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v26 + 1064LL);
v29 = (*(__int64 (__fastcall **)(_QWORD))(**((_QWORD **)this + 137) + 896LL))(*((_QWORD *)this + 137));
v30 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v29 + 1072LL))(v29);
v28(v27, v30);
v31 = (*(__int64 (__fastcall **)(_QWORD))(**((_QWORD **)this + 138) + 1072LL))(*((_QWORD *)this + 138));
(*(void (__fastcall **)(__int64))(*(_QWORD *)v31 + 144LL))(v31);
cocos2d::CCSize::operator=((char *)this + 1168, v47);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v47, v45, v46);
cocos2d::CCSize::operator=((char *)this + 1176, v47);
v32 = *((_QWORD *)this + 138);
v33 = *(void (__fastcall **)(__int64, _QWORD *))(*(_QWORD *)v32 + 1136LL);
cocos2d::CCRect::CCRect(
(cocos2d::CCRect *)v47,
-1.0,
-1.0,
*((float *)this + 294) + 2.0,
*((float *)this + 295) + 2.0);
v33(v32, v47);
(*(void (__fastcall **)(_QWORD, void *))(**((_QWORD **)this + 138) + 184LL))(*((_QWORD *)this + 138), &unk_155E230);
(*(void (__fastcall **)(_QWORD, void *))(**((_QWORD **)this + 138) + 296LL))(*((_QWORD *)this + 138), &unk_155E230);
cocos2d::CCSprite::setFlipY(*((cocos2d::CCSprite **)this + 138), 1);
v34 = (GameManager *)(*(__int64 (__fastcall **)(ShaderLayer *, _QWORD))(*(_QWORD *)this + 456LL))(
this,
*((_QWORD *)this + 138));
v35 = (GameManager *)GameManager::sharedState(v34);
GameVariable = GameManager::getGameVariable(v35, "0155");
*((_BYTE *)this + 1113) = GameVariable ^ 1;
ShaderLayer::toggleAntiAlias((__int64)this, GameVariable ^ 1);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)this + 138) + 664LL))(
*((_QWORD *)this + 138),
*((_QWORD *)this + 136));
ShaderLayer::setupCommonUniforms(this);
ShaderLayer::setupShockWaveUniforms(this);
ShaderLayer::setupShockLineUniforms(this);
ShaderLayer::setupGlitchUniforms(this);
ShaderLayer::setupChromaticUniforms(this);
ShaderLayer::setupChromaticGlitchUniforms(this);
ShaderLayer::setupLensCircleShader(this);
ShaderLayer::setupRadialBlurShader(this);
ShaderLayer::setupBulgeShader(this);
ShaderLayer::setupPinchShader(this);
ShaderLayer::setupMotionBlurShader(this);
ShaderLayer::setupGrayscaleShader(this);
ShaderLayer::setupSepiaShader(this);
ShaderLayer::setupInvertColorShader(this);
ShaderLayer::setupHueShiftShader(this);
ShaderLayer::setupColorChangeShader(this);
ShaderLayer::setupSplitScreenShader(this);
return _stack_chk_guard;
}