Skip to content

Commit

Permalink
[Soft-Float] - Fixes Itof accuracy.
Browse files Browse the repository at this point in the history
The PS2 FP Unit behave differently if exponent is less than 158, we emulate this now.

Expect some AI improvements, if any.
  • Loading branch information
GitHubProUser67 committed Jan 19, 2025
1 parent 99ee5d5 commit 48bca2a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pcsx2/PS2Float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,17 @@ PS2Float PS2Float::Itof(s32 complement, s32 f1)

s32 resExponent;

bool negative = f1 < 0;

if (f1 == -2147483648)
{
// special case
resExponent = 158 - complement;

if (resExponent >= 0)
return PS2Float(true, (u8)resExponent, 0);

return PS2Float(0);
if (complement <= 0)
// special case
return PS2Float(0xcf000000);
else
f1 = 2147483647;
}

bool negative = f1 < 0;
s32 u = std::abs(f1);

s32 shifts;
Expand All @@ -500,7 +499,9 @@ PS2Float PS2Float::Itof(s32 complement, s32 f1)

resExponent = BIAS + MANTISSA_BITS - shifts - complement;

if (resExponent >= 0)
if (resExponent >= 158)
return negative ? PS2Float(0xcf000000) : PS2Float(0x4f000000);
else if (resExponent >= 0)
return PS2Float(negative, (u8)resExponent, (u32)u);

return PS2Float(0);
Expand Down

0 comments on commit 48bca2a

Please sign in to comment.