//
// CCSpriteWithHue::initShader from 0x6dd894 to 0x6dda84 (496 bytes)
//
// 2 xrefs:
// > CCSpriteWithHue::initWithTexture @ 0x6de564
// > ??> @ 0xccd90
//
// 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 12:51:35 +0000
//
__int64 __fastcall CCSpriteWithHue::initShader(CCSpriteWithHue *this)
{
cocos2d::CCShaderCache *v2; // x21
char *v3; // x1
cocos2d::CCGLProgram *v4; // x21
const char *v6; // x0
cocos2d::CCShaderCache *updated; // x0
cocos2d::CCShaderCache *v8; // x23
char *v9; // x2
char *v10; // [xsp+48h] [xbp+48h]
char *v11[2]; // [xsp+50h] [xbp+50h] BYREF
char *v12; // [xsp+60h] [xbp+60h]
v2 = (cocos2d::CCShaderCache *)cocos2d::CCShaderCache::sharedShaderCache(_stack_chk_guard);
(*(void (__fastcall **)(char **__return_ptr, CCSpriteWithHue *))(*(_QWORD *)this + 1240LL))(v11, this);
v3 = (char *)v11 + 1;
if ( ((__int64)v11[0] & 1) != 0 )
v3 = v12;
v4 = (cocos2d::CCGLProgram *)cocos2d::CCShaderCache::programForKey(v2, v3);
if ( ((__int64)v11[0] & 1) != 0 )
{
operator delete(v12);
if ( v4 )
goto LABEL_5;
}
else if ( v4 )
{
goto LABEL_5;
}
v4 = (cocos2d::CCGLProgram *)operator new(0x78u);
cocos2d::CCGLProgram::CCGLProgram(v4);
v10 = cocos2d::ccPositionTextureColor_vert[0];
v6 = (const char *)(*(__int64 (__fastcall **)(CCSpriteWithHue *))(*(_QWORD *)this + 1248LL))(this);
cocos2d::CCGLProgram::initWithVertexShaderByteArray(v4, v10, v6);
cocos2d::CCGLProgram::addAttribute(v4, "a_position", 0);
cocos2d::CCGLProgram::addAttribute(v4, "a_color", 1u);
cocos2d::CCGLProgram::addAttribute(v4, "a_texCoord", 2u);
cocos2d::CCGLProgram::link(v4);
updated = (cocos2d::CCShaderCache *)cocos2d::CCGLProgram::updateUniforms(v4);
v8 = (cocos2d::CCShaderCache *)cocos2d::CCShaderCache::sharedShaderCache(updated);
(*(void (__fastcall **)(char **__return_ptr, CCSpriteWithHue *))(*(_QWORD *)this + 1240LL))(v11, this);
v9 = (char *)v11 + 1;
if ( ((__int64)v11[0] & 1) != 0 )
v9 = v12;
cocos2d::CCShaderCache::addProgram(v8, v4, v9);
if ( ((__int64)v11[0] & 1) != 0 )
operator delete(v12);
cocos2d::CCObject::release(v4);
LABEL_5:
(*(void (__fastcall **)(CCSpriteWithHue *, cocos2d::CCGLProgram *))(*(_QWORD *)this + 664LL))(this, v4);
CCSpriteWithHue::getUniformLocations(this);
(*(void (__fastcall **)(CCSpriteWithHue *))(*(_QWORD *)this + 1256LL))(this);
return _stack_chk_guard;
}