ref: b1ece32aaba8bf6b7f233de77b6843af179631b0
parent: 82b4201f850208da35c31b1260841ecd293d31cb
author: Simon Howard <fraggle@gmail.com>
date: Fri Jul 25 15:56:39 EDT 2008
Initial chex.exe emulation. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1155
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -325,8 +325,19 @@
{"tnt.wad", pack_tnt},
{"doom.wad", doom},
{"doom1.wad", doom},
+ {"chex.wad", doom},
};
+
+// Hack for chex quest mode
+static void CheckChex(char *iwad_name)
+{
+ if (!strcmp(iwad_name, "chex.wad"))
+ {
+ gameversion = exe_chex;
+ }
+}
+
// Search a directory to try to find an IWAD
// Returns the location of the IWAD if found, otherwise NULL.
@@ -354,7 +365,9 @@
if (M_FileExists(filename))
{
+ CheckChex(iwads[i].name);
gamemission = iwads[i].mission;
+
return filename;
}
@@ -387,6 +400,7 @@
if (!strcasecmp(name + strlen(name) - strlen(iwadname),
iwadname))
{
+ CheckChex(iwads[i].name);
gamemission = iwads[i].mission;
break;
}
@@ -619,6 +633,43 @@
}
//
+// Get the IWAD name used for savegames.
+//
+
+static char *SaveGameIWADName(void)
+{
+ size_t i;
+
+ // Chex quest hack
+
+ if (gameversion == exe_chex)
+ {
+ return "chex.wad";
+ }
+
+ // Find what subdirectory to use for savegames
+ //
+ // They should be stored in something like
+ // ~/.chocolate-doom/savegames/doom.wad/
+ //
+ // The directory depends on the IWAD, so that savegames for
+ // different IWADs are kept separate.
+ //
+ // Note that we match on gamemission rather than on IWAD name.
+ // This ensures that doom1.wad and doom.wad saves are stored
+ // in the same place.
+
+ for (i=0; i<arrlen(iwads); ++i)
+ {
+ if (gamemission == iwads[i].mission)
+ {
+ return iwads[i].name;
+ }
+ }
+
+ return NULL;
+}
+//
// SetSaveGameDir
//
// Chooses the directory used to store saved games.
@@ -626,7 +677,7 @@
void D_SetSaveGameDir(void)
{
- size_t i;
+ char *iwad_name;
if (!strcmp(configdir, ""))
{
@@ -638,34 +689,18 @@
{
// Directory for savegames
- savegamedir = Z_Malloc(strlen(configdir) + 30, PU_STATIC, 0);
- sprintf(savegamedir, "%ssavegames", configdir);
+ iwad_name = SaveGameIWADName();
- M_MakeDirectory(savegamedir);
-
- // Find what subdirectory to use for savegames
- //
- // They should be stored in something like
- // ~/.chocolate-doom/savegames/doom.wad/
- //
- // The directory depends on the IWAD, so that savegames for
- // different IWADs are kept separate.
- //
- // Note that we match on gamemission rather than on IWAD name.
- // This ensures that doom1.wad and doom.wad saves are stored
- // in the same place.
-
- for (i=0; i<arrlen(iwads); ++i)
+ if (iwad_name == NULL)
{
- if (gamemission == iwads[i].mission)
- {
- sprintf(savegamedir + strlen(savegamedir),
- "%c%s%c",
- DIR_SEPARATOR, iwads[i].name, DIR_SEPARATOR);
- M_MakeDirectory(savegamedir);
- break;
- }
+ iwad_name = "unknown.wad";
}
+
+ savegamedir = Z_Malloc(strlen(configdir) + 30, PU_STATIC, 0);
+ sprintf(savegamedir, "%ssavegames%c%s%c", configdir,
+ DIR_SEPARATOR, iwad_name, DIR_SEPARATOR);
+
+ M_MakeDirectory(savegamedir);
}
}
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -662,6 +662,7 @@
{"Doom 1.9", "1.9", exe_doom_1_9},
{"Ultimate Doom", "ultimate", exe_ultimate},
{"Final Doom", "final", exe_final},
+ {"Chex Quest", "chex", exe_chex},
{ NULL, NULL, 0},
};
@@ -710,7 +711,11 @@
{
// Determine automatically
- if (gamemode == shareware || gamemode == registered)
+ if (gameversion == exe_chex)
+ {
+ // Already determined
+ }
+ else if (gamemode == shareware || gamemode == registered)
{
// original
--- a/src/doomdef.h
+++ b/src/doomdef.h
@@ -105,6 +105,7 @@
{
exe_doom_1_9, // Doom 1.9: used for shareware, registered and commercial
exe_ultimate, // Ultimate Doom (retail)
+ exe_chex, // Chex Quest executable (based on Ultimate Doom)
exe_final, // Final Doom
} GameVersion_t;
--- a/src/f_finale.c
+++ b/src/f_finale.c
@@ -136,6 +136,13 @@
{
textscreen_t *screen = &textscreens[i];
+ // Hack for Chex Quest
+
+ if (gameversion == exe_chex && screen->mission == doom)
+ {
+ screen->level = 5;
+ }
+
if (gamemission == screen->mission
&& (gamemission != doom || gameepisode == screen->episode)
&& gamemap == screen->level)
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1258,18 +1258,33 @@
if (automapactive)
AM_Stop ();
- if ( gamemode != commercial)
- switch(gamemap)
- {
- case 8:
- gameaction = ga_victory;
- return;
- case 9:
- for (i=0 ; i<MAXPLAYERS ; i++)
- players[i].didsecret = true;
- break;
- }
-
+ if (gamemode != commercial)
+ {
+ // Chex Quest ends after 5 levels, rather than 8.
+
+ if (gameversion == exe_chex)
+ {
+ if (gamemap == 5)
+ {
+ gameaction = ga_victory;
+ return;
+ }
+ }
+ else
+ {
+ switch(gamemap)
+ {
+ case 8:
+ gameaction = ga_victory;
+ return;
+ case 9:
+ for (i=0 ; i<MAXPLAYERS ; i++)
+ players[i].didsecret = true;
+ break;
+ }
+ }
+ }
+
//#if 0 Hmmm - why?
if ( (gamemap == 8)
&& (gamemode != commercial) )
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -777,6 +777,7 @@
break;
case exe_ultimate:
+ case exe_chex:
// Ultimate Doom always displays "HELP1".
@@ -901,7 +902,9 @@
return;
}
- if ( gamemode == commercial )
+ // Chex Quest disabled the episode select screen, as did Doom II.
+
+ if (gamemode == commercial || gameversion == exe_chex)
M_SetupNextMenu(&NewDef);
else
M_SetupNextMenu(&EpiDef);