diff --git a/cgdoom/cgdoom-ui.c b/cgdoom/cgdoom-ui.c index 83013fb..019b05e 100644 --- a/cgdoom/cgdoom-ui.c +++ b/cgdoom/cgdoom-ui.c @@ -355,7 +355,7 @@ int Layout_Event(Layout *l, int key) int UI_Main(WADFileInfo *wads, int wad_count, int *dev_info, int *use_mmap, int *startmap, int *startepisode, int *trustunaligned, - int *autostart) + int *autostart, int *enabledemos) { Layout l; Layout_Init(&l); @@ -391,7 +391,9 @@ int UI_Main(WADFileInfo *wads, int wad_count, int *dev_info, int *use_mmap, Layout_Spacing(&l, 12); Layout_Integer(&l, "Start at episode:", startepisode); Layout_Integer(&l, "Start at map:", startmap); - Layout_Checkbox(&l, "Skip title screen:", autostart); + Layout_Text(&l, "Title screen:", + *autostart ? "Skip" : + !*enabledemos ? "No demos" : "Full"); Layout_Spacing(&l, 12); Layout_Checkbox(&l, "Developer info:", dev_info); @@ -403,10 +405,19 @@ int UI_Main(WADFileInfo *wads, int wad_count, int *dev_info, int *use_mmap, int key; GetKey(&key); - if(Layout_Event(&l, key)) - {} - else if(key == KEY_CTRL_EXE && l.focus < wad_count) + if(Layout_Event(&l, key)) { + } + else if(key == KEY_CTRL_EXE && l.focus == wad_count + 2) { + if (!*autostart && *enabledemos) + *autostart = 1; + else if (!*autostart) + *enabledemos = 1; + else + *autostart = 0, *enabledemos = 0; + } + else if(key == KEY_CTRL_EXE && l.focus < wad_count) { return l.focus; + } if(*startmap < 1) *startmap = 1; diff --git a/cgdoom/cgdoom-ui.h b/cgdoom/cgdoom-ui.h index 2b899f2..060492c 100644 --- a/cgdoom/cgdoom-ui.h +++ b/cgdoom/cgdoom-ui.h @@ -68,7 +68,8 @@ int UI_Main(WADFileInfo *wads, int wad_count, int *startmap, /* Warp to this map */ int *startepisode, /* Warp to this episode */ int *trustunaligned, /* Trust unaligned lumps */ - int *autostart /* Skip main menu, straight to gameplay */ + int *autostart, /* Skip title screen, straight to gameplay */ + int *enabledemos /* Enable demos on the title screen */ ); #endif /* CGDOOM_UI_H */ diff --git a/cgdoom/cgdoom.c b/cgdoom/cgdoom.c index 31ec9e5..98a2754 100644 --- a/cgdoom/cgdoom.c +++ b/cgdoom/cgdoom.c @@ -381,6 +381,8 @@ static SectorIndexInfo *gIndex = NULL; /* Global options */ int CGD_TrustUnalignedLumps = 1; +int CGD_EnableDemos = 0; +int CGD_SingleEpisodeUltimate = 0; /* Performance counters */ struct CGD_Perf CGD_Perf; @@ -638,12 +640,23 @@ int main(void) int dev_info = 0; int choice = UI_Main(wads, wad_count, &dev_info, &gWADmethod, - &startmap, &startepisode, &CGD_TrustUnalignedLumps, &autostart_); + &startmap, &startepisode, &CGD_TrustUnalignedLumps, &autostart_, + &CGD_EnableDemos); if(choice < 0) return 1; autostart = autostart_; + /* Override version detection for single-episode Ultimate Doom WADs */ + if (!CGDstrcmp(wads[choice].name, "doomu1.wad")) + CGD_SingleEpisodeUltimate = 1; + if (!CGDstrcmp(wads[choice].name, "doomu2.wad")) + CGD_SingleEpisodeUltimate = 2; + if (!CGDstrcmp(wads[choice].name, "doomu3.wad")) + CGD_SingleEpisodeUltimate = 3; + if (!CGDstrcmp(wads[choice].name, "doomu4.wad")) + CGD_SingleEpisodeUltimate = 4; + unsigned tmp=((unsigned)getSecondaryVramAddress()+3)&(~3); SaveVRAMBuffer = (unsigned char*)tmp; /* Graph 90+E: RAM starts at 0x0c000000 in physical memory */ diff --git a/cgdoom/cgdoom.h b/cgdoom/cgdoom.h index 91d0602..8bf7e2c 100644 --- a/cgdoom/cgdoom.h +++ b/cgdoom/cgdoom.h @@ -1,7 +1,7 @@ #ifndef CGDOOM_H #define CGDOOM_H -/* CGDoom-specific definitions that cover both calculator and native builds. */ +// CGDoom-specific definitions that cover both calculator and native builds. #include #include "libprof.h" @@ -19,14 +19,24 @@ typedef struct int size; } WADFileInfo; -// TODO: Move developer info here +/* CGDoom statistics */ +extern struct CGD_Perf CGD_Perf; +extern struct CGD_Stats CGD_Stats; -/* Global variables interfacing with Doom itself. */ +// CGDoom options (some more are specified in platform.h) + +/* Enable demos in the title screen (most are incompatible and look bad) */ +extern int CGD_EnableDemos; +/* The selected WAD is a split Ultimate Doom WAD with a single episode (this + exists on the fx-CG 50 and is incorrectly detected by normal logic) */ +extern int CGD_SingleEpisodeUltimate; + +// Global variables interfacing with Doom itself. /* Map and episode to start at when loading the game. */ extern int startmap, startepisode; -/* Keyboard interface. */ +// Keyboard interface. // Special key names for cheats, debugs, etc (completes doomdef.h). #define SKEY_CHEAT 0x10001 diff --git a/cgdoom/d_main.c b/cgdoom/d_main.c index 6d84c6a..b29fb64 100644 --- a/cgdoom/d_main.c +++ b/cgdoom/d_main.c @@ -30,6 +30,7 @@ #include "os.h" +#include "cgdoom.h" #include "cgdoom-alloc.h" #include @@ -343,9 +344,9 @@ void D_DoAdvanceDemo (void) gameaction = ga_nothing; if ( gamemode == retail ) - demosequence = (demosequence+1)%4; + demosequence = (demosequence+1)%7; else - demosequence = (demosequence+1)%3; + demosequence = (demosequence+1)%6; switch (demosequence) { @@ -366,6 +367,9 @@ void D_DoAdvanceDemo (void) pagename = "CREDIT"; break; case 3: + G_DeferedPlayDemo ("demo2"); + break; + case 4: gamestate = GS_DEMOSCREEN; if ( gamemode == commercial) { @@ -382,6 +386,17 @@ void D_DoAdvanceDemo (void) pagename = "HELP2"; } break; + case 5: + G_DeferedPlayDemo ("demo3"); + break; + case 6: + G_DeferedPlayDemo ("demo4"); + break; + } + + /* CGDoom: Skip demos on option (often incompatible) */ + if (gameaction == ga_playdemo && !CGD_EnableDemos) { + D_DoAdvanceDemo(); } } @@ -446,26 +461,21 @@ void D_DoomMain() if(gamemode == indetermined) // CX port return; // CX port - {//save sprintf - if (W_CheckNumForName("E2M1")!=-1) - { - maxepisode = 2; - if (W_CheckNumForName("E3M1")!=-1) - maxepisode = 3; - } -#if 0 //CG:seem to be useless - while(true) - { if(gamemode==commercial) - sprintf(res,"MAP%02i",maxmap+1); - else - sprintf(res,"E1M%i",maxmap+1); - if (W_CheckNumForName(res)==-1) - break; - maxmap++; - } -#endif + if (W_CheckNumForName("E4M1")!=-1) + maxepisode = 4; + else if (W_CheckNumForName("E3M1")!=-1) + maxepisode = 3; + else if (W_CheckNumForName("E2M1")!=-1) + maxepisode = 2; + + /* CGDoom: Override game mode for split WADs; we have single-episode WADs for + all episodes of Ultimate Doom, and they should identify as retail */ + if (CGD_SingleEpisodeUltimate > 0) { + gamemode=retail; + maxepisode = CGD_SingleEpisodeUltimate; } + nomonsters = 0; respawnparm = 0; fastparm = 0; diff --git a/cgdoom/g_game.c b/cgdoom/g_game.c index ed3b253..6987f73 100644 --- a/cgdoom/g_game.c +++ b/cgdoom/g_game.c @@ -24,6 +24,7 @@ //static const char #include "os.h" +#include "cgdoom.h" #include "doomdef.h" #include "doomstat.h" @@ -485,7 +486,10 @@ void G_Ticker (void) { cmd = &players[0].cmd; - G_BuildTiccmd (cmd); + if (demoplayback) + G_ReadDemoTiccmd (cmd); + else + G_BuildTiccmd (cmd); if (players[0].cmd.buttons & BT_SPECIAL) { @@ -789,6 +793,9 @@ void G_DoCompleted (void) wminfo.epsd = gameepisode -1; wminfo.last = gamemap -1; + if (CGD_SingleEpisodeUltimate) + wminfo.epsd = CGD_SingleEpisodeUltimate - 1; + // wminfo.next is 0 biased, unlike gamemap if ( gamemode == commercial) { @@ -955,15 +962,16 @@ void G_DeferedInitNew( skill_t skill, int episode, int map) void G_DoNewGame (void) { -// netdemo = false; -// netgame = false; + demoplayback = false; + netdemo = false; + netgame = false; deathmatch = false; playeringame[0] = true; playeringame[1] = playeringame[2] = playeringame[3] = 0; respawnparm = false; fastparm = false; nomonsters = false; -// consoleplayer = 0; + consoleplayer = 0; G_InitNew (d_skill, d_episode, d_map); gameaction = ga_nothing; } @@ -1031,6 +1039,7 @@ void G_InitNew ( skill_t skill, int episode, int map ) usergame = true; // will be set false if a demo paused = false; + demoplayback = false; automapactive = false; viewactive = true; gameepisode = episode; @@ -1136,7 +1145,11 @@ void G_DoPlayDemo (void) gameaction = ga_nothing; demobuffer = demo_p = (byte *)W_CacheLumpNameConst (defdemoname, PU_STATIC); - if ( *demo_p++ != VERSION) + + /* CGDoom: We have old WADs with demos at versions 108 and 109. They don't + really work whell though */ + byte version = *demo_p++; + if (version != VERSION && version != 109 && version != 108) { // fprintf( stderr, "Demo is from a different game version!\n"); gameaction = ga_nothing; diff --git a/cgdoom/hu_stuff.c b/cgdoom/hu_stuff.c index 4f6917a..d867302 100644 --- a/cgdoom/hu_stuff.c +++ b/cgdoom/hu_stuff.c @@ -23,6 +23,8 @@ //static const char #include "os.h" +#include "cgdoom.h" + #include "doomdef.h" #include "z_zone.h" #include "m_swap.h" @@ -239,7 +241,10 @@ void HU_Start(void) case shareware: case registered: case retail: + /* CGDoom: Use proper episode names in single-episode Ultimate Doom WADs */ a = 9*(gameepisode-1) + gamemap - 1; + if (CGD_SingleEpisodeUltimate) + a = 9*(CGD_SingleEpisodeUltimate-1) + gamemap - 1; s = mapnames[a]; break; /* FIXME diff --git a/cgdoom/m_menu.c b/cgdoom/m_menu.c index 6b8ae51..7833e04 100644 --- a/cgdoom/m_menu.c +++ b/cgdoom/m_menu.c @@ -24,6 +24,7 @@ #include "os.h" +#include "cgdoom.h" #include "doomdef.h" @@ -1289,5 +1290,10 @@ void M_Init (void) break; } + /* CGDoom: Change options when playing single-episode Ultimate Doom WADs */ + if (CGD_SingleEpisodeUltimate) { + EpiDef.numitems -= 3; + EpisodeMenu[0] = EpisodeMenu[CGD_SingleEpisodeUltimate - 1]; + } } diff --git a/src-cg/platform.h b/src-cg/platform.h index 45dab2c..e0e9386 100644 --- a/src-cg/platform.h +++ b/src-cg/platform.h @@ -79,9 +79,6 @@ extern int CGD_TrustUnalignedLumps; # define CGDOOM_SCREENS_BASE SaveVRAMBuffer #endif -extern struct CGD_Perf CGD_Perf; -extern struct CGD_Stats CGD_Stats; - //--- #include "keyboard.hpp"