From f20daa25953be46b527fda0c5a0fe2e6a7d37758 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 4 Jan 2021 22:49:29 +1100 Subject: [PATCH] - Replace `divscale64()` calls with `DivScaleU()` from common. --- source/build/include/pragmas.h | 2 -- source/build/src/clip.cpp | 2 +- source/common/utility/m_fixed.h | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 468b42365..c37614816 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -36,8 +36,6 @@ extern int32_t reciptable[2048]; static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return (int64_t(eax) << ecx) / ebx; } static inline double fdivscale(double eax, double ebx, int32_t ecx) { return (eax * (double)(qw(1) << ecx)) / ebx; } -static inline int64_t divscale64(int64_t eax, int64_t ebx, int64_t ecx) { return (eax << ecx) / ebx; } - #define EDUKE32_SCALER_PRAGMA(a) \ static FORCE_INLINE int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); } \ static FORCE_INLINE double fdivscale##a(double eax, double ebx) { return fdivscale(eax, ebx, a); } diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 1d9f10c52..f5c8ed9b9 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -753,7 +753,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int int32_t const templl2 = (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX); int32_t const i = (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829 || (klabs(templl2)>>11) < templl) ? - divscale64(templl2, templl, 20) : 0; + DivScaleL(templl2, templl, 20) : 0; goal = { MulScale(clipr.x, i, 20)+vec.x, MulScale(clipr.y, i, 20)+vec.y }; } diff --git a/source/common/utility/m_fixed.h b/source/common/utility/m_fixed.h index a7f23b870..0b90adcac 100644 --- a/source/common/utility/m_fixed.h +++ b/source/common/utility/m_fixed.h @@ -11,6 +11,7 @@ __forceinline constexpr int32_t MulScaleF(double a, double b, int32_t shift) { r __forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); } __forceinline constexpr int32_t TMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d + (int64_t)e * f) >> shift); } __forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); } +__forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { return ((a << shift) / b); } #include "xs_Float.h"