//
// LevelTools::timeForPos from 0x4217c4 to 0x421ce4 (1312 bytes)
//
// 3 xrefs:
// > PlayLayer::timeForPos @ 0x3ff514
// > DrawGridLayer::draw @ 0x465860
// > DrawGridLayer::timeForPos @ 0x465a32
//
// 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:02 +0000
//
int __fastcall LevelTools::timeForPos(
float *a1,
cocos2d::CCArray *a2,
LevelTools *a3,
int a4,
int a5,
char a6,
unsigned __int8 a7,
char a8,
char a9,
int a10)
{
float v13; // s16
int v14; // r6
float v15; // s21
float v16; // s19
float v17; // s17
float v18; // s16
float v19; // s15
_DWORD *v21; // r3
float v22; // s18
int *v23; // r8
int v24; // r4
int v25; // t1
int v26; // r11
int v27; // r9
float v28; // s17
float v29; // s17
float v30; // s15
int v31; // r9
float v32; // s20
int v33; // r1
float v34; // s15
int v35; // r3
bool v36; // r3
int v37; // r3
int v38; // r3
float v39; // s22
int *v40; // [sp+8h] [bp-8Ch]
int v41; // [sp+2Ch] [bp-68h] BYREF
float v42; // [sp+30h] [bp-64h] BYREF
float v43; // [sp+34h] [bp-60h]
float v44[2]; // [sp+38h] [bp-5Ch] BYREF
_BYTE v45[4]; // [sp+40h] [bp-54h] BYREF
float v46; // [sp+44h] [bp-50h]
float v47[2]; // [sp+48h] [bp-4Ch] BYREF
float v48[2]; // [sp+50h] [bp-44h] BYREF
_BYTE v49[4]; // [sp+58h] [bp-3Ch] BYREF
float v50; // [sp+5Ch] [bp-38h]
float v51; // [sp+60h] [bp-34h] BYREF
float v52; // [sp+64h] [bp-30h]
_BYTE v53[8]; // [sp+68h] [bp-2Ch] BYREF
_BYTE v54[8]; // [sp+70h] [bp-24h] BYREF
float v55; // [sp+78h] [bp-1Ch] BYREF
float v56; // [sp+7Ch] [bp-18h]
int *v57; // [sp+80h] [bp-14h] BYREF
_DWORD *v58[2]; // [sp+84h] [bp-10h] BYREF
v13 = 0.0;
v14 = a7;
if ( *a1 > 0.0 )
{
if ( a7 )
v15 = 311.58;
else
v15 = COERCE_FLOAT(LevelTools::valueForSpeedMod(a3, _stack_chk_guard));
v16 = 1.0;
byte_D2B7A1 = 0;
byte_D2B7A0 = 0;
flt_D1E008 = 1.0;
if ( a2 && cocos2d::CCArray::count(a2) && !a7 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v42, (const cocos2d::CCPoint *)&unk_D2B7A4);
v57 = (int *)v58;
v21 = *((_DWORD **)a2 + 13);
v58[0] = nullptr;
v58[1] = nullptr;
v41 = 0;
if ( *v21 )
{
v22 = 0.0;
v23 = (int *)v21[3];
v40 = &v23[*v21 - 1];
while ( 1 )
{
do
{
if ( v23 <= v40 )
{
v25 = *v23++;
v24 = v25;
if ( v25 )
continue;
}
goto LABEL_22;
}
while ( !a6 && *(__int16 *)(v24 + 1598) == -3 );
v26 = *std::map::operator[](&v57, &v41);
v27 = *(_DWORD *)(v24 + 1588);
if ( v27 > *std::map::operator[](&v57, &v41) )
*std::map::operator[](&v57, &v41) = *(_DWORD *)(v24 + 1588);
if ( a10 > 0 && *(_DWORD *)(v24 + 780) == a10 )
v14 = 1;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55, (const cocos2d::CCPoint *)(v24 + 1600));
if ( v55 <= 0.0 )
{
v28 = 0.0;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v44, (const cocos2d::CCPoint *)(v24 + 1600));
v28 = v44[0];
}
v29 = v28 - v42;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55, (const cocos2d::CCPoint *)(v24 + 1600));
if ( v56 <= 0.0 )
{
v30 = 0.0;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v45, (const cocos2d::CCPoint *)(v24 + 1600));
v30 = v46;
}
v31 = (unsigned __int8)byte_D2B7A0;
v32 = v30 - v43;
if ( byte_D2B7A1 )
{
if ( v32 <= 0.0 )
v32 = 0.0;
v39 = v29;
v29 = v32;
}
else
{
if ( v29 <= 0.0 )
v29 = 0.0;
v39 = v29;
}
v17 = fabsf(v29) / (float)(v15 * v16);
if ( v14
|| (a5 == v41 || a5 == -1) && (a4 <= 0 || *std::map::operator[](&v57, &v41) >= a4 || v26 == a4) )
{
if ( byte_D2B7A0 )
{
if ( a9 )
goto LABEL_54;
LABEL_82:
if ( v43 <= a1[1] )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49, (const cocos2d::CCPoint *)(v24 + 1600));
if ( v50 >= a1[1] )
goto LABEL_13;
}
if ( v43 >= a1[1] )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55, (const cocos2d::CCPoint *)(v24 + 1600));
if ( v56 <= a1[1] )
goto LABEL_13;
}
goto LABEL_54;
}
if ( v42 <= *a1
&& (cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v47, (const cocos2d::CCPoint *)(v24 + 1600)),
v47[0] >= *a1)
|| v42 >= *a1
&& (cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v48, (const cocos2d::CCPoint *)(v24 + 1600)),
v48[0] <= *a1) )
{
LABEL_13:
if ( byte_D2B7A0 )
{
v18 = a1[1];
v19 = v43;
}
else
{
v18 = *a1;
v19 = v42;
}
goto LABEL_15;
}
if ( !a9 && byte_D2B7A0 )
goto LABEL_82;
}
LABEL_54:
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, (const cocos2d::CCPoint *)&unk_D2B7A4);
switch ( *(_WORD *)(v24 + 1598) )
{
case 0xFFFB:
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v53, (const cocos2d::CCPoint *)(v24 + 1700));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54, (const cocos2d::CCPoint *)(v24 + 1600));
cocos2d::CCPoint::operator-(&v55, v53, v54);
cocos2d::CCPoint::operator=(&v51, &v55);
if ( *(_BYTE *)(v24 + 1689) )
v51 = 0.0;
if ( *(_BYTE *)(v24 + 1690) )
v52 = 0.0;
break;
case 0xFFFC:
if ( !*(_BYTE *)(v24 + 1669) )
{
v35 = *(_DWORD *)(v24 + 1648);
v36 = v35 == 3 || v35 == 4;
byte_D2B7A0 = v36;
v37 = *(_DWORD *)(v24 + 1652);
if ( v37 != 1 )
LOBYTE(v37) = v37 == 3;
byte_D2B7A1 = v37;
}
if ( *(_BYTE *)(v24 + 1668) )
v41 = *(_DWORD *)(v24 + 1672);
break;
case 0xFFFD:
break;
case 0xFFFE:
v34 = *(float *)(v24 + 1580);
flt_D1E008 = v34;
if ( !a8 )
v16 = v34;
break;
case 0xFFFF:
byte_D2B7A1 ^= 1u;
break;
default:
v15 = COERCE_FLOAT(LevelTools::valueForSpeedMod((LevelTools *)*(__int16 *)(v24 + 1598), v33));
break;
}
v22 = v22 + v17;
v38 = v31 ^ (unsigned __int8)byte_D2B7A0;
if ( v31 && !v38 || (v42 = v42 + v39, v31) || v38 )
v43 = v43 + v32;
v42 = v42 + v51;
v43 = v43 + v52;
}
}
v22 = 0.0;
LABEL_22:
if ( byte_D2B7A0 )
{
v18 = a1[1];
v19 = v43;
}
else
{
v18 = *a1;
v19 = v42;
}
LABEL_15:
v13 = v22 + (float)(fabsf(v19 - v18) / (float)(v15 * v16));
std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy(
(int)&v57,
v58[0]);
}
else
{
v13 = *a1 / v15;
}
}
return LODWORD(v13);
}