//
// cocos2d::CCSprite::setTextureRect from 0x18008ce10 to 0x18008d19e (910 bytes)
//
// 9 xrefs:
// > ??> @ 0x1800ebc48
// > ??> @ 0x1800ec120
// > ??> @ 0x1800ecca0
// > ??> @ 0x180103b58
// > ??> @ 0x180106b50
// > ??> @ 0x18013d618
// > ??> @ 0x18013d630
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b5e44
//
// 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 __fastcall cocos2d::CCSprite::setTextureRect(
cocos2d::CCSprite *this,
const struct cocos2d::CCRect *a2,
bool a3,
const struct cocos2d::CCSize *a4)
{
cocos2d::CCSprite_vtbl *v4; // rax
__int64 v7; // rdx
float v8; // xmm1_4
float v9; // xmm2_4
bool v10; // zf
float width; // xmm8_4
float height; // xmm6_4
float v13; // xmm4_4
float v14; // xmm3_4
float m_fBlVertexMod; // xmm0_4
float v16; // xmm3_4
float v17; // xmm4_4
float v18; // xmm6_4
float v19; // xmm8_4
float v20; // xmm9_4
float m_fBrVertexMod; // xmm0_4
float m_fTlVertexMod; // xmm1_4
float v23; // xmm2_4
float m_fTrVertexMod; // xmm1_4
float v25; // xmm5_4
float v26; // [rsp+70h] [rbp+8h] BYREF
float v27; // [rsp+74h] [rbp+Ch]
v4 = this->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
this->m_bRectRotated = a3;
((void (__fastcall *)(cocos2d::CCSprite *, const struct cocos2d::CCSize *))v4->setContentSize)(this, a4);
((void (__fastcall *)(cocos2d::CCSprite *, const struct cocos2d::CCRect *))this->setVertexRect)(this, a2);
((void (__fastcall *)(cocos2d::CCSprite *, const struct cocos2d::CCRect *))this->setTextureCoords)(this, a2);
cocos2d::cc_timeval::operator=(&v26, &this->m_obUnflippedOffsetPositionFromCenter);
v8 = v26;
if ( this->m_bFlipX )
{
v8 = -v26;
v26 = -v26;
}
v9 = v27;
if ( this->m_bFlipY )
{
v9 = -v27;
v27 = -v27;
}
v10 = this->m_pobBatchNode == nullptr;
width = this->m_obRect.size.width;
height = this->m_obRect.size.height;
v13 = (float)((float)(this->m_obContentSize.width - width) * 0.5) + v8;
v14 = (float)((float)(this->m_obContentSize.height - height) * 0.5) + v9;
this->m_obOffsetPosition.x = v13;
this->m_obOffsetPosition.y = v14;
if ( v10 )
{
m_fBlVertexMod = this->m_fBlVertexMod;
v16 = v14 + 0.0;
v17 = v13 + 0.0;
v18 = height + v16;
this->m_sQuad.bl.vertices.x = v17;
v19 = width + v17;
v20 = v18 - v16;
if ( m_fBlVertexMod == 0.0 )
{
this->m_sQuad.bl.vertices.y = v16;
this->m_sQuad.bl.vertices.z = 0.0;
}
else
{
this->m_sQuad.bl.vertices.y = v18 - (float)((float)(1.0 - m_fBlVertexMod) * v20);
this->m_sQuad.bl.vertices.z = 0.0;
this->m_sQuad.bl.texCoords.v = this->m_fTextureTop
- (float)((float)(this->m_fTextureTop - this->m_fTextureBottom)
* (float)(1.0 - m_fBlVertexMod));
}
m_fBrVertexMod = this->m_fBrVertexMod;
this->m_sQuad.br.vertices.x = v19;
if ( m_fBrVertexMod == 0.0 )
{
this->m_sQuad.br.vertices.y = v16;
this->m_sQuad.br.vertices.z = 0.0;
}
else
{
this->m_sQuad.br.vertices.y = v18 - (float)((float)(1.0 - m_fBrVertexMod) * v20);
this->m_sQuad.br.vertices.z = 0.0;
this->m_sQuad.br.texCoords.v = this->m_fTextureTop
- (float)((float)(this->m_fTextureTop - this->m_fTextureBottom)
* (float)(1.0 - m_fBrVertexMod));
}
m_fTlVertexMod = this->m_fTlVertexMod;
this->m_sQuad.tl.vertices.x = v17;
if ( m_fTlVertexMod == 0.0 )
{
this->m_sQuad.tl.vertices.y = v18;
this->m_sQuad.tl.vertices.z = 0.0;
}
else
{
this->m_sQuad.tl.vertices.y = (float)((float)(1.0 - m_fTlVertexMod) * v20) + v16;
this->m_sQuad.tl.vertices.z = 0.0;
if ( m_fTlVertexMod >= 0.0 )
{
v23 = 1.0 - this->m_fTlVertexMod;
if ( this->m_bRectRotated )
this->m_sQuad.tl.texCoords.u = (float)((float)(this->m_fTextureRight - this->m_fTextureLeft) * v23)
+ this->m_fTextureLeft;
else
this->m_sQuad.tl.texCoords.v = (float)((float)(this->m_fTextureTop - this->m_fTextureBottom) * v23)
+ this->m_fTextureBottom;
}
}
m_fTrVertexMod = this->m_fTrVertexMod;
this->m_sQuad.tr.vertices.x = v19;
if ( m_fTrVertexMod == 0.0 )
{
this->m_sQuad.tr.vertices.y = v18;
this->m_sQuad.tr.vertices.z = 0.0;
}
else
{
this->m_sQuad.tr.vertices.y = (float)((float)(1.0 - m_fTrVertexMod) * v20) + v16;
this->m_sQuad.tr.vertices.z = 0.0;
if ( m_fTrVertexMod >= 0.0 )
{
v25 = 1.0 - this->m_fTrVertexMod;
if ( this->m_bRectRotated )
this->m_sQuad.tr.texCoords.u = (float)((float)(this->m_fTextureRight - this->m_fTextureLeft) * v25)
+ this->m_fTextureLeft;
else
this->m_sQuad.tr.texCoords.v = (float)((float)(this->m_fTextureTop - this->m_fTextureBottom) * v25)
+ this->m_fTextureBottom;
}
}
}
else
{
LOBYTE(v7) = 1;
((void (__fastcall *)(cocos2d::CCSprite *, __int64))this->setDirty)(this, v7);
}
}