//
// GJBaseGameLayer::createCustomParticle from 0x140240d80 to 0x140241080 (768 bytes)
//
// 4 xrefs:
// > ??> @ 0x1405670b8
// > ??> @ 0x140586410
// > ??> @ 0x1405c9ca0
// > ??> @ 0x1406ce3f4
//
// 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=2
cocos2d::CCParticleSystemQuad *__fastcall GJBaseGameLayer::createCustomParticle(
__int64 a1,
void **a2,
const cocos2d::ParticleStruct *a3,
int a4,
char a5)
{
void **v7; // rbx
size_t v9; // rdi
size_t v10; // r8
__int64 v11; // rcx
cocos2d::CCArray *v12; // rsi
void *v13; // rcx
void **v14; // rcx
void **v15; // rdx
void **v16; // rdx
size_t v17; // r8
void *v18; // rcx
__int64 v19; // rcx
__int64 v20; // rax
void *v21; // rcx
cocos2d::CCParticleSystemQuad *v23; // rbx
int v24; // [rsp+20h] [rbp-78h] BYREF
void *v25[2]; // [rsp+28h] [rbp-70h] BYREF
__int128 v26; // [rsp+38h] [rbp-60h]
void *Block[2]; // [rsp+48h] [rbp-50h] BYREF
__m128i si128; // [rsp+58h] [rbp-40h]
v7 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
a2 = (void **)*a2;
*(_OWORD *)Block = 0;
si128 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( *((_BYTE *)a2 + v10) );
sub_14003A930(Block, a2, v10);
v12 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 12488), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v13 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v13);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( !v12 && !a5 )
{
v12 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
v12->setTag(v12, ++*(_DWORD *)(a1 + 12468));
v24 = v12->getTag(v12);
v14 = (void **)(*(_QWORD *)sub_1400608D0(a1 + 12504, (__int64)v25, (unsigned __int8 *)&v24) + 24LL);
if ( v14 != v7 )
{
v15 = v7;
if ( (unsigned __int64)v7[3] > 0xF )
v15 = (void **)*v7;
sub_14003CCE0(v14, v15, (size_t)v7[2]);
}
v16 = v7;
if ( (unsigned __int64)v7[3] > 0xF )
v16 = (void **)*v7;
*(_OWORD *)v25 = 0;
v26 = 0;
v17 = -1;
do
++v17;
while ( *((_BYTE *)v16 + v17) );
sub_14003A930(v25, v16, v17);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 12488), v12, v25);
if ( *((_QWORD *)&v26 + 1) > 0xFu )
{
v18 = v25[0];
if ( (unsigned __int64)(*((_QWORD *)&v26 + 1) + 1LL) >= 0x1000 )
{
v18 = *((void **)v25[0] - 1);
if ( (unsigned __int64)((char *)v25[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
if ( (unsigned __int64)v7[3] > 0xF )
v7 = (void **)*v7;
*(_OWORD *)v25 = 0;
v26 = 0;
do
++v9;
while ( *((_BYTE *)v7 + v9) );
sub_14003A930(v25, v7, v9);
v20 = cocos2d::CCArray::create(v19);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 12568), v20, v25);
if ( *((_QWORD *)&v26 + 1) > 0xFu )
{
v21 = v25[0];
if ( (unsigned __int64)(*((_QWORD *)&v26 + 1) + 1LL) >= 0x1000 )
{
v21 = *((void **)v25[0] - 1);
if ( (unsigned __int64)((char *)v25[0] - (char *)v21 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v21);
}
}
if ( a4 > 0 && cocos2d::CCArray::count(v12) >= a4 )
return nullptr;
v23 = GameToolbox::particleFromStruct(a3, nullptr, 1);
v23->setTag(v23, 0);
cocos2d::CCParticleSystem::stopSystem(v23);
v23->setVisible(v23, 0);
if ( !a5 )
{
cocos2d::CCArray::addObject(v12, v23);
v23->m_nCustomParticleIndex = v12->getTag(v12);
}
return v23;
}