//
// LevelTools::sortSpeedObjects from 0x41f734 to 0x41f9a4 (624 bytes)
//
// 2 xrefs:
// > PlayLayer::createObjectsFromSetupFinished @ 0x404a06
// > DrawGridLayer::sortSpeedObjects @ 0x463fb2
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:48:00 +0000
//
cocos2d::CCDictionary *__fastcall LevelTools::sortSpeedObjects(int **this, cocos2d::CCArray *a2, GJBaseGameLayer *a3)
{
cocos2d::CCDictionary *result; // r0
_DWORD *v6; // r3
int *v7; // r3
int *v8; // r5
int *v9; // r6
int v10; // r4
int v11; // t1
int v12; // r4
int *v13; // r3
int *v14; // r2
_BOOL4 v15; // r7
int *v16; // r6
int v17; // r4
int v18; // r5
int v19; // t1
cocos2d::CCArray *Group; // r0
cocos2d::CCArray *v21; // r10
int v22; // r1
int v23; // r2
int v24; // r2
int v25; // r7
bool v26; // zf
const cocos2d::CCRect *v27; // r0
float v28; // s15
float v29; // s15
int v30; // r1
bool v31[4]; // [sp+4h] [bp-38h]
float v32; // [sp+14h] [bp-28h] BYREF
float v33; // [sp+18h] [bp-24h]
_BYTE v34[8]; // [sp+1Ch] [bp-20h] BYREF
float v35[2]; // [sp+24h] [bp-18h] BYREF
float v36; // [sp+2Ch] [bp-10h]
float v37; // [sp+30h] [bp-Ch]
result = (cocos2d::CCDictionary *)cocos2d::CCArray::count((cocos2d::CCArray *)this);
if ( result )
{
if ( this )
{
v6 = *(this + 13);
if ( *v6 )
{
v8 = (int *)v6[3];
v9 = &v8[*v6 - 1];
while ( v8 <= v9 )
{
v11 = *v8++;
v10 = v11;
if ( !v11 )
break;
(*(void (__fastcall **)(float *, int))(*(_DWORD *)v10 + 908))(v35, v10);
cocos2d::CCPoint::operator=(v10 + 1600, v35);
LOWORD(v6) = *(_WORD *)(v10 + 1598) + 5;
if ( *(__int16 *)(v10 + 1598) == -5 )
{
Group = (cocos2d::CCArray *)GJBaseGameLayer::getGroup(a2, *(_DWORD *)(v10 + 1284));
v21 = Group;
if ( Group && cocos2d::CCArray::count(Group) && (v22 = cocos2d::CCArray::randomObject(v21)) != 0 )
(*(void (__fastcall **)(float *, int))(*(_DWORD *)v22 + 908))(v35, v22);
else
(*(void (__fastcall **)(float *, int))(*(_DWORD *)v10 + 908))(v35, v10);
cocos2d::CCPoint::operator=(v10 + 1700, v35);
}
}
}
}
LevelTools::sortChannelOrderObjects(
(cocos2d::CCDictionary *)this,
nullptr,
(cocos2d::CCDictionary *)((char *)&dword_0 + 1),
(bool)v6);
if ( this )
{
v7 = *(this + 13);
v12 = *v7;
if ( *v7 )
{
v13 = (int *)v7[3];
v14 = &v13[v12 - 1];
v15 = 0;
v16 = v13;
v17 = 0;
*(_DWORD *)v31 = v14;
while ( 1 )
{
LOBYTE(v7) = v31[0];
if ( (unsigned int)v16 > *(_DWORD *)v31 )
return LevelTools::sortChannelOrderObjects(
(cocos2d::CCDictionary *)this,
nullptr,
(cocos2d::CCDictionary *)((char *)&dword_0 + 1),
(bool)v7);
v19 = *v16++;
v18 = v19;
if ( !v19 )
return LevelTools::sortChannelOrderObjects(
(cocos2d::CCDictionary *)this,
nullptr,
(cocos2d::CCDictionary *)((char *)&dword_0 + 1),
(bool)v7);
v23 = *(_DWORD *)(v18 + 892);
if ( v23 != 1330 )
break;
LABEL_24:
v24 = *(__int16 *)(v18 + 1598);
if ( v24 == -4 )
{
if ( !*(_BYTE *)(v18 + 1669) )
{
v25 = *(_DWORD *)(v18 + 1648);
v15 = v25 == 3 || v25 == 4;
v17 = *(_DWORD *)(v18 + 1652);
if ( v17 != 1 )
v17 = v17 == 3;
}
}
else if ( v24 == -1 )
{
v17 = (unsigned __int8)v17 ^ 1;
}
}
if ( v23 > 1330 )
{
if ( v23 == 1704 )
goto LABEL_24;
if ( v23 > 1704 )
{
if ( v23 != 2902 )
{
if ( v23 == 3027 )
goto LABEL_24;
v30 = 1751;
goto LABEL_53;
}
}
else if ( v23 != 1334 )
{
if ( v23 == 1594 )
goto LABEL_24;
v30 = 1333;
goto LABEL_53;
}
}
else
{
if ( v23 == 141 )
goto LABEL_24;
if ( v23 <= 141 )
{
if ( v23 == 36 )
goto LABEL_24;
v26 = v23 == 84;
goto LABEL_54;
}
if ( v23 < 200 )
goto LABEL_39;
if ( v23 > 203 )
{
v30 = 1022;
LABEL_53:
v26 = v23 == v30;
LABEL_54:
if ( v26 )
goto LABEL_24;
LABEL_39:
if ( !*(_BYTE *)(v18 + 1292) )
goto LABEL_24;
}
}
if ( !*(_BYTE *)(v18 + 1294) )
{
v27 = (const cocos2d::CCRect *)(*(int (__fastcall **)(int))(*(_DWORD *)v18 + 664))(v18);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v35, v27);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v32, v35[0] + (float)(v36 * 0.5), v35[1] + (float)(v37 * 0.5));
if ( v15 )
{
if ( v17 )
v29 = (float)(v33 - (float)(v37 * 0.5)) - 15.0;
else
v29 = (float)(v33 + (float)(v37 * 0.5)) + 15.0;
v33 = v29;
}
else
{
if ( v17 )
v28 = (float)(v32 + (float)(v36 * 0.5)) + 15.0;
else
v28 = (float)(v32 - (float)(v36 * 0.5)) - 15.0;
v32 = v28;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v34, (const cocos2d::CCPoint *)&v32);
cocos2d::CCPoint::operator=(v18 + 1600, v34);
}
goto LABEL_24;
}
}
return LevelTools::sortChannelOrderObjects(
(cocos2d::CCDictionary *)this,
nullptr,
(cocos2d::CCDictionary *)((char *)&dword_0 + 1),
(bool)v7);
}
return result;
}