//
// PlayerObject::convertToClosestRotation from 0x10021d5d8 to 0x10021d6d4 (252 bytes)
//
// 3 xrefs:
// > PlayerObject::updateMove @ 0x10021c2cc
// > PlayerObject::updateSlopeRotation @ 0x100223ee8
// > PlayerObject::updateRotation_1 @ 0x100224444
//
// 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 __fastcall PlayerObject::convertToClosestRotation(PlayerObject *a1, float a2)
{
float v3; // s0
signed int v4; // w8
float v5; // s0
float v6; // s1
if ( !a1->m_isShip
&& !a1->m_isBird
&& !a1->m_isDart
&& !a1->m_isSwing
&& !a1->m_isRobot
&& !a1->m_isSpider
&& !a1->m_isDashing )
{
v3 = ((float (__fastcall *)(PlayerObject *))a1->getRotation)(a1);
if ( (int)v3 >= 0 )
v4 = (int)v3 % 0x168u;
else
v4 = (int)v3 + 360 * (-(int)v3 / 0x168u);
v5 = (float)v4;
if ( (float)v4 >= a2 )
{
if ( (float)v4 <= a2 )
{
v6 = a2;
}
else
{
do
{
v6 = a2;
a2 = a2 + 90.0;
}
while ( a2 < v5 );
}
}
else
{
do
{
v6 = a2;
a2 = a2 + -90.0;
}
while ( a2 > v5 );
}
if ( vabds_f32(v5, a2) >= vabds_f32(v5, v6) )
return v6;
}
return a2;
}