//
// cocos2d::CCParticleSystem::initWithTotalParticles from 0x1007c8980 to 0x1007c8ae9 (361 bytes)
//
// 2 xrefs:
// > cocos2d::CCParticleSystemQuad::initWithTotalParticles @ 0x100602099
// > ??> @ 0x100996a18
//
// 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 __fastcall cocos2d::CCParticleSystem::initWithTotalParticles(
cocos2d::CCParticleSystem *a1,
unsigned int a2,
bool a3)
{
cocos2d::tCCParticle *m_pParticles; // rdi
unsigned int m_uTotalParticles; // eax
unsigned int v7; // r12d
cocos2d::tCCParticle *v8; // rax
cocos2d::tCCParticle *v9; // r15
__int64 v10; // rcx
__int64 v11; // rax
__int64 v12; // r12
_DWORD *p_deltaRadius; // rdx
__int64 v14; // rdx
__int64 v15; // rcx
__int64 v16; // rsi
a1->m_uTotalParticles = a2;
m_pParticles = a1->m_pParticles;
m_uTotalParticles = a2;
if ( m_pParticles )
{
free(m_pParticles);
m_uTotalParticles = a1->m_uTotalParticles;
}
v7 = m_uTotalParticles;
v8 = (cocos2d::tCCParticle *)calloc(m_uTotalParticles, 0x94u);
v9 = v8;
a1->m_pParticles = v8;
if ( v8 )
{
a1->m_uAllocatedParticles = a2;
if ( a1->m_pBatchNode && v7 )
{
v10 = v7 & 3;
if ( v7 >= 4 )
{
v12 = v7 & 0xFFFFFFFC;
p_deltaRadius = (_DWORD *)&v8[4].modeB.deltaRadius;
v11 = 0;
do
{
*(p_deltaRadius - 111) = v11;
*(p_deltaRadius - 74) = v11 + 1;
*(p_deltaRadius - 37) = v11 + 2;
*p_deltaRadius = v11 + 3;
v11 += 4;
p_deltaRadius += 148;
}
while ( v11 != v12 );
}
else
{
v11 = 0;
}
if ( v10 )
{
v14 = (__int64)&v9->modeA + 148 * v11;
v15 = 148 * v10;
v16 = 0;
do
{
*(_DWORD *)(v14 + v16) = v11;
LODWORD(v11) = v11 + 1;
v16 += 148;
}
while ( v15 != v16 );
}
}
a1->m_bIsActive = 1;
a1->m_tBlendFunc = (cocos2d::ccBlendFunc)0x30300000001LL;
a1->m_ePositionType = kCCPositionTypeFree;
a1->m_nEmitterMode = 0;
a1->m_bIsAutoRemoveOnFinish = 0;
a1->m_bTransformSystemDirty = 0;
if ( !a3 )
{
cocos2d::CCNode::scheduleUpdateWithPriority(a1, 1);
a1->m_bUsingSchedule = 1;
}
}
else
{
cocos2d::CCObject::release(a1);
}
return v9 != nullptr;
}