//
// cocos2d::CCTextureAtlas::resizeCapacity from 0x5f4862 to 0x5f494c (234 bytes)
//
// 3 xrefs:
// > cocos2d::CCLabelAtlas::setString @ 0x5cb0ce
// > cocos2d::CCParticleBatchNode::increaseAtlasCapacityTo @ 0x5dd416
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0x5e7ddc
//
// 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
//
bool cocos2d::CCTextureAtlas::resizeCapacity(cocos2d::CCTextureAtlas *a1, unsigned int a2)
{
unsigned int m_uCapacity; // r6
unsigned int m_uTotalQuads; // r3
cocos2d::ccV3F_C4B_T2F_Quad *m_pQuads; // r8
unsigned int v6; // r7
cocos2d::ccV3F_C4B_T2F_Quad *v7; // r0
cocos2d::ccV3F_C4B_T2F_Quad *v8; // r5
size_t v9; // r2
cocos2d::ccV3F_C4B_T2F_Quad *v10; // r0
unsigned int v11; // r2
unsigned int v12; // r1
int v13; // r7
GLushort *v14; // r0
GLushort *v15; // r8
size_t v16; // r2
GLushort *v17; // r0
unsigned int v18; // r2
void *v20; // r0
cocos2d::ccV3F_C4B_T2F_Quad *v21; // r0
GLushort *m_pIndices; // r0
m_uCapacity = a1->m_uCapacity;
if ( a2 == m_uCapacity )
return 1;
m_uTotalQuads = a1->m_uTotalQuads;
m_pQuads = a1->m_pQuads;
a1->m_uCapacity = a2;
if ( m_uTotalQuads > a2 )
a1->m_uTotalQuads = a2;
else
a1->m_uTotalQuads = m_uTotalQuads;
if ( !m_pQuads )
{
v6 = 96 * a2;
v7 = (cocos2d::ccV3F_C4B_T2F_Quad *)malloc(96 * a2);
v8 = v7;
if ( !v7 )
goto LABEL_12;
v9 = v6;
goto LABEL_11;
}
v10 = (cocos2d::ccV3F_C4B_T2F_Quad *)realloc(m_pQuads, 96 * a2);
v8 = v10;
if ( v10 )
{
v11 = a1->m_uCapacity;
if ( v11 > m_uCapacity )
{
v7 = &v10[m_uCapacity];
v9 = 96 * (v11 - m_uCapacity);
LABEL_11:
memset(v7, 0, v9);
}
}
LABEL_12:
v12 = a1->m_uCapacity;
if ( a1->m_pIndices )
{
v17 = (GLushort *)realloc(a1->m_pIndices, 12 * v12);
v15 = v17;
if ( v17 )
{
v18 = a1->m_uCapacity;
if ( v18 <= m_uCapacity )
{
LABEL_28:
if ( v8 )
{
a1->m_pQuads = v8;
a1->m_pIndices = v15;
cocos2d::CCTextureAtlas::setupIndices(a1);
cocos2d::CCTextureAtlas::mapBuffers(a1);
a1->m_bDirty = 1;
return 1;
}
v20 = v15;
goto LABEL_22;
}
v14 = &v17[m_uCapacity];
v16 = 12 * (v18 - m_uCapacity);
LABEL_18:
memset(v14, 0, v16);
goto LABEL_28;
}
}
else
{
v13 = 12 * v12;
v14 = (GLushort *)malloc(12 * v12);
v15 = v14;
if ( v14 )
{
v16 = v13;
goto LABEL_18;
}
}
if ( v8 )
{
v20 = v8;
LABEL_22:
free(v20);
}
v21 = a1->m_pQuads;
if ( v21 )
{
free(v21);
a1->m_pQuads = nullptr;
}
m_pIndices = a1->m_pIndices;
if ( m_pIndices )
{
free(m_pIndices);
a1->m_pIndices = nullptr;
}
a1->m_uTotalQuads = 0;
a1->m_uCapacity = 0;
return 0;
}