summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-11-25 19:45:02 +0000
committerSimon Howard2006-11-25 19:45:02 +0000
commit9815f0f2325ec973c899db766faed87cac49e64d (patch)
tree404cd2572d52a651ca07dd70266ca327e5452eaa
parent610494610ac10d0e21d680d0fb7a5802ed6ce2b3 (diff)
downloadchocolate-doom-9815f0f2325ec973c899db766faed87cac49e64d.tar.gz
chocolate-doom-9815f0f2325ec973c899db766faed87cac49e64d.tar.bz2
chocolate-doom-9815f0f2325ec973c899db766faed87cac49e64d.zip
Remove FixedDiv2; use actual fixed point version of FixedDiv (wtf?)
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 758
-rw-r--r--src/m_fixed.c41
-rw-r--r--src/m_fixed.h1
2 files changed, 13 insertions, 29 deletions
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);