//
// LevelTools::timeForPos from 0x32cc08 to 0x32d134 (1324 bytes)
//
// 3 xrefs:
// > PlayLayer::timeForPos @ 0x30edc0
// > DrawGridLayer::draw @ 0x36bf90
// > DrawGridLayer::timeForPos @ 0x36c16a
//
// 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
//
float LevelTools::timeForPos(
cocos2d::CCPoint a1,
cocos2d::CCArray *a2,
int a3,
int a4,
int a5,
bool a6,
bool a7,
bool a8,
bool a9,
int a10)
{
float y; // r4
float *x_low; // r5
float v13; // s16
float v14; // s21
float v15; // s19
float v16; // s17
float v17; // s16
float v18; // s15
cocos2d::ccArray *v20; // r3
unsigned int num; // r6
cocos2d::CCObject **arr; // r3
unsigned int v23; // r4
float v24; // s18
int v25; // r6
char *v26; // r2
char *v27; // r8
int v28; // r4
int v29; // t1
int v30; // r11
int v31; // r9
int v32; // r2
int v33; // r2
float x; // s17
float v35; // s17
float v36; // s15
int v37; // r9
float v38; // s20
float v39; // s15
int v40; // r3
bool v41; // r3
int v42; // r3
int v43; // r3
float v44; // s22
char *v45; // [sp+8h] [bp-94h]
int v46; // [sp+28h] [bp-74h] BYREF
cocos2d::CCPoint v47; // [sp+2Ch] [bp-70h] BYREF
cocos2d::CCPoint v48; // [sp+34h] [bp-68h] BYREF
cocos2d::CCPoint v49; // [sp+3Ch] [bp-60h] BYREF
cocos2d::CCPoint v50; // [sp+44h] [bp-58h] BYREF
cocos2d::CCPoint v51; // [sp+4Ch] [bp-50h] BYREF
cocos2d::CCPoint v52; // [sp+54h] [bp-48h] BYREF
cocos2d::CCPoint v53; // [sp+5Ch] [bp-40h] BYREF
cocos2d::CCPoint v54; // [sp+64h] [bp-38h] BYREF
cocos2d::CCPoint v55; // [sp+6Ch] [bp-30h] BYREF
cocos2d::CCPoint v56; // [sp+74h] [bp-28h] BYREF
int v57; // [sp+7Ch] [bp-20h] BYREF
_DWORD *v58[5]; // [sp+80h] [bp-1Ch] BYREF
y = a1.y;
x_low = (float *)LODWORD(a1.x);
v13 = 0.0;
if ( *(float *)LODWORD(a1.x) > 0.0 )
{
if ( a6 )
v14 = 311.58;
else
v14 = LevelTools::valueForSpeedMod((int)a2);
v15 = 1.0;
byte_AC5BC9 = 0;
byte_AC5BC8 = 0;
flt_AB9008 = 1.0;
if ( y == 0.0 || !cocos2d::CCArray::count((cocos2d::CCArray *)LODWORD(y)) || a6 )
{
return *x_low / v14;
}
else
{
cocos2d::CCPoint::CCPoint(&v47, &stru_AC5BCC);
memset(v58, 0, 0x10u);
v20 = *(cocos2d::ccArray **)(LODWORD(y) + 52);
v58[2] = v58;
v58[3] = v58;
num = v20->num;
v58[4] = nullptr;
v46 = 0;
if ( num )
{
arr = v20->arr;
v23 = num + 0x3FFFFFFF;
v24 = 0.0;
v25 = 0;
v26 = (char *)&arr[v23];
v27 = (char *)arr;
v45 = v26;
while ( 1 )
{
do
{
if ( v27 <= v45 )
{
v29 = *(_DWORD *)v27;
v27 += 4;
v28 = v29;
if ( v29 )
continue;
}
goto LABEL_22;
}
while ( !(_BYTE)a5 && *(__int16 *)(v28 + 1590) == -3 );
v30 = *(_DWORD *)std::map::operator[](&v57, &v46, (int)v26);
v31 = *(_DWORD *)(v28 + 1580);
if ( v31 > *(_DWORD *)std::map::operator[](&v57, &v46, v32) )
*(_DWORD *)std::map::operator[](&v57, &v46, v33) = *(_DWORD *)(v28 + 1580);
if ( a9 > 0 && *(_DWORD *)(v28 + 772) == a9 )
v25 = 1;
cocos2d::CCPoint::CCPoint(&v56, (const cocos2d::CCPoint *)(v28 + 1592));
if ( v56.x <= 0.0 )
{
x = 0.0;
}
else
{
cocos2d::CCPoint::CCPoint(&v48, (const cocos2d::CCPoint *)(v28 + 1592));
x = v48.x;
}
v35 = x - v47.x;
cocos2d::CCPoint::CCPoint(&v56, (const cocos2d::CCPoint *)(v28 + 1592));
if ( v56.y <= 0.0 )
{
v36 = 0.0;
}
else
{
cocos2d::CCPoint::CCPoint(&v49, (const cocos2d::CCPoint *)(v28 + 1592));
v36 = v49.y;
}
v37 = (unsigned __int8)byte_AC5BC8;
v38 = v36 - v47.y;
if ( byte_AC5BC9 )
{
if ( v38 <= 0.0 )
v38 = 0.0;
v44 = v35;
v35 = v38;
}
else
{
if ( v35 <= 0.0 )
v35 = 0.0;
v44 = v35;
}
v16 = fabsf(v35) / (float)(v14 * v15);
if ( v25
|| (a4 == v46 || a4 == -1)
&& (a3 <= 0 || *(_DWORD *)std::map::operator[](&v57, &v46, a4) >= a3 || v30 == a3) )
{
if ( byte_AC5BC8 )
{
if ( a8 )
goto LABEL_54;
LABEL_82:
if ( v47.y <= x_low[1] )
{
cocos2d::CCPoint::CCPoint(&v52, (const cocos2d::CCPoint *)(v28 + 1592));
if ( v52.y >= x_low[1] )
goto LABEL_13;
}
if ( v47.y >= x_low[1] )
{
cocos2d::CCPoint::CCPoint(&v56, (const cocos2d::CCPoint *)(v28 + 1592));
if ( v56.y <= x_low[1] )
goto LABEL_13;
}
goto LABEL_54;
}
if ( v47.x <= *x_low
&& (cocos2d::CCPoint::CCPoint(&v50, (const cocos2d::CCPoint *)(v28 + 1592)), v50.x >= *x_low)
|| v47.x >= *x_low
&& (cocos2d::CCPoint::CCPoint(&v51, (const cocos2d::CCPoint *)(v28 + 1592)), v51.x <= *x_low) )
{
LABEL_13:
if ( byte_AC5BC8 )
{
v17 = x_low[1];
v18 = v47.y;
}
else
{
v17 = *x_low;
v18 = v47.x;
}
goto LABEL_15;
}
if ( !a8 && byte_AC5BC8 )
goto LABEL_82;
}
LABEL_54:
cocos2d::CCPoint::CCPoint(&v53, &stru_AC5BCC);
switch ( *(_WORD *)(v28 + 1590) )
{
case 0xFFFB:
cocos2d::CCPoint::CCPoint(&v54, (const cocos2d::CCPoint *)(v28 + 1688));
cocos2d::CCPoint::CCPoint(&v55, (const cocos2d::CCPoint *)(v28 + 1592));
cocos2d::CCPoint::operator-(&v56, &v54, &v55);
cocos2d::CCPoint::operator=(&v53, &v56);
if ( *(_BYTE *)(v28 + 1677) )
v53.x = 0.0;
if ( *(_BYTE *)(v28 + 1678) )
v53.y = 0.0;
break;
case 0xFFFC:
if ( !*(_BYTE *)(v28 + 1657) )
{
v40 = *(_DWORD *)(v28 + 1636);
v41 = v40 == 3 || v40 == 4;
byte_AC5BC8 = v41;
v42 = *(_DWORD *)(v28 + 1640);
if ( v42 != 1 )
LOBYTE(v42) = v42 == 3;
v26 = &byte_AC5BC8;
byte_AC5BC9 = v42;
}
if ( *(_BYTE *)(v28 + 1656) )
v46 = *(_DWORD *)(v28 + 1660);
break;
case 0xFFFD:
break;
case 0xFFFE:
v39 = *(float *)(v28 + 1572);
flt_AB9008 = v39;
if ( !a7 )
v15 = v39;
break;
case 0xFFFF:
v26 = &byte_AC5BC8;
byte_AC5BC9 ^= 1u;
break;
default:
v14 = LevelTools::valueForSpeedMod(*(__int16 *)(v28 + 1590));
break;
}
v24 = v24 + v16;
v43 = v37 ^ (unsigned __int8)byte_AC5BC8;
if ( v37 && !v43 || (v47.x = v47.x + v44, v37) || v43 )
v47.y = v47.y + v38;
v47.x = v47.x + v53.x;
v47.y = v47.y + v53.y;
}
}
v24 = 0.0;
LABEL_22:
if ( byte_AC5BC8 )
{
v17 = x_low[1];
v18 = v47.y;
}
else
{
v17 = *x_low;
v18 = v47.x;
}
LABEL_15:
v13 = v24 + (float)(fabsf(v18 - v17) / (float)(v14 * v15));
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
(int)&v57,
v58[1]);
}
}
return v13;
}