//
// cocos2d::CCSpriteBatchNode::appendChild from 0x1001d7400 to 0x1001d7584 (388 bytes)
//
// 3 xrefs:
// > cocos2d::CCSpriteBatchNode::addChild @ 0x1001d73fc
// > cocos2d::CCSpriteBatchNode::appendChild @ 0x1001d7564
// > cocos2d::CCSprite::addChild @ 0x1002386ec
//
// 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 *a1, cocos2d::CCSprite *a2)
{
int v4; // w21
cocos2d::ccArray *data; // x21
unsigned int v6; // w2
__int128 v7; // q1
__int128 v8; // q1
__int128 v9; // q1
cocos2d::CCSprite **v10; // x21
__int64 v11; // x22
unsigned __int64 v12; // x20
cocos2d::ccV3F_C4B_T2F_Quad v13; // [xsp+0h] [xbp-80h] BYREF
a1->m_bReorderChildDirty = 1;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))a2->setBatchNode)(a2, a1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a2->setDirty)(a2, 1);
if ( !a2->m_bDontDraw )
{
v4 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTotalQuads)(a1->m_pobTextureAtlas);
if ( v4 == ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getCapacity)(a1->m_pobTextureAtlas) )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity_1(a1);
data = a1->m_pobDescendants->data;
sub_1003537C4(data, a2);
v6 = data->num - 1;
a2->m_uAtlasIndex = v6;
v7 = *(_OWORD *)&a2->m_sQuad.tr.vertices.x;
*(_OWORD *)&v13.bl.vertices.z = *(_OWORD *)&a2->m_sQuad.bl.vertices.z;
*(_OWORD *)&v13.tr.vertices.x = v7;
v8 = *(_OWORD *)&a2->m_sQuad.br.vertices.z;
*(_OWORD *)&v13.tr.texCoords.u = *(_OWORD *)&a2->m_sQuad.tr.texCoords.u;
*(_OWORD *)&v13.br.vertices.z = v8;
v9 = *(_OWORD *)&a2->m_sQuad.tl.texCoords.u;
*(_OWORD *)&v13.tl.vertices.x = *(_OWORD *)&a2->m_sQuad.tl.vertices.x;
*(_OWORD *)&v13.tl.texCoords.u = v9;
cocos2d::CCTextureAtlas::insertQuad(a1->m_pobTextureAtlas, &v13, v6);
}
if ( ((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2)
&& **(_DWORD **)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56) )
{
v10 = *(cocos2d::CCSprite ***)(*(_QWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
+ 16LL);
v11 = *(_QWORD *)(*(_QWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56) + 16LL);
v12 = v11 + 8LL * **(unsigned int **)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56) - 8;
while ( (unsigned __int64)v10 <= v12 && *v10 )
cocos2d::CCSpriteBatchNode::appendChild(a1, *v10++);
}
}