//
// cocos2d::extension::CCControlSwitchSprite::initWithMaskSprite from 0xa9f658 to 0xa9f9cc (884 bytes)
//
// 2 xrefs:
// > cocos2d::extension::CCControlSwitch::initWithMaskSprite @ 0xa9fbbc
// > ??> @ 0x97218
//
// 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
//
__int64 __fastcall cocos2d::extension::CCControlSwitchSprite::initWithMaskSprite(
cocos2d::CCSprite *this,
cocos2d::CCSprite *a2,
cocos2d::CCSprite *a3,
cocos2d::CCSprite *a4,
cocos2d::CCSprite *a5,
cocos2d::CCLabelTTF *a6,
cocos2d::CCLabelTTF *a7)
{
cocos2d::CCTexture2D *v14; // x0
unsigned __int8 v15; // w0
unsigned int v16; // w23
const cocos2d::CCSize *(__fastcall *getContentSize)(const cocos2d::CCNode *__hidden); // x1
float width; // s8
const cocos2d::CCSize *v20; // x0
cocos2d::CCSprite *v21; // x1
float v22; // s0
cocos2d::CCObject *v23; // x0
cocos2d::CCSprite *v24; // x0
cocos2d::CCObject *v25; // x0
cocos2d::CCLabelTTF *v26; // x0
cocos2d::CCLabelTTF *v27; // x0
cocos2d::CCTexture2D *v28; // x0
cocos2d::CCTexture2D *v29; // x21
cocos2d::CCObject *v30; // x1
cocos2d::CCGLProgram *v31; // x22
cocos2d::CCGLProgram *v32; // x0
cocos2d::CCGLProgram *v33; // x0
cocos2d::CCGLProgram *v34; // x0
cocos2d::CCGLProgram *v35; // x0
cocos2d::CCGLProgram *v36; // x0
void (__fastcall *setContentSize)(cocos2d::CCNode *__hidden, const cocos2d::CCSize *); // x21
__int64 v38; // [xsp+70h] [xbp+70h] BYREF
v14 = a2->getTexture(a2);
v15 = cocos2d::CCSprite::initWithTexture(this, v14);
v16 = v15;
if ( v15 )
{
getContentSize = a5->getContentSize;
*((_DWORD *)this + 153) = 0;
width = getContentSize(a5)->width;
v20 = a3->getContentSize(a3);
v21 = *((cocos2d::CCSprite **)this + 80);
v22 = v20->width;
*((_DWORD *)this + 152) = *((_DWORD *)this + 153);
*((float *)this + 154) = -(float)(v22 - (float)(width * 0.5));
if ( a3 != v21 )
{
cocos2d::CCObject::retain(a3);
v23 = *((cocos2d::CCObject **)this + 80);
if ( v23 )
cocos2d::CCObject::release(v23);
*((_QWORD *)this + 80) = a3;
}
v24 = *((cocos2d::CCSprite **)this + 81);
if ( v24 != a4 )
{
if ( a4 )
{
cocos2d::CCObject::retain(a4);
v24 = *((cocos2d::CCSprite **)this + 81);
}
if ( v24 )
cocos2d::CCObject::release(v24);
*((_QWORD *)this + 81) = a4;
}
if ( a5 != *((cocos2d::CCSprite **)this + 82) )
{
cocos2d::CCObject::retain(a5);
v25 = *((cocos2d::CCObject **)this + 82);
if ( v25 )
cocos2d::CCObject::release(v25);
*((_QWORD *)this + 82) = a5;
}
v26 = *((cocos2d::CCLabelTTF **)this + 83);
if ( v26 != a6 )
{
if ( a6 )
{
cocos2d::CCObject::retain(a6);
v26 = *((cocos2d::CCLabelTTF **)this + 83);
}
if ( v26 )
cocos2d::CCObject::release(v26);
*((_QWORD *)this + 83) = a6;
}
v27 = *((cocos2d::CCLabelTTF **)this + 84);
if ( v27 != a7 )
{
if ( a7 )
{
cocos2d::CCObject::retain(a7);
v27 = *((cocos2d::CCLabelTTF **)this + 84);
}
if ( v27 )
cocos2d::CCObject::release(v27);
*((_QWORD *)this + 84) = a7;
}
this->addChild(this, *((cocos2d::CCNode **)this + 82));
v28 = a2->getTexture(a2);
v29 = v28;
v30 = *((cocos2d::CCObject **)this + 78);
if ( v30 != v28 )
{
if ( v28 )
{
cocos2d::CCObject::retain(v28);
v30 = *((cocos2d::CCObject **)this + 78);
}
if ( v30 )
cocos2d::CCObject::release(v30);
*((_QWORD *)this + 78) = v29;
}
v31 = (cocos2d::CCGLProgram *)operator new(0x78u);
cocos2d::CCGLProgram::CCGLProgram(v31);
cocos2d::CCGLProgram::initWithVertexShaderByteArray(
v31,
cocos2d::ccPositionTextureColor_vert[0],
cocos2d::ccExSwitchMask_frag[0]);
this->setShaderProgram(this, v31);
cocos2d::CCObject::release(v31);
v32 = this->getShaderProgram(this);
cocos2d::CCGLProgram::addAttribute(v32, "a_position", 0);
v33 = this->getShaderProgram(this);
cocos2d::CCGLProgram::addAttribute(v33, "a_color", 1u);
v34 = this->getShaderProgram(this);
cocos2d::CCGLProgram::addAttribute(v34, "a_texCoord", 2u);
v35 = this->getShaderProgram(this);
cocos2d::CCGLProgram::link(v35);
v36 = this->getShaderProgram(this);
cocos2d::CCGLProgram::updateUniforms(v36);
this->getShaderProgram(this);
*((_DWORD *)this + 158) = glGetUniformLocation();
this->getShaderProgram(this);
*((_DWORD *)this + 159) = glGetUniformLocation();
setContentSize = this->setContentSize;
(*(void (__fastcall **)(__int64 *__return_ptr, _QWORD))(**((_QWORD **)this + 78) + 144LL))(
&v38,
*((_QWORD *)this + 78));
setContentSize(this, (const cocos2d::CCSize *)&v38);
cocos2d::extension::CCControlSwitchSprite::needsLayout(this);
}
return v16;
}