//
// cocos2d::CCSpriteBatchNode::insertChild from 0x5e7fdc to 0x5e8194 (440 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x5e8100
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x5e817c
//
// 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 cocos2d::CCSpriteBatchNode::insertChild(cocos2d::CCSpriteBatchNode *a1, cocos2d::CCSprite *a2, unsigned int a3)
{
cocos2d::CCSprite_vtbl *v6; // r3
unsigned int v7; // r8
cocos2d::ccV3F_C4B_T2F_Quad *v8; // r0
cocos2d::CCArray *m_pobDescendants; // r3
cocos2d::CCObject *v10; // r2
unsigned int v11; // r6
cocos2d::ccArray *data; // r8
int v13; // r3
cocos2d::CCObject *v14; // r1
cocos2d::CCObject **v15; // r6
cocos2d::CCObject **v16; // r8
cocos2d::CCObject **v17; // r8
cocos2d::CCSprite *v18; // r4
cocos2d::CCSprite *v19; // t1
int v20; // r0
unsigned int v21; // r0
cocos2d::CCObject **arr; // r6
cocos2d::CCObject **v23; // r8
cocos2d::CCObject **v24; // r8
cocos2d::CCSprite *v25; // r4
cocos2d::CCSprite *v26; // t1
int v27; // r0
unsigned int v28; // r0
_BYTE v29[96]; // [sp+4h] [bp-64h] BYREF
a2->setBatchNode(a2, a1);
v6 = a2->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->m_uAtlasIndex = a3;
v6->setDirty(a2, 1);
if ( a2->m_bDontDraw )
{
if ( a2->getChildren(a2) && a2->getChildren(a2)->data->num )
{
arr = a2->getChildren(a2)->data->arr;
v23 = a2->getChildren(a2)->data->arr;
v24 = &v23[a2->getChildren(a2)->data->num] + 0x3FFFFFFF;
while ( arr <= v24 )
{
v26 = (cocos2d::CCSprite *)*arr++;
v25 = v26;
if ( !v26 )
break;
v27 = v25->getZOrder(v25);
v28 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v25, v27);
cocos2d::CCSpriteBatchNode::insertChild(a1, v25, v28);
}
}
}
else
{
v7 = a1->m_pobTextureAtlas->getTotalQuads(a1->m_pobTextureAtlas);
if ( v7 == a1->m_pobTextureAtlas->getCapacity(a1->m_pobTextureAtlas) )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(a1);
v8 = (cocos2d::ccV3F_C4B_T2F_Quad *)memcpy(v29, &a2->m_sQuad, sizeof(v29));
cocos2d::CCTextureAtlas::insertQuad(a1->m_pobTextureAtlas, v8, a3);
m_pobDescendants = a1->m_pobDescendants;
v10 = (cocos2d::CCObject *)a3;
v11 = a3 + 1;
data = m_pobDescendants->data;
cocos2d::ccArrayInsertObjectAtIndexBatch(
(cocos2d *)data,
(cocos2d::_ccArray *)a2,
v10,
(unsigned int)m_pobDescendants);
v13 = v11;
while ( v11 < data->num )
{
++v11;
v14 = data->arr[v13++];
++v14[5].m_uIndexInArray;
}
if ( a2->getChildren(a2) && a2->getChildren(a2)->data->num )
{
v15 = a2->getChildren(a2)->data->arr;
v16 = a2->getChildren(a2)->data->arr;
v17 = &v16[a2->getChildren(a2)->data->num] + 0x3FFFFFFF;
while ( v15 <= v17 )
{
v19 = (cocos2d::CCSprite *)*v15++;
v18 = v19;
if ( !v19 )
break;
v20 = v18->getZOrder(v18);
v21 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v18, v20);
cocos2d::CCSpriteBatchNode::insertChild(a1, v18, v21);
}
}
}
}