From 9815f0f2325ec973c899db766faed87cac49e64d Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 25 Nov 2006 19:45:02 +0000 Subject: Remove FixedDiv2; use actual fixed point version of FixedDiv (wtf?) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 758 --- src/m_fixed.c | 41 +++++++++++++---------------------------- src/m_fixed.h | 1 - 2 files changed, 13 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/m_fixed.c b/src/m_fixed.c index 970394a6..5e3050bc 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -52,34 +52,19 @@ FixedMul // FixedDiv, C version. // -fixed_t -FixedDiv -( fixed_t a, - fixed_t b ) +fixed_t FixedDiv(fixed_t a, fixed_t b) { - if ( (abs(a)>>14) >= abs(b)) - return (a^b)<0 ? INT_MIN : INT_MAX; - return FixedDiv2 (a,b); + if ((abs(a) >> 14) >= abs(b)) + { + return (a^b) < 0 ? INT_MIN : INT_MAX; + } + else + { + long long result; + + result = ((long long) a << 16) / b; + + return (fixed_t) result; + } } - - -fixed_t -FixedDiv2 -( fixed_t a, - fixed_t b ) -{ -#if 0 - long long c; - c = ((long long)a<<16) / ((long long)b); - return (fixed_t) c; -#endif - - double c; - - c = ((double)a) / ((double)b) * FRACUNIT; - - if (c >= 2147483648.0 || c < -2147483648.0) - I_Error("FixedDiv: divide by zero"); - return (fixed_t) c; -} diff --git a/src/m_fixed.h b/src/m_fixed.h index 6a676c31..56a716d4 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -41,7 +41,6 @@ typedef int fixed_t; fixed_t FixedMul (fixed_t a, fixed_t b); fixed_t FixedDiv (fixed_t a, fixed_t b); -fixed_t FixedDiv2 (fixed_t a, fixed_t b); -- cgit v1.2.3