//
// cocos2d::CCSpriteBatchNode::insertChild from 0xb17b24 to 0xb17e2c (776 bytes)
//
// 3 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0xb17d14
// > cocos2d::CCSpriteBatchNode::insertChild @ 0xb17e0c
// > ??> @ 0x55710
//
// 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)
{
unsigned int v6; // w23
cocos2d::CCTextureAtlas *m_pobTextureAtlas; // x0
__int64 v8; // x9
cocos2d::ccTex2F texCoords; // x6
__int64 v10; // x7
__int64 v11; // x4
cocos2d::ccTex2F v12; // x5
__int64 v13; // x10
__int64 v14; // x11
cocos2d::ccTex2F v15; // x12
__int64 v16; // x13
__int64 v17; // x14
cocos2d::ccTex2F v18; // x15
cocos2d::CCObject *v19; // x2
unsigned int v20; // w19
cocos2d::ccArray *v21; // x23
unsigned int v22; // w3
cocos2d::CCObject **v23; // x2
cocos2d::CCObject *v24; // x1
cocos2d::CCObject **v25; // x23
cocos2d::ccArray *v26; // x2
cocos2d::CCSprite_vtbl *v27; // x1
cocos2d::CCSprite *v28; // x0
cocos2d::CCObject **v29; // x22
unsigned __int64 v30; // x22
cocos2d::CCSprite *v31; // x19
cocos2d::CCNode *v32; // x0
int v33; // w0
unsigned int v34; // w0
cocos2d::CCObject **arr; // x23
cocos2d::ccArray *data; // x2
cocos2d::CCSprite_vtbl *v37; // x1
cocos2d::CCSprite *v38; // x0
cocos2d::CCObject **v39; // x22
unsigned __int64 v40; // x22
cocos2d::CCSprite *v41; // x19
cocos2d::CCNode *v42; // x0
int v43; // w0
unsigned int v44; // w0
cocos2d::ccV3F_C4B_T2F_Quad v45; // [xsp+48h] [xbp+48h] BYREF
a2->setBatchNode(a2, a1);
a2->m_uAtlasIndex = a3;
a2->setDirty(a2, 1);
if ( a2->m_bDontDraw )
{
if ( a2->getChildren(a2) )
{
if ( a2->getChildren(a2)->data->num )
{
arr = a2->getChildren(a2)->data->arr;
data = a2->getChildren(a2)->data;
v37 = a2->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v38 = a2;
v39 = data->arr;
v40 = (unsigned __int64)&v39[v37->getChildren(v38)->data->num - 1];
while ( v40 >= (unsigned __int64)arr )
{
v41 = (cocos2d::CCSprite *)*arr;
if ( !*arr )
break;
v42 = (cocos2d::CCNode *)*arr++;
v43 = v41->getZOrder(v42);
v44 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v41, v43);
cocos2d::CCSpriteBatchNode::insertChild(a1, v41, v44);
}
}
}
}
else
{
v6 = a1->m_pobTextureAtlas->getTotalQuads(a1->m_pobTextureAtlas);
if ( v6 == a1->m_pobTextureAtlas->getCapacity(a1->m_pobTextureAtlas) )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(a1);
m_pobTextureAtlas = a1->m_pobTextureAtlas;
v8 = *(_QWORD *)&a2->m_sQuad.tl.vertices.z;
texCoords = a2->m_sQuad.tl.texCoords;
v10 = *(_QWORD *)&a2->m_sQuad.bl.vertices.x;
v11 = *(_QWORD *)&a2->m_sQuad.bl.vertices.z;
v12 = a2->m_sQuad.bl.texCoords;
v13 = *(_QWORD *)&a2->m_sQuad.tr.vertices.x;
v14 = *(_QWORD *)&a2->m_sQuad.tr.vertices.z;
v15 = a2->m_sQuad.tr.texCoords;
v16 = *(_QWORD *)&a2->m_sQuad.br.vertices.x;
v17 = *(_QWORD *)&a2->m_sQuad.br.vertices.z;
v18 = a2->m_sQuad.br.texCoords;
*(_QWORD *)&v45.tl.vertices.x = *(_QWORD *)&a2->m_sQuad.tl.vertices.x;
*(_QWORD *)&v45.tl.vertices.z = v8;
v45.tl.texCoords = texCoords;
*(_QWORD *)&v45.bl.vertices.x = v10;
*(_QWORD *)&v45.bl.vertices.z = v11;
v45.bl.texCoords = v12;
*(_QWORD *)&v45.tr.vertices.x = v13;
*(_QWORD *)&v45.tr.vertices.z = v14;
v45.tr.texCoords = v15;
*(_QWORD *)&v45.br.vertices.x = v16;
*(_QWORD *)&v45.br.vertices.z = v17;
v45.br.texCoords = v18;
cocos2d::CCTextureAtlas::insertQuad(m_pobTextureAtlas, &v45, a3);
v19 = (cocos2d::CCObject *)a3;
v20 = a3 + 1;
v21 = a1->m_pobDescendants->data;
cocos2d::ccArrayInsertObjectAtIndexBatch((cocos2d *)v21, (cocos2d::_ccArray *)a2, v19, v22);
if ( v20 < v21->num )
{
v23 = v21->arr;
do
{
v24 = v23[v20++];
++v24[6].m_uAutoReleaseCount;
}
while ( v21->num > v20 );
}
if ( a2->getChildren(a2) )
{
if ( a2->getChildren(a2)->data->num )
{
v25 = a2->getChildren(a2)->data->arr;
v26 = a2->getChildren(a2)->data;
v27 = a2->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v28 = a2;
v29 = v26->arr;
v30 = (unsigned __int64)&v29[v27->getChildren(v28)->data->num - 1];
while ( v30 >= (unsigned __int64)v25 )
{
v31 = (cocos2d::CCSprite *)*v25;
if ( !*v25 )
break;
v32 = (cocos2d::CCNode *)*v25++;
v33 = v31->getZOrder(v32);
v34 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v31, v33);
cocos2d::CCSpriteBatchNode::insertChild(a1, v31, v34);
}
}
}
}
}