//
// GJBaseGameLayer::spawnGroup from 0x14021ab80 to 0x14021adfa (634 bytes)
//
// 5 xrefs:
// > ??> @ 0x140566700
// > ??> @ 0x140585978
// > ??> @ 0x1405ca540
// > ??> @ 0x1406cd38c
// > ??> @ 0x1406cd398
//
// 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=1
void GJBaseGameLayer::spawnGroup(
GJBaseGameLayer *a1,
int a2,
bool a3,
double a4,
std::vector *const a5,
int a6,
int a7)
{
__int64 v9; // rdx
int v10; // eax
unsigned __int64 v11; // r8
__int64 v12; // rcx
std::_Simple_types::value_type *Mylast; // rbp
int v14; // ebp
int v15; // edi
std::_Vector_val>::pointer v16; // rdx
std::_Simple_types::value_type v17; // rax
std::_Vector_val>::pointer v18; // rdx
std::_Simple_types::value_type v19; // rax
std::_Vector_val>::pointer v20; // rbx
_DWORD *v21; // rax
cocos2d::CCArray *Group; // rax
__int64 v23; // r8
cocos2d::ccArray *data; // rbx
__int64 num; // rax
cocos2d::CCObject **arr; // rbx
cocos2d::CCObject **i; // rdi
__int128 v28; // [rsp+30h] [rbp-68h] BYREF
__int128 v29; // [rsp+40h] [rbp-58h]
v9 = *(_QWORD *)&a1->m_gameState.m_songChannelStates._Traitsobj._Mypair._Myval2._Myval2;
v10 = a2;
if ( a2 < 0 )
v10 = 0;
if ( v10 > 9999 )
v10 = 9999;
v11 = (unsigned __int64)v10 >> 5;
v12 = v10 & 0x1F;
if ( ((1 << (v10 & 0x1F)) & *(_DWORD *)(*(_QWORD *)(v9 + 1272) + 4 * v11)) != 0 )
{
Mylast = a5->_Mypair._Myval2._Mylast;
if ( a5->_Mypair._Myval2._Myfirst == Mylast )
v14 = 0;
else
v14 = -*(Mylast - 1);
v15 = 0;
if ( HIBYTE(a1->m_gameState.m_unsortedAreaEffects._Vec._Mypair._Myval2._Myfirst) )
v15 = a6;
v16 = a1->m_groups._Mypair._Myval2._Mylast;
v17 = v16[1];
while ( !BYTE1(v17->m_uAutoReleaseCount) )
{
if ( v17->m_uUnknown < a2
|| v17->m_uUnknown <= a2 && (v17->m_uIndexInArray < v15 || v17->m_uIndexInArray <= v15 && v17->m_eObjType < v14) )
{
v17 = *(std::_Simple_types::value_type *)&v17->m_nTag;
}
else
{
v16 = (std::_Vector_val>::pointer)v17;
v17 = (std::_Simple_types::value_type)v17->__vftable;
}
}
if ( *((_BYTE *)v16 + 25)
|| a2 < *((_DWORD *)v16 + 9)
|| a2 <= *((_DWORD *)v16 + 9)
&& (v15 < *((_DWORD *)v16 + 8) || v15 <= *((_DWORD *)v16 + 8) && v14 < *((_DWORD *)v16 + 7)) )
{
v18 = a1->m_groups._Mypair._Myval2._Mylast;
v19 = v18[1];
*(_QWORD *)&v29 = v19;
DWORD2(v29) = 0;
while ( !BYTE1(v19->m_uAutoReleaseCount) )
{
*(_QWORD *)&v29 = v19;
if ( v19->m_uUnknown < a2
|| v19->m_uUnknown <= a2
&& (v19->m_uIndexInArray < v15 || v19->m_uIndexInArray <= v15 && v19->m_eObjType < v14) )
{
DWORD2(v29) = 0;
v19 = *(std::_Simple_types::value_type *)&v19->m_nTag;
}
else
{
DWORD2(v29) = 1;
v18 = (std::_Vector_val>::pointer)v19;
v19 = (std::_Simple_types::value_type)v19->__vftable;
}
}
if ( *((_BYTE *)v18 + 25)
|| a2 < *((_DWORD *)v18 + 9)
|| a2 <= *((_DWORD *)v18 + 9)
&& (v15 < *((_DWORD *)v18 + 8) || v15 <= *((_DWORD *)v18 + 8) && v14 < *((_DWORD *)v18 + 7)) )
{
if ( a1->m_groups._Mypair._Myval2._Myend == (std::_Vector_val>::pointer)0x666666666666666LL )
sub_140052E40(v12, v18, v11);
v20 = a1->m_groups._Mypair._Myval2._Mylast;
v21 = operator new(0x28u);
v21[7] = v14;
v21[8] = v15;
v21[9] = a2;
*(_QWORD *)v21 = v20;
*((_QWORD *)v21 + 1) = v20;
*((_QWORD *)v21 + 2) = v20;
*((_WORD *)v21 + 12) = 0;
v28 = v29;
sub_1400636D0(&a1->m_groups._Mypair._Myval2._Mylast, (__int64)&v28, (__int64)v21);
}
Group = GJBaseGameLayer::getGroup((GJBaseGameLayer *)((char *)a1 - 408), a2);
if ( a3 )
{
GJBaseGameLayer::spawnObjectsInOrder((GJBaseGameLayer *)((char *)a1 - 408), Group, a4, a5, a6, a7);
}
else if ( Group )
{
data = Group->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
if ( !*arr )
break;
((void (__fastcall *)(GJBaseGameLayer *, cocos2d::CCObject *, __int64, std::vector *const))a1->isEqual)(
a1,
*arr,
v23,
a5);
}
}
}
}
}
}