//
// cocos2d::CCSpriteBatchNode::updateAtlasIndex from 0x100177060 to 0x100177596 (1334 bytes)
//
// 3 xrefs:
// > cocos2d::CCSpriteBatchNode::sortAllChildren @ 0x10017702e
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0x1001770c2
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0x1001772bb
//
// 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::updateAtlasIndex(
cocos2d::CCSpriteBatchNode *a1,
cocos2d::CCSprite *a2,
int *a3)
{
cocos2d::CCSprite *v4; // r14
__int64 v5; // rax
unsigned int *v6; // rdx
cocos2d::CCSprite **v7; // rbx
unsigned __int64 v8; // r14
signed int m_uAtlasIndex; // r12d
int v10; // ebx
cocos2d::CCSpriteBatchNode *v11; // rax
signed int v12; // r13d
int v13; // ebx
cocos2d::CCObject **v14; // r15
__int64 v15; // rax
cocos2d::CCObject *v16; // rcx
__int64 v17; // rdx
cocos2d::CCObject *v18; // rsi
__int64 v19; // rsi
__int128 v20; // xmm0
__int128 v21; // xmm1
__int128 v22; // xmm2
cocos2d::CCObject *v23; // rax
char v24; // bl
unsigned int *v25; // rax
__int64 v26; // rcx
cocos2d::CCSprite **v27; // r13
cocos2d::CCSprite *v28; // r12
int v29; // ebx
int *v30; // rax
int v31; // r15d
cocos2d::CCObject **v32; // r14
__int64 v33; // rax
cocos2d::CCObject *v34; // rcx
__int64 v35; // rdx
cocos2d::CCObject *v36; // rsi
__int64 v37; // rsi
__int128 v38; // xmm0
__int128 v39; // xmm1
__int128 v40; // xmm2
cocos2d::CCObject *v41; // rax
cocos2d::CCObject **arr; // r14
__int64 v43; // rax
cocos2d::CCObject *v44; // rcx
__int64 v45; // rdx
cocos2d::CCObject *v46; // rsi
__int64 v47; // rsi
__int128 v48; // xmm0
__int128 v49; // xmm1
__int128 v50; // xmm2
__int128 v52; // [rsp+20h] [rbp-A0h]
__int128 v53; // [rsp+20h] [rbp-A0h]
__int128 v54; // [rsp+20h] [rbp-A0h]
__int128 v55; // [rsp+30h] [rbp-90h]
__int128 v56; // [rsp+30h] [rbp-90h]
__int128 v57; // [rsp+30h] [rbp-90h]
__int128 v58; // [rsp+40h] [rbp-80h]
__int128 v59; // [rsp+40h] [rbp-80h]
__int128 v60; // [rsp+40h] [rbp-80h]
__int128 v61; // [rsp+50h] [rbp-70h]
__int128 v62; // [rsp+50h] [rbp-70h]
__int128 v63; // [rsp+50h] [rbp-70h]
__int128 v64; // [rsp+60h] [rbp-60h]
__int128 v65; // [rsp+60h] [rbp-60h]
__int128 v66; // [rsp+60h] [rbp-60h]
__int128 v67; // [rsp+70h] [rbp-50h]
__int128 v68; // [rsp+70h] [rbp-50h]
__int128 v69; // [rsp+70h] [rbp-50h]
int *v70; // [rsp+88h] [rbp-38h]
__int64 v71; // [rsp+90h] [rbp-30h]
cocos2d::CCSprite **v72; // [rsp+90h] [rbp-30h]
v4 = a2;
v5 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2);
if ( !v5 || (v6 = *(unsigned int **)(v5 + 56), !*v6) )
{
if ( a2->m_bDontDraw )
return;
m_uAtlasIndex = a2->m_uAtlasIndex;
v10 = *a3;
a2->m_uAtlasIndex = *a3;
if ( m_uAtlasIndex == v10 )
goto LABEL_29;
v70 = a3;
v11 = a1;
LABEL_28:
arr = v11->m_pobDescendants->data->arr;
v43 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))v11->m_pobTextureAtlas->getQuads)(v11->m_pobTextureAtlas);
v44 = arr[m_uAtlasIndex];
v45 = 96LL * m_uAtlasIndex;
v69 = *(_OWORD *)(v43 + v45 + 80);
v66 = *(_OWORD *)(v43 + v45 + 64);
v63 = *(_OWORD *)(v43 + v45 + 48);
v60 = *(_OWORD *)(v43 + v45 + 32);
v57 = *(_OWORD *)(v43 + v45 + 16);
v54 = *(_OWORD *)(v43 + v45);
v46 = arr[v10];
v46[6].m_uAutoReleaseCount = m_uAtlasIndex;
arr[m_uAtlasIndex] = v46;
v47 = 96LL * v10;
*(_OWORD *)(v43 + v45 + 80) = *(_OWORD *)(v43 + v47 + 80);
*(_OWORD *)(v43 + v45 + 64) = *(_OWORD *)(v43 + v47 + 64);
v48 = *(_OWORD *)(v43 + v47);
v49 = *(_OWORD *)(v43 + v47 + 16);
v50 = *(_OWORD *)(v43 + v47 + 32);
*(_OWORD *)(v43 + v45 + 48) = *(_OWORD *)(v43 + v47 + 48);
*(_OWORD *)(v43 + v45 + 32) = v50;
*(_OWORD *)(v43 + v45 + 16) = v49;
*(_OWORD *)(v43 + v45) = v48;
arr[v10] = v44;
*(_OWORD *)(v43 + v47 + 80) = v69;
*(_OWORD *)(v43 + v47 + 64) = v66;
*(_OWORD *)(v43 + v47 + 48) = v63;
*(_OWORD *)(v43 + v47 + 32) = v60;
*(_OWORD *)(v43 + v47 + 16) = v57;
*(_OWORD *)(v43 + v47) = v54;
arr[m_uAtlasIndex]->m_unknown2 = m_uAtlasIndex;
arr[v10]->m_unknown2 = v10;
a3 = v70;
m_uAtlasIndex = *v70;
LABEL_29:
*a3 = m_uAtlasIndex + 1;
return;
}
v7 = *((cocos2d::CCSprite ***)v6 + 2);
if ( !a2->m_bDontDraw )
{
v71 = v5;
v70 = a3;
if ( ((int (__fastcall *)(cocos2d::CCSprite *))(*v7)->getZOrder)(*v7) < 0 )
{
v24 = 1;
v25 = *(unsigned int **)(v71 + 56);
v26 = *v25;
if ( !*v25 )
goto LABEL_26;
}
else
{
v12 = a2->m_uAtlasIndex;
v13 = *a3;
a2->m_uAtlasIndex = *a3;
if ( v12 != v13 )
{
v14 = a1->m_pobDescendants->data->arr;
v15 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getQuads)(a1->m_pobTextureAtlas);
v16 = v14[v12];
v17 = 96LL * v12;
v67 = *(_OWORD *)(v15 + v17 + 80);
v64 = *(_OWORD *)(v15 + v17 + 64);
v61 = *(_OWORD *)(v15 + v17 + 48);
v58 = *(_OWORD *)(v15 + v17 + 32);
v55 = *(_OWORD *)(v15 + v17 + 16);
v52 = *(_OWORD *)(v15 + v17);
v18 = v14[v13];
v18[6].m_uAutoReleaseCount = v12;
v14[v12] = v18;
v19 = 96LL * v13;
*(_OWORD *)(v15 + v17 + 80) = *(_OWORD *)(v15 + v19 + 80);
*(_OWORD *)(v15 + v17 + 64) = *(_OWORD *)(v15 + v19 + 64);
v20 = *(_OWORD *)(v15 + v19);
v21 = *(_OWORD *)(v15 + v19 + 16);
v22 = *(_OWORD *)(v15 + v19 + 32);
*(_OWORD *)(v15 + v17 + 48) = *(_OWORD *)(v15 + v19 + 48);
*(_OWORD *)(v15 + v17 + 32) = v22;
*(_OWORD *)(v15 + v17 + 16) = v21;
*(_OWORD *)(v15 + v17) = v20;
v14[v13] = v16;
*(_OWORD *)(v15 + v19 + 80) = v67;
*(_OWORD *)(v15 + v19 + 64) = v64;
*(_OWORD *)(v15 + v19 + 48) = v61;
*(_OWORD *)(v15 + v19 + 32) = v58;
*(_OWORD *)(v15 + v19 + 16) = v55;
*(_OWORD *)(v15 + v19) = v52;
v14[v12]->m_unknown2 = v12;
v23 = v14[v13];
a3 = v70;
v4 = a2;
v23->m_unknown2 = v13;
v12 = *v70;
}
*a3 = v12 + 1;
v24 = 0;
v25 = *(unsigned int **)(v71 + 56);
v26 = *v25;
if ( !*v25 )
{
LABEL_26:
v11 = a1;
if ( (v24 & 1) == 0 )
return;
m_uAtlasIndex = v4->m_uAtlasIndex;
v10 = *a3;
v4->m_uAtlasIndex = *a3;
if ( m_uAtlasIndex == v10 )
goto LABEL_29;
goto LABEL_28;
}
}
v27 = *((cocos2d::CCSprite ***)v25 + 2);
v72 = &v27[v26 - 1];
do
{
v28 = *v27;
if ( !*v27 )
break;
if ( (v24 & 1) != 0 && ((int (__fastcall *)(cocos2d::CCSprite *))v28->getZOrder)(*v27) >= 0 )
{
v29 = v4->m_uAtlasIndex;
v30 = a3;
v31 = *a3;
v4->m_uAtlasIndex = v31;
if ( v29 == v31 )
{
a3 = v30;
}
else
{
v32 = a1->m_pobDescendants->data->arr;
v33 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getQuads)(a1->m_pobTextureAtlas);
v34 = v32[v29];
v35 = 96LL * v29;
v68 = *(_OWORD *)(v33 + v35 + 80);
v65 = *(_OWORD *)(v33 + v35 + 64);
v62 = *(_OWORD *)(v33 + v35 + 48);
v59 = *(_OWORD *)(v33 + v35 + 32);
v56 = *(_OWORD *)(v33 + v35 + 16);
v53 = *(_OWORD *)(v33 + v35);
v36 = v32[v31];
v36[6].m_uAutoReleaseCount = v29;
v32[v29] = v36;
v37 = 96LL * v31;
*(_OWORD *)(v33 + v35 + 80) = *(_OWORD *)(v33 + v37 + 80);
*(_OWORD *)(v33 + v35 + 64) = *(_OWORD *)(v33 + v37 + 64);
v38 = *(_OWORD *)(v33 + v37);
v39 = *(_OWORD *)(v33 + v37 + 16);
v40 = *(_OWORD *)(v33 + v37 + 32);
*(_OWORD *)(v33 + v35 + 48) = *(_OWORD *)(v33 + v37 + 48);
*(_OWORD *)(v33 + v35 + 32) = v40;
*(_OWORD *)(v33 + v35 + 16) = v39;
*(_OWORD *)(v33 + v35) = v38;
v32[v31] = v34;
*(_OWORD *)(v33 + v37 + 80) = v68;
*(_OWORD *)(v33 + v37 + 64) = v65;
*(_OWORD *)(v33 + v37 + 48) = v62;
*(_OWORD *)(v33 + v37 + 32) = v59;
*(_OWORD *)(v33 + v37 + 16) = v56;
*(_OWORD *)(v33 + v37) = v53;
v32[v29]->m_unknown2 = v29;
v41 = v32[v31];
v4 = a2;
v41->m_unknown2 = v31;
a3 = v70;
v29 = *v70;
}
*a3 = v29 + 1;
v24 = 0;
}
cocos2d::CCSpriteBatchNode::updateAtlasIndex(a1, v28, a3);
++v27;
}
while ( v27 <= v72 );
goto LABEL_26;
}
v8 = (unsigned __int64)&v7[*v6 - 1];
do
{
if ( !*v7 )
break;
cocos2d::CCSpriteBatchNode::updateAtlasIndex(a1, *v7++, a3);
}
while ( (unsigned __int64)v7 <= v8 );
}