shithub: choc

Download patch

ref: 9815f0f2325ec973c899db766faed87cac49e64d
parent: 610494610ac10d0e21d680d0fb7a5802ed6ce2b3
author: Simon Howard <fraggle@gmail.com>
date: Sat Nov 25 14:45:02 EST 2006

Remove FixedDiv2; use actual fixed point version of FixedDiv (wtf?)

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 758

--- a/src/m_fixed.c
+++ b/src/m_fixed.c
@@ -52,34 +52,19 @@
 // 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;
 
-
-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;
+	return (fixed_t) result;
+    }
 }
+
--- a/src/m_fixed.h
+++ b/src/m_fixed.h
@@ -41,7 +41,6 @@
 
 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);