From 25962d361ea38196a54d931f819618db4d725f43 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Tue, 18 Feb 2025 02:18:26 -0600 Subject: [PATCH] Interpreter: Accurate ABS --- pcsx2/VUops.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index 04fc191a89..f1ed263b25 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -492,15 +492,26 @@ static __fi float vuADD_TriAceHack(u32 a, u32 b) return ret; } -void _vuABS(VURegs* VU) +template +void __fi applyUnaryFunction(VURegs* VU) { if (_Ft_ == 0) return; - if (_X){ VU->VF[_Ft_].f.x = fabs(vuDouble(VU->VF[_Fs_].i.x)); } - if (_Y){ VU->VF[_Ft_].f.y = fabs(vuDouble(VU->VF[_Fs_].i.y)); } - if (_Z){ VU->VF[_Ft_].f.z = fabs(vuDouble(VU->VF[_Fs_].i.z)); } - if (_W){ VU->VF[_Ft_].f.w = fabs(vuDouble(VU->VF[_Fs_].i.w)); } + if (_X) { VU->VF[_Ft_].i.x = Fn(VU->VF[_Fs_].i.x); } + if (_Y) { VU->VF[_Ft_].i.y = Fn(VU->VF[_Fs_].i.y); } + if (_Z) { VU->VF[_Ft_].i.z = Fn(VU->VF[_Fs_].i.z); } + if (_W) { VU->VF[_Ft_].i.w = Fn(VU->VF[_Fs_].i.w); } +} + +u32 __fi vuOpABS(u32 fs) +{ + return fs & 0x7fffffff; +} + +void __fi _vuABS(VURegs* VU) +{ + return applyUnaryFunction(VU); }