From af3482b7cd5909102dd582aab6efa64349d7ba5a Mon Sep 17 00:00:00 2001 From: Sacha Date: Thu, 14 Aug 2014 10:58:31 +1000 Subject: [PATCH 1/3] Improve readability in the VUops. --- pcsx2/VUops.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index b3601335ad..2815ddd0e8 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -117,7 +117,6 @@ void _vuFlushAll(VURegs* VU) if ((VU->cycle - VU->fdiv.sCycle) >= VU->fdiv.Cycle) { VUM_LOG("flushing FDIV pipe"); - nRepeat = 1; VU->fdiv.enable = 0; VU->VI[REG_Q].UL = VU->fdiv.reg.UL; VU->VI[REG_STATUS_FLAG].UL = VU->fdiv.statusflag; @@ -131,7 +130,6 @@ void _vuFlushAll(VURegs* VU) if ((VU->cycle - VU->efu.sCycle) >= VU->efu.Cycle) { // VUM_LOG("flushing EFU pipe"); - nRepeat = 1; VU->efu.enable = 0; VU->VI[REG_P].UL = VU->efu.reg.UL; } @@ -160,14 +158,13 @@ static void __fastcall _vuFMACTestStall(VURegs * VU, int reg, int xyzw) { if (i == 8) return; - cycle = VU->fmac[i].Cycle - (VU->cycle - VU->fmac[i].sCycle) + 1; // add 1 delay! (fixes segaclassics bad geom) VU->fmac[i].enable = 0; VU->VI[REG_MAC_FLAG].UL = VU->fmac[i].macflag; VU->VI[REG_STATUS_FLAG].UL = VU->fmac[i].statusflag; VU->VI[REG_CLIP_FLAG].UL = VU->fmac[i].clipflag; - VUM_LOG("FMAC[%d] stall %d", i, cycle); + VUM_LOG("FMAC[%d] stall %d", i, VU->fmac[i].Cycle - (VU->cycle - VU->fmac[i].sCycle) + 1); - VU->cycle+= cycle; + VU->cycle = VU->fmac[i].Cycle + VU->fmac[i].sCycle + 1; // HACK: add 1 delay (fixes segaclassics bad geom) _vuTestPipes(VU); } @@ -216,27 +213,24 @@ static __ri void __fastcall _vuEFUAdd(VURegs * VU, int cycles) { static __ri void __fastcall _vuFlushFDIV(VURegs * VU) { int cycle; - if (VU->fdiv.enable == 0) return; + if (VU->fdiv.enable == 0) + return; - cycle = VU->fdiv.Cycle - (VU->cycle - VU->fdiv.sCycle); - VUM_LOG("waiting FDIV pipe %d", cycle); + VUM_LOG("waiting FDIV pipe %d", VU->fdiv.Cycle - (VU->cycle - VU->fdiv.sCycle)); VU->fdiv.enable = 0; - VU->cycle+= cycle; + VU->cycle = VU->fdiv.Cycle + VU->fdiv.sCycle; + VU->VI[REG_Q].UL = VU->fdiv.reg.UL; VU->VI[REG_STATUS_FLAG].UL = VU->fdiv.statusflag; } static __ri void __fastcall _vuFlushEFU(VURegs * VU) { - int cycle; - - if (VU->efu.enable == 0) return; - - cycle = VU->efu.Cycle - (VU->cycle - VU->efu.sCycle); -// VUM_LOG("waiting EFU pipe %d", cycle); + if (VU->efu.enable == 0) + return; VU->efu.enable = 0; - VU->cycle+= cycle; + VU->cycle = VU->efu.Cycle + VU->efu.sCycle; VU->VI[REG_P].UL = VU->efu.reg.UL; } From 9dea86068a5a8726d4ec6af7a541e8c1b22ba5df Mon Sep 17 00:00:00 2001 From: Sacha Date: Thu, 14 Aug 2014 12:46:57 +1000 Subject: [PATCH 2/3] Remove giant min/max defines and make their usage more understandable. --- pcsx2/VUops.cpp | 134 +++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 82 deletions(-) diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index 2815ddd0e8..cdc2c3cb81 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -1174,42 +1174,30 @@ static __fi void _vuMSUBAw(VURegs * VU) { VU_STAT_UPDATE(VU); }/*last updated 11/05/03 shadow*/ -u32 _MAX(u32 a, u32 b) { - if (a & 0x80000000) { // -a - if (b & 0x80000000) { // -b - return (a & 0x7fffffff) > (b & 0x7fffffff) ? b : a; - } else { // +b - return b; - } - } else { // +a - if (b & 0x80000000) { // -b - return a; - } else { // +b - return (a & 0x7fffffff) > (b & 0x7fffffff) ? a : b; - } - } +// Finds the maximum integer value. Unless both values are negative, in which case it finds the minimum value. +#define _FPMAX(a, b) ((s32)a < 0 && (s32)b < 0) ? std::min(a, b) : std::max(a, b) - return 0; -} +// Finds the minimum integer value. Unless both values are negative, in which case it finds the maximum value. +#define _FPMIN(a, b) ((s32)a < 0 && (s32)b < 0) ? std::max(a, b) : std::min(a, b) static __fi void _vuMAX(VURegs * VU) { if (_Fd_ == 0) return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, (s32)VU->VF[_Ft_].i.x); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, (s32)VU->VF[_Ft_].i.y); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, (s32)VU->VF[_Ft_].i.z); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, (s32)VU->VF[_Ft_].i.w); + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); }//checked 13/05/03 shadow static __fi void _vuMAXi(VURegs * VU) { if (_Fd_ == 0) return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); }//checked 13/05/03 shadow static __fi void _vuMAXx(VURegs * VU) { @@ -1217,10 +1205,10 @@ static __fi void _vuMAXx(VURegs * VU) { if (_Fd_ == 0) return; ftx=(s32)VU->VF[_Ft_].i.x; - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, ftx); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, ftx); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, ftx); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, ftx); + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftx); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftx); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftx); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftx); } //checked 13/05/03 shadow @@ -1229,10 +1217,10 @@ static __fi void _vuMAXy(VURegs * VU) { if (_Fd_ == 0) return; fty=(s32)VU->VF[_Ft_].i.y; - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, fty); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, fty); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, fty); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, fty); + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, fty); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, fty); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, fty); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, fty); }//checked 13/05/03 shadow static __fi void _vuMAXz(VURegs * VU) { @@ -1240,10 +1228,10 @@ static __fi void _vuMAXz(VURegs * VU) { if (_Fd_ == 0) return; ftz=(s32)VU->VF[_Ft_].i.z; - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, ftz); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, ftz); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, ftz); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, ftz); + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftz); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftz); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftz); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftz); } static __fi void _vuMAXw(VURegs * VU) { @@ -1251,48 +1239,30 @@ static __fi void _vuMAXw(VURegs * VU) { if (_Fd_ == 0) return; ftw=(s32)VU->VF[_Ft_].i.w; - if (_X) VU->VF[_Fd_].i.x = _MAX(VU->VF[_Fs_].i.x, ftw); - if (_Y) VU->VF[_Fd_].i.y = _MAX(VU->VF[_Fs_].i.y, ftw); - if (_Z) VU->VF[_Fd_].i.z = _MAX(VU->VF[_Fs_].i.z, ftw); - if (_W) VU->VF[_Fd_].i.w = _MAX(VU->VF[_Fs_].i.w, ftw); -} - -u32 _MINI(u32 a, u32 b) { - if (a & 0x80000000) { // -a - if (b & 0x80000000) { // -b - return (a & 0x7fffffff) < (b & 0x7fffffff) ? b : a; - } else { // +b - return a; - } - } else { // +a - if (b & 0x80000000) { // -b - return b; - } else { // +b - return (a & 0x7fffffff) < (b & 0x7fffffff) ? a : b; - } - } - - return 0; + if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftw); + if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftw); + if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftw); + if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftw); } static __fi void _vuMINI(VURegs * VU) { if (_Fd_ == 0) return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, (s32)VU->VF[_Ft_].i.x); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, (s32)VU->VF[_Ft_].i.y); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, (s32)VU->VF[_Ft_].i.z); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, (s32)VU->VF[_Ft_].i.w); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); }//checked 13/05/03 shadow static __fi void _vuMINIi(VURegs * VU) { if (_Fd_ == 0) return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); }//checked 13/05/03 shadow static __fi void _vuMINIx(VURegs * VU) { @@ -1300,10 +1270,10 @@ static __fi void _vuMINIx(VURegs * VU) { if (_Fd_ == 0) return; ftx=(s32)VU->VF[_Ft_].i.x; - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, ftx); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, ftx); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, ftx); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, ftx); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftx); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftx); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftx); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftx); } //checked 13/05/03 shadow @@ -1312,10 +1282,10 @@ static __fi void _vuMINIy(VURegs * VU) { if (_Fd_ == 0) return; fty=(s32)VU->VF[_Ft_].i.y; - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, fty); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, fty); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, fty); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, fty); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, fty); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, fty); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, fty); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, fty); }//checked 13/05/03 shadow static __fi void _vuMINIz(VURegs * VU) { @@ -1323,10 +1293,10 @@ static __fi void _vuMINIz(VURegs * VU) { if (_Fd_ == 0) return; ftz=(s32)VU->VF[_Ft_].i.z; - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, ftz); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, ftz); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, ftz); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, ftz); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftz); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftz); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftz); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftz); } static __fi void _vuMINIw(VURegs * VU) { @@ -1334,10 +1304,10 @@ static __fi void _vuMINIw(VURegs * VU) { if (_Fd_ == 0) return; ftw=(s32)VU->VF[_Ft_].i.w; - if (_X) VU->VF[_Fd_].i.x = _MINI(VU->VF[_Fs_].i.x, ftw); - if (_Y) VU->VF[_Fd_].i.y = _MINI(VU->VF[_Fs_].i.y, ftw); - if (_Z) VU->VF[_Fd_].i.z = _MINI(VU->VF[_Fs_].i.z, ftw); - if (_W) VU->VF[_Fd_].i.w = _MINI(VU->VF[_Fs_].i.w, ftw); + if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftw); + if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftw); + if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftw); + if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftw); } static __fi void _vuOPMULA(VURegs * VU) { From 791bfc181b281c982a6f50416adf8698f1ea8d1e Mon Sep 17 00:00:00 2001 From: Sacha Date: Fri, 15 Aug 2014 13:55:14 +1000 Subject: [PATCH 3/3] Use a function with u32 inputs and make sure all the casts match, because.. --- pcsx2/VUops.cpp | 172 +++++++++++++++++++++++++----------------------- 1 file changed, 91 insertions(+), 81 deletions(-) diff --git a/pcsx2/VUops.cpp b/pcsx2/VUops.cpp index cdc2c3cb81..bdaa481bbb 100644 --- a/pcsx2/VUops.cpp +++ b/pcsx2/VUops.cpp @@ -162,9 +162,10 @@ static void __fastcall _vuFMACTestStall(VURegs * VU, int reg, int xyzw) { VU->VI[REG_MAC_FLAG].UL = VU->fmac[i].macflag; VU->VI[REG_STATUS_FLAG].UL = VU->fmac[i].statusflag; VU->VI[REG_CLIP_FLAG].UL = VU->fmac[i].clipflag; - VUM_LOG("FMAC[%d] stall %d", i, VU->fmac[i].Cycle - (VU->cycle - VU->fmac[i].sCycle) + 1); + u32 newCycle = VU->fmac[i].Cycle + VU->fmac[i].sCycle + 1; // HACK: add 1 delay (fixes segaclassics bad geom) + VUM_LOG("FMAC[%d] stall %d", i, newCycle - VU->cycle); - VU->cycle = VU->fmac[i].Cycle + VU->fmac[i].sCycle + 1; // HACK: add 1 delay (fixes segaclassics bad geom) + VU->cycle = newCycle; _vuTestPipes(VU); } @@ -216,10 +217,11 @@ static __ri void __fastcall _vuFlushFDIV(VURegs * VU) { if (VU->fdiv.enable == 0) return; - VUM_LOG("waiting FDIV pipe %d", VU->fdiv.Cycle - (VU->cycle - VU->fdiv.sCycle)); + u32 newCycle = VU->fdiv.Cycle + VU->fdiv.sCycle; + VUM_LOG("waiting FDIV pipe %d", newCycle - VU->cycle); VU->fdiv.enable = 0; - VU->cycle = VU->fdiv.Cycle + VU->fdiv.sCycle; + VU->cycle = newCycle; VU->VI[REG_Q].UL = VU->fdiv.reg.UL; VU->VI[REG_STATUS_FLAG].UL = VU->fdiv.statusflag; @@ -1174,140 +1176,148 @@ static __fi void _vuMSUBAw(VURegs * VU) { VU_STAT_UPDATE(VU); }/*last updated 11/05/03 shadow*/ -// Finds the maximum integer value. Unless both values are negative, in which case it finds the minimum value. -#define _FPMAX(a, b) ((s32)a < 0 && (s32)b < 0) ? std::min(a, b) : std::max(a, b) +// The functions below are floating point semantics min/max on integer representations to get +// the effect of a floating point min/max without issues with denormal and special numbers. -// Finds the minimum integer value. Unless both values are negative, in which case it finds the maximum value. -#define _FPMIN(a, b) ((s32)a < 0 && (s32)b < 0) ? std::max(a, b) : std::min(a, b) +// Finds the maximum integer value unless both values are negative, in which case it finds the minimum value. +static __fi u32 fp_max(u32 a, u32 b) { + return ((s32)a < 0 && (s32)b < 0) ? std::min(a, b) : std::max(a, b); +} + +// Finds the minimum integer value unless both values are negative, in which case it finds the maximum value. +static __fi u32 fp_min(u32 a, u32 b) { + return ((s32)a < 0 && (s32)b < 0) ? std::max(a, b) : std::min(a, b); +} static __fi void _vuMAX(VURegs * VU) { - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); }//checked 13/05/03 shadow static __fi void _vuMAXi(VURegs * VU) { - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); }//checked 13/05/03 shadow static __fi void _vuMAXx(VURegs * VU) { - s32 ftx; - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; - ftx=(s32)VU->VF[_Ft_].i.x; - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftx); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftx); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftx); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftx); + u32 ftx = VU->VF[_Ft_].i.x; + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, ftx); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, ftx); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, ftx); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, ftx); } //checked 13/05/03 shadow static __fi void _vuMAXy(VURegs * VU) { - s32 fty; - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; - fty=(s32)VU->VF[_Ft_].i.y; - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, fty); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, fty); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, fty); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, fty); + u32 fty = VU->VF[_Ft_].i.y; + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, fty); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, fty); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, fty); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, fty); }//checked 13/05/03 shadow static __fi void _vuMAXz(VURegs * VU) { - s32 ftz; - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; - ftz=(s32)VU->VF[_Ft_].i.z; - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftz); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftz); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftz); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftz); + u32 ftz = VU->VF[_Ft_].i.z; + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, ftz); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, ftz); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, ftz); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, ftz); } static __fi void _vuMAXw(VURegs * VU) { - s32 ftw; - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; - ftw=(s32)VU->VF[_Ft_].i.w; - if (_X) VU->VF[_Fd_].i.x = _FPMAX(VU->VF[_Fs_].i.x, ftw); - if (_Y) VU->VF[_Fd_].i.y = _FPMAX(VU->VF[_Fs_].i.y, ftw); - if (_Z) VU->VF[_Fd_].i.z = _FPMAX(VU->VF[_Fs_].i.z, ftw); - if (_W) VU->VF[_Fd_].i.w = _FPMAX(VU->VF[_Fs_].i.w, ftw); + u32 ftw = VU->VF[_Ft_].i.w; + if (_X) VU->VF[_Fd_].i.x = fp_max(VU->VF[_Fs_].i.x, ftw); + if (_Y) VU->VF[_Fd_].i.y = fp_max(VU->VF[_Fs_].i.y, ftw); + if (_Z) VU->VF[_Fd_].i.z = fp_max(VU->VF[_Fs_].i.z, ftw); + if (_W) VU->VF[_Fd_].i.w = fp_max(VU->VF[_Fs_].i.w, ftw); } static __fi void _vuMINI(VURegs * VU) { - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, VU->VF[_Ft_].i.x); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, VU->VF[_Ft_].i.y); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, VU->VF[_Ft_].i.z); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, VU->VF[_Ft_].i.w); }//checked 13/05/03 shadow static __fi void _vuMINIi(VURegs * VU) { - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; /* ft is bc */ - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, VU->VI[REG_I].UL); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, VU->VI[REG_I].UL); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, VU->VI[REG_I].UL); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, VU->VI[REG_I].UL); }//checked 13/05/03 shadow static __fi void _vuMINIx(VURegs * VU) { - s32 ftx; - if (_Fd_ == 0) return; + if (_Fd_ == 0) + return; - ftx=(s32)VU->VF[_Ft_].i.x; - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftx); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftx); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftx); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftx); + u32 ftx = VU->VF[_Ft_].i.x; + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, ftx); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, ftx); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, ftx); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, ftx); } //checked 13/05/03 shadow static __fi void _vuMINIy(VURegs * VU) { - s32 fty; if (_Fd_ == 0) return; - fty=(s32)VU->VF[_Ft_].i.y; - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, fty); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, fty); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, fty); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, fty); + u32 fty = VU->VF[_Ft_].i.y; + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, fty); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, fty); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, fty); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, fty); }//checked 13/05/03 shadow static __fi void _vuMINIz(VURegs * VU) { - s32 ftz; if (_Fd_ == 0) return; - ftz=(s32)VU->VF[_Ft_].i.z; - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftz); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftz); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftz); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftz); + u32 ftz = VU->VF[_Ft_].i.z; + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, ftz); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, ftz); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, ftz); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, ftz); } static __fi void _vuMINIw(VURegs * VU) { - s32 ftw; if (_Fd_ == 0) return; - ftw=(s32)VU->VF[_Ft_].i.w; - if (_X) VU->VF[_Fd_].i.x = _FPMIN(VU->VF[_Fs_].i.x, ftw); - if (_Y) VU->VF[_Fd_].i.y = _FPMIN(VU->VF[_Fs_].i.y, ftw); - if (_Z) VU->VF[_Fd_].i.z = _FPMIN(VU->VF[_Fs_].i.z, ftw); - if (_W) VU->VF[_Fd_].i.w = _FPMIN(VU->VF[_Fs_].i.w, ftw); + u32 ftw = VU->VF[_Ft_].i.w; + if (_X) VU->VF[_Fd_].i.x = fp_min(VU->VF[_Fs_].i.x, ftw); + if (_Y) VU->VF[_Fd_].i.y = fp_min(VU->VF[_Fs_].i.y, ftw); + if (_Z) VU->VF[_Fd_].i.z = fp_min(VU->VF[_Fs_].i.z, ftw); + if (_W) VU->VF[_Fd_].i.w = fp_min(VU->VF[_Fs_].i.w, ftw); } static __fi void _vuOPMULA(VURegs * VU) {