diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19f7c9c197..84d6f06b93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1091,7 +1091,6 @@ set (PCH_SOURCES statistics.cpp stats.cpp stringtable.cpp - tables.cpp teaminfo.cpp tempfiles.cpp v_blend.cpp diff --git a/src/actor.h b/src/actor.h index 37815ba3c6..0336c41857 100644 --- a/src/actor.h +++ b/src/actor.h @@ -24,7 +24,6 @@ #define __P_MOBJ_H__ // Basics. -#include "tables.h" #include "templates.h" // We need the thinker_t stuff. diff --git a/src/b_bot.h b/src/b_bot.h index 9f9fe55ba0..f9085d6fb4 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -8,7 +8,6 @@ #define __B_BOT_H__ #include "c_cvars.h" -#include "tables.h" #include "info.h" #include "doomdef.h" #include "d_ticcmd.h" diff --git a/src/basictypes.h b/src/basictypes.h index 7816fa557d..ff2cd972e6 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -72,6 +72,14 @@ typedef DWORD dsfixed_t; // fixedpt used by span drawer #define DWORD_MIN ((uint32)0) #define DWORD_MAX ((uint32)0xffffffff) +// the last remnants of tables.h +#define ANGLE_90 (0x40000000) +#define ANGLE_180 (0x80000000) +#define ANGLE_270 (0xc0000000) +#define ANGLE_MAX (0xffffffff) + +typedef uint32 angle_t; + #ifdef __GNUC__ #define GCCPRINTF(stri,firstargi) __attribute__((format(printf,stri,firstargi))) diff --git a/src/p_effect.h b/src/p_effect.h index 8ae2723297..033bf042c9 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -32,7 +32,6 @@ */ #include "vectors.h" -#include "tables.h" #define FX_ROCKET 0x00000001 #define FX_GRENADE 0x00000002 diff --git a/src/p_enemy.h b/src/p_enemy.h index 9e6b03b726..298c60725b 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -2,7 +2,6 @@ #define __P_ENEMY_H__ #include "thingdef/thingdef.h" -#include "tables.h" struct sector_t; class AActor; diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 94c294d2aa..3f2b06f951 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -28,7 +28,6 @@ #include "s_sndseq.h" #include "doomstat.h" #include "r_state.h" -#include "tables.h" #include "farchive.h" #include "p_3dmidtex.h" #include "p_spec.h" diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 2e6acd8568..2f3052203d 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -40,7 +40,6 @@ #include "p_enemy.h" #include "g_level.h" #include "v_palette.h" -#include "tables.h" #include "i_system.h" #include "a_sharedglobal.h" #include "a_lightning.h" diff --git a/src/p_local.h b/src/p_local.h index 1a89154956..ac92ad7b70 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -25,7 +25,6 @@ #include #include "doomtype.h" -#include "tables.h" #include "vectors.h" const double NO_VALUE = FLT_MAX; diff --git a/src/p_pspr.h b/src/p_pspr.h index 27f1778f37..397ac4fff4 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -25,7 +25,6 @@ // Basic data types. // Needs fixed point, and BAM angles. -#include "tables.h" #include "thingdef/thingdef.h" #define WEAPONBOTTOM 128. diff --git a/src/p_things.cpp b/src/p_things.cpp index 4afc5deaf3..ba1b29a1a3 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -36,7 +36,6 @@ #include "p_local.h" #include "info.h" #include "s_sound.h" -#include "tables.h" #include "doomstat.h" #include "m_random.h" #include "c_console.h" diff --git a/src/p_udmf.h b/src/p_udmf.h index 9e7bce5e22..919f6e7314 100644 --- a/src/p_udmf.h +++ b/src/p_udmf.h @@ -3,7 +3,6 @@ #include "sc_man.h" #include "m_fixed.h" -#include "tables.h" class UDMFParserBase { diff --git a/src/po_man.cpp b/src/po_man.cpp index d2faa6690f..1f9c6dbfd3 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -18,7 +18,6 @@ #include "w_wad.h" #include "m_swap.h" #include "m_bbox.h" -#include "tables.h" #include "s_sndseq.h" #include "a_sharedglobal.h" #include "p_3dmidtex.h" diff --git a/src/r_local.h b/src/r_local.h index 7977e69237..b0ba8841ee 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -24,7 +24,6 @@ #define __R_LOCAL_H__ // Binary Angles, sine/cosine/atan lookups. -#include "tables.h" // Screen size related parameters. #include "doomdef.h" diff --git a/src/r_main.cpp b/src/r_main.cpp index 5eb2e44f80..518eaec7f3 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -175,7 +175,7 @@ static int lastcenteryfrac; static inline int viewangletox(int i) { - const double pimul = M_PI * 2 / FINEANGLES; + const double pimul = M_PI / 4096; // Don't waste time calculating the tangent of values outside the valid range. // Checking the index where tan(i) becomes too large is a lot faster @@ -188,7 +188,7 @@ static inline int viewangletox(int i) return -1; } - double t = tan((i - FINEANGLES / 4)*pimul) * FocalLengthX; + double t = tan((i - 2048)*pimul) * FocalLengthX; return clamp(xs_CeilToInt(CenterX - t), -1, viewwidth+1); } @@ -230,7 +230,7 @@ void R_InitTextureMapping () { ++i; } - xtoviewangle[x] = (i << ANGLETOFINESHIFT) - ANGLE_90; + xtoviewangle[x] = (i << 19) - ANGLE_90; } for (x = t2 + 1; x <= viewwidth; ++x) { diff --git a/src/r_utility.cpp b/src/r_utility.cpp index c145998b72..701a3cffd3 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -157,35 +157,6 @@ DAngle viewpitch; // CODE -------------------------------------------------------------------- static void R_Shutdown (); -//========================================================================== -// -// R_InitTables -// -//========================================================================== - -void R_InitTables (void) -{ - int i; - const double pimul = M_PI*2/FINEANGLES; - - // finesine table - for (i = 0; i < FINEANGLES/4; i++) - { - finesine[i] = (fixed_t)(FRACUNIT * g_sin (i*pimul)); - } - for (i = 0; i < FINEANGLES/4; i++) - { - finesine[i+FINEANGLES/4] = finesine[FINEANGLES/4-1-i]; - } - for (i = 0; i < FINEANGLES/2; i++) - { - finesine[i+FINEANGLES/2] = -finesine[i]; - } - finesine[FINEANGLES/4] = FRACUNIT; - finesine[FINEANGLES*3/4] = -FRACUNIT; - memcpy (&finesine[FINEANGLES], &finesine[0], sizeof(angle_t)*FINEANGLES/4); -} - //========================================================================== // // R_SetFOV @@ -364,7 +335,6 @@ void R_Init () //R_InitColormaps (); //StartScreen->Progress(); - R_InitTables (); R_InitTranslationTables (); R_SetViewSize (screenblocks); Renderer->Init(); diff --git a/src/tables.cpp b/src/tables.cpp deleted file mode 100644 index 9a88a9715b..0000000000 --- a/src/tables.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id:$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This source is available for distribution and/or modification -// only under the terms of the DOOM Source Code License as -// published by id Software. All rights reserved. -// -// The source is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License -// for more details. -// -// DESCRIPTION: -// Lookup tables. -// Do not try to look them up :-). -// In the order of appearance: -// -// int finesine[10240] - Sine lookup. -// Guess what, serves as cosine, too. -// Remarkable thing is, how to use BAMs with this? -// -// -//----------------------------------------------------------------------------- - -#include "tables.h" - -fixed_t finesine[10240]; - diff --git a/src/tables.h b/src/tables.h deleted file mode 100644 index 1b2868a542..0000000000 --- a/src/tables.h +++ /dev/null @@ -1,54 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id:$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This source is available for distribution and/or modification -// only under the terms of the DOOM Source Code License as -// published by id Software. All rights reserved. -// -// The source is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License -// for more details. -// -// DESCRIPTION: -// Lookup tables. -// Do not try to look them up :-). -// In the order of appearance: -// -// int finesine[10240] - Sine lookup. -// Remarkable thing is, how to use BAMs with this? -// -// -//----------------------------------------------------------------------------- - - -#ifndef __TABLES_H__ -#define __TABLES_H__ - -#include -#include -#include "basictypes.h" - -#define FINEANGLES 8192 -#define FINEMASK (FINEANGLES-1) - -// 0x100000000 to 0x2000 -#define ANGLETOFINESHIFT 19 - -// Effective size is 10240. -extern fixed_t finesine[5*FINEANGLES/4]; - -// Binary Angle Measument, BAM. -#define ANGLE_90 (0x40000000) -#define ANGLE_180 (0x80000000) -#define ANGLE_270 (0xc0000000) -#define ANGLE_MAX (0xffffffff) - - -typedef uint32 angle_t; - -#endif // __TABLES_H__ diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index b2c7164e2b..1147f51681 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -72,6 +72,10 @@ FTextureManager::FTextureManager () { memset (HashFirst, -1, sizeof(HashFirst)); + for (int i = 0; i < 2048; ++i) + { + sintable[i] = short(sin(i*(M_PI / 1024)) * 16384); + } } //========================================================================== diff --git a/src/textures/textures.h b/src/textures/textures.h index 318e32644f..23b66972da 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -446,6 +446,12 @@ private: TArray mSwitchDefs; TArray mAnimatedDoors; TArray BuildTileFiles; +public: + short sintable[2048]; // for texture warping + enum + { + SINMASK = 2047 + }; }; // A texture that doesn't really exist @@ -483,7 +489,7 @@ protected: BYTE *Pixels; Span **Spans; float Speed; - int WidthOffsetMultipiler, HeightOffsetMultipiler; // [mxd] + int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] virtual void MakeTexture (DWORD time); int NextPo2 (int v); // [mxd] diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 4f166f24fe..5ffd9138a1 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -120,9 +120,9 @@ const BYTE *FWarpTexture::GetColumn (unsigned int column, const Span **spans_out return Pixels + column*Height; } -void FWarpTexture::MakeTexture (DWORD time) +void FWarpTexture::MakeTexture(DWORD time) { - const BYTE *otherpix = SourcePic->GetPixels (); + const BYTE *otherpix = SourcePic->GetPixels(); if (Pixels == NULL) { @@ -130,17 +130,17 @@ void FWarpTexture::MakeTexture (DWORD time) } if (Spans != NULL) { - FreeSpans (Spans); + FreeSpans(Spans); Spans = NULL; } GenTime = time; - BYTE *buffer = (BYTE *)alloca (MAX (Width, Height)); + BYTE *buffer = (BYTE *)alloca(MAX(Width, Height)); int xsize = Width; int ysize = Height; - int xmul = WidthOffsetMultipiler; // [mxd] - int ymul = HeightOffsetMultipiler; // [mxd] + int xmul = WidthOffsetMultiplier; // [mxd] + int ymul = HeightOffsetMultiplier; // [mxd] int xmask = WidthMask; int ymask = Height - 1; int ybits = HeightBits; @@ -153,39 +153,39 @@ void FWarpTexture::MakeTexture (DWORD time) DWORD timebase = DWORD(time * Speed * 32 / 28); // [mxd] Rewrote to fix animation for NPo2 textures - for (y = ysize-1; y >= 0; y--) + for (y = ysize - 1; y >= 0; y--) { - int xf = (finesine[(timebase+y*ymul)&FINEMASK]>>13) % xsize; - if(xf < 0) xf += xsize; + int xf = (TexMan.sintable[((timebase + y*ymul) >> 2)&TexMan.SINMASK] >> 11) % xsize; + if (xf < 0) xf += xsize; int xt = xf; const BYTE *source = otherpix + y; BYTE *dest = Pixels + y; - for (xt = xsize; xt; xt--, xf = (xf+1)%xsize, dest += ysize) + for (xt = xsize; xt; xt--, xf = (xf + 1) % xsize, dest += ysize) *dest = source[xf + ymask * xf]; } timebase = DWORD(time * Speed * 23 / 28); - for (x = xsize-1; x >= 0; x--) + for (x = xsize - 1; x >= 0; x--) { - int yf = (finesine[(time+(x+17)*xmul)&FINEMASK]>>13) % ysize; - if(yf < 0) yf += ysize; + int yf = (TexMan.sintable[((time + (x + 17)*xmul) >> 2)&TexMan.SINMASK] >> 11) % ysize; + if (yf < 0) yf += ysize; int yt = yf; const BYTE *source = Pixels + (x + ymask * x); BYTE *dest = buffer; - for (yt = ysize; yt; yt--, yf = (yf+1)%ysize) + for (yt = ysize; yt; yt--, yf = (yf + 1) % ysize) *dest++ = source[yf]; - memcpy (Pixels+(x+ymask*x), buffer, ysize); + memcpy(Pixels + (x + ymask*x), buffer, ysize); } } // [mxd] Non power of 2 textures need different offset multipliers, otherwise warp animation won't sync across texture void FWarpTexture::SetupMultipliers (int width, int height) { - WidthOffsetMultipiler = width; - HeightOffsetMultipiler = height; + WidthOffsetMultiplier = width; + HeightOffsetMultiplier = height; int widthpo2 = NextPo2(Width); int heightpo2 = NextPo2(Height); - if(widthpo2 != Width) WidthOffsetMultipiler = (int)(WidthOffsetMultipiler * ((float)widthpo2 / Width)); - if(heightpo2 != Height) HeightOffsetMultipiler = (int)(HeightOffsetMultipiler * ((float)heightpo2 / Height)); + if(widthpo2 != Width) WidthOffsetMultiplier = (int)(WidthOffsetMultiplier * ((float)widthpo2 / Width)); + if(heightpo2 != Height) HeightOffsetMultiplier = (int)(HeightOffsetMultiplier * ((float)heightpo2 / Height)); } int FWarpTexture::NextPo2 (int v) @@ -225,8 +225,8 @@ void FWarp2Texture::MakeTexture (DWORD time) int xsize = Width; int ysize = Height; - int xmul = WidthOffsetMultipiler; // [mxd] - int ymul = HeightOffsetMultipiler; // [mxd] + int xmul = WidthOffsetMultiplier; // [mxd] + int ymul = HeightOffsetMultiplier; // [mxd] int xmask = WidthMask; int ymask = Height - 1; int ybits = HeightBits; @@ -245,12 +245,12 @@ void FWarp2Texture::MakeTexture (DWORD time) for (y = 0; y < ysize; y++) { int xt = (x + 128 - + ((finesine[(y*ymul + timebase*5 + 900) & FINEMASK]*2)>>FRACBITS) - + ((finesine[(x*xmul + timebase*4 + 300) & FINEMASK]*2)>>FRACBITS)) % xsize; + + ((TexMan.sintable[((y*ymul + timebase*5 + 900) >> 2) & TexMan.SINMASK])>>13) + + ((TexMan.sintable[((x*xmul + timebase*4 + 300) >> 2) & TexMan.SINMASK])>>13)) % xsize; int yt = (y + 128 - + ((finesine[(y*ymul + timebase*3 + 700) & FINEMASK]*2)>>FRACBITS) - + ((finesine[(x*xmul + timebase*4 + 1200) & FINEMASK]*2)>>FRACBITS)) % ysize; + + ((TexMan.sintable[((y*ymul + timebase*3 + 700) >> 2) & TexMan.SINMASK])>>13) + + ((TexMan.sintable[((x*xmul + timebase*4 + 1200) >> 2) & TexMan.SINMASK])>>13)) % ysize; *dest++ = otherpix[(xt + ymask * xt) + yt]; }