From e5c62b8baf2a25e220894bad37ed2592ab0067cf Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 10 Jul 2024 20:19:27 +1000 Subject: [PATCH] CPU/PGXP: Fix incorrect Y on invalid add/sub --- src/core/cpu_pgxp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/cpu_pgxp.cpp b/src/core/cpu_pgxp.cpp index 45ff4c7cf..6a35a08a0 100644 --- a/src/core/cpu_pgxp.cpp +++ b/src/core/cpu_pgxp.cpp @@ -972,7 +972,7 @@ void CPU::PGXP::CPU_ADD(u32 instr, u32 rsVal, u32 rtVal) float of = (ret.x > USHRT_MAX) ? 1.f : (ret.x < 0) ? -1.f : 0.f; ret.x = (float)f16Sign(ret.x); // ret.x -= of * (USHRT_MAX + 1); - ret.y += prtVal.GetValidY(rtVal) + of; + ret.y = prsVal.GetValidY(rsVal) + prtVal.GetValidY(rtVal) + of; // truncate on overflow/underflow ret.y += (ret.y > SHRT_MAX) ? -(USHRT_MAX + 1) : (ret.y < SHRT_MIN) ? USHRT_MAX + 1 : 0.f; @@ -1016,7 +1016,7 @@ void CPU::PGXP::CPU_SUB(u32 instr, u32 rsVal, u32 rtVal) float of = (ret.x > USHRT_MAX) ? 1.f : (ret.x < 0) ? -1.f : 0.f; ret.x = (float)f16Sign(ret.x); // ret.x -= of * (USHRT_MAX + 1); - ret.y -= prtVal.GetValidY(rtVal) - of; + ret.y = prsVal.GetValidY(rsVal) - (prtVal.GetValidY(rtVal) - of); // truncate on overflow/underflow ret.y += (ret.y > SHRT_MAX) ? -(USHRT_MAX + 1) : (ret.y < SHRT_MIN) ? USHRT_MAX + 1 : 0.f;