Improved WiiVC check to avoid false positives & added functions to read and manipulate fcr31 (#669)

* Added functions to access and manipulate the fcr31 register

* Improved WiiVC emulator check to avoid false positives

* Updated comments

* Moved float.h to include directory
This commit is contained in:
Matt Pharoah
2023-09-22 13:05:53 -04:00
committed by GitHub
parent 42cbaed631
commit 3a312e101c
4 changed files with 137 additions and 4 deletions

View File

@@ -8,6 +8,7 @@
#include <ultra64.h>
#include <string.h>
#include "emutest_vc.h"
#include "float.h"
#include "types.h"
extern OSMesgQueue gSIEventMesgQueue;
@@ -90,18 +91,22 @@ void detect_emulator() {
}
/*
* This check forces RTZ bug on vc
* If console is N64/adequate Emu round-to-nearest (RTN) rounding mode is used
* If console is VC round-to-zero (RTZ) mode is used
* This check forces RZ bug on vc
* If console is N64/adequate Emu, the current rounding mode, which is initialized to round-to-nearest (RN), is used
* If console is VC round-to-zero (RZ) mode is always used
*
* The double value 0.9999999999999999 used is 0x3FEFFFFFFFFFFFFF in binary
* Exponent=01111111110, Mantissa=1111111111111111111111111111111111111111111111111111
* RTZ will output not 1.0f, RTN will output exactly 1.0f
* RZ will output not 1.0f, RN will output exactly 1.0f
*/
const FloatRoundingMode roundingMode = fcr_get_rounding_mode();
fcr_set_rounding_mode(FRC_RM_ROUND_TO_NEAREST);
if (1.0f != round_double_to_float(0.9999999999999999)) {
gEmulator = EMU_WIIVC;
fcr_set_rounding_mode(roundingMode);
return;
}
fcr_set_rounding_mode(roundingMode);
// Perform a read from unmapped PIF ram.
// On console and well behaved emulators, this echos back the lower half of