//
// cocos2d::CCTextureAtlas::resizeCapacity from 0x1800a6c70 to 0x1800a6e72 (514 bytes)
//
// 9 xrefs:
// > cocos2d::CCLabelAtlas::setString @ 0x1800466c1
// > cocos2d::CCParticleBatchNode::increaseAtlasCapacityTo @ 0x180061697
// > cocos2d::CCParticleBatchNode::insertChild @ 0x18006184e
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0x18008e539
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0x18008e596
// > cocos2d::CCSpriteBatchNode::insertQuadFromSprite @ 0x18008eaea
// > cocos2d::CCSpriteBatchNode::updateQuadFromSprite @ 0x18008f53a
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7da0
//
// 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
//
char __fastcall cocos2d::CCTextureAtlas::resizeCapacity(cocos2d::CCTextureAtlas *this, unsigned int a2)
{
float v2; // xmm1_4
__int64 m_uCapacity; // rbp
unsigned int m_uTotalQuads; // ecx
__int64 v7; // rax
cocos2d::ccV3F_C4B_T2F_Quad *m_pQuads; // rcx
size_t v9; // rdx
cocos2d::ccV3F_C4B_T2F_Quad *v10; // rax
cocos2d::ccV3F_C4B_T2F_Quad *v11; // rsi
__int64 v12; // r8
cocos2d::ccV3F_C4B_T2F_Quad *v13; // rcx
unsigned int v14; // eax
GLushort *m_pIndices; // rcx
__int64 v16; // rax
GLushort *v17; // rax
GLushort *v18; // rdi
GLushort *v19; // rcx
__int64 v20; // r8
unsigned int v21; // eax
unsigned int v22; // eax
unsigned int v23; // edi
__int64 v24; // r9
GLushort v25; // r10
void *v26; // rcx
cocos2d::ccV3F_C4B_T2F_Quad *v27; // rcx
GLushort *v28; // rcx
m_uCapacity = this->m_uCapacity;
if ( a2 == (_DWORD)m_uCapacity )
return 1;
m_uTotalQuads = a2;
v7 = a2;
if ( this->m_uTotalQuads < a2 )
m_uTotalQuads = this->m_uTotalQuads;
this->m_uCapacity = a2;
this->m_uTotalQuads = m_uTotalQuads;
m_pQuads = this->m_pQuads;
v9 = 96LL * a2;
if ( !m_pQuads )
{
v10 = (cocos2d::ccV3F_C4B_T2F_Quad *)malloc(96 * v7);
v11 = v10;
if ( !v10 )
goto LABEL_12;
v12 = 3LL * this->m_uCapacity;
v13 = v10;
goto LABEL_11;
}
v11 = (cocos2d::ccV3F_C4B_T2F_Quad *)realloc(m_pQuads, v9);
if ( v11 )
{
v14 = this->m_uCapacity;
if ( v14 > (unsigned int)m_uCapacity )
{
v13 = &v11[m_uCapacity];
v12 = 3LL * (v14 - (unsigned int)m_uCapacity);
LABEL_11:
memset(v13, 0, 32 * v12);
}
}
LABEL_12:
m_pIndices = this->m_pIndices;
v16 = this->m_uCapacity;
if ( !m_pIndices )
{
v17 = (GLushort *)malloc(2LL * (unsigned int)(6 * v16));
v18 = v17;
if ( !v17 )
goto LABEL_19;
v19 = v17;
v20 = 6 * this->m_uCapacity;
goto LABEL_18;
}
v18 = (GLushort *)realloc(m_pIndices, 12 * v16);
if ( v18 )
{
v21 = this->m_uCapacity;
if ( v21 > (unsigned int)m_uCapacity )
{
v19 = &v18[m_uCapacity];
v20 = 6 * (v21 - (unsigned int)m_uCapacity);
LABEL_18:
memset(v19, 0, 2 * v20);
}
}
LABEL_19:
if ( v11 )
{
if ( v18 )
{
v22 = this->m_uCapacity;
this->m_pQuads = v11;
this->m_pIndices = v18;
if ( v22 )
{
v23 = 0;
do
{
v24 = 6 * v23;
v25 = 4 * v23++;
this->m_pIndices[v24] = v25;
this->m_pIndices[(unsigned int)(v24 + 1)] = v25 + 1;
this->m_pIndices[(unsigned int)(v24 + 2)] = v25 + 2;
this->m_pIndices[(unsigned int)(v24 + 3)] = v25 + 3;
this->m_pIndices[(unsigned int)(v24 + 4)] = v25 + 2;
this->m_pIndices[(unsigned int)(v24 + 5)] = v25 + 1;
}
while ( v23 < this->m_uCapacity );
}
cocos2d::CCTextureAtlas::mapBuffers(this, v2);
this->m_bDirty = 1;
return 1;
}
v26 = v11;
goto LABEL_28;
}
if ( v18 )
{
v26 = v18;
LABEL_28:
free(v26);
}
v27 = this->m_pQuads;
if ( v27 )
{
free(v27);
this->m_pQuads = nullptr;
}
v28 = this->m_pIndices;
if ( v28 )
{
free(v28);
this->m_pIndices = nullptr;
}
*(_QWORD *)&this->m_uTotalQuads = 0;
return 0;
}