shithub: riscv

Download patch

ref: 66f76c28212d3a25d4b039de2ce817fc74c5ca1e
parent: 17d932eca9cb6b5ec1acbb4d27d782b72cdbf806
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun May 11 16:24:27 EDT 2014

doom: get rid of floating point code for division

--- a/sys/src/games/doom/m_fixed.c
+++ b/sys/src/games/doom/m_fixed.c
@@ -60,21 +60,5 @@
 {
     if ( (abs(a)>>14) >= abs(b))
 	return (a^b)<0 ? MININT : MAXINT;
-    return FixedDiv2 (a,b);
-}
-
-
-
-fixed_t
-FixedDiv2
-( fixed_t	a,
-  fixed_t	b )
-{
-    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 ((long long)a << FRACBITS) / (long long)b;
 }
--- a/sys/src/games/doom/m_fixed.h
+++ b/sys/src/games/doom/m_fixed.h
@@ -39,7 +39,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);