//
// cocos2d::CCSpriteBatchNode::appendChild from 0x18008df50 to 0x18008e0fd (429 bytes)
//
// 7 xrefs:
// > cocos2d::CCSprite::addChild @ 0x18008b479
// > cocos2d::CCSpriteBatchNode::addChild @ 0x18008de98
// > cocos2d::CCSpriteBatchNode::appendChild @ 0x18008e0cc
// > ??> @ 0x18013d7e8
// > ??> @ 0x18013d7f8
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b5f64
//
// 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::CCSpriteBatchNode::appendChild(cocos2d::CCSpriteBatchNode *this, struct cocos2d::CCSprite *a2)
{
__int64 v4; // rdx
int v5; // ebx
cocos2d::ccArray *data; // rbx
__int128 v7; // xmm0
unsigned int v8; // r8d
__int128 v9; // xmm1
cocos2d::CCTextureAtlas *m_pobTextureAtlas; // rcx
__int128 v11; // xmm0
__int128 v12; // xmm1
__int128 v13; // xmm0
__int128 v14; // xmm1
struct cocos2d::CCSprite **v15; // rbx
__int64 v16; // rdi
unsigned __int64 i; // rdi
struct cocos2d::_ccV3F_C4B_T2F_Quad v18; // [rsp+20h] [rbp-88h] BYREF
this->m_bReorderChildDirty = 1;
((void (__fastcall *)(struct cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))a2->setBatchNode)(a2, this);
LOBYTE(v4) = 1;
((void (__fastcall *)(struct cocos2d::CCSprite *, __int64))a2->setDirty)(a2, v4);
if ( !a2->m_bDontDraw )
{
v5 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getCapacity)(this->m_pobTextureAtlas);
if ( ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getTotalQuads)(this->m_pobTextureAtlas) == v5 )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(this);
data = this->m_pobDescendants->data;
sub_18009D680(data, a2);
v7 = *(_OWORD *)&a2->m_sQuad.tl.vertices.x;
v8 = data->num - 1;
v9 = *(_OWORD *)&a2->m_sQuad.tl.texCoords.u;
a2->m_uAtlasIndex = v8;
m_pobTextureAtlas = this->m_pobTextureAtlas;
*(_OWORD *)&v18.tl.vertices.x = v7;
v11 = *(_OWORD *)&a2->m_sQuad.bl.vertices.z;
*(_OWORD *)&v18.tl.texCoords.u = v9;
v12 = *(_OWORD *)&a2->m_sQuad.tr.vertices.x;
*(_OWORD *)&v18.bl.vertices.z = v11;
v13 = *(_OWORD *)&a2->m_sQuad.tr.texCoords.u;
*(_OWORD *)&v18.tr.vertices.x = v12;
v14 = *(_OWORD *)&a2->m_sQuad.br.vertices.z;
*(_OWORD *)&v18.tr.texCoords.u = v13;
*(_OWORD *)&v18.br.vertices.z = v14;
cocos2d::CCTextureAtlas::insertQuad(m_pobTextureAtlas, &v18, v8);
}
if ( ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) )
{
if ( **(_DWORD **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56) )
{
v15 = *(struct cocos2d::CCSprite ***)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2)
+ 56)
+ 16LL);
v16 = 8LL * **(unsigned int **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56);
for ( i = *(_QWORD *)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
+ 16LL)
+ v16
- 8; (unsigned __int64)v15 <= i; ++v15 )
{
if ( !*v15 )
break;
cocos2d::CCSpriteBatchNode::appendChild(this, *v15);
}
}
}
}