tables.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef __TABLES__
  47. #define __TABLES__
  48. #include "m_fixed.h"
  49. #define FINEANGLES 8192
  50. #define FINEMASK (FINEANGLES-1)
  51. // 0x100000000 to 0x2000
  52. #define ANGLETOFINESHIFT 19
  53. // Binary Angle Measument, BAM.
  54. #define ANG45 0x20000000
  55. #define ANG90 0x40000000
  56. #define ANG180 0x80000000
  57. #define ANG270 0xc0000000
  58. #ifndef M_PI
  59. #define M_PI 3.14159265358979323846
  60. #endif
  61. #define SLOPERANGE 2048
  62. #define SLOPEBITS 11
  63. #define DBITS (FRACBITS-SLOPEBITS)
  64. typedef unsigned angle_t;
  65. // Load trig tables if needed
  66. void R_LoadTrigTables(void);
  67. // Effective size is 10240.
  68. extern fixed_t finesine[5*FINEANGLES/4];
  69. // Re-use data, is just PI/2 phase shift.
  70. static fixed_t *const finecosine = finesine + (FINEANGLES/4);
  71. // Effective size is 4096.
  72. extern fixed_t finetangent[FINEANGLES/2];
  73. // Effective size is 2049;
  74. // The +1 size is to handle the case when x==y without additional checking.
  75. extern angle_t tantoangle[SLOPERANGE+1];
  76. // Utility function, called by R_PointToAngle.
  77. int SlopeDiv(unsigned num, unsigned den);
  78. #endif