mirror of https://github.com/PCSX2/pcsx2.git
VU Int: Properly limit ints when converting from float
This commit is contained in:
parent
77eb380305
commit
d7e6ef4ce6
|
@ -1450,40 +1450,49 @@ static __fi void _vuOPMSUB(VURegs * VU) {
|
|||
static __fi void _vuNOP(VURegs * VU) {
|
||||
}
|
||||
|
||||
static __fi s32 float_to_int(float value)
|
||||
{
|
||||
if (value >= 2147483647.0)
|
||||
return 2147483647LL;
|
||||
if (value <= -2147483648.0)
|
||||
return -2147483648LL;
|
||||
return value;
|
||||
}
|
||||
|
||||
static __fi void _vuFTOI0(VURegs * VU) {
|
||||
if (_Ft_ == 0) return;
|
||||
|
||||
if (_X) VU->VF[_Ft_].SL[0] = (s32)vuDouble(VU->VF[_Fs_].i.x);
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = (s32)vuDouble(VU->VF[_Fs_].i.y);
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = (s32)vuDouble(VU->VF[_Fs_].i.z);
|
||||
if (_W) VU->VF[_Ft_].SL[3] = (s32)vuDouble(VU->VF[_Fs_].i.w);
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int(vuDouble(VU->VF[_Fs_].i.x));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int(vuDouble(VU->VF[_Fs_].i.y));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int(vuDouble(VU->VF[_Fs_].i.z));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int(vuDouble(VU->VF[_Fs_].i.w));
|
||||
}
|
||||
|
||||
static __fi void _vuFTOI4(VURegs * VU) {
|
||||
if (_Ft_ == 0) return;
|
||||
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int4(vuDouble(VU->VF[_Fs_].i.x));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int4(vuDouble(VU->VF[_Fs_].i.y));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int4(vuDouble(VU->VF[_Fs_].i.z));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int4(vuDouble(VU->VF[_Fs_].i.w));
|
||||
}
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int(float_to_int4(vuDouble(VU->VF[_Fs_].i.x)));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int(float_to_int4(vuDouble(VU->VF[_Fs_].i.y)));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int(float_to_int4(vuDouble(VU->VF[_Fs_].i.z)));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int(float_to_int4(vuDouble(VU->VF[_Fs_].i.w)));
|
||||
}
|
||||
|
||||
static __fi void _vuFTOI12(VURegs * VU) {
|
||||
if (_Ft_ == 0) return;
|
||||
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int12(vuDouble(VU->VF[_Fs_].i.x));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int12(vuDouble(VU->VF[_Fs_].i.y));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int12(vuDouble(VU->VF[_Fs_].i.z));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int12(vuDouble(VU->VF[_Fs_].i.w));
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int(float_to_int12(vuDouble(VU->VF[_Fs_].i.x)));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int(float_to_int12(vuDouble(VU->VF[_Fs_].i.y)));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int(float_to_int12(vuDouble(VU->VF[_Fs_].i.z)));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int(float_to_int12(vuDouble(VU->VF[_Fs_].i.w)));
|
||||
}
|
||||
|
||||
static __fi void _vuFTOI15(VURegs * VU) {
|
||||
if (_Ft_ == 0) return;
|
||||
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int15(vuDouble(VU->VF[_Fs_].i.x));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int15(vuDouble(VU->VF[_Fs_].i.y));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int15(vuDouble(VU->VF[_Fs_].i.z));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int15(vuDouble(VU->VF[_Fs_].i.w));
|
||||
if (_X) VU->VF[_Ft_].SL[0] = float_to_int(float_to_int15(vuDouble(VU->VF[_Fs_].i.x)));
|
||||
if (_Y) VU->VF[_Ft_].SL[1] = float_to_int(float_to_int15(vuDouble(VU->VF[_Fs_].i.y)));
|
||||
if (_Z) VU->VF[_Ft_].SL[2] = float_to_int(float_to_int15(vuDouble(VU->VF[_Fs_].i.z)));
|
||||
if (_W) VU->VF[_Ft_].SL[3] = float_to_int(float_to_int15(vuDouble(VU->VF[_Fs_].i.w)));
|
||||
}
|
||||
|
||||
static __fi void _vuITOF0(VURegs * VU) {
|
||||
|
@ -1694,7 +1703,7 @@ static __fi void _vuMTIR(VURegs * VU) {
|
|||
|
||||
_vuBackupVI(VU, _It_);
|
||||
|
||||
VU->VI[_It_].US[0] = *(u16*)&VU->VF[_Fs_].F[_Fsf_];
|
||||
VU->VI[_It_].US[0] = *(u16*)&VU->VF[_Fs_].F[_Fsf_];
|
||||
}
|
||||
|
||||
static __fi void _vuMR32(VURegs * VU) {
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "VU.h"
|
||||
#include "VUflags.h"
|
||||
|
||||
#define float_to_int4(x) (s32)((float)x * (1.0f / 0.0625f))
|
||||
#define float_to_int12(x) (s32)((float)x * (1.0f / 0.000244140625f))
|
||||
#define float_to_int15(x) (s32)((float)x * (1.0f / 0.000030517578125))
|
||||
#define float_to_int4(x) ((float)x * (1.0f / 0.0625f))
|
||||
#define float_to_int12(x) ((float)x * (1.0f / 0.000244140625f))
|
||||
#define float_to_int15(x) ((float)x * (1.0f / 0.000030517578125))
|
||||
|
||||
#define int4_to_float(x) (float)((float)x * 0.0625f)
|
||||
#define int12_to_float(x) (float)((float)x * 0.000244140625f)
|
||||
|
|
Loading…
Reference in New Issue