Fix actions

This commit is contained in:
SimoneN64
2023-10-24 15:33:19 +02:00
parent 45f15f1ec9
commit 607071853b
5 changed files with 28 additions and 49 deletions

View File

@@ -153,6 +153,24 @@ FORCE_INLINE void SetFPUCauseCVTRaised(Registers& regs, int raised) {
SetFPUCauseRaised(regs, raised);
}
#define F_TO_U32(f) (*((u32*)(&(f))))
#define D_TO_U64(d) (*((u64*)(&(d))))
#define U64_TO_D(d) (*((double*)(&(d))))
#define U32_TO_F(f) (*((float*)(&(f))))
template <typename T>
FORCE_INLINE bool isqnan(T f) {
if constexpr(std::is_same_v<T, float>) {
u32 v = F_TO_U32(f);
return (v & 0x7FC00000) == 0x7FC00000;
} else if constexpr(std::is_same_v<T, double>) {
u64 v = D_TO_U64(f);
return (v & 0x7FF8000000000000) == 0x7FF8000000000000;
} else {
Util::panic("Invalid float type in isqnan");
}
}
template <typename T>
FORCE_INLINE void SetCauseByArg(Registers& regs, T f) {
int c = std::fpclassify(f);
@@ -176,11 +194,6 @@ FORCE_INLINE void SetCauseByArg(Registers& regs, T f) {
}
}
#define F_TO_U32(f) (*((u32*)(&(f))))
#define D_TO_U64(d) (*((u64*)(&(d))))
#define U64_TO_D(d) (*((double*)(&(d))))
#define U32_TO_F(f) (*((float*)(&(f))))
template <typename T>
FORCE_INLINE void SetCauseOnResult(Registers& regs, T& d) {
Cop1& cop1 = regs.cop1;
@@ -254,19 +267,6 @@ FORCE_INLINE bool isnan(T f) {
}
}
template <typename T>
FORCE_INLINE bool isqnan(T f) {
if constexpr(std::is_same_v<T, float>) {
u32 v = F_TO_U32(f);
return (v & 0x7FC00000) == 0x7FC00000;
} else if constexpr(std::is_same_v<T, double>) {
u64 v = D_TO_U64(f);
return (v & 0x7FF8000000000000) == 0x7FF8000000000000;
} else {
Util::panic("Invalid float type in isqnan");
}
}
#define checknanregs(fs, ft) do { \
if(isnan(fs) || isnan(ft)) { \
regs.cop1.fcr31.cause_invalid_operation = true; \