From c704eb9c9ff00e858cfa167e5dc73ee42234e46b Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 4 May 2023 01:03:18 -0700 Subject: [PATCH 1/3] Fix 32 bit builds --- Makefile | 6 +++--- src/pc/utils/misc.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index f305cc04..f4658937 100644 --- a/Makefile +++ b/Makefile @@ -158,9 +158,9 @@ endif ifeq ($(WINDOWS_AUTO_BUILDER),1) export SHELL=sh.exe - ifeq ($(TARGET_BITS), 32) + ifeq ($(TARGET_BITS),32) EXTRA_INCLUDES := ../include/1 ../include/2 ../include/3 ../include/4 - EXTRA_CPP_INCLUDES := ../include/cpp + EXTRA_CPP_INCLUDES := -I../include/cpp else EXTRA_INCLUDES := EXTRA_CPP_INCLUDES := @@ -1634,7 +1634,7 @@ ifeq ($(TARGET_N64),1) else $(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS) $(BUILD_DIR)/$(DISCORD_SDK_LIBS) $(BUILD_DIR)/$(BASS_LIBS) $(BUILD_DIR)/$(COOPNET_LIBS) $(BUILD_DIR)/$(LANG_DIR) $(BUILD_DIR)/$(MOD_DIR) @$(PRINT) "$(GREEN)Linking executable: $(BLUE)$@ $(NO_COL)\n" - $(V)$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) $(EXTRA_INCLUDES) + $(V)$(LD) $(PROF_FLAGS) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) endif diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index 6567dfd6..da3c6603 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -330,8 +330,9 @@ static f32 unmat_unscale_shear(f32 shear, f32 scale) { // tranfs is returned as follows: // scale(x, y, z), shear(xy, xz, zy), rotation(a, b, c, d), translation(x, y, z) static void unmatrix(Mtx * mat, f32 tranfs[13]) { - register int i; - Vec3f axisVecs[3], yzCross; + int i = 0; + Vec3f axisVecs[3] = { 0 }; + Vec3f yzCross = { 0 }; Mtx locMat = *mat; @@ -430,13 +431,13 @@ static void unmatrix(Mtx * mat, f32 tranfs[13]) { // builds a transformation matrix from a decomposed sequence from unmatrix // see unmatrix for what tranfs means static void rematrix(Mtx * mat, f32 tranfs[13]) { - register int i; - Vec3f rotAxes[3]; - Mat4 rotMat; + int i; + Vec3f rotAxes[3] = { 0 }; + Mat4 rotMat = { 0 }; // start with the identity matrix for (i = 0; i < 4; ++i) { - register int j; + int j; mat->m[i][i] = 1.0f; for (j = 3; j > i; --j) { @@ -476,8 +477,9 @@ static void rematrix(Mtx * mat, f32 tranfs[13]) { } void delta_interpolate_mtx_accurate(Mtx* out, Mtx* a, Mtx* b, f32 delta) { - register int i; - f32 matTranfsA[13], matTranfsB[13]; + int i; + f32 matTranfsA[13] = { 0 }; + f32 matTranfsB[13] = { 0 }; f32 antiDelta = 1.0f - delta; From f8829186b73b51c2046e8b49256777385bf8bad8 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 4 May 2023 01:26:39 -0700 Subject: [PATCH 2/3] Disable accurate interpolation on 32 bit --- src/engine/math_util.c | 2 +- src/pc/utils/misc.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/engine/math_util.c b/src/engine/math_util.c index ee6fd8f5..664c167e 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -164,7 +164,7 @@ f32 vec3f_dot(Vec3f a, Vec3f b) /// takes respective scales of vecA and vecB, and sums them void vec3f_combine(Vec3f dest, Vec3f vecA, Vec3f vecB, f32 sclA, f32 sclB) { - register int i; + int i = 0; for (i = 0; i < 3; ++i) { dest[i] = vecA[i] * sclA + vecB[i] * sclB; diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index da3c6603..d10513e1 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -215,7 +215,7 @@ static void rot_mat_to_rot_quat(Vec4f q, Vec3f a[3]) { // adjust signs of coefficients; base on greatest magnitude to improve float accuracy switch (maxCompoMagCase) { - f32 divFactor; + f32 divFactor = 0; case 0: divFactor = 0.25f / q[0]; @@ -270,7 +270,11 @@ static void rot_quat_slerp(Vec4f out, Vec4f a, Vec4f b, f32 t) { // Martin John Baker // https://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/index.htm - f32 halfTh, halfSin, st, sat, halfCos = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; + f32 halfTh = 0; + f32 halfSin = 0; + f32 st = 0; + f32 sat = 0; + f32 halfCos = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; memcpy(out, b, sizeof(f32) * 4); @@ -477,7 +481,7 @@ static void rematrix(Mtx * mat, f32 tranfs[13]) { } void delta_interpolate_mtx_accurate(Mtx* out, Mtx* a, Mtx* b, f32 delta) { - int i; + int i = 0; f32 matTranfsA[13] = { 0 }; f32 matTranfsB[13] = { 0 }; @@ -500,9 +504,12 @@ void delta_interpolate_mtx_accurate(Mtx* out, Mtx* a, Mtx* b, f32 delta) { } void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta) { - if (configInterpolationMode) { - delta_interpolate_mtx_accurate(out, a, b, delta); - return; + // HACK: Limit accurate interpolation to 64-bit builds + if (sizeof(int) > 4) { + if (configInterpolationMode) { + delta_interpolate_mtx_accurate(out, a, b, delta); + return; + } } // this isn't the right way to do things. From 822c31bfe476de2dc4723c0c0ee0a328bfe8915a Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 4 May 2023 01:43:01 -0700 Subject: [PATCH 3/3] Whoops --- src/pc/utils/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index d10513e1..1f29afbc 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -214,9 +214,8 @@ static void rot_mat_to_rot_quat(Vec4f q, Vec3f a[3]) { : 3; // adjust signs of coefficients; base on greatest magnitude to improve float accuracy + f32 divFactor = 0; switch (maxCompoMagCase) { - f32 divFactor = 0; - case 0: divFactor = 0.25f / q[0]; q[1] = (a[1][2] - a[2][1]) * divFactor; @@ -505,7 +504,7 @@ void delta_interpolate_mtx_accurate(Mtx* out, Mtx* a, Mtx* b, f32 delta) { void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta) { // HACK: Limit accurate interpolation to 64-bit builds - if (sizeof(int) > 4) { + if (sizeof(void*) > 4) { if (configInterpolationMode) { delta_interpolate_mtx_accurate(out, a, b, delta); return;