From f4a3757145a508fa9338562b6524f488b0a0c492 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 16:16:44 -0300 Subject: [PATCH 01/10] Further fixes to MXE compilation Adds on the work of PR #130. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 91049539..a0dd34c5 100644 --- a/Makefile +++ b/Makefile @@ -423,7 +423,13 @@ else endif ifeq ($(WINDOWS_BUILD),1) - LD := $(CXX) + ifeq ($(CROSS),i686-w64-mingw32.static-) # fixes compilation in MXE on Linux and WSL + LD := $(CC) + else ifeq ($(CROSS),x86_64-w64-mingw32.static-) + LD := $(CC) + else + LD := $(CXX) + endif else LD := $(CC) endif From 5dd43ad674da23a86067f6b484d9467d15573b5b Mon Sep 17 00:00:00 2001 From: Hyenadae <Hyenadae@github.com> Date: Sat, 16 May 2020 15:30:27 -0400 Subject: [PATCH 02/10] OSX_BUILD cleaned commit --- Makefile | 42 +++++++++++++------- include/PR/os_libc.h | 5 +++ lib/src/ldiv.c | 2 + lib/src/math/cosf.c | 3 ++ src/pc/gfx/gfx_opengl.c | 30 +++++++++++--- src/pc/gfx/gfx_sdl2.c | 24 ++++++----- tools/Makefile | 9 ++++- tools/n64graphics_ci_dir/exoquant/exoquant.c | 6 ++- 8 files changed, 89 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 91049539..19f42e56 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,9 @@ TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 -# Compiler to use (ido or gcc) -COMPILER ?= ido + +# Makeflag to enable OSX fixes +OSX_BUILD ?= 0 # Disable better camera by default BETTERCAMERA ?= 0 @@ -141,6 +142,10 @@ ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints VERSION_CFLAGS += -DUSE_GLES endif +ifeq ($(OSX_BUILD),1) # Modify GFX & SDL2 for OSX GL + VERSION_CFLAGS += -DOSX_BUILD +endif + VERSION_ASFLAGS := --defsym AVOID_UB=1 COMPARE := 0 @@ -167,7 +172,7 @@ endif endif # Make tools if out of date -DUMMY != make -s -C tools >&2 || echo FAIL +DUMMY != make -C tools >&2 || echo FAIL ifeq ($(DUMMY),FAIL) $(error Failed to build tools) endif @@ -228,10 +233,6 @@ GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists MIPSISET := -mips2 MIPSBIT := -32 -ifeq ($(COMPILER),gcc) - MIPSISET := -mips3 -endif - ifeq ($(VERSION),eu) OPT_FLAGS := -O2 else @@ -250,9 +251,8 @@ ifeq ($(TARGET_WEB),1) endif # Use a default opt flag for gcc, then override if RPi -ifeq ($(COMPILER),gcc) -OPT_FLAGS := -O2 # Breaks sound on x86? -endif +# OPT_FLAGS := -O2 # -O2 opt breaks sound on x86? + ifeq ($(TARGET_RPI),1) machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown') @@ -415,6 +415,10 @@ ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth AS := as +ifeq ($(OSX_BUILD),1) +AS := i686-w64-mingw32-as +endif + ifneq ($(TARGET_WEB),1) # As in, not-web PC port CC := $(CROSS)gcc CXX := $(CROSS)g++ @@ -431,11 +435,19 @@ endif ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL CPP := cpp -P OBJCOPY := objcopy + OBJDUMP := $(CROSS)objdump else +ifeq ($(OSX_BUILD),1) + CPP := cpp-9 -P + OBJDUMP := i686-w64-mingw32-objdump + OBJCOPY := i686-w64-mingw32-objcopy +else # Linux & other builds CPP := $(CROSS)cpp -P OBJCOPY := $(CROSS)objcopy + OBJDUMP := $(CROSS)objdump endif -OBJDUMP := $(CROSS)objdump +endif + PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config @@ -498,9 +510,12 @@ else ifeq ($(TARGET_RPI),1) # Linux / Other builds below LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(SDLCONFIG) --libs` -no-pie else +ifeq ($(OSX_BUILD),1) +LDFLAGS := -lm -framework OpenGL `$(SDLCONFIG) --libs` -no-pie -lpthread `pkg-config --libs libusb-1.0 glfw3 glew` +else LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(SDLCONFIG) --libs` -no-pie -lpthread endif - +endif # End of LDFLAGS # Prevent a crash with -sopt export LANG := C @@ -711,7 +726,6 @@ $(BUILD_DIR)/assets/mario_anim_data.c: $(wildcard assets/anims/*.inc.c) $(BUILD_DIR)/assets/demo_data.c: assets/demo_data.json $(wildcard assets/demos/*.bin) $(PYTHON) tools/demo_data_converter.py assets/demo_data.json $(VERSION_CFLAGS) > $@ -ifeq ($(COMPILER),ido) # Source code $(BUILD_DIR)/levels/%/leveldata.o: OPT_FLAGS := -g $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -g @@ -753,8 +767,6 @@ $(BUILD_DIR)/src/audio/%.acpp: src/audio/%.c $(BUILD_DIR)/src/audio/%.copt: $(BUILD_DIR)/src/audio/%.acpp $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/copt -signed -I=$< -CMP=$@ -cp=i -scalaroptimize=1 endif -endif - # Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes. $(GLOBAL_ASM_O_FILES): $(GLOBAL_ASM_DEP).$(NON_MATCHING) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 94111c0b..987abefe 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -3,8 +3,13 @@ #include "ultratypes.h" +#ifdef OSX_BUILD +#include <strings.h> // OSX doesn't like it not being included? +#else + // Old deprecated functions from strings.h, replaced by memcpy/memset. extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); +#endif #endif /* !_OS_LIBC_H_ */ diff --git a/lib/src/ldiv.c b/lib/src/ldiv.c index 01b04be2..b7c28efa 100644 --- a/lib/src/ldiv.c +++ b/lib/src/ldiv.c @@ -1,6 +1,7 @@ #include "libultra_internal.h" #include <stdlib.h> +#ifndef OSX_BUILD lldiv_t lldiv(long long num, long long denom) { lldiv_t ret; @@ -13,6 +14,7 @@ lldiv_t lldiv(long long num, long long denom) { return ret; } +#endif // OSX_BUILD cannot use this ldiv_t ldiv(long num, long denom) { ldiv_t ret; diff --git a/lib/src/math/cosf.c b/lib/src/math/cosf.c index 2b01c12a..f1130b44 100644 --- a/lib/src/math/cosf.c +++ b/lib/src/math/cosf.c @@ -33,6 +33,7 @@ static const du pilo = { static const fu zero = {0.0}; extern const fu NAN; +#ifndef OSX_BUILD float cosf(float x) { double dx; // double x @@ -92,3 +93,5 @@ float cosf(float x) return zero.f; } +#endif // OSX_BUILD cannot use this + diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index b7067e91..1e323a1a 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -18,12 +18,19 @@ #include <SDL2/SDL.h> #define GL_GLEXT_PROTOTYPES 1 #include <SDL2/SDL_opengl.h> + #else #include <SDL2/SDL.h> #define GL_GLEXT_PROTOTYPES 1 + +#ifdef OSX_BUILD +#include <SDL2/SDL_opengl.h> +#else #include <SDL2/SDL_opengles2.h> #endif +#endif + #include "gfx_cc.h" #include "gfx_rendering_api.h" @@ -49,7 +56,7 @@ static bool gfx_opengl_z_is_from_0_to_1(void) { static void gfx_opengl_vertex_array_set_attribs(struct ShaderProgram *prg) { size_t num_floats = prg->num_floats; size_t pos = 0; - + for (int i = 0; i < prg->num_attribs; i++) { glEnableVertexAttribArray(prg->attrib_locations[i]); glVertexAttribPointer(prg->attrib_locations[i], prg->attrib_sizes[i], GL_FLOAT, GL_FALSE, num_floats * sizeof(float), (void *)(pos * sizeof(float))); @@ -179,15 +186,19 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad bool do_multiply[2] = {c[0][1] == 0 && c[0][3] == 0, c[1][1] == 0 && c[1][3] == 0}; bool do_mix[2] = {c[0][1] == c[0][3], c[1][1] == c[1][3]}; bool color_alpha_same = (shader_id & 0xfff) == ((shader_id >> 12) & 0xfff); - + char vs_buf[1024]; char fs_buf[1024]; size_t vs_len = 0; size_t fs_len = 0; size_t num_floats = 4; - + // Vertex shader +#ifdef OSX_BUILD + append_line(vs_buf, &vs_len, ""); +#else append_line(vs_buf, &vs_len, "#version 100"); +#endif append_line(vs_buf, &vs_len, "attribute vec4 aVtxPos;"); if (used_textures[0] || used_textures[1]) { append_line(vs_buf, &vs_len, "attribute vec2 aTexCoord;"); @@ -216,10 +227,15 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad } append_line(vs_buf, &vs_len, "gl_Position = aVtxPos;"); append_line(vs_buf, &vs_len, "}"); - + // Fragment shader +#ifdef OSX_BUILD + append_line(fs_buf, &fs_len, ""); +#else append_line(fs_buf, &fs_len, "#version 100"); append_line(fs_buf, &fs_len, "precision mediump float;"); +#endif + if (used_textures[0] || used_textures[1]) { append_line(fs_buf, &fs_len, "varying vec2 vTexCoord;"); } @@ -464,7 +480,11 @@ static void gfx_opengl_init(void) { #if FOR_WINDOWS glewInit(); #endif - + +#ifdef OSX_BUILD + glewInit(); +#endif + glGenBuffers(1, &opengl_vbo); glBindBuffer(GL_ARRAY_BUFFER, opengl_vbo); diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index e7018476..309de78b 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -13,9 +13,15 @@ #else #include <SDL2/SDL.h> #define GL_GLEXT_PROTOTYPES 1 + +#ifdef OSX_BUILD +#include <SDL2/SDL_opengl.h> +#else #include <SDL2/SDL_opengles2.h> #endif +#endif // End of OS-Specific GL defines + #include "gfx_window_manager_api.h" #include "gfx_screen_config.h" #include "../configfile.h" @@ -30,7 +36,7 @@ static bool cur_fullscreen; static uint32_t cur_width, cur_height; const SDL_Scancode windows_scancode_table[] = -{ +{ /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */ @@ -53,7 +59,7 @@ const SDL_Scancode windows_scancode_table[] = SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, /* 6 */ SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 6 */ - + SDL_SCANCODE_INTERNATIONAL2, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL1, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL4, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL5, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL3, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */ }; @@ -98,16 +104,16 @@ static void gfx_sdl_init(void) { Uint32 window_flags = 0; SDL_Init(SDL_INIT_VIDEO); - + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #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_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); #endif - + //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); @@ -122,9 +128,9 @@ static void gfx_sdl_init(void) { } SDL_DisplayMode sdl_displaymode; - SDL_GetCurrentDisplayMode(0, &sdl_displaymode); + SDL_GetCurrentDisplayMode(0, &sdl_displaymode); - const char* window_title = + const char* window_title = #ifndef USE_GLES "Super Mario 64 PC port (OpenGL)"; #else @@ -140,10 +146,10 @@ static void gfx_sdl_init(void) { DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, window_flags); SDL_ShowCursor(SDL_ENABLE); } - + SDL_GL_CreateContext(wnd); 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; } diff --git a/tools/Makefile b/tools/Makefile index 467b8d4c..1809ab92 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,5 +1,10 @@ +UNAME := $(shell uname) +ifeq ($(UNAME),Darwin) + OSX_BUILD := -DOSX_BUILD +endif + CC := gcc -CFLAGS := -Llib -Iinclude -I . -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 -O3 -s +CFLAGS := -Llib -Iinclude -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 -O3 -s PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math iplfontutil aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv n64graphics_SOURCES := n64graphics.c utils.c @@ -43,7 +48,7 @@ clean: define COMPILE $(1): $($1_SOURCES) - $(CC) $(CFLAGS) $$^ -lm -o $$@ $($1_CFLAGS) + $(CC) $(CFLAGS) $(OSX_BUILD) $$^ -lm -o $$@ $($1_CFLAGS) endef $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) diff --git a/tools/n64graphics_ci_dir/exoquant/exoquant.c b/tools/n64graphics_ci_dir/exoquant/exoquant.c index 9f33c066..a70bc038 100644 --- a/tools/n64graphics_ci_dir/exoquant/exoquant.c +++ b/tools/n64graphics_ci_dir/exoquant/exoquant.c @@ -23,7 +23,11 @@ SOFTWARE. */ #include "exoquant.h" + +#ifndef OSX_BUILD // OSX build cannot have malloc defined #include <malloc.h> +#endif + #include <math.h> #include <stdlib.h> #include <stdio.h> @@ -705,4 +709,4 @@ exq_float exq_sort_by_dir(const exq_histogram *pHist) pHist->color.g * exq_sort_dir.g + pHist->color.b * exq_sort_dir.b + pHist->color.a * exq_sort_dir.a; -} \ No newline at end of file +} From 3d7bdc300cd5c818ee7c677d4ef9718ddfe0402d Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 17:12:56 -0300 Subject: [PATCH 03/10] Add NO_BZERO for MXE --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index a0dd34c5..ece07b95 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 +# No BZERO (for building under MXE) +NO_BZERO ?= 0 # Compiler to use (ido or gcc) COMPILER ?= ido @@ -461,6 +463,12 @@ endif # Check for enhancement options +# Check for no bzero option +ifeq ($(NO_BZERO),1) +CC_CHECK += -DNO_BZERO +CFLAGS += -DNO_BZERO +endif + # Check for Puppycam option ifeq ($(BETTERCAMERA),1) CC_CHECK += -DBETTERCAMERA From e42e1587b24c7042de03cf00a715f6fcbd4a8fb4 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 17:14:10 -0300 Subject: [PATCH 04/10] MXE fix for os_libc.h --- include/PR/os_libc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 94111c0b..13ec2124 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -4,7 +4,13 @@ #include "ultratypes.h" // Old deprecated functions from strings.h, replaced by memcpy/memset. +#ifdef NO_BZERO +#include <string.h> +#define bzero(buf, size) memset(buf, 0, size) +#define bcopy(src, dst, size) memcpy(dst, src, size) +#else extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); +#endif #endif /* !_OS_LIBC_H_ */ From 8736776545859a9dd6bb33fd4022d1bc598c8dbb Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 17:20:33 -0300 Subject: [PATCH 05/10] Another fix to MXE --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index ece07b95..5903e52f 100644 --- a/Makefile +++ b/Makefile @@ -450,6 +450,12 @@ SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` + ifeq ($(CROSS),i686-w64-mingw32.static-) + ifeq ($(CROSS),x86_64-w64-mingw32.static-) + CC_CHECK += D_NOBZERO + CFLAGS += D_NOBZERO + endif + endif 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 From 385e396feb6d6afd4d71d096ddb9378425206402 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 17:21:59 -0300 Subject: [PATCH 06/10] fix the MXE fix for os_libc.h --- include/PR/os_libc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 13ec2124..4c2fc3e1 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -6,8 +6,8 @@ // Old deprecated functions from strings.h, replaced by memcpy/memset. #ifdef NO_BZERO #include <string.h> -#define bzero(buf, size) memset(buf, 0, size) -#define bcopy(src, dst, size) memcpy(dst, src, size) +#define bzero(buf, size) memset((buf), 0, (size)) +#define bcopy(src, dst, size) memcpy((dst), (src), (size)) #else extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); From 0402ad463b84fe5049bd491c9a8ff951342755c7 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 19:18:50 -0300 Subject: [PATCH 07/10] fixed MXE once and for all thanks to @fgsfdsfgs, this is the final thing needed for MXE support --- include/PR/os_libc.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 4c2fc3e1..e7567516 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -3,14 +3,28 @@ #include "ultratypes.h" -// Old deprecated functions from strings.h, replaced by memcpy/memset. -#ifdef NO_BZERO +// old bstring functions that aren't present on some platforms + +#if defined(__APPLE__) + +// macOS libc has them +#include <strings.h> + +#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) + +// there's no way that shit's defined, use memcpy/memset #include <string.h> -#define bzero(buf, size) memset((buf), 0, (size)) -#define bcopy(src, dst, size) memcpy((dst), (src), (size)) +#undef bzero +#undef bcopy +#define bzero(buf, len) memset((buf), 0, (len)) +#define bcopy(src, dst, len) memcpy((dst), (src), (len)) + #else + +// hope for the best extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); + #endif #endif /* !_OS_LIBC_H_ */ From 5c9e3c60a7b14ccc387ea1e7bcdb98585ba8446e Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 19:20:45 -0300 Subject: [PATCH 08/10] strip out now-needless NOBZERO flag --- Makefile | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Makefile b/Makefile index 5903e52f..a0dd34c5 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,6 @@ TARGET_N64 = 0 # Build and optimize for Raspberry Pi(s) TARGET_RPI ?= 0 -# No BZERO (for building under MXE) -NO_BZERO ?= 0 # Compiler to use (ido or gcc) COMPILER ?= ido @@ -450,12 +448,6 @@ SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` - ifeq ($(CROSS),i686-w64-mingw32.static-) - ifeq ($(CROSS),x86_64-w64-mingw32.static-) - CC_CHECK += D_NOBZERO - CFLAGS += D_NOBZERO - endif - endif 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 @@ -469,12 +461,6 @@ endif # Check for enhancement options -# Check for no bzero option -ifeq ($(NO_BZERO),1) -CC_CHECK += -DNO_BZERO -CFLAGS += -DNO_BZERO -endif - # Check for Puppycam option ifeq ($(BETTERCAMERA),1) CC_CHECK += -DBETTERCAMERA From bd4187c92bd14288b15a023f06e1a96bcdb290ef Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 21:04:55 -0300 Subject: [PATCH 09/10] Make MXE easier to compile in Specifying the target arch MXE expects in the makefile makes it easier for MXE users to compile the game. --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index 7091f336..80213c10 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,17 @@ EXT_OPTIONS_MENU ?= 1 TARGET_WEB ?= 0 # Specify the target you are building for, 0 means native TARGET_ARCH ?= native + +ifeq ($(CROSS),i686-w64-mingw32.static-) + ifeq ($(CROSS),x86_64-w64-mingw32.static-) + TARGET_ARCH = i386pe + else + TARGET_ARCH = i386pe + endif +else + TARGET_ARCH = native +endif + TARGET_BITS ?= 0 ifneq ($(TARGET_BITS),0) From 410090a84c5d5d10dabf0893309c792c3c460ec6 Mon Sep 17 00:00:00 2001 From: "Colton G. Rushton" <colton51919@gmail.com> Date: Sat, 16 May 2020 21:24:29 -0300 Subject: [PATCH 10/10] Fix a few minor bugs with MXE compilation --- Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 80213c10..fe9add23 100644 --- a/Makefile +++ b/Makefile @@ -42,11 +42,9 @@ TARGET_WEB ?= 0 TARGET_ARCH ?= native ifeq ($(CROSS),i686-w64-mingw32.static-) - ifeq ($(CROSS),x86_64-w64-mingw32.static-) - TARGET_ARCH = i386pe - else - TARGET_ARCH = i386pe - endif + TARGET_ARCH = i386pe +else ifeq ($(CROSS),x86_64-w64-mingw32.static-) + TARGET_ARCH = i386pe else TARGET_ARCH = native endif @@ -517,9 +515,9 @@ LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base ht else ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static ifneq ($(CROSS),i686-w64-mingw32.static-) - ifneq ($(CROSS),x86_64-w64-mingw32.static-) - LDFLAGS += -no-pie - endif + LDFLAGS += -no-pie + else ifneq ($(CROSS),x86_64-w64-mingw32.static-) + LDFLAGS += -no-pie endif ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole