From 48bca2af5a51ed942fb623d1b9479d2d63bd42ea Mon Sep 17 00:00:00 2001 From: GitHubProUser67 <127040195+GitHubProUser67@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:17:43 +0100 Subject: [PATCH] [Soft-Float] - Fixes Itof accuracy. The PS2 FP Unit behave differently if exponent is less than 158, we emulate this now. Expect some AI improvements, if any. --- pcsx2/PS2Float.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pcsx2/PS2Float.cpp b/pcsx2/PS2Float.cpp index 3bd0c5ede1b5f..65977af69d219 100644 --- a/pcsx2/PS2Float.cpp +++ b/pcsx2/PS2Float.cpp @@ -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; @@ -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);