Dehacked and BEX support for Doom - currently only supports a DEHACKED file in a WAD (not as a standalone file yet).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11738 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/plugins/doom/Makefile b/apps/plugins/doom/Makefile
index f0e858a..538d577 100644
--- a/apps/plugins/doom/Makefile
+++ b/apps/plugins/doom/Makefile
@@ -3,7 +3,10 @@
 # $Id$
 #
 # $Log$
-# Revision 1.10  2006/10/27 21:47:55  amiconn
+# Revision 1.11  2006/12/13 04:44:17  kkurbjun
+# Dehacked and BEX support for Doom - currently only supports a DEHACKED file in a WAD (not as a standalone file yet).
+#
+# Revision 1.10  2006-10-27 21:47:55  amiconn
 # Next step of Makefile tuning: * Use 'make' internal commands for printing messages. Saves build time especially on cygwin. * SILENT variable used in more places. * Bitmap build system uses one Makefille less.
 #
 # Revision 1.9  2006-10-23 22:33:36  amiconn
@@ -39,16 +42,20 @@
  -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \
  -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN \
- -Wno-strict-prototypes -O2 $(PROFILE_OPTS)
+ -Wno-strict-prototypes $(PROFILE_OPTS)
 
 ifdef APPEXTRA
    INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
 endif
 
-ifneq (,$(strip $(foreach tgt,IPOD_NANO IPOD_COLOR IPOD_VIDEO,$(findstring $(tgt),$(TARGET)))))
+# The arm code compiles too large for the plugin buffer when set to optimize for speed
+ifeq ($(CC), arm-elf-gcc)
+    CFLAGS += -Os
 ifndef SIMVER
     CFLAGS += -mstructure-size-boundary=8
 endif
+else
+    CFLAGS += -O2
 endif
 
 LINKFILE := $(OBJDIR)/link.lds
@@ -62,8 +69,10 @@
    r_plane.c r_segs.c r_sky.c r_things.c wi_stuff.c v_video.c st_lib.c \
    st_stuff.c hu_stuff.c hu_lib.c s_sound.c z_zone.c z_bmalloc.c sounds.c \
    d_main.c m_misc.c m_bbox.c i_system.c i_sound.c i_video.c \
-   w_wad.c rockdoom.c
-# fixmath2.S
+   w_wad.c rockdoom.c d_deh.c ../../../firmware/common/sscanf.c
+
+# sscanf isn't built into the core right now - should remove from here if that
+# changes
 
 SOURCES = $(SRC)
 OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
@@ -73,13 +82,8 @@
 
 
 ifndef SIMVER
-ifneq (,$(findstring RECORDER,$(TARGET))) ## Archos recorder targets
-    LDS := archos.lds
-    OUTPUT = $(OUTDIR)/doom.ovl
-else  ## iRiver target
     LDS := ../plugin.lds
     OUTPUT = $(OUTDIR)/doom.rock
-endif
 else  ## simulators
     OUTPUT = $(OUTDIR)/doom.rock
 endif
diff --git a/apps/plugins/doom/am_map.c b/apps/plugins/doom/am_map.c
index 8f04f0d..eb4e132 100644
--- a/apps/plugins/doom/am_map.c
+++ b/apps/plugins/doom/am_map.c
@@ -41,7 +41,7 @@
 #include "p_spec.h"
 #include "am_map.h"
 #include "dstrings.h"
-//#include "d_deh.h"    // Ty 03/27/98 - externalizations
+#include "d_deh.h"    // Ty 03/27/98 - externalizations
 #include "g_game.h"
 #include "rockmacros.h"
 
@@ -72,7 +72,7 @@
 int mapcolor_plyr[4] = { 112, 88, 64, 176 }; // colors for player arrows in multiplayer
 
 //jff 3/9/98 add option to not show secret sectors until entered
-int map_secret_after=0;
+int map_secret_after;
 //jff 4/3/98 add symbols for "no-color" for disable and "black color" for black
 #define NC 0
 #define BC 247
@@ -702,33 +702,33 @@
          automapmode ^= am_follow;     // CPhipps - put all automap mode stuff into one enum
          f_oldloc.x = INT_MAX;
          // Ty 03/27/98 - externalized
-         plr->message = (automapmode & am_follow) ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF;
+         plr->message = (automapmode & am_follow) ? s_AMSTR_FOLLOWON : s_AMSTR_FOLLOWOFF;
       }
       else if (ch == key_map_grid)
       {
          automapmode ^= am_grid;      // CPhipps
          // Ty 03/27/98 - *not* externalized
-         plr->message = (automapmode & am_grid) ? AMSTR_GRIDON : AMSTR_GRIDOFF;
+         plr->message = (automapmode & am_grid) ? s_AMSTR_GRIDON : s_AMSTR_GRIDOFF;
       }
       else if (ch == key_map_mark)
       {
          // Ty 03/27/98 - *not* externalized
-         snprintf(buffer, sizeof(buffer), "%s %d", AMSTR_MARKEDSPOT, markpointnum);
+         snprintf(buffer, sizeof(buffer), "%s %d", s_AMSTR_MARKEDSPOT, markpointnum);
          plr->message = buffer;
          AM_addMark();
       }
       else if (ch == key_map_clear)
       {
          AM_clearMarks();  // Ty 03/27/98 - *not* externalized
-         plr->message = AMSTR_MARKSCLEARED;                      //    ^
+         plr->message = s_AMSTR_MARKSCLEARED;                      //    ^
       }                                                           //    |
       else if (ch == key_map_rotate) {
          automapmode ^= am_rotate;
-         plr->message = (automapmode & am_rotate) ? AMSTR_ROTATEON : AMSTR_ROTATEOFF;
+         plr->message = (automapmode & am_rotate) ? s_AMSTR_ROTATEON : s_AMSTR_ROTATEOFF;
       }
       else if (ch == key_map_overlay) {
          automapmode ^= am_overlay;
-         plr->message = (automapmode & am_overlay) ? AMSTR_OVERLAYON : AMSTR_OVERLAYOFF;
+         plr->message = (automapmode & am_overlay) ? s_AMSTR_OVERLAYON : s_AMSTR_OVERLAYOFF;
       }
       else                                                        // phares
       {
diff --git a/apps/plugins/doom/d_main.c b/apps/plugins/doom/d_main.c
index b8c1366..3dc6487 100644
--- a/apps/plugins/doom/d_main.c
+++ b/apps/plugins/doom/d_main.c
@@ -62,9 +62,13 @@
 #include "r_draw.h"
 #include "r_main.h"
 #include "d_main.h"
+#include "d_deh.h"  // Ty 04/08/98 - Externalizations
 #include "am_map.h"
 #include "m_swap.h"
 
+// DEHacked support - Ty 03/09/97 // CPhipps - const char*'s
+void ProcessDehFile(const char *filename, const char *outfilename, int lumpnum);
+
 // CPhipps - removed wadfiles[] stuff
 
 boolean devparm;        // started game with -devparm
@@ -78,6 +82,7 @@
 boolean nomonsters;     // working -nomonsters
 boolean respawnparm;    // working -respawn
 boolean fastparm;       // working -fast
+boolean dehout=false;
 
 boolean singletics = false; // debug flag to cancel adaptiveness
 
@@ -725,6 +730,9 @@
    printf ("W_Init: Init WADfiles.\n");
    W_Init();
 
+	if ((p = W_CheckNumForName("DEHACKED")) != -1) // cph - add dehacked-in-a-wad support
+		ProcessDehFile(NULL, dehout ? NULL : "/dehlog.txt", p);
+
    V_InitColorTranslation(); //jff 4/24/98 load color translation lumps
 
    // Check for -file in shareware
diff --git a/apps/plugins/doom/dstrings.h b/apps/plugins/doom/dstrings.h
index 4402c21..f885faa 100644
--- a/apps/plugins/doom/dstrings.h
+++ b/apps/plugins/doom/dstrings.h
@@ -26,7 +26,7 @@
  *
  * DESCRIPTION:
  *   DOOM strings, by language.
- *   Note:  In BOOM, some new strings hav ebeen defined that are
+ *   Note:  In BOOM, some new strings have been defined that are
  *          not found in the French version.  A better approach is
  *          to create a BEX text-replacement file for other
  *          languages since any language can be supported that way
diff --git a/apps/plugins/doom/f_finale.c b/apps/plugins/doom/f_finale.c
index 3af27d2..0b912c8 100644
--- a/apps/plugins/doom/f_finale.c
+++ b/apps/plugins/doom/f_finale.c
@@ -32,13 +32,12 @@
 
 #include "doomstat.h"
 #include "d_event.h"
-#include "d_englsh.h"
 #include "m_swap.h"
 #include "v_video.h"
 #include "w_wad.h"
 #include "s_sound.h"
 #include "sounds.h"
-//#include "d_deh.h"  // Ty 03/22/98 - externalizations
+#include "d_deh.h"  // Ty 03/22/98 - externalizations
 #include "f_finale.h" // CPhipps - hmm...
 #include "rockmacros.h"
 
@@ -98,20 +97,20 @@
          switch (gameepisode)
          {
          case 1:
-            finaleflat = "FLOOR4_8";
-            finaletext = E1TEXT;
+            finaleflat = bgflatE1; // Ty 03/30/98 - new externalized bg flats
+            finaletext = s_E1TEXT; // Ty 03/23/98 - Was e1text variable.
             break;
          case 2:
-            finaleflat = "SFLR6_1";
-            finaletext = E2TEXT;
+            finaleflat = bgflatE2;
+            finaletext = s_E2TEXT; // Ty 03/23/98 - Same stuff for each
             break;
          case 3:
-            finaleflat = "MFLR8_4";
-            finaletext = E3TEXT;
+            finaleflat = bgflatE3;
+            finaletext = s_E3TEXT;
             break;
          case 4:
-            finaleflat = "MFLR8_3";
-            finaletext = E4TEXT;
+            finaleflat = bgflatE4;
+            finaletext = s_E4TEXT;
             break;
          default:
             // Ouch.
@@ -129,48 +128,48 @@
          switch (gamemap)
          {
          case 6:
-            finaleflat = "SLIME16";
-            finaletext = (gamemission==pack_tnt)  ? T1TEXT :
-                         (gamemission==pack_plut) ? P1TEXT : C1TEXT;
+            finaleflat = bgflat06;
+            finaletext = (gamemission==pack_tnt)  ? s_T1TEXT :
+                         (gamemission==pack_plut) ? s_P1TEXT : s_C1TEXT;
             break;
          case 11:
-            finaleflat = "RROCK14";
-            finaletext = (gamemission==pack_tnt)  ? T2TEXT :
-                         (gamemission==pack_plut) ? P2TEXT : C2TEXT;
+            finaleflat = bgflat11;
+            finaletext = (gamemission==pack_tnt)  ? s_T2TEXT :
+                         (gamemission==pack_plut) ? s_P2TEXT : s_C2TEXT;
             break;
          case 20:
-            finaleflat = "RROCK07";
-            finaletext = (gamemission==pack_tnt)  ? T3TEXT :
-                         (gamemission==pack_plut) ? P3TEXT : C3TEXT;
+            finaleflat = bgflat20;
+            finaletext = (gamemission==pack_tnt)  ? s_T3TEXT :
+                         (gamemission==pack_plut) ? s_P3TEXT : s_C3TEXT;
             break;
          case 30:
-            finaleflat = "RROCK17";
-            finaletext = (gamemission==pack_tnt)  ? T4TEXT :
-                         (gamemission==pack_plut) ? P4TEXT : C4TEXT;
+            finaleflat = bgflat30;
+            finaletext = (gamemission==pack_tnt)  ? s_T4TEXT :
+                         (gamemission==pack_plut) ? s_P4TEXT : s_C4TEXT;
             break;
          case 15:
-            finaleflat = "RROCK13";
-            finaletext = (gamemission==pack_tnt)  ? T5TEXT :
-                         (gamemission==pack_plut) ? P5TEXT : C5TEXT;
+            finaleflat = bgflat15;
+            finaletext = (gamemission==pack_tnt)  ? s_T5TEXT :
+                         (gamemission==pack_plut) ? s_P5TEXT : s_C5TEXT;
             break;
          case 31:
-            finaleflat = "RROCK19";
-            finaletext = (gamemission==pack_tnt)  ? T6TEXT :
-                         (gamemission==pack_plut) ? P6TEXT : C6TEXT;
+            finaleflat = bgflat31;
+            finaletext = (gamemission==pack_tnt)  ? s_T6TEXT :
+                         (gamemission==pack_plut) ? s_P6TEXT : s_C6TEXT;
             break;
          default:
             // Ouch.
             break;
          }
          break;
+         // Ty 08/27/98 - end gamemission logic
       }
 
-
       // Indeterminate.
-   default:
+   default:  // Ty 03/30/98 - not externalized
       S_ChangeMusic(mus_read_m, true);
       finaleflat = "F_SKY1"; // Not used anywhere else.
-      finaletext = C1TEXT;  // FIXME - other text, music?
+      finaletext = s_C1TEXT;  // FIXME - other text, music?
       break;
    }
 
@@ -320,29 +319,29 @@
 //
 typedef struct
 {
-   const char *name; // CPhipps - const**
+   const char **name; // CPhipps - const**
    mobjtype_t   type;
 } castinfo_t;
 
 #define MAX_CASTORDER 18 /* Ty - hard coded for now */
 static const castinfo_t castorder[] = { // CPhipps - static const, initialised here
-                                         { CC_ZOMBIE,  MT_POSSESSED },
-                                         { CC_SHOTGUN, MT_SHOTGUY },
-                                         { CC_HEAVY,   MT_CHAINGUY },
-                                         { CC_IMP,     MT_TROOP },
-                                         { CC_DEMON,   MT_SERGEANT },
-                                         { CC_LOST,    MT_SKULL },
-                                         { CC_CACO,    MT_HEAD },
-                                         { CC_HELL,    MT_KNIGHT },
-                                         { CC_BARON,   MT_BRUISER },
-                                         { CC_ARACH,   MT_BABY },
-                                         { CC_PAIN,    MT_PAIN },
-                                         { CC_REVEN,   MT_UNDEAD },
-                                         { CC_MANCU,   MT_FATSO },
-                                         { CC_ARCH,    MT_VILE },
-                                         { CC_SPIDER,  MT_SPIDER },
-                                         { CC_CYBER,   MT_CYBORG },
-                                         { CC_HERO,    MT_PLAYER },
+                                         { &s_CC_ZOMBIE,  MT_POSSESSED },
+                                         { &s_CC_SHOTGUN, MT_SHOTGUY },
+                                         { &s_CC_HEAVY,   MT_CHAINGUY },
+                                         { &s_CC_IMP,     MT_TROOP },
+                                         { &s_CC_DEMON,   MT_SERGEANT },
+                                         { &s_CC_LOST,    MT_SKULL },
+                                         { &s_CC_CACO,    MT_HEAD },
+                                         { &s_CC_HELL,    MT_KNIGHT },
+                                         { &s_CC_BARON,   MT_BRUISER },
+                                         { &s_CC_ARACH,   MT_BABY },
+                                         { &s_CC_PAIN,    MT_PAIN },
+                                         { &s_CC_REVEN,   MT_UNDEAD },
+                                         { &s_CC_MANCU,   MT_FATSO },
+                                         { &s_CC_ARCH,    MT_VILE },
+                                         { &s_CC_SPIDER,  MT_SPIDER },
+                                         { &s_CC_CYBER,   MT_CYBORG },
+                                         { &s_CC_HERO,    MT_PLAYER },
                                          { NULL,         0}
                                       };
 
@@ -560,7 +559,6 @@
 //
 // F_CastDrawer
 //
-void V_DrawPatchFlipped (int x, int y, int scrn, patch_t *patch);
 
 void F_CastDrawer (void)
 {
@@ -570,9 +568,10 @@
    boolean  flip;
 
    // erase the entire screen to a background
-   V_DrawNamePatch(0,0,0, "BOSSBACK", CR_DEFAULT, VPT_STRETCH); // Ty 03/30/98 bg texture extern
+   // CPhipps - patch drawing updated
+   V_DrawNamePatch(0,0,0, bgcastcall, CR_DEFAULT, VPT_STRETCH); // Ty 03/30/98 bg texture extern
 
-   F_CastPrint (castorder[castnum].name);
+   F_CastPrint (*(castorder[castnum].name));
 
    // draw the current frame in the middle of the screen
    sprdef = &sprites[caststate->sprite];
diff --git a/apps/plugins/doom/g_game.c b/apps/plugins/doom/g_game.c
index 7410e01..b5944ea 100644
--- a/apps/plugins/doom/g_game.c
+++ b/apps/plugins/doom/g_game.c
@@ -2771,7 +2771,7 @@
       // killough -- added fps information and made it work for longer demos:
       unsigned realtics = endtime-starttime;
       int fd=open("/games/doom/timedemo.txt",O_WRONLY | O_CREAT);
-      fprintf (fd,"Timed %d gametics in %d realtics = %d frames per second",
+      fdprintf (fd,"Timed %d gametics in %d realtics = %d frames per second",
                (unsigned) gametic, realtics,
                (unsigned) gametic * (double) TICRATE / realtics);
       close(fd);
diff --git a/apps/plugins/doom/hu_stuff.c b/apps/plugins/doom/hu_stuff.c
index cc240de..747be18 100644
--- a/apps/plugins/doom/hu_stuff.c
+++ b/apps/plugins/doom/hu_stuff.c
@@ -56,10 +56,10 @@
 //
 // Ty 03/28/98 -
 // These four shortcuts modifed to reflect char ** of mapnamesx[]
-#define HU_TITLE  (mapnames[(gameepisode-1)*9+gamemap-1])
-#define HU_TITLE2 (mapnames2[gamemap-1])
-#define HU_TITLEP (mapnamesp[gamemap-1])
-#define HU_TITLET (mapnamest[gamemap-1])
+#define HU_TITLE  (*mapnames[(gameepisode-1)*9+gamemap-1])
+#define HU_TITLE2 (*mapnames2[gamemap-1])
+#define HU_TITLEP (*mapnamesp[gamemap-1])
+#define HU_TITLET (*mapnamest[gamemap-1])
 #define HU_TITLEHEIGHT  1
 #define HU_TITLEX 0
 //jff 2/16/98 change 167 to ST_Y-1
@@ -131,16 +131,16 @@
    // Ty 03/27/98 - *not* externalized
    // CPhipps - const char*
    {
-      HUSTR_CHATMACRO0,
       HUSTR_CHATMACRO1,
-      HUSTR_CHATMACRO2,
-      HUSTR_CHATMACRO3,
-      HUSTR_CHATMACRO4,
-      HUSTR_CHATMACRO5,
-      HUSTR_CHATMACRO6,
-      HUSTR_CHATMACRO7,
-      HUSTR_CHATMACRO8,
-      HUSTR_CHATMACRO9
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1,
+      HUSTR_CHATMACRO1
    };
 
 const char* player_names[] =
@@ -206,16 +206,16 @@
 int hud_list_bgon;  // enable for solid window background for message list
 
 //jff 2/16/98 initialization strings for ammo, health, armor widgets
-static char hud_coordstrx[32];
-static char hud_coordstry[32];
-static char hud_coordstrz[32];
-static char hud_ammostr[80];
-static char hud_healthstr[80];
-static char hud_armorstr[80];
-static char hud_weapstr[80];
-static char hud_keysstr[80];
-static char hud_gkeysstr[80]; //jff 3/7/98 add support for graphic key display
-static char hud_monsecstr[80];
+static char *hud_coordstrx;
+static char *hud_coordstry;
+static char *hud_coordstrz;
+static char *hud_ammostr;
+static char *hud_healthstr;
+static char *hud_armorstr;
+static char *hud_weapstr;
+static char *hud_keysstr;
+static char *hud_gkeysstr; //jff 3/7/98 add support for graphic key display
+static char *hud_monsecstr;
 
 //jff 2/16/98 declaration of color switch points
 extern int ammo_red;
@@ -234,175 +234,10 @@
 // Ty 03/27/98 - externalized map name arrays - now in d_deh.c
 // and converted to arrays of pointers to char *
 // See modified HUTITLEx macros
-char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
-   {
-
-      HUSTR_E1M1,
-      HUSTR_E1M2,
-      HUSTR_E1M3,
-      HUSTR_E1M4,
-      HUSTR_E1M5,
-      HUSTR_E1M6,
-      HUSTR_E1M7,
-      HUSTR_E1M8,
-      HUSTR_E1M9,
-
-      HUSTR_E2M1,
-      HUSTR_E2M2,
-      HUSTR_E2M3,
-      HUSTR_E2M4,
-      HUSTR_E2M5,
-      HUSTR_E2M6,
-      HUSTR_E2M7,
-      HUSTR_E2M8,
-      HUSTR_E2M9,
-
-      HUSTR_E3M1,
-      HUSTR_E3M2,
-      HUSTR_E3M3,
-      HUSTR_E3M4,
-      HUSTR_E3M5,
-      HUSTR_E3M6,
-      HUSTR_E3M7,
-      HUSTR_E3M8,
-      HUSTR_E3M9,
-
-      HUSTR_E4M1,
-      HUSTR_E4M2,
-      HUSTR_E4M3,
-      HUSTR_E4M4,
-      HUSTR_E4M5,
-      HUSTR_E4M6,
-      HUSTR_E4M7,
-      HUSTR_E4M8,
-      HUSTR_E4M9,
-
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL",
-      "NEWLEVEL"
-   };
-
-char* mapnames2[] = // DOOM 2 map names.
-   {
-      HUSTR_1,
-      HUSTR_2,
-      HUSTR_3,
-      HUSTR_4,
-      HUSTR_5,
-      HUSTR_6,
-      HUSTR_7,
-      HUSTR_8,
-      HUSTR_9,
-      HUSTR_10,
-      HUSTR_11,
-
-      HUSTR_12,
-      HUSTR_13,
-      HUSTR_14,
-      HUSTR_15,
-      HUSTR_16,
-      HUSTR_17,
-      HUSTR_18,
-      HUSTR_19,
-      HUSTR_20,
-
-      HUSTR_21,
-      HUSTR_22,
-      HUSTR_23,
-      HUSTR_24,
-      HUSTR_25,
-      HUSTR_26,
-      HUSTR_27,
-      HUSTR_28,
-      HUSTR_29,
-      HUSTR_30,
-      HUSTR_31,
-      HUSTR_32
-   };
-
-
-char* mapnamesp[] = // Plutonia WAD map names.
-   {
-      PHUSTR_1,
-      PHUSTR_2,
-      PHUSTR_3,
-      PHUSTR_4,
-      PHUSTR_5,
-      PHUSTR_6,
-      PHUSTR_7,
-      PHUSTR_8,
-      PHUSTR_9,
-      PHUSTR_10,
-      PHUSTR_11,
-
-      PHUSTR_12,
-      PHUSTR_13,
-      PHUSTR_14,
-      PHUSTR_15,
-      PHUSTR_16,
-      PHUSTR_17,
-      PHUSTR_18,
-      PHUSTR_19,
-      PHUSTR_20,
-
-      PHUSTR_21,
-      PHUSTR_22,
-      PHUSTR_23,
-      PHUSTR_24,
-      PHUSTR_25,
-      PHUSTR_26,
-      PHUSTR_27,
-      PHUSTR_28,
-      PHUSTR_29,
-      PHUSTR_30,
-      PHUSTR_31,
-      PHUSTR_32
-   };
-
-
-char *mapnamest[] = // TNT WAD map names.
-   {
-      THUSTR_1,
-      THUSTR_2,
-      THUSTR_3,
-      THUSTR_4,
-      THUSTR_5,
-      THUSTR_6,
-      THUSTR_7,
-      THUSTR_8,
-      THUSTR_9,
-      THUSTR_10,
-      THUSTR_11,
-
-      THUSTR_12,
-      THUSTR_13,
-      THUSTR_14,
-      THUSTR_15,
-      THUSTR_16,
-      THUSTR_17,
-      THUSTR_18,
-      THUSTR_19,
-      THUSTR_20,
-
-      THUSTR_21,
-      THUSTR_22,
-      THUSTR_23,
-      THUSTR_24,
-      THUSTR_25,
-      THUSTR_26,
-      THUSTR_27,
-      THUSTR_28,
-      THUSTR_29,
-      THUSTR_30,
-      THUSTR_31,
-      THUSTR_32
-   };
+extern char **mapnames[];
+extern char **mapnames2[];
+extern char **mapnamesp[];
+extern char **mapnamest[];
 
 // key tables
 // jff 5/10/98 french support removed,
@@ -466,6 +301,18 @@
 
    shiftxform = english_shiftxform;
 
+   // malloc all the strings, trying to get size down
+   hud_ammostr=malloc(80*sizeof(char));
+   hud_healthstr=malloc(80*sizeof(char));
+   hud_armorstr=malloc(80*sizeof(char));
+   hud_weapstr=malloc(80*sizeof(char));
+   hud_keysstr=malloc(80*sizeof(char));
+   hud_gkeysstr=malloc(80*sizeof(char));
+   hud_monsecstr=malloc(80*sizeof(char));
+   hud_coordstrx=malloc(32*sizeof(char));
+   hud_coordstry=malloc(32*sizeof(char));
+   hud_coordstrz=malloc(32*sizeof(char));
+
    // load the heads-up font
    j = HU_FONTSTART;
    for (i=0;i<HU_FONTSIZE;i++,j++)
@@ -768,15 +615,15 @@
 
    // initialize the automaps coordinate widget
    //jff 3/3/98 split coordstr widget into 3 parts
-   snprintf(hud_coordstrx,sizeof(hud_coordstrx),"X: %d",0); //jff 2/22/98 added z
+   snprintf(hud_coordstrx,32*sizeof(char),"X: %d",0); //jff 2/22/98 added z
    s = hud_coordstrx;
    while (*s)
       HUlib_addCharToTextLine(&w_coordx, *(s++));
-   snprintf(hud_coordstry,sizeof(hud_coordstry),"Y: %d",0); //jff 3/3/98 split x,y,z
+   snprintf(hud_coordstry,32*sizeof(char),"Y: %d",0); //jff 3/3/98 split x,y,z
    s = hud_coordstry;
    while (*s)
       HUlib_addCharToTextLine(&w_coordy, *(s++));
-   snprintf(hud_coordstrz,sizeof(hud_coordstrz),"Z: %d",0); //jff 3/3/98 split x,y,z
+   snprintf(hud_coordstrz,32*sizeof(char),"Z: %d",0); //jff 3/3/98 split x,y,z
    s = hud_coordstrz;
    while (*s)
       HUlib_addCharToTextLine(&w_coordz, *(s++));
@@ -915,7 +762,7 @@
 
       //jff 2/16/98 output new coord display
       // x-coord
-      snprintf(hud_coordstrx,sizeof(hud_coordstrx),"X: %d", (plr->mo->x)>>FRACBITS);
+      snprintf(hud_coordstrx,32*sizeof(char),"X: %d", (plr->mo->x)>>FRACBITS);
       HUlib_clearTextLine(&w_coordx);
       s = hud_coordstrx;
       while (*s)
@@ -924,7 +771,7 @@
 
       //jff 3/3/98 split coord display into x,y,z lines
       // y-coord
-      snprintf(hud_coordstry,sizeof(hud_coordstry),"Y: %d", (plr->mo->y)>>FRACBITS);
+      snprintf(hud_coordstry,32*sizeof(char),"Y: %d", (plr->mo->y)>>FRACBITS);
       HUlib_clearTextLine(&w_coordy);
       s = hud_coordstry;
       while (*s)
@@ -934,7 +781,7 @@
       //jff 3/3/98 split coord display into x,y,z lines
       //jff 2/22/98 added z
       // z-coord
-      snprintf(hud_coordstrz,sizeof(hud_coordstrz),"Z: %d", (plr->mo->z)>>FRACBITS);
+      snprintf(hud_coordstrz,32*sizeof(char),"Z: %d", (plr->mo->z)>>FRACBITS);
       HUlib_clearTextLine(&w_coordz);
       s = hud_coordstrz;
       while (*s)
@@ -1399,7 +1246,7 @@
             // build the init string with fixed colors
             snprintf
             (
-               hud_monsecstr,sizeof(hud_monsecstr),
+               hud_monsecstr,80*sizeof(char),
                "STS \x1b\x36K \x1b\x33%d \x1b\x36M \x1b\x33%d \x1b\x37I \x1b\x33%d/%d \x1b\x35S \x1b\x33%d/%d",
                plr->killcount,totallive,
                plr->itemcount,totalitems,
diff --git a/apps/plugins/doom/hu_stuff.h b/apps/plugins/doom/hu_stuff.h
index 76c6a90..c0e927d 100644
--- a/apps/plugins/doom/hu_stuff.h
+++ b/apps/plugins/doom/hu_stuff.h
@@ -84,9 +84,9 @@
 extern int hud_active;      /* hud mode 0=off, 1=small, 2=full          */
 extern int hud_nosecrets;   /* status does not list secrets/items/kills */
 
-extern char* mapnames[];
-extern char* mapnames2[];
-extern char* mapnamesp[];
-extern char* mapnamest[];
+extern char **mapnames[];
+extern char **mapnames2[];
+extern char **mapnamesp[];
+extern char **mapnamest[];
 
 #endif
diff --git a/apps/plugins/doom/i_sound.c b/apps/plugins/doom/i_sound.c
index 641721a..e2eeab0 100644
--- a/apps/plugins/doom/i_sound.c
+++ b/apps/plugins/doom/i_sound.c
@@ -50,7 +50,7 @@
 // Needed for calling the actual sound output.
 #define SAMPLECOUNT     512
 
-#define NUM_CHANNELS    16
+#define NUM_CHANNELS    24
 // It is 2 for 16bit, and 2 for two channels.
 #define BUFMUL          2
 #define MIXBUFFERSIZE  (SAMPLECOUNT*BUFMUL)
@@ -66,7 +66,7 @@
 //  Basically, samples from all active internal channels
 //  are modifed and added, and stored in the buffer
 //  that is submitted to the audio device.
-signed short mixbuffer[MIXBUFFERSIZE];
+signed short *mixbuffer;
 /* Don't place this in IRAM!
  * Sound playback uses DMA, and not all IRAM is DMA capable on coldfire. */
 
@@ -97,7 +97,7 @@
 
 int *vol_lookup; // Volume lookups.
 
-int   steptable[256]; // Pitch to stepping lookup. (Not setup properly right now)
+int   *steptable; // Pitch to stepping lookup. (Not setup properly right now)
 
 //
 // This function loads the sound data from the WAD lump for single sound.
@@ -501,6 +501,9 @@
 
    vol_lookup=malloc(128*256*sizeof(int));
 
+   mixbuffer=malloc(MIXBUFFERSIZE*sizeof(short));
+   steptable=malloc(256*sizeof(int));
+
    for (i=1 ; i<NUMSFX ; i++)
    {
       if (!S_sfx[i].link) // Alias? Example is the chaingun sound linked to pistol.
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index 0e9d20f..0ddede0 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -16,7 +16,10 @@
  * GNU General Public License for more details.
  *
  * $Log$
- * Revision 1.25  2006/10/26 13:38:04  barrywardell
+ * Revision 1.26  2006/12/13 04:44:17  kkurbjun
+ * Dehacked and BEX support for Doom - currently only supports a DEHACKED file in a WAD (not as a standalone file yet).
+ *
+ * Revision 1.25  2006-10-26 13:38:04  barrywardell
  * Allow the Sansa e200 UI simulator to be built. Thanks to Andre Smith for the nice image of the Sansa. Lots more to be done including testing and tweaking the keymaps and modifying the plugins for the Sansa's 176x220 LCD.
  *
  * Revision 1.24  2006-09-05 00:23:06  barrywardell
@@ -418,45 +421,45 @@
 #if (CONFIG_LCD == LCD_H300) && !defined(SIMULATOR)
 
 #if 1
-   /* ASM screen update (drops 600 tics (100 asm)) */
+   /* ASM screen update (drops 200 tics (100 asm)) */
    asm (
       "move.w #33,(%[LCD])    \n" /* Setup the LCD controller */
       "clr.w (%[LCD2])        \n"
       "move.w #34,(%[LCD])    \n" /* End LCD controller setup */
-      "move.l #220,%%d0       \n"
-      "move.l #176,%%d1       \n"
-      "clr.l %%d3             \n"
-      "clr.l %%d2             \n"
+      "clr.l %%d1             \n"
+      "clr.l %%d0             \n"
       "widthloop:             \n"
-      "move.l (%[screenptr])+, %%d2             \n"
-      "swap.w %%d2                              \n"
-      "move.w %%d2, %%d3                        \n"
-      "lsr.l #8,%%d3                            \n"
-      "move.w (%[palette], %%d3.l:2), (%[LCD2]) \n"
-      "move.b %%d2,%%d3                         \n"
-      "move.w (%[palette], %%d3.l:2), (%[LCD2]) \n"
-      "swap.w %%d2                              \n"
-      "move.w %%d2, %%d3                        \n"
-      "lsr.l #8,%%d3                            \n"
-      "move.w (%[palette], %%d3.l:2), (%[LCD2]) \n"
-      "move.b %%d2,%%d3                         \n"
-      "move.w (%[palette], %%d3.l:2), (%[LCD2]) \n"
-      "subq.l #4,%%d0         \n"
+      "move.l (%[screenptr])+, %%d0             \n"
+      "swap.w %%d0                              \n"
+      "move.w %%d0, %%d1                        \n"
+      "lsr.l #8,%%d1                            \n"
+      "move.w (%[palette], %%d1.l:2), (%[LCD2]) \n"
+      "move.b %%d0,%%d1                         \n"
+      "move.w (%[palette], %%d1.l:2), (%[LCD2]) \n"
+      "swap.w %%d0                              \n"
+      "move.w %%d0, %%d1                        \n"
+      "lsr.l #8,%%d1                            \n"
+      "move.w (%[palette], %%d1.l:2), (%[LCD2]) \n"
+      "move.b %%d0,%%d1                         \n"
+      "move.w (%[palette], %%d1.l:2), (%[LCD2]) \n"
+      "subq.l #4,%[WIDTH]         \n"
       "bne widthloop          \n"
-      "move.w #220,%%d0       \n"
-      "subq.l #1,%%d1         \n"
+      "move.w #220,%[WIDTH]       \n"
+      "subq.l #1,%[HEIGHT]         \n"
       "bne widthloop          \n"
    : /* outputs */
    : /* inputs */
       [screenptr] "a" (d_screens[0]),
       [palette]   "a" (palette),
       [LCD]       "a" (0xf0000000),
-      [LCD2]      "a" (0xf0000002)
+      [LCD2]      "a" (0xf0000002), 
+      [WIDTH]     "d" (220),
+      [HEIGHT]    "d" (176)
    : /* clobbers */
-      "d0", "d1", "d2", "d3"
+      "d0", "d1"
    );
 #else
-   /* C version of above (drops 500 tics) */
+   /* C version of above (drops 100 tics) */
 
    // Start the write
    *(volatile unsigned short *) 0xf0000000 = 0x21; // register
@@ -464,37 +467,29 @@
    *(volatile unsigned short *) 0xf0000000 = 0x22; // GRAM
 
    unsigned char *screenptr=d_screens[0];
-   int wcnt=0, hcnt=0;
+   int hcnt=LCD_HEIGHT*LCD_WIDTH;
 
-   while(hcnt<LCD_HEIGHT)
+   while(hcnt--)
    {
-      while(wcnt<LCD_WIDTH)
-      {
-         *(volatile unsigned short *)0xf0000002 = palette[*screenptr];
-         screenptr++;
-         wcnt++;
-      }
-      wcnt=0;
-      hcnt++;
+      *(volatile unsigned short *)0xf0000002 = palette[*screenptr];
+      screenptr++;
    }
 #endif
 
 #else
    unsigned char paletteIndex;
-   int x, y;
+   int y;
 
 #ifdef HAVE_LCD_COLOR
-   for (y = 0; y < LCD_HEIGHT; y++)
+
+   for (y = 0; y < LCD_HEIGHT*LCD_WIDTH; y++)
    {
-      for (x = 0; x < LCD_WIDTH; x++)
-      {
-         paletteIndex = d_screens[0][y*SCREENWIDTH + x];
-         rb->lcd_framebuffer[y * LCD_WIDTH + x] = palette[paletteIndex];
-      }
+         paletteIndex = d_screens[0][y];
+         rb->lcd_framebuffer[y] = palette[paletteIndex];
    }
    rb->lcd_update();
 #else /* !HAVE_LCD_COLOR */
-   int yd = 0;
+   int x, yd = 0;
 
    for (y = 0; y < LCD_HEIGHT; y++)
    {
diff --git a/apps/plugins/doom/m_menu.c b/apps/plugins/doom/m_menu.c
index 415ca08..14d8474 100644
--- a/apps/plugins/doom/m_menu.c
+++ b/apps/plugins/doom/m_menu.c
@@ -16,7 +16,10 @@
 // GNU General Public License for more details.
 //
 // $Log$
-// Revision 1.6  2006/04/16 23:14:04  kkurbjun
+// Revision 1.7  2006/12/13 04:44:17  kkurbjun
+// Dehacked and BEX support for Doom - currently only supports a DEHACKED file in a WAD (not as a standalone file yet).
+//
+// Revision 1.6  2006-04-16 23:14:04  kkurbjun
 // Fix run so that it stays enabled across level loads.  Removed some unused code and added some back in for hopeful future use.
 //
 // Revision 1.5  2006-04-04 23:58:37  kkurbjun
@@ -53,7 +56,7 @@
 #include "w_wad.h"
 
 #include "r_main.h"
-
+#include "d_deh.h"
 #include "hu_stuff.h"
 
 #include "g_game.h"
@@ -96,7 +99,7 @@
 // 1 = message to be printed
 int   messageToPrint;
 // ...and here is the message string!
-char*   messageString;
+const char*   messageString;
 
 // message x & y
 int   messx;
@@ -110,15 +113,6 @@
 
 #define SAVESTRINGSIZE  24
 
-char gammamsg[5][26] =
-   {
-      GAMMALVL0,
-      GAMMALVL1,
-      GAMMALVL2,
-      GAMMALVL3,
-      GAMMALVL4
-   };
-
 // we are going to be entering a savegame string
 int   saveStringEnter;
 int              saveSlot; // which slot to save in
@@ -233,7 +227,7 @@
 int M_StringWidth(const char* string);
 int M_StringHeight(const char* string);
 void M_StartControlPanel(void);
-void M_StartMessage(char *string,void *routine,boolean input);
+void M_StartMessage(const char *string,void *routine,boolean input);
 void M_StopMessage(void);
 void M_ClearMenus (void);
 
@@ -657,11 +651,11 @@
    saveSlot = choice;
    snprintf(savegamestrings[choice], sizeof(savegamestrings[choice]), 
       (gamemode==shareware||gamemode==registered||gamemode==retail) ? 
-      mapnames[(gameepisode-1)*9+gamemap-1]  : (gamemission==doom2)     ?
-      mapnames2[gamemap-1] : (gamemission==pack_plut) ?
-      mapnamesp[gamemap-1] : (gamemission==pack_tnt)  ?
-      mapnamest[gamemap-1] : "Unknown Location", choice);
-   if (!strcmp(savegamestrings[choice],EMPTYSTRING))
+      *mapnames[(gameepisode-1)*9+gamemap-1]  : (gamemission==doom2)     ?
+      *mapnames2[gamemap-1] : (gamemission==pack_plut) ?
+      *mapnamesp[gamemap-1] : (gamemission==pack_tnt)  ?
+      *mapnamest[gamemap-1] : "Unknown Location", choice);
+   if (!strcmp(savegamestrings[choice],s_EMPTYSTRING))
       savegamestrings[choice][0] = 0;
    saveCharIndex = strlen(savegamestrings[choice]);
 }
@@ -674,7 +668,7 @@
    (void)choice;
    if (!usergame)
    {
-      M_StartMessage(SAVEDEAD,NULL,false);
+      M_StartMessage(s_SAVEDEAD,NULL,false);
       return;
    }
 
@@ -722,7 +716,7 @@
       quickSaveSlot = -2; // means to pick a slot now
       return;
    }
-   snprintf(tempstring,sizeof(tempstring),QSPROMPT,savegamestrings[quickSaveSlot]);
+   snprintf(tempstring,sizeof(tempstring),s_QSPROMPT,savegamestrings[quickSaveSlot]);
    M_StartMessage(tempstring,M_QuickSaveResponse,true);
 }
 
@@ -917,7 +911,7 @@
    (void) choice;
    if (netgame && !demoplayback)
    {
-      M_StartMessage(NEWGAME,NULL,false);
+      M_StartMessage(s_NEWGAME,NULL,false);
       return;
    }
 
@@ -952,7 +946,7 @@
 {
    if (choice == nightmare)
    {
-      M_StartMessage(NIGHTMARE,M_VerifyNightmare,true);
+      M_StartMessage(s_NIGHTMARE,M_VerifyNightmare,true);
       return;
    }
 
@@ -969,7 +963,7 @@
    if ( (gamemode == shareware)
          && choice)
    {
-      M_StartMessage(SWSTRING,NULL,false);
+      M_StartMessage(s_SWSTRING,NULL,false); // Ty 03/27/98 - externalized
       M_SetupNextMenu(&ReadDef1);
       return;
    }
@@ -1030,9 +1024,9 @@
    showMessages = 1 - showMessages;
 
    if (!showMessages)
-      players[consoleplayer].message = MSGOFF;
+      players[consoleplayer].message = s_MSGOFF;
    else
-      players[consoleplayer].message = MSGON ;
+      players[consoleplayer].message = s_MSGON ;
 
    message_dontfuckwithme = true;
 }
@@ -1066,11 +1060,11 @@
 
    if (netgame)
    {
-      M_StartMessage(NETEND,NULL,false);
+      M_StartMessage(s_NETEND,NULL,false);
       return;
    }
 
-   M_StartMessage(ENDGAME,M_EndGameResponse,true);
+   M_StartMessage(s_ENDGAME,M_EndGameResponse,true);
 }
 
 
@@ -1153,9 +1147,9 @@
    // We pick index 0 which is language sensitive,
    //  or one at random, between 1 and maximum number.
    if (language != english )
-      snprintf(endstring,sizeof(endstring),"%s\n\n"DOSY, endmsg[0] );
+      snprintf(endstring,sizeof(endstring),"%s\n\n%s",s_DOSY, endmsg[0] );
    else
-      snprintf(endstring,sizeof(endstring),"%s\n\n%s", endmsg[gametic%(NUM_QUITMESSAGES-1)+1], DOSY);
+      snprintf(endstring,sizeof(endstring),"%s\n\n%s", endmsg[gametic%(NUM_QUITMESSAGES-1)+1], s_DOSY);
 
    M_StartMessage(endstring,M_QuitResponse,true);
 }
@@ -1256,7 +1250,7 @@
 
 void
 M_StartMessage
-( char*  string,
+( const char*  string,
   void*  routine,
   boolean input )
 {
diff --git a/apps/plugins/doom/p_doors.c b/apps/plugins/doom/p_doors.c
index 9d8f28c..0b6d777 100644
--- a/apps/plugins/doom/p_doors.c
+++ b/apps/plugins/doom/p_doors.c
@@ -36,7 +36,7 @@
 #include "sounds.h"
 #include "r_main.h"
 #include "dstrings.h"
-//#include "d_deh.h"  // Ty 03/27/98 - externalized
+#include "d_deh.h"  // Ty 03/27/98 - externalized
 
 #include "rockmacros.h"
 
@@ -295,7 +295,7 @@
    case 133:
       if (!p->cards[it_bluecard] && !p->cards[it_blueskull])
       {
-         p->message = PD_BLUEO;             // Ty 03/27/98 - externalized
+         p->message = s_PD_BLUEO;             // Ty 03/27/98 - externalized
          S_StartSound(p->mo,sfx_oof);         // killough 3/20/98
          return 0;
       }
@@ -305,7 +305,7 @@
    case 135:
       if (!p->cards[it_redcard] && !p->cards[it_redskull])
       {
-         p->message = PD_REDO;              // Ty 03/27/98 - externalized
+         p->message = s_PD_REDO;              // Ty 03/27/98 - externalized
          S_StartSound(p->mo,sfx_oof);         // killough 3/20/98
          return 0;
       }
@@ -315,7 +315,7 @@
    case 137:
       if (!p->cards[it_yellowcard] && !p->cards[it_yellowskull])
       {
-         p->message = PD_YELLOWO;           // Ty 03/27/98 - externalized
+         p->message = s_PD_YELLOWO;           // Ty 03/27/98 - externalized
          S_StartSound(p->mo,sfx_oof);         // killough 3/20/98
          return 0;
       }
@@ -449,7 +449,7 @@
          return 0;
       if (!player->cards[it_bluecard] && !player->cards[it_blueskull])
       {
-         player->message = PD_BLUEK;         // Ty 03/27/98 - externalized
+         player->message = s_PD_BLUEK;         // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);     // killough 3/20/98
          return 0;
       }
@@ -461,7 +461,7 @@
          return 0;
       if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull])
       {
-         player->message = PD_YELLOWK;       // Ty 03/27/98 - externalized
+         player->message = s_PD_YELLOWK;       // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);     // killough 3/20/98
          return 0;
       }
@@ -473,7 +473,7 @@
          return 0;
       if (!player->cards[it_redcard] && !player->cards[it_redskull])
       {
-         player->message = PD_REDK;          // Ty 03/27/98 - externalized
+         player->message = s_PD_REDK;          // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);     // killough 3/20/98
          return 0;
       }
diff --git a/apps/plugins/doom/p_inter.c b/apps/plugins/doom/p_inter.c
index f4a0f80..9a34af1 100644
--- a/apps/plugins/doom/p_inter.c
+++ b/apps/plugins/doom/p_inter.c
@@ -36,9 +36,10 @@
 #include "r_main.h"
 #include "s_sound.h"
 #include "sounds.h"
-//#include "d_deh.h"  // Ty 03/22/98 - externalized strings
+#include "d_deh.h"  // Ty 03/22/98 - externalized strings
 #include "p_tick.h"
 #include "i_system.h"
+
 #include "p_inter.h"
 #include "p_enemy.h"
 
@@ -315,13 +316,13 @@
    case SPR_ARM1:
       if (!P_GiveArmor (player, green_armor_class))
          return;
-      player->message = GOTARMOR; // Ty 03/22/98 - externalized
+      player->message = s_GOTARMOR; // Ty 03/22/98 - externalized
       break;
 
    case SPR_ARM2:
       if (!P_GiveArmor (player, blue_armor_class))
          return;
-      player->message = GOTMEGA; // Ty 03/22/98 - externalized
+      player->message = s_GOTMEGA; // Ty 03/22/98 - externalized
       break;
 
       // bonus items
@@ -330,7 +331,7 @@
       if (player->health > (maxhealth * 2))
          player->health = (maxhealth * 2);
       player->mo->health = player->health;
-      player->message = GOTHTHBONUS; // Ty 03/22/98 - externalized
+      player->message = s_GOTHTHBONUS; // Ty 03/22/98 - externalized
       break;
 
    case SPR_BON2:
@@ -339,7 +340,7 @@
          player->armorpoints = max_armor;
       if (!player->armortype)
          player->armortype = green_armor_class;
-      player->message = GOTARMBONUS; // Ty 03/22/98 - externalized
+      player->message = s_GOTARMBONUS; // Ty 03/22/98 - externalized
       break;
 
    case SPR_SOUL:
@@ -347,7 +348,7 @@
       if (player->health > max_soul)
          player->health = max_soul;
       player->mo->health = player->health;
-      player->message = GOTSUPER; // Ty 03/22/98 - externalized
+      player->message = s_GOTSUPER; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
@@ -357,7 +358,7 @@
       player->health = mega_health;
       player->mo->health = player->health;
       P_GiveArmor (player,blue_armor_class);
-      player->message = GOTMSPHERE; // Ty 03/22/98 - externalized
+      player->message = s_GOTMSPHERE; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
@@ -365,7 +366,7 @@
       // leave cards for everyone
    case SPR_BKEY:
       if (!player->cards[it_bluecard])
-         player->message = GOTBLUECARD; // Ty 03/22/98 - externalized
+         player->message = s_GOTBLUECARD; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_bluecard);
       if (!netgame)
          break;
@@ -373,7 +374,7 @@
 
    case SPR_YKEY:
       if (!player->cards[it_yellowcard])
-         player->message = GOTYELWCARD; // Ty 03/22/98 - externalized
+         player->message = s_GOTYELWCARD; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_yellowcard);
       if (!netgame)
          break;
@@ -381,7 +382,7 @@
 
    case SPR_RKEY:
       if (!player->cards[it_redcard])
-         player->message = GOTREDCARD; // Ty 03/22/98 - externalized
+         player->message = s_GOTREDCARD; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_redcard);
       if (!netgame)
          break;
@@ -389,7 +390,7 @@
 
    case SPR_BSKU:
       if (!player->cards[it_blueskull])
-         player->message = GOTBLUESKUL; // Ty 03/22/98 - externalized
+         player->message = s_GOTBLUESKUL; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_blueskull);
       if (!netgame)
          break;
@@ -397,7 +398,7 @@
 
    case SPR_YSKU:
       if (!player->cards[it_yellowskull])
-         player->message = GOTYELWSKUL; // Ty 03/22/98 - externalized
+         player->message = s_GOTYELWSKUL; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_yellowskull);
       if (!netgame)
          break;
@@ -405,7 +406,7 @@
 
    case SPR_RSKU:
       if (!player->cards[it_redskull])
-         player->message = GOTREDSKULL; // Ty 03/22/98 - externalized
+         player->message = s_GOTREDSKULL; // Ty 03/22/98 - externalized
       P_GiveCard (player, it_redskull);
       if (!netgame)
          break;
@@ -415,7 +416,7 @@
    case SPR_STIM:
       if (!P_GiveBody (player, 10))
          return;
-      player->message = GOTSTIM; // Ty 03/22/98 - externalized
+      player->message = s_GOTSTIM; // Ty 03/22/98 - externalized
       break;
 
    case SPR_MEDI:
@@ -423,9 +424,9 @@
          return;
 
       if (player->health < 50) // cph - 25 + the 25 just added, thanks to Quasar for reporting this bug
-         player->message = GOTMEDINEED; // Ty 03/22/98 - externalized
+         player->message = s_GOTMEDINEED; // Ty 03/22/98 - externalized
       else
-         player->message = GOTMEDIKIT; // Ty 03/22/98 - externalized
+         player->message = s_GOTMEDIKIT; // Ty 03/22/98 - externalized
       break;
 
 
@@ -433,14 +434,14 @@
    case SPR_PINV:
       if (!P_GivePower (player, pw_invulnerability))
          return;
-      player->message = GOTINVUL; // Ty 03/22/98 - externalized
+      player->message = s_GOTINVUL; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
    case SPR_PSTR:
       if (!P_GivePower (player, pw_strength))
          return;
-      player->message = GOTBERSERK; // Ty 03/22/98 - externalized
+      player->message = s_GOTBERSERK; // Ty 03/22/98 - externalized
       if (player->readyweapon != wp_fist)
          player->pendingweapon = wp_fist;
       sound = sfx_getpow;
@@ -449,28 +450,28 @@
    case SPR_PINS:
       if (!P_GivePower (player, pw_invisibility))
          return;
-      player->message = GOTINVIS; // Ty 03/22/98 - externalized
+      player->message = s_GOTINVIS; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
    case SPR_SUIT:
       if (!P_GivePower (player, pw_ironfeet))
          return;
-      player->message = GOTSUIT; // Ty 03/22/98 - externalized
+      player->message = s_GOTSUIT; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
    case SPR_PMAP:
       if (!P_GivePower (player, pw_allmap))
          return;
-      player->message = GOTMAP; // Ty 03/22/98 - externalized
+      player->message = s_GOTMAP; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
    case SPR_PVIS:
       if (!P_GivePower (player, pw_infrared))
          return;
-      player->message = GOTVISOR; // Ty 03/22/98 - externalized
+      player->message = s_GOTVISOR; // Ty 03/22/98 - externalized
       sound = sfx_getpow;
       break;
 
@@ -486,49 +487,49 @@
          if (!P_GiveAmmo (player,am_clip,1))
             return;
       }
-      player->message = GOTCLIP; // Ty 03/22/98 - externalized
+      player->message = s_GOTCLIP; // Ty 03/22/98 - externalized
       break;
 
    case SPR_AMMO:
       if (!P_GiveAmmo (player, am_clip,5))
          return;
-      player->message = GOTCLIPBOX; // Ty 03/22/98 - externalized
+      player->message = s_GOTCLIPBOX; // Ty 03/22/98 - externalized
       break;
 
    case SPR_ROCK:
       if (!P_GiveAmmo (player, am_misl,1))
          return;
-      player->message = GOTROCKET; // Ty 03/22/98 - externalized
+      player->message = s_GOTROCKET; // Ty 03/22/98 - externalized
       break;
 
    case SPR_BROK:
       if (!P_GiveAmmo (player, am_misl,5))
          return;
-      player->message = GOTROCKBOX; // Ty 03/22/98 - externalized
+      player->message = s_GOTROCKBOX; // Ty 03/22/98 - externalized
       break;
 
    case SPR_CELL:
       if (!P_GiveAmmo (player, am_cell,1))
          return;
-      player->message = GOTCELL; // Ty 03/22/98 - externalized
+      player->message = s_GOTCELL; // Ty 03/22/98 - externalized
       break;
 
    case SPR_CELP:
       if (!P_GiveAmmo (player, am_cell,5))
          return;
-      player->message = GOTCELLBOX; // Ty 03/22/98 - externalized
+      player->message = s_GOTCELLBOX; // Ty 03/22/98 - externalized
       break;
 
    case SPR_SHEL:
       if (!P_GiveAmmo (player, am_shell,1))
          return;
-      player->message = GOTSHELLS; // Ty 03/22/98 - externalized
+      player->message = s_GOTSHELLS; // Ty 03/22/98 - externalized
       break;
 
    case SPR_SBOX:
       if (!P_GiveAmmo (player, am_shell,5))
          return;
-      player->message = GOTSHELLBOX; // Ty 03/22/98 - externalized
+      player->message = s_GOTSHELLBOX; // Ty 03/22/98 - externalized
       break;
 
    case SPR_BPAK:
@@ -540,56 +541,56 @@
       }
       for (i=0 ; i<NUMAMMO ; i++)
          P_GiveAmmo (player, i, 1);
-      player->message = GOTBACKPACK; // Ty 03/22/98 - externalized
+      player->message = s_GOTBACKPACK; // Ty 03/22/98 - externalized
       break;
 
       // weapons
    case SPR_BFUG:
       if (!P_GiveWeapon (player, wp_bfg, false) )
          return;
-      player->message = GOTBFG9000; // Ty 03/22/98 - externalized
+      player->message = s_GOTBFG9000; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_MGUN:
       if (!P_GiveWeapon (player, wp_chaingun, (special->flags&MF_DROPPED)!=0) )
          return;
-      player->message = GOTCHAINGUN; // Ty 03/22/98 - externalized
+      player->message = s_GOTCHAINGUN; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_CSAW:
       if (!P_GiveWeapon (player, wp_chainsaw, false) )
          return;
-      player->message = GOTCHAINSAW; // Ty 03/22/98 - externalized
+      player->message = s_GOTCHAINSAW; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_LAUN:
       if (!P_GiveWeapon (player, wp_missile, false) )
          return;
-      player->message = GOTLAUNCHER; // Ty 03/22/98 - externalized
+      player->message = s_GOTLAUNCHER; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_PLAS:
       if (!P_GiveWeapon (player, wp_plasma, false) )
          return;
-      player->message = GOTPLASMA; // Ty 03/22/98 - externalized
+      player->message = s_GOTPLASMA; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_SHOT:
       if (!P_GiveWeapon (player, wp_shotgun, (special->flags&MF_DROPPED)!=0 ) )
          return;
-      player->message = GOTSHOTGUN; // Ty 03/22/98 - externalized
+      player->message = s_GOTSHOTGUN; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
    case SPR_SGN2:
       if (!P_GiveWeapon(player, wp_supershotgun, (special->flags&MF_DROPPED)!=0))
          return;
-      player->message = GOTSHOTGUN2; // Ty 03/22/98 - externalized
+      player->message = s_GOTSHOTGUN2; // Ty 03/22/98 - externalized
       sound = sfx_wpnup;
       break;
 
diff --git a/apps/plugins/doom/p_pspr.c b/apps/plugins/doom/p_pspr.c
index 9ef9e73..c3bc422 100644
--- a/apps/plugins/doom/p_pspr.c
+++ b/apps/plugins/doom/p_pspr.c
@@ -46,9 +46,7 @@
 #define WEAPONBOTTOM (FRACUNIT*128)
 #define WEAPONTOP    (FRACUNIT*32)
 
-// plasma cells for a bfg attack
-#define BFGCELLS  40
-//#define BFGCELLS bfgcells        /* Ty 03/09/98 externalized in p_inter.c */
+#define BFGCELLS bfgcells        /* Ty 03/09/98 externalized in p_inter.c */
 
 extern void P_Thrust(player_t *, angle_t, fixed_t);
 
diff --git a/apps/plugins/doom/p_spec.c b/apps/plugins/doom/p_spec.c
index c8c04fa..f2757f8 100644
--- a/apps/plugins/doom/p_spec.c
+++ b/apps/plugins/doom/p_spec.c
@@ -54,7 +54,7 @@
 #include "s_sound.h"
 #include "sounds.h"
 #include "m_bbox.h"                                         // phares 3/20/98
-//#include "d_deh.h"
+#include "d_deh.h"
 #include "r_plane.h"
 #include "i_system.h"
 #include "rockmacros.h"
@@ -818,7 +818,7 @@
          !player->cards[it_yellowskull]
       )
       {
-         player->message = PD_ANY; // Ty 03/27/98 - externalized
+         player->message = s_PD_ANY; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -830,7 +830,7 @@
          (!skulliscard || !player->cards[it_redskull])
       )
       {
-         player->message = skulliscard? PD_REDK : PD_REDC; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_REDK : s_PD_REDC; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -842,7 +842,7 @@
          (!skulliscard || !player->cards[it_blueskull])
       )
       {
-         player->message = skulliscard? PD_BLUEK : PD_BLUEC; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_BLUEK : s_PD_BLUEC; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -854,7 +854,7 @@
          (!skulliscard || !player->cards[it_yellowskull])
       )
       {
-         player->message = skulliscard? PD_YELLOWK : PD_YELLOWC; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_YELLOWK : s_PD_YELLOWC; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -866,7 +866,7 @@
          (!skulliscard || !player->cards[it_redcard])
       )
       {
-         player->message = skulliscard? PD_REDK : PD_REDS; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_REDK : s_PD_REDS; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -878,7 +878,7 @@
          (!skulliscard || !player->cards[it_bluecard])
       )
       {
-         player->message = skulliscard? PD_BLUEK : PD_BLUES; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_BLUEK : s_PD_BLUES; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -890,7 +890,7 @@
          (!skulliscard || !player->cards[it_yellowcard])
       )
       {
-         player->message = skulliscard? PD_YELLOWK : PD_YELLOWS; // Ty 03/27/98 - externalized
+         player->message = skulliscard? s_PD_YELLOWK : s_PD_YELLOWS; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -909,7 +909,7 @@
          )
       )
       {
-         player->message = PD_ALL6; // Ty 03/27/98 - externalized
+         player->message = s_PD_ALL6; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
@@ -926,7 +926,7 @@
          )
       )
       {
-         player->message = PD_ALL3; // Ty 03/27/98 - externalized
+         player->message = s_PD_ALL3; // Ty 03/27/98 - externalized
          S_StartSound(player->mo,sfx_oof);             // killough 3/20/98
          return false;
       }
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index d66d86d..00bd22b 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -782,14 +782,6 @@
 
    rb->lcd_setfont(0);
 
-#ifdef FANCY_MENU
-   /* TO FIX: Don't use load_main_backdrop() - use lcd_set_backdrop() */
-   if(rb->load_main_backdrop(GAMEBASE"backdrop.bmp"))
-      rb->lcd_set_foreground(LCD_RGBPACK(85,208,56));
-
-   rb->lcd_clear_display();
-#endif
-
    // We're using doom's memory management since it implements a proper free (and re-uses the memory)
    // and now with prboom's code: realloc and calloc
    printf ("Z_Init: Init zone memory allocation daemon.\n");
@@ -798,15 +790,7 @@
    printf ("M_LoadDefaults: Load system defaults.\n");
    M_LoadDefaults ();              // load before initing other systems
 
-#ifdef FANCY_MENU
-   rb->lcd_setfont(FONT_UI);
-   rb->lcd_putsxy(5,LCD_HEIGHT-20, "Welcome to RockDoom");
-   rb->lcd_update();
-   rb->sleep(HZ*2);
-   rb->lcd_setfont(0);
-#else
    rb->splash(HZ*2, true, "Welcome to RockDoom");
-#endif
 
    myargv =0;
    myargc=0;
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h
index bda8219..31b16c7 100644
--- a/apps/plugins/doom/rockmacros.h
+++ b/apps/plugins/doom/rockmacros.h
@@ -35,7 +35,7 @@
 int my_close(int id);
 char *my_strtok( char * s, const char * delim );
 #define alloca             __builtin_alloca
-#define fprintf(...)       rb->fdprintf(__VA_ARGS__)
+#define fdprintf(...)       rb->fdprintf(__VA_ARGS__)
 #define vsnprintf(...)     rb->vsnprintf(__VA_ARGS__)
 
 #ifdef SIMULATOR
@@ -61,6 +61,7 @@
 #define lseek(a,b,c)       rb->lseek((a),(b),(c))
 #endif /* !SIMULATOR */
 
+#define strtok(a,b)        my_strtok((a),(b))
 #define strcat(a,b)        rb->strcat((a),(b))
 #define read(a,b,c)        rb->read((a),(b),(c))
 #define write(a,b,c)       rb->write((a),(b),(c))
@@ -91,7 +92,6 @@
 //#define SIMPLECHECKS
 #define NO_PREDEFINED_LUMPS
 #define TABLES_AS_LUMPS // This frees up alot of space in the plugin buffer
-//#define FANCY_MENU  // This is a call to allow load_main_backdrop to run in doom
 
 #define MAKE_FOURCC(a,b,c,d) (uint32_t)((((a)<<24)|((b)<<16)|((c)<<8)|(d)))