N64: Fix FPU underflow/overflow exceptions still being triggered

This commit is contained in:
UnknownShadow200 2024-09-21 08:12:34 +10:00
parent 15a454c83c
commit 21afe3027c
3 changed files with 44 additions and 16 deletions

View File

@ -81,6 +81,7 @@ jobs:
COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn" COMMON_FLAGS: "-O1 -s -fno-stack-protector -fno-math-errno -Qn"
NIX64_FLAGS: "-no-pie -fno-pie -m64 -fvisibility=hidden -fcf-protection=none -rdynamic -DCC_BUILD_ICON" NIX64_FLAGS: "-no-pie -fno-pie -m64 -fvisibility=hidden -fcf-protection=none -rdynamic -DCC_BUILD_ICON"
run: | run: |
sudo apt-get -y update
sudo apt-get -y install libx11-dev libxi-dev libgl1-mesa-dev libsdl2-dev sudo apt-get -y install libx11-dev libxi-dev libgl1-mesa-dev libsdl2-dev
LATEST_FLAG=-DCC_COMMIT_SHA=\"$(git rev-parse --short "$GITHUB_SHA")\" LATEST_FLAG=-DCC_COMMIT_SHA=\"$(git rev-parse --short "$GITHUB_SHA")\"

View File

@ -142,7 +142,9 @@ Compiling with TCC:
##### Using gcc/clang ##### Using gcc/clang
1. Install X11, XInput2, and OpenGL development libraries if necessary. <br> 1. Install X11, XInput2, and OpenGL development libraries if necessary. <br>
For Ubuntu, these are the `libx11-dev`, `libxi-dev` and `libgl1-mesa-dev` packages For Ubuntu, these are the `libx11-dev`, `libxi-dev` and `libgl1-mesa-dev` packages
2. Run ```cc -fno-math-errno src/*.c -o ClassiCube -rdynamic -lpthread -lX11 -lXi -lGL -ldl``` 2. Run either:
* `make linux` or
* `cc -fno-math-errno src/*.c -o ClassiCube -rdynamic -lpthread -lX11 -lXi -lGL -ldl`
##### Cross compiling for Windows (32 bit): ##### Cross compiling for Windows (32 bit):
1. Install MinGW-w64 if necessary. (Ubuntu: `gcc-mingw-w64` package) 1. Install MinGW-w64 if necessary. (Ubuntu: `gcc-mingw-w64` package)
@ -159,7 +161,9 @@ Although the regular linux compiliation flags will work fine, to take full advan
## Compiling - macOS ## Compiling - macOS
1. Install a C compiler if necessary. The easiest way of obtaining one is by installing **Xcode**. 1. Install a C compiler if necessary. The easiest way of obtaining one is by installing **Xcode**.
2. Run ```cc -fno-math-errno src/*.c src/*.m -o ClassiCube -framework Cocoa -framework OpenGL -framework IOKit -lobjc``` 2. Run either:
* `make darwin` or
* `cc -fno-math-errno src/*.c src/*.m -o ClassiCube -framework Cocoa -framework OpenGL -framework IOKit -lobjc`
##### Using Xcode GUI ##### Using Xcode GUI
@ -196,11 +200,13 @@ NOTE: If you are distributing a modified version, **please change the bundle ID
## Compiling - webclient ## Compiling - webclient
1. Install emscripten if necessary. 1. Install emscripten if necessary.
2. Run ```emcc src/*.c -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=1Mb --js-library interop_web.js``` 2. Run either:
* `make web` or
* `emcc src/*.c -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=1Mb --js-library interop_web.js`
The generated javascript file has some issues. [See here for how to fix](doc/compile-fixes.md#webclient-patches) The generated javascript file has some issues. [See here for how to fix](doc/compile-fixes.md#webclient-patches)
For more details on how to integrate into a website, see [here](doc/hosting-webclient.md) For details on how to integrate the webclient into a website, see [here](doc/hosting-webclient.md)
<details> <details>
<summary><h2>Compiling - consoles</h2></summary> <summary><h2>Compiling - consoles</h2></summary>
@ -317,44 +323,65 @@ Run `make saturn`. You'll need [libyaul](https://github.com/yaul-org/libyaul)
#### FreeBSD #### FreeBSD
1. Install `libxi`, `libexecinfo`, `curl` and `openal-soft` packages if needed 1. Install `libxi`, `libexecinfo`, `curl` and `openal-soft` packages if needed
2. Run ```cc src/*.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo``` 2. Run either:
* `make freebsd` or
* `cc src/*.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo`
#### OpenBSD #### OpenBSD
1. Install `libexecinfo`, `curl` and `openal` packages if needed 1. Install `libexecinfo`, `curl` and `openal` packages if needed
2. Run ```cc src/*.c -o ClassiCube -I /usr/X11R6/include -I /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo``` 2. Run either:
* `make opensd` or
* `cc src/*.c -o ClassiCube -I /usr/X11R6/include -I /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo`
#### NetBSD #### NetBSD
1. Install `libexecinfo`, `curl` and `openal-soft` packages if needed 1. Install `libexecinfo`, `curl` and `openal-soft` packages if needed
2. Run ```cc src/*.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lXi -lGL -lexecinfo``` 2. Run either:
* `make netbsd` or
* `cc src/*.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lXi -lGL -lexecinfo`
#### DragonflyBSD #### DragonflyBSD
```cc src/*.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo``` 1. Install `libxi`, `libexecinfo`, `curl` and `openal-soft` packages if needed
2. Run either:
* `make dragonfly` or
* `cc src/*.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo`
#### Solaris #### Solaris
```gcc -fno-math-errno src/*.c -o ClassiCube -lsocket -lX11 -lXi -lGL``` 1. Install required packages if needed
2. Run either:
* `make sunos` or
* `gcc -fno-math-errno src/*.c -o ClassiCube -lsocket -lX11 -lXi -lGL`
#### Haiku #### Haiku
1. Install openal_devel packages if needed 1. Install `gcc`, `haiku_devel`, `openal_devel` packages if needed
2. Run ```cc -fno-math-errno src/*.c interop_BeOS.cpp -o ClassiCube -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker``` 2. Run either:
* `make haiku` or
* `cc -fno-math-errno src/*.c interop_BeOS.cpp -o ClassiCube -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker`
#### BeOS #### BeOS
1. Install a C compiler 1. Install a C compiler
2. Run ```cc -fno-math-errno src/*.c interop_BeOS.cpp -o ClassiCube -lGL -lbe -lgame -ltracker``` 2. Run either:
* `make beos` or
* `cc -fno-math-errno src/*.c interop_BeOS.cpp -o ClassiCube -lGL -lbe -lgame -ltracker`
#### IRIX #### IRIX
```gcc -fno-math-errno src/*.c -o ClassiCube -lGL -lX11 -lXi -lpthread -ldl``` 1. Install required packages if needed
2. Run either:
* `make irix` or
* gcc -fno-math-errno src/*.c -o ClassiCube -lGL -lX11 -lXi -lpthread -ldl`
#### SerenityOS #### SerenityOS
1. Install SDL2 port if needed 1. Install SDL2 port if needed
2. Run ```cc src/*.c -o ClassiCube -lgl -lSDL2``` 2. Run either:
* `make serenityos` or
* `cc src/*.c -o ClassiCube -lgl -lSDL2`
#### Classic Mac OS #### Classic Mac OS

View File

@ -252,9 +252,9 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
static void DisableFpuExceptions(void) { static void DisableFpuExceptions(void) {
uint32_t fcr31 = C1_FCR31(); uint32_t fcr31 = C1_FCR31();
fcr31 &= ~(C1_CAUSE_OVERFLOW | C1_CAUSE_UNDERFLOW | C1_CAUSE_NOT_IMPLEMENTED | C1_CAUSE_INEXACT_OP); fcr31 &= ~(C1_ENABLE_OVERFLOW | C1_ENABLE_UNDERFLOW | C1_ENABLE_INEXACT_OP);
fcr31 |= C1_ENABLE_DIV_BY_0 | C1_ENABLE_INVALID_OP; fcr31 |= C1_ENABLE_DIV_BY_0 | C1_ENABLE_INVALID_OP;
fcr31 |= C1_FCR31_FS; fcr31 |= C1_FCR31_FS; // flush denormals to zero
C1_WRITE_FCR31(fcr31); C1_WRITE_FCR31(fcr31);
} }