tables.h
1 // 2 // Copyright(C) 1993-1996 Id Software, Inc. 3 // Copyright(C) 1993-2008 Raven Software 4 // Copyright(C) 2005-2014 Simon Howard 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // DESCRIPTION: 17 // Lookup tables. 18 // Do not try to look them up :-). 19 // In the order of appearance: 20 // 21 // int finetangent[4096] - Tangens LUT. 22 // Should work with BAM fairly well (12 of 16bit, 23 // effectively, by shifting). 24 // 25 // int finesine[10240] - Sine lookup. 26 // Guess what, serves as cosine, too. 27 // Remarkable thing is, how to use BAMs with this? 28 // 29 // int tantoangle[2049] - ArcTan LUT, 30 // maps tan(angle) to angle fast. Gotta search. 31 // 32 33 34 #ifndef __TABLES__ 35 #define __TABLES__ 36 37 #include "doomtype.h" 38 39 #include "m_fixed.h" 40 41 #define FINEANGLES 8192 42 #define FINEMASK (FINEANGLES-1) 43 44 45 // 0x100000000 to 0x2000 46 #define ANGLETOFINESHIFT 19 47 48 // Effective size is 10240. 49 extern const fixed_t finesine[5*FINEANGLES/4]; 50 51 // Re-use data, is just PI/2 pahse shift. 52 extern const fixed_t *finecosine; 53 54 55 // Effective size is 4096. 56 extern const fixed_t finetangent[FINEANGLES/2]; 57 58 // Gamma correction tables. 59 extern const byte gammatable[5][256]; 60 61 // Binary Angle Measument, BAM. 62 63 #define ANG45 0x20000000 64 #define ANG90 0x40000000 65 #define ANG180 0x80000000 66 #define ANG270 0xc0000000 67 #define ANG_MAX 0xffffffff 68 69 #define ANG1 (ANG45 / 45) 70 #define ANG60 (ANG180 / 3) 71 72 // Heretic code uses this definition as though it represents one 73 // degree, but it is not! This is actually ~1.40 degrees. 74 75 #define ANG1_X 0x01000000 76 77 #define SLOPERANGE 2048 78 #define SLOPEBITS 11 79 #define DBITS (FRACBITS-SLOPEBITS) 80 81 typedef unsigned angle_t; 82 83 84 // Effective size is 2049; 85 // The +1 size is to handle the case when x==y 86 // without additional checking. 87 extern const angle_t tantoangle[SLOPERANGE+1]; 88 89 90 // Utility function, 91 // called by R_PointToAngle. 92 int SlopeDiv(unsigned int num, unsigned int den); 93 94 95 #endif 96