//
// GJBaseGameLayer::createParticle from 0x1402405f0 to 0x1402409cf (991 bytes)
//
// 2 xrefs:
// > GameObject::createAndAddParticle @ 0x140198bb4
// > ??> @ 0x1406ce3d0
//
// 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
//
// Hidden C++ exception states: #wind=4
cocos2d::CCParticleSystemQuad *GJBaseGameLayer::createParticle(
GJBaseGameLayer *a1,
int a2,
const char *a3,
int a4,
cocos2d::tCCPositionType a5)
{
const char *v5; // r15
GJBaseGameLayer *v7; // r14
__int64 v8; // rcx
__int64 v9; // rax
void **v11; // rdx
struct cocos2d::CCParticleSystemQuad *v12; // rdi
size_t v13; // rbx
size_t v14; // r8
__int64 v15; // rcx
__int64 v16; // rsi
void *v17; // rcx
__int64 v18; // rsi
__int64 v19; // rcx
void **v20; // rdx
size_t v21; // r8
__int64 v22; // rcx
__int64 v23; // r8
__int64 v24; // r9
unsigned __int64 v25; // rdx
void *v26; // rcx
void **v27; // r15
void **v28; // r12
unsigned __int64 v29; // r13
__int64 v30; // rsi
unsigned __int64 v31; // r14
_QWORD *ParticleKey2; // rax
void **v33; // rdx
cocos2d::CCArray *v34; // rbx
void *v35; // rcx
unsigned int v36; // [rsp+30h] [rbp-81h]
void *v37; // [rsp+38h] [rbp-79h]
__int64 v38; // [rsp+38h] [rbp-79h]
void *Block[2]; // [rsp+58h] [rbp-59h] BYREF
unsigned __int64 v42; // [rsp+68h] [rbp-49h]
unsigned __int64 v43; // [rsp+70h] [rbp-41h]
void *Src[2]; // [rsp+78h] [rbp-39h] BYREF
unsigned __int64 v45; // [rsp+88h] [rbp-29h]
unsigned __int64 v46; // [rsp+90h] [rbp-21h]
_QWORD v47[4]; // [rsp+98h] [rbp-19h] BYREF
v36 = a4;
v5 = a3;
v7 = a1;
v8 = (unsigned int)a5;
v9 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v37 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v9 = qword_1406C2ED8;
a4 = v36;
v8 = (unsigned int)a5;
}
if ( *(_BYTE *)(v9 + 917) )
return nullptr;
GJBaseGameLayer::getParticleKey(v8, Src, a2, (unsigned __int64)v5, a4, v8);
v11 = Src;
if ( v46 > 0xF )
v11 = (void **)Src[0];
*(_OWORD *)Block = 0;
v12 = nullptr;
v42 = 0;
v43 = 0;
v13 = -1;
v14 = -1;
do
++v14;
while ( *((_BYTE *)v11 + v14) );
sub_14003A930(Block, v11, v14);
v16 = cocos2d::CCDictionary::objectForKey(v7->m_particlesDict, Block);
if ( v43 > 0xF )
{
v17 = Block[0];
if ( v43 + 1 >= 0x1000 )
{
v17 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v17 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v17);
}
if ( v16 )
{
v29 = v46;
v28 = (void **)Src[0];
}
else
{
v18 = cocos2d::CCArray::create(v15);
v38 = cocos2d::CCArray::create(v19);
v20 = Src;
if ( v46 > 0xF )
v20 = (void **)Src[0];
*(_OWORD *)Block = 0;
v42 = 0;
v43 = 0;
v21 = -1;
do
++v21;
while ( *((_BYTE *)v20 + v21) );
sub_14003A930(Block, v20, v21);
cocos2d::CCDictionary::setObject(v7->m_particlesDict, v18, Block);
v25 = v43;
if ( v43 > 0xF )
{
v26 = Block[0];
if ( v43 + 1 >= 0x1000 )
{
v26 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v26);
}
*(_OWORD *)Block = 0;
v42 = 0;
v43 = 0;
v27 = Src;
v28 = (void **)Src[0];
v29 = v46;
if ( v46 > 0xF )
v27 = (void **)Src[0];
v30 = 0x7FFFFFFFFFFFFFFFLL;
v31 = v45;
if ( v45 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v22, v25, v23, v24);
v43 = 15;
if ( v45 > 0xF )
{
if ( (v45 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v30 = v45 | 0xF;
if ( (v45 | 0xF) < 0x16 )
v30 = 22;
}
Block[0] = sub_14003AA10(v30 + 1);
v42 = v31;
v43 = v30;
memcpy(Block[0], v27, v31 + 1);
}
else
{
v42 = v45;
*(_OWORD *)Block = *(_OWORD *)v27;
}
ParticleKey2 = GJBaseGameLayer::getParticleKey2(v22, v47, (const char *)Block);
v7 = a1;
cocos2d::CCDictionary::setObject(a1->m_particlesDict, v38, ParticleKey2);
sub_14003A830((__int64)v47);
v5 = a3;
}
v33 = Src;
if ( v29 > 0xF )
v33 = v28;
*(_OWORD *)Block = 0;
v42 = 0;
v43 = 0;
do
++v13;
while ( *((_BYTE *)v33 + v13) );
sub_14003A930(Block, v33, v13);
v34 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v7->m_particlesDict, Block);
if ( v43 > 0xF )
{
v35 = Block[0];
if ( v43 + 1 >= 0x1000 )
{
v35 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v35 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v35);
}
v42 = 0;
v43 = 15;
LOBYTE(Block[0]) = 0;
if ( cocos2d::CCArray::count(v34) < v7->m_particleSystemLimit )
{
v12 = cocos2d::CCParticleSystemQuad::create(v5, 1);
v12->setTag(v12, v36);
v12->setPositionType(v12, a5);
cocos2d::CCParticleSystem::stopSystem(v12);
v12->setVisible(v12, 0);
cocos2d::CCArray::addObject(v34, v12);
}
sub_14003A830((__int64)Src);
return v12;
}