//
// CCSpriteWithHue::initShader from 0x5bc748 to 0x5bca28 (736 bytes)
//
// 2 xrefs:
// > CCSpriteWithHue::initWithTexture @ 0x5bd4e8
// > ??> @ 0x9b730
//
// 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 CCSpriteWithHue::initShader(CCSpriteWithHue *a1)
{
cocos2d::CCShaderCache *v2; // x21
cocos2d::CCGLProgram *v3; // x21
char *v4; // x0
const char *v5; // x0
cocos2d::CCShaderCache *v6; // x24
char *v7; // x0
unsigned int *v8; // x1
int v9; // w2
unsigned int *v10; // x1
int v11; // w2
char *v12; // [xsp+48h] [xbp+48h]
char *v13; // [xsp+60h] [xbp+60h] BYREF
v2 = cocos2d::CCShaderCache::sharedShaderCache();
((void (__fastcall *)(char **__return_ptr, CCSpriteWithHue *))a1->getShaderName)(&v13, a1);
v3 = cocos2d::CCShaderCache::programForKey(v2, v13);
v4 = v13 - 24;
if ( v13 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v13 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v13 - 2);
*((_DWORD *)v13 - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v4);
}
if ( !v3 )
{
v3 = (cocos2d::CCGLProgram *)operator new(0x78u);
cocos2d::CCGLProgram::CCGLProgram(v3);
v12 = cocos2d::ccPositionTextureColor_vert[0];
v5 = (const char *)a1->shaderBody(a1);
cocos2d::CCGLProgram::initWithVertexShaderByteArray(v3, v12, v5);
cocos2d::CCGLProgram::addAttribute(v3, "a_position", 0);
cocos2d::CCGLProgram::addAttribute(v3, "a_color", 1u);
cocos2d::CCGLProgram::addAttribute(v3, "a_texCoord", 2u);
cocos2d::CCGLProgram::link(v3);
cocos2d::CCGLProgram::updateUniforms(v3);
v6 = cocos2d::CCShaderCache::sharedShaderCache();
((void (__fastcall *)(char **__return_ptr, CCSpriteWithHue *))a1->getShaderName)(&v13, a1);
cocos2d::CCShaderCache::addProgram(v6, v3, v13);
v7 = v13 - 24;
if ( v13 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v13 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *((_DWORD *)v13 - 2);
*((_DWORD *)v13 - 2) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v7);
}
cocos2d::CCObject::release(v3);
}
a1->setShaderProgram(a1, v3);
CCSpriteWithHue::getUniformLocations(a1);
a1->updateColor(a1);
}