//
// cocos2d::CCParticleSystemQuad::setTotalParticles from 0x100253e24 to 0x100254004 (480 bytes)
//
// 1 xrefs:
// > ??> @ 0x1007cf7a0
//
// 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::CCParticleSystemQuad::setTotalParticles(cocos2d::CCParticleSystemQuad *a1, unsigned int a2)
{
size_t v4; // x23
size_t v5; // x22
cocos2d::tCCParticle *v6; // x20
cocos2d::ccV3F_C4B_T2F_Quad *v7; // x26
GLushort *v8; // x0
GLushort *v9; // x25
bool v10; // zf
__int64 v12; // x8
int64x2_t v13; // q0
int64x2_t v14; // q1
uint64x2_t v15; // q2
int64x2_t v16; // q3
int16x4_t v17; // d4
if ( a1->m_uAllocatedParticles >= a2 )
{
a1->m_uTotalParticles = a2;
LABEL_29:
cocos2d::CCParticleSystem::resetSystem(a1);
return;
}
v4 = 96LL * a2;
v5 = 12LL * a2;
v6 = (cocos2d::tCCParticle *)realloc(a1->m_pParticles, 148LL * a2);
v7 = (cocos2d::ccV3F_C4B_T2F_Quad *)realloc(a1->m_pQuads, v4);
v8 = (GLushort *)realloc(a1->m_pIndices, v5);
v9 = v8;
if ( v6 )
v10 = v7 == nullptr;
else
v10 = 1;
if ( !v10 && v8 != nullptr )
{
a1->m_pParticles = v6;
a1->m_pQuads = v7;
a1->m_pIndices = v8;
bzero(v6, 148LL * a2);
bzero(v7, v4);
bzero(v9, v5);
a1->m_uAllocatedParticles = a2;
a1->m_uTotalParticles = a2;
if ( a1->m_pBatchNode )
{
v12 = 0;
v13 = (int64x2_t)xmmword_100635BC0;
v14 = (int64x2_t)xmmword_100635BD0;
v15 = (uint64x2_t)vdupq_n_s64((unsigned __int64)a2 - 1);
v16 = vdupq_n_s64(4u);
do
{
v17 = (int16x4_t)vmovn_s64((int64x2_t)vcgeq_u64(v15, (uint64x2_t)v14));
if ( (vuzp1_s16(v17, *(int16x4_t *)v13.i8).u8[0] & 1) != 0 )
LODWORD(v6->modeA.dir.x) = v12;
if ( (vuzp1_s16(v17, *(int16x4_t *)v13.i8).i8[2] & 1) != 0 )
LODWORD(v6[2].startPos.y) = v12 + 1;
if ( (vuzp1_s16(*(int16x4_t *)v13.i8, (int16x4_t)vmovn_s64((int64x2_t)vcgeq_u64(v15, (uint64x2_t)v13))).i32[1]
& 1) != 0 )
{
LODWORD(v6[3].rotation) = v12 + 2;
LODWORD(v6[4].modeB.deltaRadius) = v12 + 3;
}
v12 += 4;
v13 = vaddq_s64(v13, v16);
v14 = vaddq_s64(v14, v16);
v6 = (cocos2d::tCCParticle *)((char *)v6 + 592);
}
while ( ((a2 + 3LL) & 0x1FFFFFFFCLL) != v12 );
}
cocos2d::CCParticleSystemQuad::initIndices(a1);
cocos2d::CCParticleSystemQuad::setupVBOandVAO(a1);
if ( a1->m_pTexture )
cocos2d::CCParticleSystemQuad::initTexCoordsWithRect(a1, (const cocos2d::CCRect *)&a1->m_tTextureRect.origin.y);
goto LABEL_29;
}
if ( v6 )
a1->m_pParticles = v6;
if ( v7 )
a1->m_pQuads = v7;
if ( v8 )
a1->m_pIndices = v8;
}