summaryrefslogtreecommitdiff
path: root/src/tables.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tables.c')
-rw-r--r--src/tables.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/tables.c b/src/tables.c
index ffafeb7e..543fda8c 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -38,33 +38,37 @@
//
//-----------------------------------------------------------------------------
-
-
-
-
#include "tables.h"
+// to get a global angle from cartesian coordinates, the coordinates are
+// flipped until they are in the first octant of the coordinate system, then
+// the y (<=x) is scaled and divided by x to get a tangent (slope) value
+// which is looked up in the tantoangle[] table. The +1 size is to handle
+// the case when x==y without additional checking.
-
-
-int
-SlopeDiv
-( unsigned num,
- unsigned den)
+int SlopeDiv(unsigned int num, unsigned int den)
{
- unsigned ans;
+ unsigned ans;
if (den < 512)
- return SLOPERANGE;
+ {
+ return SLOPERANGE;
+ }
+ else
+ {
+ ans = (num << 3) / (den >> 8);
- ans = (num<<3)/(den>>8);
-
- return ans <= SLOPERANGE ? ans : SLOPERANGE;
+ if (ans <= SLOPERANGE)
+ {
+ return ans;
+ }
+ else
+ {
+ return SLOPERANGE;
+ }
+ }
}
-
-
-
const int finetangent[4096] =
{
-170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683,
@@ -1866,7 +1870,7 @@ const int finesine[10240] =
65534,65535,65535,65535,65535,65535,65535,65535
};
-
+const fixed_t *finecosine = &finesine[FINEANGLES/4];
const angle_t tantoangle[2049] =
{