From 14b0282267b8098c076e3f7fbc2393ccdb752031 Mon Sep 17 00:00:00 2001 From: HengiFettlich Date: Fri, 8 May 2020 12:11:59 +0200 Subject: [PATCH 01/10] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ade7cab1..06cc0022 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ # Text editor remnants *.swp .vscode/* +.idea/* # General project-specific ignores doxygen/doxygen/* From 848f7c352b15c9e564eede771ac682bdef8bcef0 Mon Sep 17 00:00:00 2001 From: HengiFettlich Date: Fri, 8 May 2020 12:24:40 +0200 Subject: [PATCH 02/10] Update gfx_sdl2.c if fullscreened, escape to exit fullscreen --- src/pc/gfx/gfx_sdl2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 1afe5eab..1df686b6 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -167,6 +167,11 @@ static void gfx_sdl_onkeydown(int scancode) { configFullscreen = !configFullscreen; } + else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen) + { + SDL_SetWindowFullscreen(wnd, 0); + configFullscreen = false; + } } static void gfx_sdl_onkeyup(int scancode) { From c540898c71eb667aef4cd9ed2689f9b39c7b876a Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Fri, 8 May 2020 13:41:12 +0200 Subject: [PATCH 03/10] revert -O2 when non matching,fix EU compile,disable cursor in fullscreen - O2 caused problems with audio on US builds when targeting generic systems - compiling an EU version previously caused problems due to race condition in the Makefile - not being able to see the cursor on a small window is annoying, only hide on fullscreen --- Makefile | 11 ++++++++--- src/pc/gfx/gfx_sdl2.c | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c862063a..aa36bc0a 100644 --- a/Makefile +++ b/Makefile @@ -254,7 +254,7 @@ endif endif # Use a default opt flag for gcc -ifeq ($(NON_MATCHING),1) +ifeq ($(COMPILER),gcc) OPT_FLAGS := -O2 endif @@ -644,17 +644,22 @@ $(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) # Make sure build directory exists before compiling anything 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 # diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 1df686b6..5a782f5d 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -80,7 +80,6 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = { static void gfx_sdl_init(void) { SDL_Init(SDL_INIT_VIDEO); - SDL_ShowCursor(SDL_DISABLE); // Removes the cursor from view when upon the game's window. SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); @@ -105,6 +104,7 @@ static void gfx_sdl_init(void) { if (configFullscreen) { SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); + SDL_ShowCursor(SDL_DISABLE); } SDL_GL_CreateContext(wnd); @@ -159,10 +159,12 @@ static void gfx_sdl_onkeydown(int scancode) { if (!configFullscreen) { SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP); + SDL_ShowCursor(SDL_DISABLE); } else { SDL_SetWindowFullscreen(wnd, 0); + SDL_ShowCursor(SDL_ENABLE); } configFullscreen = !configFullscreen; @@ -170,6 +172,7 @@ static void gfx_sdl_onkeydown(int scancode) { else if (state[SDL_SCANCODE_ESCAPE] && configFullscreen) { SDL_SetWindowFullscreen(wnd, 0); + SDL_ShowCursor(SDL_ENABLE); configFullscreen = false; } } From c4707eb36f7334f7c509ee7e186a38306b104d3d Mon Sep 17 00:00:00 2001 From: HengiFettlich Date: Fri, 8 May 2020 14:35:38 +0200 Subject: [PATCH 04/10] 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 05/10] 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 06/10] 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 07/10] 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 08/10] 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 09/10] 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 10/10] 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`.