From c4707eb36f7334f7c509ee7e186a38306b104d3d Mon Sep 17 00:00:00 2001 From: HengiFettlich Date: Fri, 8 May 2020 14:35:38 +0200 Subject: [PATCH 01/19] refactor fullscreen into own static function --- src/pc/gfx/gfx_sdl2.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 5a782f5d..ba6044f0 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -78,6 +78,22 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { {SDL_SCANCODE_KP_MULTIPLY, SDL_SCANCODE_PRINTSCREEN} }; +static void gfx_sdl_set_fullscreen(bool fullscreen) +{ + if (fullscreen) + { + SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); + SDL_ShowCursor(SDL_DISABLE); + } + else + { + SDL_SetWindowFullscreen(wnd, 0); + SDL_ShowCursor(SDL_ENABLE); + } + + configFullscreen = fullscreen; +} + static void gfx_sdl_init(void) { SDL_Init(SDL_INIT_VIDEO); @@ -101,11 +117,7 @@ static void gfx_sdl_init(void) { DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); #endif - if (configFullscreen) - { - SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); - SDL_ShowCursor(SDL_DISABLE); - } + gfx_sdl_set_fullscreen(configFullscreen); SDL_GL_CreateContext(wnd); SDL_GL_SetSwapInterval(2); // TODO 0, 1 or 2 or remove this line @@ -156,24 +168,11 @@ static void gfx_sdl_onkeydown(int scancode) { if (state[SDL_SCANCODE_LALT] && state[SDL_SCANCODE_RETURN]) { - if (!configFullscreen) - { - SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); - SDL_ShowCursor(SDL_DISABLE); - } - else - { - SDL_SetWindowFullscreen(wnd, 0); - SDL_ShowCursor(SDL_ENABLE); - } - - configFullscreen = !configFullscreen; + gfx_sdl_set_fullscreen(!configFullscreen); } else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen) { - SDL_SetWindowFullscreen(wnd, 0); - SDL_ShowCursor(SDL_ENABLE); - configFullscreen = false; + gfx_sdl_set_fullscreen(false); } } From b0404194d232175ba2153e807018b46f1ba348cd Mon Sep 17 00:00:00 2001 From: vanfanel Date: Fri, 8 May 2020 16:47:17 +0200 Subject: [PATCH 02/19] Pass the correct CFLAGs for Rpi3 and Rpi4 when both models run a system with aarch64 kernel and libs. --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aa36bc0a..1c5a5e6f 100644 --- a/Makefile +++ b/Makefile @@ -265,7 +265,7 @@ ifeq ($(TARGET_RPI),1) OPT_FLAGS := -march=armv6zk+fp -mfpu=vfp -Ofast endif -# Raspberry Pi 2 and 3 +# Raspberry Pi 2 and 3 in ARM 32bit mode ifneq (,$(findstring armv7l,$(machine))) model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') @@ -276,9 +276,15 @@ ifeq ($(TARGET_RPI),1) endif endif -# RPi4 / ARM A64 NEEDS TESTING 32BIT. +# RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT. +# DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM. ifneq (,$(findstring aarch64,$(machine))) - OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3 + model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') + ifneq (,$(findstring 3,$(model))) + OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -O3 + else ifneq (,$(findstring 4,$(model))) + OPT_FLAGS := -march=armv8-a+crc+simd -mtune=cortex-a72 -O3 + endif endif endif From ab52a3cbf56b1c77363eac359cbf7e5e82680089 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Fri, 8 May 2020 17:06:23 +0200 Subject: [PATCH 03/19] Pass -DUSE_GLES to sdl2 GL init context instead of -DTARGET_RPI, since there are more GLES platforms out there that this engine will run on. --- Makefile | 3 ++- src/pc/gfx/gfx_sdl2.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1c5a5e6f..1b0898cf 100644 --- a/Makefile +++ b/Makefile @@ -133,7 +133,8 @@ endif ifeq ($(NON_MATCHING),1) VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints - VERSION_CFLAGS += -DTARGET_RPI + # Other platforms will use GLES2 eventually, not only RPis. + VERSION_CFLAGS += -DUSE_GLES endif VERSION_ASFLAGS := --defsym AVOID_UB=1 COMPARE := 0 diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index ba6044f0..309c19a2 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -100,7 +100,7 @@ static void gfx_sdl_init(void) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - #ifdef TARGET_RPI + #ifdef USE_GLES SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); // These attributes allow for hardware acceleration on RPis. SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); @@ -109,18 +109,18 @@ static void gfx_sdl_init(void) { //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); - #ifndef TARGET_RPI - wnd = SDL_CreateWindow("Super Mario 64 PC-Port", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + #ifndef USE_GLES + wnd = SDL_CreateWindow("Super Mario 64 PC port (OpenGL)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); #else - wnd = SDL_CreateWindow("Super Mario 64 RPi (GLES2)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + wnd = SDL_CreateWindow("Super Mario 64 PC port (OpenGL_ES2)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); #endif gfx_sdl_set_fullscreen(configFullscreen); SDL_GL_CreateContext(wnd); - SDL_GL_SetSwapInterval(2); // TODO 0, 1 or 2 or remove this line + SDL_GL_SetSwapInterval(1); // We have a double buffered GL context, it makes no sense to want tearing. for (size_t i = 0; i < sizeof(windows_scancode_table) / sizeof(SDL_Scancode); i++) { inverted_scancode_table[windows_scancode_table[i]] = i; From bdfdb176845094ca1d0f96c9610cb5ca030dce5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Fri, 8 May 2020 13:29:35 -0300 Subject: [PATCH 04/19] Added a new Windows guide. --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32cd8b64..ce833e2b 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,62 @@ make VERSION=us WINDOWS_BUILD=1 # builds a (U) Windows executable ### On Windows -A full guide is to be written. You can use [mxe](https://mxe.cc/) and MinGW. +#### 1. Set up MSYS2, following [this guide](https://github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2). + +#### 2. Install dependencies +``` +pacman -S mingw-w64-i686-glew mingw-w64-x86_64-glew mingw-w64-i686-SDL2 mingw-w64-x86_64-SDL2 python3 +``` +#### 3. Copy baserom(s) for asset extraction + +For each version (jp/us/eu) that you want to build an executable for, put an existing ROM at +`./baserom..z64` for asset extraction. + +#### 4. On MSYS2, navigate to the sm64pc folder and then enter `./tools/audiofile-0.3.6/`. Inside this directory, run +``` +autoreconf -i +``` + +Only leave this directory on step 9. + +#### 5. Run the `configure` script +``` +PATH=/mingw64/bin:/mingw32/bin:$PATH LIBS=-lstdc++ ./configure --disable-docs +``` +#### 6. Run the `make` script +``` +PATH=/mingw64/bin:/mingw32/bin:$PATH make +``` +#### 7. Create a lib directory in `tools/` +``` +mkdir ../lib +``` + +#### 8. Copy the compiled libaudiofile to `tools/lib/` +``` +cp libaudiofile/.libs/libaudiofile.a ../lib/ +cp libaudiofile/.libs/libaudiofile.la ../lib/ +``` + +#### 9. Navigate back to `tools/`, then alter the `Makefile` and add `-lstdc++` on the following line +``` +tabledesign_CFLAGS := -Wno-uninitialized -laudiofile -lstdc++ +``` + +#### 10. Run `make` +``` +PATH=/mingw64/bin:/mingw32/bin:$PATH make +``` + +#### 11. Navigate back to the sm64pc root directory. + +#### 12. Finally, run `make` once more. (Note that mingw32 and mingw64 have been swapped. This is so you can build the 32bit application successfully.) +``` +PATH=/mingw32/bin:/mingw64/bin:$PATH make +``` + +This guide is a courtesy of [XNBlank](https://github.com/XNBlank). + ### For the web From 65c297dcf04a9c8c77994589673c4ac1113126f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Fri, 8 May 2020 13:32:31 -0300 Subject: [PATCH 05/19] Mention Raspberry Pi building and formatting fix. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ce833e2b..7f87181c 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Run `make` to build (defaults to `VERSION=us`) ``` make VERSION=jp -j6 # build (J) version with 6 jobs make VERSION=us WINDOWS_BUILD=1 # builds a (U) Windows executable +make TARGET_RPI=1 # targets an executable for a Raspberry Pi ``` ### On Windows @@ -114,7 +115,10 @@ PATH=/mingw64/bin:/mingw32/bin:$PATH make #### 11. Navigate back to the sm64pc root directory. -#### 12. Finally, run `make` once more. (Note that mingw32 and mingw64 have been swapped. This is so you can build the 32bit application successfully.) +#### 12. Finally, run `make` once more. + +(Note that mingw32 and mingw64 have been swapped. This is so you can build the 32bit application successfully.) + ``` PATH=/mingw32/bin:/mingw64/bin:$PATH make ``` From 0690451684937273dcd8a77acafba61ce461ba43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Fri, 8 May 2020 14:55:25 -0300 Subject: [PATCH 06/19] Update .gitignore to remove patch/wiggle residue `git patch` makes a .rej file for every rejection, and wiggle makes a .porig for every rejection fixed. This can add up to a lot of junk. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 06cc0022..2f56cebf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ *.ilk *.exp +# Patch and wiggle related residdue +*.rej +*.porig + # Precompiled Headers *.gch *.pch From 0859a0cfefb7521c7204172fe79e97cf045b37fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Fri, 8 May 2020 16:16:53 -0300 Subject: [PATCH 07/19] Nothing to see here --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 7f87181c..180f12f4 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,6 @@ PATH=/mingw64/bin:/mingw32/bin:$PATH make PATH=/mingw32/bin:/mingw64/bin:$PATH make ``` -This guide is a courtesy of [XNBlank](https://github.com/XNBlank). - - ### For the web The game can be compiled for web browsers that support WebGL using [Emscripten](https://github.com/emscripten-core). To do so, install [emsdk](https://github.com/emscripten-core/emsdk) and run `make TARGET_WEB=1`. From aaa26021f6c500ceed65522352313dbc2a91031f Mon Sep 17 00:00:00 2001 From: albertw <3dsgitasw@gmail.com> Date: Fri, 8 May 2020 19:11:59 -0700 Subject: [PATCH 08/19] Add libSDL and emsdk to support building linux and web in container --- Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dbc31e2a..a4344f26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,14 @@ RUN apt-get update && \ binutils-mips-linux-gnu \ bsdmainutils \ build-essential \ + git \ libaudiofile-dev \ + libsdl2-dev \ pkg-config \ python3 \ wget \ - zlib1g-dev + zlib1g-dev && \ + rm -rf /var/lib/apt/lists/* RUN wget \ https://github.com/n64decomp/qemu-irix/releases/download/v2.11-deb/qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb \ @@ -18,9 +21,16 @@ RUN wget \ dpkg -i qemu.deb && \ rm qemu.deb +RUN cd /tmp && \ + git clone https://github.com/emscripten-core/emsdk.git && \ + cd emsdk && \ + ./emsdk install latest && \ + cd .. && \ + rm -rf emsdk + RUN mkdir /sm64 WORKDIR /sm64 -ENV PATH="/sm64/tools:${PATH}" +ENV PATH="/sm64/tools:/emsdk:${PATH}" CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=${VERSION:-us} -j4\n' \ 'see https://github.com/n64decomp/sm64/blob/master/README.md for advanced usage' From 3ff6d4d38e86f67cb2798fcef456974921b04c22 Mon Sep 17 00:00:00 2001 From: Hyenadae Date: Sat, 9 May 2020 03:29:10 +0100 Subject: [PATCH 09/19] Strip out N64 ROM building from Makefile --- Makefile | 317 +++++++++++++++---------------------------------------- 1 file changed, 87 insertions(+), 230 deletions(-) diff --git a/Makefile b/Makefile index c862063a..7640d351 100644 --- a/Makefile +++ b/Makefile @@ -16,17 +16,15 @@ GRUCODE ?= f3d_old # If COMPARE is 1, check the output sha1sum when building 'all' COMPARE ?= 1 # If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended) -NON_MATCHING ?= 0 -# Build for the N64 (turn this off for ports) +NON_MATCHING ?= 1 +# Sane default until N64 build scripts rm'd TARGET_N64 ?= 0 + # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 # Compiler to use (ido or gcc) COMPILER ?= ido -ifeq ($(COMPILER),gcc) - NON_MATCHING := 1 -endif # Build for Emscripten/WebGL TARGET_WEB ?= 0 # Specify the target you are building for, 0 means native @@ -39,18 +37,18 @@ else BITS := endif -# Automatic settings only for ports -ifeq ($(TARGET_N64),0) - NON_MATCHING := 1 - GRUCODE := f3dex2e - WINDOWS_BUILD := 0 - ifeq ($(TARGET_WEB),0) - ifeq ($(OS),Windows_NT) - WINDOWS_BUILD := 1 - endif - endif +# Automatic settings for PC port(s) -# Release +NON_MATCHING := 1 +GRUCODE := f3dex2e +WINDOWS_BUILD := 0 + +ifeq ($(TARGET_WEB),0) +ifeq ($(OS),Windows_NT) +WINDOWS_BUILD := 1 +endif + +# Release (version) flag defs ifeq ($(VERSION),jp) VERSION_CFLAGS := -DVERSION_JP @@ -103,7 +101,7 @@ ifeq ($(GRUCODE), f3dex2) # Fast3DEX2 TARGET := $(TARGET).f3dex2 COMPARE := 0 else -ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (for PC) +ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default) GRUCODE_CFLAGS := -DF3DEX_GBI_2E TARGET := $(TARGET).f3dex2e COMPARE := 0 @@ -126,18 +124,15 @@ endif endif endif -ifeq ($(TARGET_N64),0) - NON_MATCHING := 1 +# Default build is for PC now +VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB + +ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints + VERSION_CFLAGS += -DUSE_GLES endif -ifeq ($(NON_MATCHING),1) - VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB - ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints - VERSION_CFLAGS += -DTARGET_RPI - endif - VERSION_ASFLAGS := --defsym AVOID_UB=1 - COMPARE := 0 -endif +VERSION_ASFLAGS := --defsym AVOID_UB=1 +COMPARE := 0 ifeq ($(TARGET_WEB),1) VERSION_CFLAGS := $(VERSION_CFLAGS) -DTARGET_WEB @@ -174,34 +169,30 @@ endif # BUILD_DIR is location where all build artifacts are placed BUILD_DIR_BASE := build -ifeq ($(TARGET_N64),1) - BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION) -else + ifeq ($(TARGET_WEB),1) BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_web else BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_pc endif -endif LIBULTRA := $(BUILD_DIR)/libultra.a + ifeq ($(TARGET_WEB),1) EXE := $(BUILD_DIR)/$(TARGET).html -else -ifeq ($(WINDOWS_BUILD),1) -EXE := $(BUILD_DIR)/$(TARGET).exe + else + ifeq ($(WINDOWS_BUILD),1) + EXE := $(BUILD_DIR)/$(TARGET).exe -else #Linux builds here -ifeq ($(TARGET_RPI),1) -EXE := $(BUILD_DIR)/$(TARGET).arm -else -EXE := $(BUILD_DIR)/$(TARGET) -endif + else # Linux builds/binary namer + ifeq ($(TARGET_RPI),1) + EXE := $(BUILD_DIR)/$(TARGET).arm + else + EXE := $(BUILD_DIR)/$(TARGET) + endif + endif endif -endif - -ROM := $(BUILD_DIR)/$(TARGET).z64 ELF := $(BUILD_DIR)/$(TARGET).elf LD_SCRIPT := sm64.ld MIO0_DIR := $(BUILD_DIR)/bin @@ -211,14 +202,11 @@ ACTOR_DIR := actors LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h))) # Directories containing source files -SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets -ASM_DIRS := lib -ifeq ($(TARGET_N64),1) - ASM_DIRS := asm $(ASM_DIRS) -else - SRC_DIRS := $(SRC_DIRS) src/pc src/pc/gfx src/pc/audio src/pc/controller - ASM_DIRS := -endif + +# Hi, I'm a PC +SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets src/pc src/pc/gfx src/pc/audio src/pc/controller +ASM_DIRS := + BIN_DIRS := bin bin/$(VERSION) ULTRA_SRC_DIRS := lib/src lib/src/math @@ -244,28 +232,27 @@ else endif endif -ifeq ($(TARGET_N64),0) - OPT_FLAGS += $(BITS) -endif +# Set BITS (32/64) to compile for +OPT_FLAGS += $(BITS) ifeq ($(TARGET_WEB),1) OPT_FLAGS := -O2 -g4 --source-map-base http://localhost:8080/ endif endif -# Use a default opt flag for gcc -ifeq ($(NON_MATCHING),1) - OPT_FLAGS := -O2 +# Use a default opt flag for gcc, then override if RPi +ifeq ($(COMPILER),gcc) +OPT_FLAGS := -O2 # Breaks sound on x86? endif ifeq ($(TARGET_RPI),1) - machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown') + machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown') # Raspberry Pi B+, Zero, etc - ifneq (,$(findstring armv6l,$(machine))) + ifneq (,$(findstring armv6l,$(machine))) OPT_FLAGS := -march=armv6zk+fp -mfpu=vfp -Ofast endif -# Raspberry Pi 2 and 3 +# Raspberry Pi 2 and 3 in ARM 32bit mode ifneq (,$(findstring armv7l,$(machine))) model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') @@ -276,9 +263,19 @@ ifeq ($(TARGET_RPI),1) endif endif -# RPi4 / ARM A64 NEEDS TESTING 32BIT. - ifneq (,$(findstring aarch64,$(machine))) - OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3 + +# RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT. +# DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM. + + ifneq (,$(findstring aarch64,$(machine))) + model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown') + + ifneq (,$(findstring 3,$(model))) + OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -O3 + else ifneq (,$(findstring 4,$(model))) + OPT_FLAGS := -march=armv8-a+crc+simd -mtune=cortex-a72 -O3 + endif + endif endif @@ -292,9 +289,7 @@ CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp)) S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s)) ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c)) GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c)) -ifeq ($(TARGET_N64),1) - ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s)) -endif + GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c \ $(addprefix $(BUILD_DIR)/bin/,$(addsuffix _skybox.c,$(notdir $(basename $(wildcard textures/skyboxes/*.png))))) @@ -302,7 +297,9 @@ ifeq ($(WINDOWS_BUILD),0) CXX_FILES := endif -ifneq ($(TARGET_N64),1) +# We need to keep this for now +# If we're not N64 use below + ULTRA_C_FILES_SKIP := \ sqrtf.c \ string.c \ @@ -361,7 +358,8 @@ ifneq ($(TARGET_N64),1) C_FILES := $(filter-out src/game/main.c,$(C_FILES)) ULTRA_C_FILES := $(filter-out $(addprefix lib/src/,$(ULTRA_C_FILES_SKIP)),$(ULTRA_C_FILES)) -endif + +# "If we're not N64, use the above" ifeq ($(VERSION),sh) SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json) @@ -386,7 +384,6 @@ SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \ $(SOUND_BIN_DIR)/sequences.bin.o \ $(SOUND_BIN_DIR)/bank_sets.o - # Object files O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \ $(foreach file,$(CXX_FILES),$(BUILD_DIR)/$(file:.cpp=.o)) \ @@ -401,13 +398,6 @@ GODDARD_O_FILES := $(foreach file,$(GODDARD_C_FILES),$(BUILD_DIR)/$(file:.c=.o)) # Automatic dependency files DEP_FILES := $(O_FILES:.o=.d) $(ULTRA_O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d -# Files with GLOBAL_ASM blocks -ifneq ($(NON_MATCHING),1) -GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(wildcard src/**/*.c) -GLOBAL_ASM_O_FILES = $(foreach file,$(GLOBAL_ASM_C_FILES),$(BUILD_DIR)/$(file:.c=.o)) -GLOBAL_ASM_DEP = $(BUILD_DIR)/src/audio/non_matching_dep -endif - # Segment elf files SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES) @@ -415,82 +405,23 @@ SEG_FILES := $(SEGMENT_ELF_FILES) $(ACTOR_ELF_FILES) $(LEVEL_ELF_FILES) INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I . ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth -ifeq ($(TARGET_N64),1) -IRIX_ROOT := tools/ido5.3_compiler - -ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) - CROSS := mips-linux-gnu- -else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) - CROSS := mips64-linux-gnu- -else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0) - CROSS := mips64-elf- -endif - -# check that either QEMU_IRIX is set or qemu-irix package installed -ifndef QEMU_IRIX - QEMU_IRIX := $(shell which qemu-irix) - ifeq (, $(QEMU_IRIX)) - $(error Please install qemu-irix package or set QEMU_IRIX env var to the full qemu-irix binary path) - endif -endif - -AS := $(CROSS)as -CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc -CPP := cpp -P -Wno-trigraphs -LD := $(CROSS)ld -AR := $(CROSS)ar -OBJDUMP := $(CROSS)objdump -OBJCOPY := $(CROSS)objcopy -PYTHON := python3 - -# change the compiler to gcc, to use the default, install the gcc-mips-linux-gnu package -ifeq ($(COMPILER),gcc) - CC := $(CROSS)gcc -endif - -ifeq ($(TARGET_N64),1) - TARGET_CFLAGS := -nostdinc -I include/libc -DTARGET_N64 - CC_CFLAGS := -fno-builtin -endif - -# Check code syntax with host compiler -CC_CHECK := gcc -fsyntax-only -fsigned-char $(CC_CFLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) - -COMMON_CFLAGS = $(OPT_FLAGS) $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS) - -ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) $(GRUCODE_ASFLAGS) -CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $(COMMON_CFLAGS) $(MIPSBIT) -OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF -SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES)) -LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS) -ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth - -ifeq ($(COMPILER),gcc) - CFLAGS := -march=vr4300 -mfix4300 -mno-shared -G 0 -mhard-float -fno-stack-protector -fno-common -I include -I src/ -I $(BUILD_DIR)/include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra $(COMMON_CFLAGS) -endif - -ifeq ($(shell getconf LONG_BIT), 32) - # Work around memory allocation bug in QEMU - export QEMU_GUEST_BASE := 1 -else - # Ensure that gcc treats the code as 32-bit - CC_CHECK += $(BITS) -endif - -else # TARGET_N64 +# Huge deleted N64 section was here AS := as -ifneq ($(TARGET_WEB),1) + +ifneq ($(TARGET_WEB),1) # As in, not-web PC port CC := $(CROSS)gcc CXX := $(CROSS)g++ else CC := emcc endif + ifeq ($(WINDOWS_BUILD),1) LD := $(CXX) else LD := $(CC) endif + CPP := cpp -P OBJDUMP := objdump OBJCOPY := objcopy @@ -499,9 +430,11 @@ PYTHON := python3 ifeq ($(WINDOWS_BUILD),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags` CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags` + else ifeq ($(TARGET_WEB),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2 + # Linux / Other builds below else CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags` @@ -513,9 +446,11 @@ ASFLAGS := -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) ifeq ($(TARGET_WEB),1) LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" else + ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static else + # Linux / Other builds below ifeq ($(TARGET_RPI),1) LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(CROSS)sdl2-config --libs` -no-pie @@ -525,14 +460,13 @@ endif endif endif #Added for Pi ifeq -endif # Prevent a crash with -sopt export LANG := C ####################### Other Tools ######################### -# N64 tools +# N64 conversion tools TOOLS_DIR = tools MIO0TOOL = $(TOOLS_DIR)/mio0 N64CKSUM = $(TOOLS_DIR)/n64cksum @@ -550,32 +484,13 @@ LOADER = loader64 LOADER_FLAGS = -vwf SHA1SUM = sha1sum -# Use Objcopy instead of extract_data_for_mio -ifeq ($(COMPILER),gcc) -EXTRACT_DATA_FOR_MIO := $(OBJCOPY) -O binary --only-section=.data -endif - ###################### Dependency Check ##################### -ifeq ($(TARGET_N64),1) -BINUTILS_VER_MAJOR := $(shell $(LD) --version | grep ^GNU | sed 's/^.* //; s/\..*//g') -BINUTILS_VER_MINOR := $(shell $(LD) --version | grep ^GNU | sed 's/^[^.]*\.//; s/\..*//g') -BINUTILS_DEPEND := $(shell expr $(BINUTILS_VER_MAJOR) \>= 2 \& $(BINUTILS_VER_MINOR) \>= 27) -ifeq ($(BINUTILS_DEPEND),0) -$(error binutils version 2.27 required, version $(BINUTILS_VER_MAJOR).$(BINUTILS_VER_MINOR) detected) -endif -endif +# Stubbed ######################## Targets ############################# -ifeq ($(TARGET_N64),1) -all: $(ROM) -ifeq ($(COMPARE),1) - @$(SHA1SUM) -c $(TARGET).sha1 || (echo 'The build succeeded, but did not match the official ROM. This is expected if you are making changes to the game.\nTo silence this message, use "make COMPARE=0"'. && false) -endif -else all: $(EXE) -endif clean: $(RM) -r $(BUILD_DIR_BASE) @@ -606,10 +521,6 @@ $(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in $(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in $(TEXTCONV) charmap_menu.txt $< $@ -ifeq ($(COMPILER),gcc) -$(BUILD_DIR)/lib/src/math/%.o: CFLAGS += -fno-builtin -endif - ifeq ($(VERSION),eu) TEXT_DIRS := text/de text/us text/fr @@ -635,7 +546,6 @@ $(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c endif endif - $(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h $(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/ $(TEXTCONV) charmap.txt $@ $@ @@ -644,7 +554,6 @@ $(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h t $(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/ $(TEXTCONV) charmap.txt $@ $@ -O_FILES += $(wildcard $(BUILD_DIR)/bin/$(VERSION)/*.o) ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_ASM_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION) @@ -652,9 +561,17 @@ ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GOD DUMMY != mkdir -p $(ALL_DIRS) $(BUILD_DIR)/include/text_strings.h: $(BUILD_DIR)/include/text_menu_strings.h + +ifeq ($(VERSION),eu) +$(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o +$(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o +$(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o +O_FILES += $(BUILD_DIR)/bin/eu/translation_en.o $(BUILD_DIR)/bin/eu/translation_de.o $(BUILD_DIR)/bin/eu/translation_fr.o +else $(BUILD_DIR)/src/menu/file_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/src/menu/star_select.o: $(BUILD_DIR)/include/text_strings.h $(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h +endif ################################################################ # TEXTURE GENERATION # @@ -680,38 +597,7 @@ $(BUILD_DIR)/%.ci4: %.ci4.png # compressed segment generation -ifeq ($(TARGET_N64),1) -# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address - -$(BUILD_DIR)/bin/%.elf: $(BUILD_DIR)/bin/%.o - $(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $< -$(BUILD_DIR)/actors/%.elf: $(BUILD_DIR)/actors/%.o - $(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $< - -# Override for level.elf, which otherwise matches the above pattern -.SECONDEXPANSION: -$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf - $(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $< - -$(BUILD_DIR)/bin/%.bin: $(BUILD_DIR)/bin/%.elf - $(EXTRACT_DATA_FOR_MIO) $< $@ - -$(BUILD_DIR)/actors/%.bin: $(BUILD_DIR)/actors/%.elf - $(EXTRACT_DATA_FOR_MIO) $< $@ - -$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf - $(EXTRACT_DATA_FOR_MIO) $< $@ - -$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin - $(MIO0TOOL) $< $@ - -$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s - $(AS) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0 - printf ".section .data\n\n.incbin \"$<\"\n" > $@ -endif - +# PC Area $(BUILD_DIR)/%.table: %.aiff $(AIFF_EXTRACT_CODEBOOK) $< >$@ @@ -748,10 +634,7 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o $(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s $(AS) $(ASFLAGS) -o $@ $< -ifeq ($(TARGET_N64),1) -$(SOUND_BIN_DIR)/%.s: $(SOUND_BIN_DIR)/% - printf ".section .data\n\n.incbin \"$<\"\n" > $@ -else + $(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl echo "unsigned char gSoundDataADSR[] = {" > $@ hexdump -v -e '1/1 "0x%X,"' $< >> $@ @@ -771,7 +654,6 @@ $(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets echo "unsigned char gBankSetsData[] = {" > $@ hexdump -v -e '1/1 "0x%X,"' $< >> $@ echo "};" >> $@ -endif $(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h @@ -828,9 +710,6 @@ $(BUILD_DIR)/src/audio/%.copt: $(BUILD_DIR)/src/audio/%.acpp endif endif -ifeq ($(NON_MATCHING),0) -$(GLOBAL_ASM_O_FILES): CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -endif # Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes. $(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING) @@ -854,32 +733,10 @@ $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(BUILD_DIR)/%.o: %.s $(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $< -ifeq ($(TARGET_N64),1) -$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) - $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $< -$(BUILD_DIR)/libultra.a: $(ULTRA_O_FILES) - $(AR) rcs -o $@ $(ULTRA_O_FILES) - tools/patch_libultra_math $@ -$(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES) - $(AR) rcs -o $@ $(GODDARD_O_FILES) - -$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SOUND_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a - $(LD) -L $(BUILD_DIR) $(LDFLAGS) -o $@ $(O_FILES)$(LIBS) -lultra -lgoddard - -$(ROM): $(ELF) - $(OBJCOPY) $(OBJCOPYFLAGS) $< $(@:.z64=.bin) -O binary - $(N64CKSUM) $(@:.z64=.bin) $@ - -$(BUILD_DIR)/$(TARGET).objdump: $(ELF) - $(OBJDUMP) -D $< > $@ - -else $(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) -endif - .PHONY: all clean distclean default diff test load libultra .PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/% From 2b188036cbd2ee730b3e66564a15db611e60c6a6 Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Sat, 9 May 2020 01:17:42 -0300 Subject: [PATCH 10/19] Slight Makefile update Change TARGET_N64 ?= to TARGET_N64 = --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 625384a1..9b829f36 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ COMPARE ?= 1 # If NON_MATCHING is 1, define the NON_MATCHING and AVOID_UB macros when building (recommended) NON_MATCHING ?= 1 # Sane default until N64 build scripts rm'd -TARGET_N64 ?= 0 +TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 From 75aeb9d6869aaa1d4ee165b1d2c19a6e49eebad8 Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Sat, 9 May 2020 02:32:57 -0300 Subject: [PATCH 11/19] Fix goddard/sfx.h header --- src/goddard/sfx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goddard/sfx.h b/src/goddard/sfx.h index 0ba48c0a..d0b6f6fd 100644 --- a/src/goddard/sfx.h +++ b/src/goddard/sfx.h @@ -20,6 +20,6 @@ enum GdSfx { extern void gd_reset_sfx(void); extern u32 gd_new_sfx_to_play(void); extern void gd_sfx_played(void); -extern void gd_play_sfx(u32); +extern void gd_play_sfx(enum GdSfx sfx); #endif /* GD_MARIO_HEAD_SFX_H */ From f43c06303fabf2c8246efe2596b7e6cf0902d59b Mon Sep 17 00:00:00 2001 From: Hyenadae Date: Sat, 9 May 2020 09:28:19 +0100 Subject: [PATCH 12/19] L (Trigger) is real. Keyboard only for now. --- src/pc/configfile.c | 2 ++ src/pc/controller/controller_keyboard.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 10ff1e68..8bcc24db 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -34,6 +34,7 @@ bool configFullscreen = false; unsigned int configKeyA = 0x26; unsigned int configKeyB = 0x33; unsigned int configKeyStart = 0x39; +unsigned int configKeyL = 0x35; unsigned int configKeyR = 0x36; unsigned int configKeyZ = 0x25; unsigned int configKeyCUp = 0x148; @@ -51,6 +52,7 @@ static const struct ConfigOption options[] = { {.name = "key_a", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyA}, {.name = "key_b", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyB}, {.name = "key_start", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyStart}, + {.name = "key_l", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyL}, {.name = "key_r", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyR}, {.name = "key_z", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyZ}, {.name = "key_cup", .type = CONFIG_TYPE_UINT, .uintValue = &configKeyCUp}, diff --git a/src/pc/controller/controller_keyboard.c b/src/pc/controller/controller_keyboard.c index a49b86a8..87eaee0d 100644 --- a/src/pc/controller/controller_keyboard.c +++ b/src/pc/controller/controller_keyboard.c @@ -11,7 +11,7 @@ static int keyboard_buttons_down; -static int keyboard_mapping[13][2]; +static int keyboard_mapping[14][2]; static int keyboard_map_scancode(int scancode) { int ret = 0; @@ -58,6 +58,7 @@ static void keyboard_init(void) { set_keyboard_mapping(i++, L_CBUTTONS, configKeyCLeft); set_keyboard_mapping(i++, D_CBUTTONS, configKeyCDown); set_keyboard_mapping(i++, R_CBUTTONS, configKeyCRight); + set_keyboard_mapping(i++, L_TRIG, configKeyL); set_keyboard_mapping(i++, R_TRIG, configKeyR); set_keyboard_mapping(i++, START_BUTTON, configKeyStart); From 0413703a6023123e0263951865fb16b90938d1cb Mon Sep 17 00:00:00 2001 From: Hyenadae Date: Sat, 9 May 2020 09:31:15 +0100 Subject: [PATCH 13/19] L (Trigger) is real. Keyboard only for now. --- src/pc/configfile.c | 2 +- src/pc/configfile.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 8bcc24db..a2de665e 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -34,7 +34,7 @@ bool configFullscreen = false; unsigned int configKeyA = 0x26; unsigned int configKeyB = 0x33; unsigned int configKeyStart = 0x39; -unsigned int configKeyL = 0x35; +unsigned int configKeyL = 0x34; unsigned int configKeyR = 0x36; unsigned int configKeyZ = 0x25; unsigned int configKeyCUp = 0x148; diff --git a/src/pc/configfile.h b/src/pc/configfile.h index ae9070b7..7128aaab 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -5,6 +5,7 @@ extern bool configFullscreen; extern unsigned int configKeyA; extern unsigned int configKeyB; extern unsigned int configKeyStart; +extern unsigned int configKeyL; extern unsigned int configKeyR; extern unsigned int configKeyZ; extern unsigned int configKeyCUp; From 76783f2ab01f29ca4eee9de251a90dc088ad0f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Sat, 9 May 2020 12:18:30 -0300 Subject: [PATCH 14/19] Add optional support for L-trigger on controllers. --- enhancements/L-trigger-mapping/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 enhancements/L-trigger-mapping/README.md diff --git a/enhancements/L-trigger-mapping/README.md b/enhancements/L-trigger-mapping/README.md new file mode 100644 index 00000000..0538f094 --- /dev/null +++ b/enhancements/L-trigger-mapping/README.md @@ -0,0 +1,12 @@ +# L-trigger mapping + +Some parts of the code might require the pressing of the L-trigger for testing reasons. + +If you need that, alter `controller_sdl.c`. +In the following line: +``` + if (SDL_GameControllerGetButton(sdl_cntrl, SDL_CONTROLLER_BUTTON_LEFTSHOULDER)) pad->button |= Z_TRIG; +``` +Replace `Z_TRIG` with `L_TRIG`, save and rebuild. + +On a DS4, this now means that Z-trigger will be mapped to L2 and the L-trigger to L1. From 7a81769abc4702a52e8b9e129f220e84c4b4155b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Sat, 9 May 2020 18:20:20 -0300 Subject: [PATCH 15/19] Delete fps.patch --- enhancements/fps.patch | 60 ------------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 enhancements/fps.patch diff --git a/enhancements/fps.patch b/enhancements/fps.patch deleted file mode 100644 index 9e28d22a..00000000 --- a/enhancements/fps.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/src/game/game_init.c b/src/game/game_init.c -index 0852a141..18c5e8fe 100644 ---- a/src/game/game_init.c -+++ b/src/game/game_init.c -@@ -56,6 +56,47 @@ struct DemoInput *gCurrDemoInput = NULL; // demo input sequence - u16 gDemoInputListID = 0; - struct DemoInput gRecordedDemoInput = { 0 }; // possibly removed in EU. TODO: Check - -+// SDK states that 1 cycle takes about 21.33 nanoseconds -+#define SECONDS_PER_CYCLE 0.00000002133f -+ -+#define FPS_COUNTER_X_POS 24 -+#define FPS_COUNTER_Y_POS 190 -+ -+static OSTime gLastOSTime = 0; -+static float gFrameTime = 0.0f; -+static u16 gFrames = 0; -+static u16 gFPS = 0; -+static u8 gRenderFPS = FALSE; -+ -+static void calculate_frameTime_from_OSTime(OSTime diff) { -+ gFrameTime += diff * SECONDS_PER_CYCLE; -+ gFrames++; -+} -+ -+static void render_fps(void) { -+ // Toggle rendering framerate with the L button. -+ if (gPlayer1Controller->buttonPressed & L_TRIG) { -+ gRenderFPS ^= 1; -+ } -+ -+ if (gRenderFPS) { -+ OSTime newTime = osGetTime(); -+ -+ calculate_frameTime_from_OSTime(newTime - gLastOSTime); -+ -+ // If frame time is longer or equal to a second, update FPS counter. -+ if (gFrameTime >= 1.0f) { -+ gFPS = gFrames; -+ gFrames = 0; -+ gFrameTime -= 1.0f; -+ } -+ -+ print_text_fmt_int(FPS_COUNTER_X_POS, FPS_COUNTER_Y_POS, "FPS %d", gFPS); -+ -+ gLastOSTime = newTime; -+ } -+} -+ - /** - * Initializes the Reality Display Processor (RDP). - * This function initializes settings such as texture filtering mode, -@@ -614,5 +655,7 @@ void thread5_game_loop(UNUSED void *arg) { - // amount of free space remaining. - print_text_fmt_int(180, 20, "BUF %d", gGfxPoolEnd - (u8 *) gDisplayListHead); - } -+ -+ render_fps(); - } - } From 1c86dca5816afddcb266adc013977b9348650a55 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sat, 9 May 2020 21:13:57 -0300 Subject: [PATCH 16/19] Fix save corruption in some 64-bit builds --- src/game/game_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/game_init.c b/src/game/game_init.c index 4603acc4..511bae2c 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -306,7 +306,7 @@ void rendering_init(void) { } void config_gfx_pool(void) { - gGfxPool = &gGfxPools[gGlobalTimer % 2]; + gGfxPool = &gGfxPools[gGlobalTimer % GFX_NUM_POOLS]; set_segment_base_addr(1, gGfxPool->buffer); gGfxSPTask = &gGfxPool->spTask; gDisplayListHead = gGfxPool->buffer; From 3f9236a23345981e8511961811abea44cec5c541 Mon Sep 17 00:00:00 2001 From: Zero-Shift Date: Sat, 9 May 2020 20:32:50 -0500 Subject: [PATCH 17/19] Update script.c Changed amount of sleep frames when transitioning from main menu and exiting a stage to fix TAS sync issues --- levels/menu/script.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/levels/menu/script.c b/levels/menu/script.c index 46cd0668..5a9d3e44 100644 --- a/levels/menu/script.c +++ b/levels/menu/script.c @@ -50,7 +50,7 @@ const LevelScript level_main_menu_entry_1[] = { GET_OR_SET(/*op*/ OP_SET, /*var*/ VAR_CURR_SAVE_FILE_NUM), STOP_MUSIC(/*fadeOutTime*/ 0x00BE), TRANSITION(/*transType*/ WARP_TRANSITION_FADE_INTO_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF), - SLEEP(/*frames*/ 24), + SLEEP(/*frames*/ 16), CLEAR_LEVEL(), SLEEP_BEFORE_EXIT(/*frames*/ 1), SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS), @@ -89,7 +89,7 @@ const LevelScript level_main_menu_entry_2[] = { /*35*/ GET_OR_SET(/*op*/ OP_SET, /*var*/ VAR_CURR_ACT_NUM), /*36*/ STOP_MUSIC(/*fadeOutTime*/ 0x00BE), /*37*/ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_INTO_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF), - /*39*/ SLEEP(/*frames*/ 24), + /*39*/ SLEEP(/*frames*/ 16), /*40*/ CLEAR_LEVEL(), /*41*/ SLEEP_BEFORE_EXIT(/*frames*/ 1), // L1: From 8e2e2f49f0e9cb0def8b34bd43a0c1c2ff41ccba Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sun, 10 May 2020 00:03:14 -0300 Subject: [PATCH 18/19] Port fixes from fdsfgsfds' fork see https://github.com/fgsfdsfgs/sm64pc/commit/63bed21d26cfa2aad7fd5b9339a1770f7b293978 for details --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9b829f36..6102eab7 100644 --- a/Makefile +++ b/Makefile @@ -647,7 +647,7 @@ $(SOUND_BIN_DIR)/sequences.bin.c: $(SOUND_BIN_DIR)/sequences.bin echo "};" >> $@ $(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets - echo "unsigned char gBankSetsData[] = {" > $@ + echo "unsigned char gBankSetsData[0x100] = {" > $@ hexdump -v -e '1/1 "0x%X,"' $< >> $@ echo "};" >> $@ From ad89f663f3fd3c19bf373c6a312f3caadea49843 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" Date: Sun, 10 May 2020 00:05:33 -0300 Subject: [PATCH 19/19] More fixes ported from fdsfgsfds' fork --- src/pc/gfx/gfx_sdl2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 309c19a2..fb7f6a07 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -131,8 +131,8 @@ static void gfx_sdl_init(void) { } for (size_t i = 0; i < sizeof(scancode_rmapping_nonextended) / sizeof(scancode_rmapping_nonextended[0]); i++) { - inverted_scancode_table[scancode_rmapping_extended[i][0]] = inverted_scancode_table[scancode_rmapping_extended[i][1]]; - inverted_scancode_table[scancode_rmapping_extended[i][1]] += 0x100; + inverted_scancode_table[scancode_rmapping_nonextended[i][0]] = inverted_scancode_table[scancode_rmapping_nonextended[i][1]]; + inverted_scancode_table[scancode_rmapping_nonextended[i][1]] += 0x100; } }