Prepare new maemo release
[maemo-rb.git] / apps / plugins / doom / tables.h
blobf9ec4381ee35fcc4973c27cf5e2357f26138337c
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
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
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * Lookup tables.
29 * Do not try to look them up :-).
30 * In the order of appearance:
32 * int finetangent[4096] - Tangens LUT.
33 * Should work with BAM fairly well (12 of 16bit,
34 * effectively, by shifting).
36 * int finesine[10240] - Sine lookup.
37 * Guess what, serves as cosine, too.
38 * Remarkable thing is, how to use BAMs with this?
40 * int tantoangle[2049] - ArcTan LUT,
41 * maps tan(angle) to angle fast. Gotta search.
43 *-----------------------------------------------------------------------------*/
45 #ifndef __TABLES__
46 #define __TABLES__
48 #include "m_fixed.h"
49 #include "rockmacros.h"
51 #define FINEANGLES 8192
52 #define FINEMASK (FINEANGLES-1)
54 // 0x100000000 to 0x2000
55 #define ANGLETOFINESHIFT 19
57 #ifndef ALL_IN_ONE
59 // TABLES_AS_LUMPS causes the tables to be loaded from a wad lump, and the normal
60 // data to be stored as a predefined lump.
61 // Only really useful for dumping the trig tables or with NO_PREDEFINED_LUMPS
62 #define TABLES_AS_LUMPS
63 #endif
65 // Binary Angle Measument, BAM.
66 #define ANG45 0x20000000
67 #define ANG90 0x40000000
68 #define ANG180 0x80000000
69 #define ANG270 0xc0000000
71 #define SLOPERANGE 2048
72 #define SLOPEBITS 11
73 #define DBITS (FRACBITS-SLOPEBITS)
75 typedef unsigned angle_t;
77 // Load trig tables if needed
78 #ifdef TABLES_AS_LUMPS
79 void R_LoadTrigTables(void);
80 #define TRIG_CONST
81 #else
82 #define TRIG_CONST const
83 #endif
85 // Effective size is 10240.
86 extern TRIG_CONST fixed_t *finesine;
88 // Re-use data, is just PI/2 phase shift.
89 extern TRIG_CONST fixed_t *finecosine;
91 // Effective size is 4096.
92 extern TRIG_CONST fixed_t *finetangent;
94 // Effective size is 2049;
95 // The +1 size is to handle the case when x==y without additional checking.
97 extern TRIG_CONST angle_t *tantoangle;
99 // Utility function, called by R_PointToAngle.
100 int SlopeDiv(unsigned num, unsigned den);
102 #undef TRIG_CONST
103 #endif