shithub: choc

Download patch

ref: bf5e84859e2aca7f543f88a4a93bb971332aa989
parent: fde2f7883fbd50ea4b56c0cc35f15161ff3ab649
author: Simon Howard <fraggle@gmail.com>
date: Wed Oct 1 13:31:28 EDT 2008

Merge Hexen fixed_t and angle definitions to common code, plus byte
swapping macros, bounding box checking, read/write file, screenshot and
command line argument code. Update Heretic code to use ANG1_X rather
than the new (correct) ANG1 definition.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1311

--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -1245,7 +1245,7 @@
 
 void A_MummyFX1Seek(mobj_t * actor)
 {
-    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 20);
+    P_SeekerMissile(actor, ANG1_X * 10, ANG1_X * 20);
 }
 
 //----------------------------------------------------------------------------
@@ -1326,8 +1326,8 @@
         {
             momz = mo->momz;
             angle = mo->angle;
-            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle - ANG1 * 3, momz);
-            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle + ANG1 * 3, momz);
+            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle - ANG1_X * 3, momz);
+            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle + ANG1_X * 3, momz);
         }
         if (actor->health < actor->info->spawnhealth / 3)
         {                       // Maybe attack again
@@ -1892,7 +1892,7 @@
     {
         return;
     }
-    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 30);
+    P_SeekerMissile(actor, ANG1_X * 10, ANG1_X * 30);
 }
 
 //----------------------------------------------------------------------------
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -1465,7 +1465,7 @@
 
 void A_SkullRodPL2Seek(mobj_t * actor)
 {
-    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 30);
+    P_SeekerMissile(actor, ANG1_X * 10, ANG1_X * 30);
 }
 
 //----------------------------------------------------------------------------
@@ -1634,7 +1634,7 @@
     mobj_t *puff;
     angle_t angle;
 
-    P_SeekerMissile(actor, ANG1 * 5, ANG1 * 10);
+    P_SeekerMissile(actor, ANG1_X * 5, ANG1_X * 10);
     puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF);
     angle = actor->angle + ANG90;
     angle >>= ANGLETOFINESHIFT;
--- a/src/hexen/Makefile.am
+++ b/src/hexen/Makefile.am
@@ -1,3 +1,4 @@
+AM_CFLAGS=-I.. @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
 
 noinst_LIBRARIES=libhexen.a
 
@@ -64,4 +65,3 @@
 i_sound.c           i_sound.h
 
 libhexen_a_SOURCES=$(SOURCE_FILES)
-libhexen_a_CFLAGS=-I..
--- a/src/hexen/a_action.c
+++ b/src/hexen/a_action.c
@@ -206,7 +206,7 @@
         if (P_CheckSight(actor, pmo) && (abs(R_PointToAngle2(pmo->x,
                                                              pmo->y, actor->x,
                                                              actor->y) -
-                                             pmo->angle) <= ANGLE_45))
+                                             pmo->angle) <= ANG45))
         {                       // Previous state (pottery bit waiting state)
             P_SetMobjState(actor, actor->state - &states[0] - 1);
         }
@@ -228,7 +228,7 @@
                                                                  pmo->y,
                                                                  actor->x,
                                                                  actor->y) -
-                                                 pmo->angle) <= ANGLE_45))
+                                                 pmo->angle) <= ANG45))
             {                   // Previous state (pottery bit waiting state)
                 P_SetMobjState(actor, actor->state - &states[0] - 1);
                 return;
@@ -925,7 +925,7 @@
                     P_DamageMobj(victim, NULL, NULL, HITDICE(1));
                 }
                 // Thrust player around
-                an = victim->angle + ANGLE_1 * P_Random();
+                an = victim->angle + ANG1 * P_Random();
                 P_ThrustMobj(victim, an, richters << (FRACBITS - 1));
             }
         }
@@ -1292,11 +1292,11 @@
 
     if (P_Random() < 128)
     {
-        newangle = actor->angle + ANGLE_1 * actor->args[4];
+        newangle = actor->angle + ANG1 * actor->args[4];
     }
     else
     {
-        newangle = actor->angle - ANGLE_1 * actor->args[4];
+        newangle = actor->angle - ANG1 * actor->args[4];
     }
 
     // Adjust momentum vector to new direction
--- a/src/hexen/am_map.c
+++ b/src/hexen/am_map.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_swap.h"
 #include "p_local.h"
 #include "am_map.h"
 #include "am_data.h"
--- a/src/hexen/d_net.c
+++ b/src/hexen/d_net.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_argv.h"
 #include "p_local.h"
 #include <stdlib.h>             // for atoi()
 
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -24,6 +24,7 @@
 
 #include <string.h>
 #include "h2def.h"
+#include "m_misc.h"
 #include "p_local.h"
 #include "soundst.h"
 
@@ -1024,7 +1025,8 @@
                 G_DoPlayDemo();
                 break;
             case ga_screenshot:
-                M_ScreenShot();
+                V_ScreenShot("HEXEN%02i.pcx");
+                P_SetMessage(&players[consoleplayer], "SCREEN SHOT", false);
                 gameaction = ga_nothing;
                 break;
             case ga_leavemap:
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include "h2def.h"
+#include "m_argv.h"
 #include "p_local.h"
 #include "soundst.h"
 
@@ -833,22 +834,6 @@
 }
 */
 #endif
-
-//==========================================================================
-//
-// FixedDiv
-//
-//==========================================================================
-
-fixed_t FixedDiv(fixed_t a, fixed_t b)
-{
-    if ((abs(a) >> 14) >= abs(b))
-    {
-        return ((a ^ b) < 0 ? INT_MIN : INT_MAX);
-    }
-    return (FixedDiv2(a, b));
-}
-
 
 //==========================================================================
 //
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -36,6 +36,14 @@
 #define	strncasecmp strnicmp
 #endif
 
+// for fixed_t:
+
+#include "m_fixed.h"
+
+// angle definitions:
+
+#include "tables.h"
+
 #define VERSION 110
 #define VERSION_TEXT "v1.1"
 
@@ -140,27 +148,8 @@
 #define MINIMUM_HEAP_SIZE	0x800000        //  8 meg
 #define MAXIMUM_HEAP_SIZE	0x2000000       // 32 meg
 
-#define	FRACBITS		16
-#define	FRACUNIT		(1<<FRACBITS)
-typedef int fixed_t;
-
 typedef unsigned int uint;
 
-//#define ANGLE_1               0x01000000
-#define ANGLE_45	0x20000000
-#define ANGLE_90	0x40000000
-#define ANGLE_180	0x80000000
-#define ANGLE_MAX	0xffffffff
-#define ANGLE_1		(ANGLE_45/45)
-#define ANGLE_60	(ANGLE_180/3)
-
-#define	ANG45	0x20000000
-#define	ANG90	0x40000000
-#define	ANG180	0x80000000
-#define	ANG270	0xc0000000
-
-typedef unsigned angle_t;
-
 typedef enum
 {
     sk_baby,
@@ -745,9 +734,6 @@
 extern int eventhead;
 extern int eventtail;
 
-extern fixed_t finesine[5 * FINEANGLES / 4];
-extern fixed_t *finecosine;
-
 extern gameaction_t gameaction;
 
 extern boolean paused;
@@ -859,40 +845,6 @@
 ===============================================================================
 */
 
-
-fixed_t FixedMul(fixed_t a, fixed_t b);
-fixed_t FixedDiv(fixed_t a, fixed_t b);
-fixed_t FixedDiv2(fixed_t a, fixed_t b);
-
-#ifdef __WATCOMC__
-#pragma aux FixedMul =	\
-	"imul ebx",			\
-	"shrd eax,edx,16"	\
-	parm	[eax] [ebx] \
-	value	[eax]		\
-	modify exact [eax edx]
-
-#pragma aux FixedDiv2 =	\
-	"cdq",				\
-	"shld edx,eax,16",	\
-	"sal eax,16",		\
-	"idiv ebx"			\
-	parm	[eax] [ebx] \
-	value	[eax]		\
-	modify exact [eax edx]
-#endif
-
-#ifdef __BIG_ENDIAN__
-short ShortSwap(short);
-long LongSwap(long);
-#define SHORT(x)	ShortSwap(x)
-#define LONG(x)		LongSwap(x)
-#else
-#define SHORT(x)	(x)
-#define LONG(x)		(x)
-#endif
-
-
 #include "w_wad.h"
 #include "z_zone.h"
 
@@ -1171,14 +1123,8 @@
 //----
 //MISC
 //----
-extern int myargc;
-extern char **myargv;
 extern int localQuakeHappening[MAXPLAYERS];
 
-int M_CheckParm(char *check);
-// returns the position of the given parameter in the arg list (0 if not found)
-boolean M_ParmExists(char *check);
-
 void M_ExtractFileBase(char *path, char *dest);
 
 void M_ForceUppercase(char *text);
@@ -1195,20 +1141,7 @@
 void M_ClearRandom(void);
 // fix randoms for demos
 
-void M_FindResponseFile(void);
-
-void M_ClearBox(fixed_t * box);
-void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y);
-// bounding box functions
-
-boolean M_WriteFile(char const *name, void *source, int length);
-int M_ReadFile(char const *name, byte ** buffer);
-int M_ReadFileCLib(char const *name, byte ** buffer);
-
-void M_ScreenShot(void);
-
 void M_LoadDefaults(char *fileName);
-
 void M_SaveDefaults(void);
 
 int M_DrawText(int x, int y, boolean direct, char *string);
@@ -1220,7 +1153,6 @@
 void SC_Open(char *name);
 void SC_OpenLump(char *name);
 void SC_OpenFile(char *name);
-void SC_OpenFileCLib(char *name);
 void SC_Close(void);
 boolean SC_GetString(void);
 void SC_MustGetString(void);
--- a/src/hexen/i_ibm.c
+++ b/src/hexen/i_ibm.c
@@ -28,6 +28,7 @@
 #include <stdarg.h>
 #include <graph.h>
 #include "h2def.h"
+#include "m_argv.h"
 #include "r_local.h"
 #include "p_local.h"            // for P_AproxDistance
 #include "sounds.h"
--- a/src/hexen/i_sound.c
+++ b/src/hexen/i_sound.c
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include "h2def.h"
+#include "m_argv.h"
 #include "dmx.h"
 #include "sounds.h"
 #include "i_sound.h"
--- a/src/hexen/info.c
+++ b/src/hexen/info.c
@@ -21,6 +21,7 @@
 //
 //-----------------------------------------------------------------------------
 #include "h2def.h"
+#include "i_swap.h"
 // generated by stateco
 
 char *sprnames[NUMSPRITES] = {
--- a/src/hexen/m_misc.c
+++ b/src/hexen/m_misc.c
@@ -34,6 +34,7 @@
 #endif
 #include <ctype.h>
 #include "h2def.h"
+#include "m_argv.h"
 #include "p_local.h"
 #include "soundst.h"
 
@@ -50,16 +51,11 @@
 
 // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
 
-static int ReadFile(char const *name, byte ** buffer, int mallocType);
-
 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
 extern char *SavePath;
 
 // PUBLIC DATA DEFINITIONS -------------------------------------------------
 
-int myargc;
-char **myargv;
-
 // PRIVATE DATA DEFINITIONS ------------------------------------------------
 
 // CODE --------------------------------------------------------------------
@@ -66,43 +62,6 @@
 
 //==========================================================================
 //
-// M_CheckParm
-//
-// Checks for the given parameter in the program's command line arguments.
-// Returns the argument number (1 to argc-1) or 0 if not present.
-//
-//==========================================================================
-
-int M_CheckParm(char *check)
-{
-    int i;
-
-    for (i = 1; i < myargc; i++)
-    {
-        if (!strcasecmp(check, myargv[i]))
-        {
-            return i;
-        }
-    }
-    return 0;
-}
-
-//==========================================================================
-//
-// M_ParmExists
-//
-// Returns true if the given parameter exists in the program's command
-// line arguments, false if not.
-//
-//==========================================================================
-
-boolean M_ParmExists(char *check)
-{
-    return M_CheckParm(check) != 0 ? true : false;
-}
-
-//==========================================================================
-//
 // M_ExtractFileBase
 //
 //==========================================================================
@@ -185,208 +144,8 @@
     rndindex = prndindex = 0;
 }
 
-
-void M_ClearBox(fixed_t * box)
-{
-    box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
-    box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
-}
-
-void M_AddToBox(fixed_t * box, fixed_t x, fixed_t y)
-{
-    if (x < box[BOXLEFT])
-        box[BOXLEFT] = x;
-    else if (x > box[BOXRIGHT])
-        box[BOXRIGHT] = x;
-    if (y < box[BOXBOTTOM])
-        box[BOXBOTTOM] = y;
-    else if (y > box[BOXTOP])
-        box[BOXTOP] = y;
-}
-
-/*
-==================
-=
-= M_WriteFile
-=
-==================
-*/
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-boolean M_WriteFile(char const *name, void *source, int length)
-{
-    int handle, count;
-
-    handle = open(name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
-    if (handle == -1)
-        return false;
-    count = write(handle, source, length);
-    close(handle);
-
-    if (count < length)
-        return false;
-
-    return true;
-}
-
-//==========================================================================
-//
-// M_ReadFile
-//
-// Read a file into a buffer allocated using Z_Malloc().
-//
-//==========================================================================
-
-int M_ReadFile(char const *name, byte ** buffer)
-{
-    return ReadFile(name, buffer, MALLOC_ZONE);
-}
-
-//==========================================================================
-//
-// M_ReadFileCLib
-//
-// Read a file into a buffer allocated using malloc().
-//
-//==========================================================================
-
-int M_ReadFileCLib(char const *name, byte ** buffer)
-{
-    return ReadFile(name, buffer, MALLOC_CLIB);
-}
-
-//==========================================================================
-//
-// ReadFile
-//
-//==========================================================================
-
-static int ReadFile(char const *name, byte ** buffer, int mallocType)
-{
-    int handle, count, length;
-    struct stat fileinfo;
-    byte *buf;
-
-    handle = open(name, O_RDONLY | O_BINARY, 0666);
-    if (handle == -1)
-    {
-        I_Error("Couldn't read file %s", name);
-    }
-    if (fstat(handle, &fileinfo) == -1)
-    {
-        I_Error("Couldn't read file %s", name);
-    }
-    length = fileinfo.st_size;
-    if (mallocType == MALLOC_ZONE)
-    {                           // Use zone memory allocation
-        buf = Z_Malloc(length, PU_STATIC, NULL);
-    }
-    else
-    {                           // Use c library memory allocation
-        buf = malloc(length);
-        if (buf == NULL)
-        {
-            I_Error("Couldn't malloc buffer %d for file %s.", length, name);
-        }
-    }
-    count = read(handle, buf, length);
-    close(handle);
-    if (count < length)
-    {
-        I_Error("Couldn't read file %s", name);
-    }
-    *buffer = buf;
-    return length;
-}
-
 //---------------------------------------------------------------------------
 //
-// PROC M_FindResponseFile
-//
-//---------------------------------------------------------------------------
-
-#define MAXARGVS 100
-
-void M_FindResponseFile(void)
-{
-    int i;
-
-    for (i = 1; i < myargc; i++)
-    {
-        if (myargv[i][0] == '@')
-        {
-            FILE *handle;
-            int size;
-            int k;
-            int index;
-            int indexinfile;
-            char *infile;
-            char *file;
-            char *moreargs[20];
-            char *firstargv;
-
-            // READ THE RESPONSE FILE INTO MEMORY
-            handle = fopen(&myargv[i][1], "rb");
-            if (!handle)
-            {
-                printf("\nNo such response file!");
-                exit(1);
-            }
-            ST_Message("Found response file %s!\n", &myargv[i][1]);
-            fseek(handle, 0, SEEK_END);
-            size = ftell(handle);
-            fseek(handle, 0, SEEK_SET);
-            file = malloc(size);
-            fread(file, size, 1, handle);
-            fclose(handle);
-
-            // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
-            for (index = 0, k = i + 1; k < myargc; k++)
-                moreargs[index++] = myargv[k];
-
-            firstargv = myargv[0];
-            myargv = malloc(sizeof(char *) * MAXARGVS);
-            memset(myargv, 0, sizeof(char *) * MAXARGVS);
-            myargv[0] = firstargv;
-
-            infile = file;
-            indexinfile = k = 0;
-            indexinfile++;      // SKIP PAST ARGV[0] (KEEP IT)
-            do
-            {
-                myargv[indexinfile++] = infile + k;
-                while (k < size &&
-                       ((*(infile + k) >= ' ' + 1) && (*(infile + k) <= 'z')))
-                    k++;
-                *(infile + k) = 0;
-                while (k < size &&
-                       ((*(infile + k) <= ' ') || (*(infile + k) > 'z')))
-                    k++;
-            }
-            while (k < size);
-
-            for (k = 0; k < index; k++)
-                myargv[indexinfile++] = moreargs[k];
-            myargc = indexinfile;
-            // DISPLAY ARGS
-            if (M_CheckParm("-debug"))
-            {
-                ST_Message("%d command-line args:\n", myargc);
-                for (k = 1; k < myargc; k++)
-                {
-                    ST_Message("%s\n", myargv[k]);
-                }
-            }
-            break;
-        }
-    }
-}
-
-//---------------------------------------------------------------------------
-//
 // PROC M_ForceUppercase
 //
 // Change string to uppercase.
@@ -734,157 +493,3 @@
 #endif
 }
 
-/*
-==============================================================================
-
-						SCREEN SHOTS
-
-==============================================================================
-*/
-
-
-typedef struct
-{
-    char manufacturer;
-    char version;
-    char encoding;
-    char bits_per_pixel;
-    unsigned short xmin, ymin, xmax, ymax;
-    unsigned short hres, vres;
-    unsigned char palette[48];
-    char reserved;
-    char color_planes;
-    unsigned short bytes_per_line;
-    unsigned short palette_type;
-    char filler[58];
-    unsigned char data;         // unbounded
-} pcx_t;
-
-/*
-==============
-=
-= WritePCXfile
-=
-==============
-*/
-
-void WritePCXfile(char *filename, byte * data, int width, int height,
-                  byte * palette)
-{
-    int i, length;
-    pcx_t *pcx;
-    byte *pack;
-
-    pcx = Z_Malloc(width * height * 2 + 1000, PU_STATIC, NULL);
-
-    pcx->manufacturer = 0x0a;   // PCX id
-    pcx->version = 5;           // 256 color
-    pcx->encoding = 1;          // uncompressed
-    pcx->bits_per_pixel = 8;    // 256 color
-    pcx->xmin = 0;
-    pcx->ymin = 0;
-    pcx->xmax = SHORT(width - 1);
-    pcx->ymax = SHORT(height - 1);
-    pcx->hres = SHORT(width);
-    pcx->vres = SHORT(height);
-    memset(pcx->palette, 0, sizeof(pcx->palette));
-    pcx->color_planes = 1;      // chunky image
-    pcx->bytes_per_line = SHORT(width);
-    pcx->palette_type = SHORT(2);       // not a grey scale
-    memset(pcx->filler, 0, sizeof(pcx->filler));
-
-//
-// pack the image
-//
-    pack = &pcx->data;
-
-    for (i = 0; i < width * height; i++)
-        if ((*data & 0xc0) != 0xc0)
-            *pack++ = *data++;
-        else
-        {
-            *pack++ = 0xc1;
-            *pack++ = *data++;
-        }
-
-//
-// write the palette
-//
-    *pack++ = 0x0c;             // palette ID byte
-    for (i = 0; i < 768; i++)
-        *pack++ = *palette++;
-
-//
-// write output file
-//
-    length = pack - (byte *) pcx;
-    M_WriteFile(filename, pcx, length);
-
-    Z_Free(pcx);
-}
-
-
-//==============================================================================
-
-/*
-==================
-=
-= M_ScreenShot
-=
-==================
-*/
-
-void M_ScreenShot(void)
-{
-    int i;
-    byte *linear;
-    char lbmname[12];
-    byte *pal;
-
-#ifdef _WATCOMC_
-    extern byte *pcscreen;
-#endif
-//
-// munge planar buffer to linear
-//
-#ifdef _WATCOMC_
-    linear = pcscreen;
-#else
-    linear = screen;
-#endif
-//
-// find a file name to save it to
-//
-    strcpy(lbmname, "HEXEN00.pcx");
-
-    for (i = 0; i <= 99; i++)
-    {
-        lbmname[5] = i / 10 + '0';
-        lbmname[6] = i % 10 + '0';
-        if (access(lbmname, 0) == -1)
-            break;              // file doesn't exist
-    }
-    if (i == 100)
-        I_Error("M_ScreenShot: Couldn't create a PCX");
-
-//
-// save the pcx file
-//
-#ifdef __WATCOMC__
-    pal = (byte *) Z_Malloc(768, PU_STATIC, NULL);
-    outp(0x3c7, 0);
-    for (i = 0; i < 768; i++)
-    {
-        *(pal + i) = inp(0x3c9) << 2;
-    }
-#else
-    pal = (byte *) W_CacheLumpName("PLAYPAL", PU_CACHE);
-#endif
-
-    WritePCXfile(lbmname, linear, SCREENWIDTH, SCREENHEIGHT, pal);
-
-    P_SetMessage(&players[consoleplayer], "SCREEN SHOT", false);
-#ifdef __WATCOMC__
-    Z_Free(pal);
-#endif
-}
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_swap.h"
 #include "p_local.h"
 #include "soundst.h"
 
@@ -2640,7 +2641,7 @@
 
 void A_BishopMissileSeek(mobj_t * actor)
 {
-    P_SeekerMissile(actor, ANGLE_1 * 2, ANGLE_1 * 3);
+    P_SeekerMissile(actor, ANG1 * 2, ANG1 * 3);
 }
 
 //============================================================================
@@ -2838,7 +2839,7 @@
 
         if (abs(actor->angle - R_PointToAngle2(actor->x, actor->y,
                                                target->x,
-                                               target->y)) < ANGLE_45 / 2)
+                                               target->y)) < ANG45 / 2)
         {
             oldTarget = actor->target;
             actor->target = target;
@@ -2860,7 +2861,7 @@
         if (actor->target && P_Random() < 200)
         {
             bestArg = -1;
-            bestAngle = ANGLE_MAX;
+            bestAngle = ANG_MAX;
             angleToTarget = R_PointToAngle2(actor->x, actor->y,
                                             actor->target->x,
                                             actor->target->y);
@@ -2935,7 +2936,7 @@
 {
     angle_t angle;
 
-    DragonSeek(actor, 4 * ANGLE_1, 8 * ANGLE_1);
+    DragonSeek(actor, 4 * ANG1, 8 * ANG1);
     if (actor->target)
     {
         if (!(actor->target->flags & MF_SHOOTABLE))
@@ -2945,13 +2946,13 @@
         }
         angle = R_PointToAngle2(actor->x, actor->y, actor->target->x,
                                 actor->target->y);
-        if (abs(actor->angle - angle) < ANGLE_45 / 2
+        if (abs(actor->angle - angle) < ANG45 / 2
             && P_CheckMeleeRange(actor))
         {
             P_DamageMobj(actor->target, actor, actor, HITDICE(8));
             S_StartSound(actor, SFX_DRAGON_ATTACK);
         }
-        else if (abs(actor->angle - angle) <= ANGLE_1 * 20)
+        else if (abs(actor->angle - angle) <= ANG1 * 20)
         {
             P_SetMobjState(actor, actor->info->missilestate);
             S_StartSound(actor, SFX_DRAGON_ATTACK);
@@ -3646,9 +3647,9 @@
                 ang =
                     R_PointToAngle2(actor->x, actor->y, target->x, target->y);
                 if (P_Random() < 128)
-                    ang += ANGLE_90;
+                    ang += ANG90;
                 else
-                    ang -= ANGLE_90;
+                    ang -= ANG90;
                 ang >>= ANGLETOFINESHIFT;
                 actor->momx = FixedMul(8 * FRACUNIT, finecosine[ang]);
                 actor->momy = FixedMul(8 * FRACUNIT, finesine[ang]);
@@ -3892,8 +3893,8 @@
 #define SORC_FIRING_SPELL	6
 
 #define BALL1_ANGLEOFFSET	0
-#define BALL2_ANGLEOFFSET	(ANGLE_MAX/3)
-#define BALL3_ANGLEOFFSET	((ANGLE_MAX/3)*2)
+#define BALL2_ANGLEOFFSET	(ANG_MAX/3)
+#define BALL3_ANGLEOFFSET	((ANG_MAX/3)*2)
 
 void A_SorcBallOrbit(mobj_t * actor);
 void A_SorcSpinBalls(mobj_t * actor);
@@ -3922,7 +3923,7 @@
     actor->args[0] = 0;         // Currently no defense
     actor->args[3] = SORC_NORMAL;
     actor->args[4] = SORCBALL_INITIAL_SPEED;    // Initial orbit speed
-    actor->special1 = ANGLE_1;
+    actor->special1 = ANG1;
     z = actor->z - actor->floorclip + actor->info->height;
 
     mo = P_SpawnMobj(actor->x, actor->y, z, MT_SORCBALL1);
@@ -4172,7 +4173,7 @@
 {
     if (actor->type == MT_SORCBALL1)
     {
-        actor->target->special1 += ANGLE_1 * actor->target->args[4];
+        actor->target->special1 += ANG1 * actor->target->args[4];
     }
 }
 
@@ -4207,8 +4208,8 @@
                 mo->target = parent;
             break;
         case MT_SORCBALL3:     // Reinforcements
-            ang1 = actor->angle - ANGLE_45;
-            ang2 = actor->angle + ANGLE_45;
+            ang1 = actor->angle - ANG45;
+            ang2 = actor->angle + ANG45;
             if (actor->health < (actor->info->spawnhealth / 3))
             {                   // Spawn 2 at a time
                 mo = P_SpawnMissileAngle(parent, MT_SORCFX3, ang1,
@@ -4242,7 +4243,7 @@
 	mobj_t *mo;
 	angle_t ang;
 
-	ang = ANGLE_1 * P_Random();
+	ang = ANG1 * P_Random();
 	mo = P_SpawnMissileAngle(actor, MT_SORCFX3, ang, 5*FRACUNIT);
 	if (mo) mo->target = parent;
 }
@@ -4255,8 +4256,8 @@
     angle_t ang1, ang2;
     mobj_t *parent = (mobj_t *) actor->target;
 
-    ang1 = actor->angle + ANGLE_1 * 70;
-    ang2 = actor->angle - ANGLE_1 * 70;
+    ang1 = actor->angle + ANG1 * 70;
+    ang2 = actor->angle - ANG1 * 70;
     mo = P_SpawnMissileAngle(parent, MT_SORCFX1, ang1, 0);
     if (mo)
     {
@@ -4289,7 +4290,7 @@
     index = actor->args[4] << 5;
     actor->args[4] += 15;
     delta = (finesine[index]) * SORCFX4_SPREAD_ANGLE;
-    delta = (delta >> FRACBITS) * ANGLE_1;
+    delta = (delta >> FRACBITS) * ANG1;
     ang1 = actor->angle + delta;
     mo = P_SpawnMissileAngle(parent, MT_SORCFX4, ang1, 0);
     if (mo)
@@ -4347,7 +4348,7 @@
 void A_SorcFX1Seek(mobj_t * actor)
 {
     A_BounceCheck(actor);
-    P_SeekerMissile(actor, ANGLE_1 * 2, ANGLE_1 * 6);
+    P_SeekerMissile(actor, ANG1 * 2, ANG1 * 6);
 }
 
 
@@ -4414,7 +4415,7 @@
     // Move to new position based on angle
     if (actor->args[0])         // Counter clock-wise
     {
-        actor->special1 += ANGLE_1 * 10;
+        actor->special1 += ANG1 * 10;
         angle = ((angle_t) actor->special1) >> ANGLETOFINESHIFT;
         x = parent->x + FixedMul(dist, finecosine[angle]);
         y = parent->y + FixedMul(dist, finesine[angle]);
@@ -4425,7 +4426,7 @@
     }
     else                        // Clock wise
     {
-        actor->special1 -= ANGLE_1 * 10;
+        actor->special1 -= ANG1 * 10;
         angle = ((angle_t) actor->special1) >> ANGLETOFINESHIFT;
         x = parent->x + FixedMul(dist, finecosine[angle]);
         y = parent->y + FixedMul(dist, finesine[angle]);
@@ -4629,9 +4630,9 @@
                 ang = R_PointToAngle2(actor->x, actor->y,
                                       target->x, target->y);
                 if (P_Random() < 128)
-                    ang += ANGLE_90;
+                    ang += ANG90;
                 else
-                    ang -= ANGLE_90;
+                    ang -= ANG90;
                 ang >>= ANGLETOFINESHIFT;
                 actor->momx = FixedMul(13 * FRACUNIT, finecosine[ang]);
                 actor->momy = FixedMul(13 * FRACUNIT, finesine[ang]);
@@ -4979,27 +4980,27 @@
     x = actor->x, y = actor->y, z = actor->z;
 
     // Spawn 6 spirits equalangularly
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT1, ANGLE_60 * 0,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT1, ANG60 * 0,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT2, ANGLE_60 * 1,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT2, ANG60 * 1,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT3, ANGLE_60 * 2,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT3, ANG60 * 2,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT4, ANGLE_60 * 3,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT4, ANG60 * 3,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT5, ANGLE_60 * 4,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT5, ANG60 * 4,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
-    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT6, ANGLE_60 * 5,
+    mo = P_SpawnMissileAngle(actor, MT_KORAX_SPIRIT6, ANG60 * 5,
                              5 * FRACUNIT);
     if (mo)
         KSpiritInit(mo, actor);
@@ -5101,7 +5102,7 @@
     S_StartSound(actor, SFX_KORAX_COMMAND);
 
     // Shoot stream of lightning to ceiling
-    ang = (actor->angle - ANGLE_90) >> ANGLETOFINESHIFT;
+    ang = (actor->angle - ANG90) >> ANGLETOFINESHIFT;
     x = actor->x + FixedMul(KORAX_COMMAND_OFFSET, finecosine[ang]);
     y = actor->y + FixedMul(KORAX_COMMAND_OFFSET, finesine[ang]);
     z = actor->z + KORAX_COMMAND_HEIGHT;
@@ -5139,7 +5140,7 @@
 }
 
 
-#define KORAX_DELTAANGLE			(85*ANGLE_1)
+#define KORAX_DELTAANGLE			(85*ANG1)
 #define KORAX_ARM_EXTENSION_SHORT	(40*FRACUNIT)
 #define KORAX_ARM_EXTENSION_LONG	(55*FRACUNIT)
 
@@ -5346,8 +5347,8 @@
     {
         if (actor->special1)
         {
-            A_KSpiritSeeker(actor, actor->args[0] * ANGLE_1,
-                            actor->args[0] * ANGLE_1 * 2);
+            A_KSpiritSeeker(actor, actor->args[0] * ANG1,
+                            actor->args[0] * ANG1 * 2);
         }
         A_KSpiritWeave(actor);
         if (P_Random() < 50)
--- a/src/hexen/p_map.c
+++ b/src/hexen/p_map.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_bbox.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_maputl.c
+++ b/src/hexen/p_maputl.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_bbox.h"
 #include "p_local.h"
 
 static mobj_t *RoughBlockCheck(mobj_t * mo, int index);
--- a/src/hexen/p_mobj.c
+++ b/src/hexen/p_mobj.c
@@ -274,9 +274,9 @@
     if (angle2 > angle1)
     {
         diff = angle2 - angle1;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
-            *delta = ANGLE_MAX - diff;
+            *delta = ANG_MAX - diff;
             return (0);
         }
         else
@@ -288,9 +288,9 @@
     else
     {
         diff = angle1 - angle2;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
-            *delta = ANGLE_MAX - diff;
+            *delta = ANG_MAX - diff;
             return (1);
         }
         else
@@ -494,7 +494,7 @@
                             angle = R_PointToAngle2(BlockingMobj->x,
                                                     BlockingMobj->y, mo->x,
                                                     mo->y) +
-                                ANGLE_1 * ((P_Random() % 16) - 8);
+                                ANG1 * ((P_Random() % 16) - 8);
                             speed = P_AproxDistance(mo->momx, mo->momy);
                             speed = FixedMul(speed, 0.75 * FRACUNIT);
                             mo->angle = angle;
@@ -550,13 +550,13 @@
                         case MT_SORCBOSS:
                             // Deflection
                             if (P_Random() < 128)
-                                angle += ANGLE_45;
+                                angle += ANG45;
                             else
-                                angle -= ANGLE_45;
+                                angle -= ANG45;
                             break;
                         default:
                             // Reflection
-                            angle += ANGLE_1 * ((P_Random() % 16) - 8);
+                            angle += ANG1 * ((P_Random() % 16) - 8);
                             break;
                     }
 
--- a/src/hexen/p_pspr.c
+++ b/src/hexen/p_pspr.c
@@ -672,7 +672,7 @@
 //
 //============================================================================
 
-#define MAX_ANGLE_ADJUST (5*ANGLE_1)
+#define MAX_ANGADJUST (5*ANG1)
 
 void AdjustPlayerAngle(mobj_t * pmo)
 {
@@ -681,9 +681,9 @@
 
     angle = R_PointToAngle2(pmo->x, pmo->y, linetarget->x, linetarget->y);
     difference = (int) angle - (int) pmo->angle;
-    if (abs(difference) > MAX_ANGLE_ADJUST)
+    if (abs(difference) > MAX_ANGADJUST)
     {
-        pmo->angle += difference > 0 ? MAX_ANGLE_ADJUST : -MAX_ANGLE_ADJUST;
+        pmo->angle += difference > 0 ? MAX_ANGADJUST : -MAX_ANGADJUST;
     }
     else
     {
@@ -1182,8 +1182,8 @@
     angle = pmo->angle;
 
     MStaffSpawn(pmo, angle);
-    MStaffSpawn(pmo, angle - ANGLE_1 * 5);
-    MStaffSpawn(pmo, angle + ANGLE_1 * 5);
+    MStaffSpawn(pmo, angle - ANG1 * 5);
+    MStaffSpawn(pmo, angle + ANG1 * 5);
     S_StartSound(player->mo, SFX_MAGE_STAFF_FIRE);
     if (player == &players[consoleplayer])
     {
@@ -1263,7 +1263,7 @@
     {
         actor->special1 = (int) P_RoughMonsterSearch(actor, 10);
     }
-    P_SeekerMissile(actor, ANGLE_1 * 2, ANGLE_1 * 10);
+    P_SeekerMissile(actor, ANG1 * 2, ANG1 * 10);
 }
 
 
@@ -1296,8 +1296,8 @@
     angle_t angle;
     angle = actor->angle;
     MStaffSpawn2(actor, angle);
-    MStaffSpawn2(actor, angle - ANGLE_1 * 5);
-    MStaffSpawn2(actor, angle + ANGLE_1 * 5);
+    MStaffSpawn2(actor, angle - ANG1 * 5);
+    MStaffSpawn2(actor, angle + ANG1 * 5);
     S_StartSound(actor, SFX_MAGE_STAFF_FIRE);
 }
 
@@ -1753,15 +1753,15 @@
 	P_AimLineAttack(pmo, angle, CFLAMERANGE); // Correctly set linetarget
 	if(!linetarget)
 	{
-		angle += ANGLE_1*2;
+		angle += ANG1*2;
 		P_AimLineAttack(pmo, angle, CFLAMERANGE);
 		if(!linetarget)
 		{
-			angle -= ANGLE_1*4;
+			angle -= ANG1*4;
 			P_AimLineAttack(pmo, angle, CFLAMERANGE);
 			if(!linetarget)
 			{
-				angle += ANGLE_1*2;
+				angle += ANG1*2;
 			}
 		}		
 	}
@@ -1885,7 +1885,7 @@
                 break;
         }
         mo->z = actor->z;
-        mo->angle = actor->angle + (ANGLE_45 + ANGLE_45 / 2) - ANGLE_45 * j;
+        mo->angle = actor->angle + (ANG45 + ANG45 / 2) - ANG45 * j;
         P_ThrustMobj(mo, mo->angle, mo->info->speed);
         mo->target = actor->target;
         mo->args[0] = 10;       // initial turn value
@@ -2106,8 +2106,8 @@
     }
     if (actor->special1)
     {
-        CHolySeekerMissile(actor, actor->args[0] * ANGLE_1,
-                           actor->args[0] * ANGLE_1 * 2);
+        CHolySeekerMissile(actor, actor->args[0] * ANG1,
+                           actor->args[0] * ANG1 * 2);
         if (!((leveltime + 7) & 15))
         {
             actor->args[0] = 5 + (P_Random() / 20);
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -27,6 +27,9 @@
 #include <math.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "m_argv.h"
+#include "m_bbox.h"
+#include "i_swap.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_spec.c
+++ b/src/hexen/p_spec.c
@@ -680,7 +680,7 @@
         case 72:               // Thrust Mobj
             if (!side)          // Only thrust on side 0
             {
-                P_ThrustMobj(mo, args[0] * (ANGLE_90 / 64),
+                P_ThrustMobj(mo, args[0] * (ANG90 / 64),
                              args[1] << FRACBITS);
                 buttonSuccess = 1;
             }
--- a/src/hexen/p_user.c
+++ b/src/hexen/p_user.c
@@ -384,7 +384,7 @@
     if (player->attacker && player->attacker != player->mo)
     {                           // Watch killer
         dir = P_FaceMobj(player->mo, player->attacker, &delta);
-        if (delta < ANGLE_1 * 10)
+        if (delta < ANG1 * 10)
         {                       // Looking at killer, so fade damage and poison counters
             if (player->damagecount)
             {
@@ -396,9 +396,9 @@
             }
         }
         delta = delta / 8;
-        if (delta > ANGLE_1 * 5)
+        if (delta > ANG1 * 5)
         {
-            delta = ANGLE_1 * 5;
+            delta = ANG1 * 5;
         }
         if (dir)
         {                       // Turn clockwise
--- a/src/hexen/po_man.c
+++ b/src/hexen/po_man.c
@@ -25,6 +25,8 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_bbox.h"
+#include "i_swap.h"
 #include "p_local.h"
 #include "r_local.h"
 
@@ -153,14 +155,14 @@
         }
         else
         {
-            pe->dist = args[2] * (ANGLE_90 / 64);       // Angle
+            pe->dist = args[2] * (ANG90 / 64);       // Angle
         }
     }
     else
     {
-        pe->dist = ANGLE_MAX - 1;
+        pe->dist = ANG_MAX - 1;
     }
-    pe->speed = (args[1] * direction * (ANGLE_90 / 64)) >> 3;
+    pe->speed = (args[1] * direction * (ANG90 / 64)) >> 3;
     poly->specialdata = pe;
     SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
                      poly->seqType);
@@ -185,12 +187,12 @@
             }
             else
             {
-                pe->dist = args[2] * (ANGLE_90 / 64);   // Angle
+                pe->dist = args[2] * (ANG90 / 64);   // Angle
             }
         }
         else
         {
-            pe->dist = ANGLE_MAX - 1;
+            pe->dist = ANG_MAX - 1;
         }
         poly = GetPolyobj(polyNum);
         if (poly != NULL)
@@ -202,7 +204,7 @@
             I_Error("EV_RotatePoly:  Invalid polyobj num: %d\n", polyNum);
         }
         direction = -direction;
-        pe->speed = (args[1] * direction * (ANGLE_90 / 64)) >> 3;
+        pe->speed = (args[1] * direction * (ANG90 / 64)) >> 3;
         polyNum = mirror;
         SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
                          poly->seqType);
@@ -288,7 +290,7 @@
     pe->speed = args[1] * (FRACUNIT / 8);
     poly->specialdata = pe;
 
-    an = args[2] * (ANGLE_90 / 64);
+    an = args[2] * (ANG90 / 64);
 
     pe->angle = an >> ANGLETOFINESHIFT;
     pe->xSpeed = FixedMul(pe->speed, finecosine[pe->angle]);
@@ -317,7 +319,7 @@
             pe->dist = args[3] * FRACUNIT;      // Distance
         }
         pe->speed = args[1] * (FRACUNIT / 8);
-        an = an + ANGLE_180;    // reverse the angle
+        an = an + ANG180;    // reverse the angle
         pe->angle = an >> ANGLETOFINESHIFT;
         pe->xSpeed = FixedMul(pe->speed, finecosine[pe->angle]);
         pe->ySpeed = FixedMul(pe->speed, finesine[pe->angle]);
@@ -365,7 +367,7 @@
                         pd->dist = pd->totalDist;
                         pd->close = true;
                         pd->tics = pd->waitTics;
-                        pd->direction = (ANGLE_MAX >> ANGLETOFINESHIFT) -
+                        pd->direction = (ANG_MAX >> ANGLETOFINESHIFT) -
                             pd->direction;
                         pd->xSpeed = -pd->xSpeed;
                         pd->ySpeed = -pd->ySpeed;
@@ -391,7 +393,7 @@
                 else
                 {               // open back up
                     pd->dist = pd->totalDist - pd->dist;
-                    pd->direction = (ANGLE_MAX >> ANGLETOFINESHIFT) -
+                    pd->direction = (ANG_MAX >> ANGLETOFINESHIFT) -
                         pd->direction;
                     pd->xSpeed = -pd->xSpeed;
                     pd->ySpeed = -pd->ySpeed;
@@ -493,7 +495,7 @@
         pd->speed = args[1] * (FRACUNIT / 8);
         pd->totalDist = args[3] * FRACUNIT;     // Distance
         pd->dist = pd->totalDist;
-        an = args[2] * (ANGLE_90 / 64);
+        an = args[2] * (ANG90 / 64);
         pd->direction = an >> ANGLETOFINESHIFT;
         pd->xSpeed = FixedMul(pd->speed, finecosine[pd->direction]);
         pd->ySpeed = FixedMul(pd->speed, finesine[pd->direction]);
@@ -504,8 +506,8 @@
     {
         pd->waitTics = args[3];
         pd->direction = 1;      // ADD:  PODOOR_SWINGL, PODOOR_SWINGR
-        pd->speed = (args[1] * pd->direction * (ANGLE_90 / 64)) >> 3;
-        pd->totalDist = args[2] * (ANGLE_90 / 64);
+        pd->speed = (args[1] * pd->direction * (ANG90 / 64)) >> 3;
+        pd->totalDist = args[2] * (ANG90 / 64);
         pd->dist = pd->totalDist;
         SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
                          poly->seqType);
@@ -533,7 +535,7 @@
             pd->speed = args[1] * (FRACUNIT / 8);
             pd->totalDist = args[3] * FRACUNIT; // Distance
             pd->dist = pd->totalDist;
-            an = an + ANGLE_180;        // reverse the angle
+            an = an + ANG180;        // reverse the angle
             pd->direction = an >> ANGLETOFINESHIFT;
             pd->xSpeed = FixedMul(pd->speed, finecosine[pd->direction]);
             pd->ySpeed = FixedMul(pd->speed, finesine[pd->direction]);
@@ -544,8 +546,8 @@
         {
             pd->waitTics = args[3];
             pd->direction = -1; // ADD:  same as above
-            pd->speed = (args[1] * pd->direction * (ANGLE_90 / 64)) >> 3;
-            pd->totalDist = args[2] * (ANGLE_90 / 64);
+            pd->speed = (args[1] * pd->direction * (ANG90 / 64)) >> 3;
+            pd->totalDist = args[2] * (ANG90 / 64);
             pd->dist = pd->totalDist;
             SN_StartSequence((mobj_t *) & poly->startSpot, SEQ_DOOR_STONE +
                              poly->seqType);
@@ -616,7 +618,7 @@
     {
         return;
     }
-    thrustAngle = (seg->angle - ANGLE_90) >> ANGLETOFINESHIFT;
+    thrustAngle = (seg->angle - ANG90) >> ANGLETOFINESHIFT;
 
     pe = po->specialdata;
     if (pe)
--- a/src/hexen/r_bsp.c
+++ b/src/hexen/r_bsp.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "m_bbox.h"
 #include "r_local.h"
 
 seg_t *curline;
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_swap.h"
 #include "r_local.h"
 #include "p_local.h"
 
--- a/src/hexen/r_local.h
+++ b/src/hexen/r_local.h
@@ -324,7 +324,6 @@
 
 extern int viewangletox[FINEANGLES / 2];
 extern angle_t xtoviewangle[SCREENWIDTH + 1];
-extern fixed_t finetangent[FINEANGLES / 2];
 
 extern fixed_t rw_distance;
 extern angle_t rw_normalangle;
--- a/src/hexen/r_main.c
+++ b/src/hexen/r_main.c
@@ -24,6 +24,7 @@
 
 #include <math.h>
 #include "h2def.h"
+#include "m_bbox.h"
 #include "r_local.h"
 
 int viewangleoffset;
@@ -66,14 +67,6 @@
 // that maps back to x ranges from clipangle to -clipangle
 angle_t xtoviewangle[SCREENWIDTH + 1];
 
-// the finetangentgent[angle+FINEANGLES/4] table holds the fixed_t tangent
-// values for view angles, ranging from INT_MIN to 0 to INT_MAX.
-// fixed_t              finetangent[FINEANGLES/2];
-
-// fixed_t              finesine[5*FINEANGLES/4];
-fixed_t *finecosine = &finesine[FINEANGLES / 4];
-
-
 lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
 lighttable_t *scalelightfixed[MAXLIGHTSCALE];
 lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
@@ -219,8 +212,6 @@
 #define	SLOPEBITS	11
 #define	DBITS		(FRACBITS-SLOPEBITS)
 
-
-extern int tantoangle[SLOPERANGE + 1];  // get from tables.c
 
 // int  tantoangle[SLOPERANGE+1];
 
--- a/src/hexen/r_things.c
+++ b/src/hexen/r_things.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "i_swap.h"
 #include "r_local.h"
 
 void R_DrawColumn(void);
--- a/src/hexen/sb_bar.c
+++ b/src/hexen/sb_bar.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_bbox.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/sc_man.c
+++ b/src/hexen/sc_man.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "m_misc.h"
 
 // MACROS ------------------------------------------------------------------
 
@@ -35,7 +36,6 @@
 #define ASCII_QUOTE (34)
 #define LUMP_SCRIPT 1
 #define FILE_ZONE_SCRIPT 2
-#define FILE_CLIB_SCRIPT 3
 
 // TYPES -------------------------------------------------------------------
 
@@ -124,20 +124,6 @@
 
 //==========================================================================
 //
-// SC_OpenFileCLib
-//
-// Loads a script (from a file) and prepares it for parsing.  Uses C
-// library function calls for memory allocation and de-allocation.
-//
-//==========================================================================
-
-void SC_OpenFileCLib(char *name)
-{
-    OpenScript(name, FILE_CLIB_SCRIPT);
-}
-
-//==========================================================================
-//
 // OpenScript
 //
 //==========================================================================
@@ -157,12 +143,6 @@
         ScriptSize = M_ReadFile(name, (byte **) & ScriptBuffer);
         M_ExtractFileBase(name, ScriptName);
         ScriptFreeCLib = false; // De-allocate using Z_Free()
-    }
-    else
-    {                           // File script - clib
-        ScriptSize = M_ReadFileCLib(name, (byte **) & ScriptBuffer);
-        M_ExtractFileBase(name, ScriptName);
-        ScriptFreeCLib = true;  // De-allocate using free()
     }
     ScriptPtr = ScriptBuffer;
     ScriptEndPtr = ScriptPtr + ScriptSize;
--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -25,6 +25,8 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "m_misc.h"
+#include "i_swap.h"
 #include "p_local.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/v_video.c
+++ b/src/hexen/v_video.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_swap.h"
 
 #define SC_INDEX 0x3c4
 
--- a/src/hexen/xddefs.h
+++ b/src/hexen/xddefs.h
@@ -129,14 +129,6 @@
     short offset;
 } mapseg_t;
 
-enum
-{                               // bbox coordinates
-    BOXTOP,
-    BOXBOTTOM,
-    BOXLEFT,
-    BOXRIGHT
-};
-
 #define	NF_SUBSECTOR	0x8000
 typedef struct
 {
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -60,6 +60,18 @@
     return 0;
 }
 
+//
+// M_ParmExists
+//
+// Returns true if the given parameter exists in the program's command
+// line arguments, false if not.
+//
+
+boolean M_ParmExists(char *check)
+{
+    return M_CheckParm(check) != 0;
+}
+
 #define MAXARGVS        100
 	
 static void LoadResponseFile(int argv_index)
--- a/src/m_argv.h
+++ b/src/m_argv.h
@@ -40,4 +40,8 @@
 
 void M_FindResponseFile(void);
 
+// Parameter has been specified?
+
+boolean M_ParmExists(char *check);
+
 #endif
--- a/src/tables.h
+++ b/src/tables.h
@@ -64,7 +64,6 @@
 
 // Binary Angle Measument, BAM.
 
-#define ANG1            0x01000000
 #define ANG45           0x20000000
 #define ANG90           0x40000000
 #define ANG180          0x80000000
@@ -71,6 +70,13 @@
 #define ANG270          0xc0000000
 #define ANG_MAX         0xffffffff
 
+#define ANG1            (ANG45 / 45)
+#define ANG60           (ANG180 / 3)
+
+// Heretic code uses this definition as though it represents one 
+// degree, but it is not!  This is actually ~1.40 degrees.
+
+#define ANG1_X          0x01000000
 
 #define SLOPERANGE		2048
 #define SLOPEBITS		11