aboutsummaryrefslogtreecommitdiff
path: root/src/tables.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tables.h')
-rw-r--r--src/tables.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/tables.h b/src/tables.h
new file mode 100644
index 0000000..bbb4a27
--- /dev/null
+++ b/src/tables.h
@@ -0,0 +1,93 @@
1/* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 * DESCRIPTION:
30 * Lookup tables.
31 * Do not try to look them up :-).
32 * In the order of appearance:
33 *
34 * int finetangent[4096] - Tangens LUT.
35 * Should work with BAM fairly well (12 of 16bit,
36 * effectively, by shifting).
37 *
38 * int finesine[10240] - Sine lookup.
39 * Guess what, serves as cosine, too.
40 * Remarkable thing is, how to use BAMs with this?
41 *
42 * int tantoangle[2049] - ArcTan LUT,
43 * maps tan(angle) to angle fast. Gotta search.
44 *
45 *-----------------------------------------------------------------------------*/
46
47#ifndef __TABLES__
48#define __TABLES__
49
50#include "m_fixed.h"
51
52#define FINEANGLES 8192
53#define FINEMASK (FINEANGLES-1)
54
55// 0x100000000 to 0x2000
56#define ANGLETOFINESHIFT 19
57
58// Binary Angle Measument, BAM.
59#define ANG45 0x20000000
60#define ANG90 0x40000000
61#define ANG180 0x80000000
62#define ANG270 0xc0000000
63#ifndef M_PI
64#define M_PI 3.14159265358979323846
65#endif
66
67#define SLOPERANGE 2048
68#define SLOPEBITS 11
69#define DBITS (FRACBITS-SLOPEBITS)
70
71typedef unsigned angle_t;
72
73// Load trig tables if needed
74void R_LoadTrigTables(void);
75
76// Effective size is 10240.
77extern fixed_t finesine[5*FINEANGLES/4];
78
79// Re-use data, is just PI/2 phase shift.
80static fixed_t *const finecosine = finesine + (FINEANGLES/4);
81
82// Effective size is 4096.
83extern fixed_t finetangent[FINEANGLES/2];
84
85// Effective size is 2049;
86// The +1 size is to handle the case when x==y without additional checking.
87
88extern angle_t tantoangle[SLOPERANGE+1];
89
90// Utility function, called by R_PointToAngle.
91int SlopeDiv(unsigned num, unsigned den);
92
93#endif