foxygit / doom Log in
commit 44fea0d80e7f7be8783e77303253ed40d492ce29
Author:     nukeykt <alexeytf2@icloud.com>
AuthorDate: Thu Jun 9 21:13:35 2016 +0900
Commit:     nukeykt <alexeytf2@icloud.com>
CommitDate: Thu Jun 9 21:13:35 2016 +0900

    doom: Fix minor Ultimate/Final Doom and Chex emulation bugs.
---
 src/doom/d_main.c   |   2 +-
 src/doom/f_finale.c |   2 +-
 src/doom/m_menu.c   | 143 +++++++++++++++-------------------------------------
 src/doom/wi_stuff.c |   4 +-
 4 files changed, 45 insertions(+), 106 deletions(-)

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 1b708381..cb9cbf13 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -581,7 +581,7 @@ void D_DoAdvanceDemo (void)
 	{
 	    pagetic = 200;

-	    if ( gamemode == retail )
+	    if (gameversion >= exe_ultimate)
 	      pagename = DEH_String("CREDIT");
 	    else
 	      pagename = DEH_String("HELP2");
diff --git a/src/doom/f_finale.c b/src/doom/f_finale.c
index 02651357..467483a8 100644
--- a/src/doom/f_finale.c
+++ b/src/doom/f_finale.c
@@ -671,7 +671,7 @@ static void F_ArtScreenDrawer(void)
         switch (gameepisode)
         {
             case 1:
-                if (gamemode == retail)
+                if (gameversion >= exe_ultimate)
                 {
                     lumpname = "CREDIT";
                 }
diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c
index 3d0539ff..837b9d4c 100644
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -742,74 +742,9 @@ void M_QuickLoad(void)
 //
 void M_DrawReadThis1(void)
 {
-    char *lumpname = "CREDIT";
-    int skullx = 330, skully = 175;
-
     inhelpscreens = true;
-
-    // Different versions of Doom 1.9 work differently
-
-    switch (gameversion)
-    {
-        case exe_doom_1_666:
-        case exe_doom_1_7:
-        case exe_doom_1_8:
-        case exe_doom_1_9:
-        case exe_hacx:
-
-            if (gamemode == commercial)
-            {
-                // Doom 2
-
-                lumpname = "HELP";
-
-                skullx = 330;
-                skully = 165;
-            }
-            else
-            {
-                // Doom 1
-                // HELP2 is the first screen shown in Doom 1
-
-                lumpname = "HELP2";
-
-                skullx = 280;
-                skully = 185;
-            }
-            break;
-
-        case exe_ultimate:
-        case exe_chex:
-
-            // Ultimate Doom always displays "HELP1".
-
-            // Chex Quest version also uses "HELP1", even though it is based
-            // on Final Doom.
-
-            lumpname = "HELP1";
-
-            break;
-
-        case exe_final:
-        case exe_final2:
-
-            // Final Doom always displays "HELP".
-
-            lumpname = "HELP";
-
-            break;
-
-        default:
-            I_Error("Unhandled game version");
-            break;
-    }
-
-    lumpname = DEH_String(lumpname);
-
-    V_DrawPatchDirect (0, 0, W_CacheLumpName(lumpname, PU_CACHE));

-    ReadDef1.x = skullx;
-    ReadDef1.y = skully;
+    V_DrawPatchDirect(0, 0, W_CacheLumpName(DEH_String("HELP2"), PU_CACHE));
 }


@@ -827,6 +762,13 @@ void M_DrawReadThis2(void)
     V_DrawPatchDirect(0, 0, W_CacheLumpName(DEH_String("HELP1"), PU_CACHE));
 }

+void M_DrawReadThisCommercial(void)
+{
+    inhelpscreens = true;
+
+    V_DrawPatchDirect(0, 0, W_CacheLumpName(DEH_String("HELP"), PU_CACHE));
+}
+

 //
 // Change Sfx & Music volumes
@@ -962,7 +904,7 @@ void M_Episode(int choice)
 	M_SetupNextMenu(&ReadDef1);
 	return;
     }
-
+#if 0
     // Yet another hack...
     if ( (gamemode == registered)
 	 && (choice > 2))
@@ -971,7 +913,7 @@ void M_Episode(int choice)
 	       "M_Episode: 4th episode requires UltimateDOOM\n");
       choice = 0;
     }
-
+#endif
     epi = choice;
     M_SetupNextMenu(&NewDef);
 }
@@ -1074,20 +1016,8 @@ void M_ReadThis(int choice)

 void M_ReadThis2(int choice)
 {
-    // Doom 1.9 had two menus when playing Doom 1
-    // All others had only one
-
-    if (gameversion <= exe_doom_1_9 && gamemode != commercial)
-    {
-        choice = 0;
-        M_SetupNextMenu(&ReadDef2);
-    }
-    else
-    {
-        // Close the menu
-
-        M_FinishReadThis(0);
-    }
+    choice = 0;
+    M_SetupNextMenu(&ReadDef2);
 }

 void M_FinishReadThis(int choice)
@@ -1673,7 +1603,7 @@ boolean M_Responder (event_t* ev)
         {
 	    M_StartControlPanel ();

-	    if ( gamemode == retail )
+	    if (gameversion >= exe_ultimate)
 	      currentMenu = &ReadDef2;
 	    else
 	      currentMenu = &ReadDef1;
@@ -2088,25 +2018,29 @@ void M_Init (void)
     // Here we could catch other version dependencies,
     //  like HELP1/2, and four episodes.

-
-    switch ( gamemode )
+    // The same hacks were used in the original Doom EXEs.
+
+    if (gameversion >= exe_ultimate)
     {
-      case commercial:
-        // Commercial has no "read this" entry.
-	MainMenu[readthis] = MainMenu[quitdoom];
-	MainDef.numitems--;
-	MainDef.y += 8;
-	NewDef.prevMenu = &MainDef;
-	break;
-      case shareware:
-	// Episode 2 and 3 are handled,
-	//  branching to an ad screen.
-      case registered:
-	break;
-      case retail:
-	// We are fine.
-      default:
-	break;
+        MainMenu[readthis].routine = M_ReadThis2;
+        ReadDef2.prevMenu = NULL;
+    }
+
+    if (gameversion >= exe_final && gameversion <= exe_final2)
+    {
+        ReadDef2.routine = M_DrawReadThisCommercial;
+    }
+
+    if (gamemode == commercial)
+    {
+        MainMenu[readthis] = MainMenu[quitdoom];
+        MainDef.numitems--;
+        MainDef.y += 8;
+        NewDef.prevMenu = &MainDef;
+        ReadDef1.routine = M_DrawReadThisCommercial;
+        ReadDef1.x = 330;
+        ReadDef1.y = 165;
+        ReadMenu1[rdthsempty1].routine = M_FinishReadThis;
     }

     // Versions of doom.exe before the Ultimate Doom release only had
@@ -2115,7 +2049,12 @@ void M_Init (void)
     // (should crash if missing).
     if (gameversion < exe_ultimate)
     {
-	EpiDef.numitems--;
+        EpiDef.numitems--;
+    }
+    // chex.exe shows only one episode.
+    else if (gameversion == exe_chex)
+    {
+        EpiDef.numitems = 1;
     }

     opldev = M_CheckParm("-opldev") > 0;
diff --git a/src/doom/wi_stuff.c b/src/doom/wi_stuff.c
index a7e18bf0..1d6466bb 100644
--- a/src/doom/wi_stuff.c
+++ b/src/doom/wi_stuff.c
@@ -1687,7 +1687,7 @@ static void WI_loadUnloadData(load_callback_t callback)
     {
         M_StringCopy(name, DEH_String("INTERPIC"), sizeof(name));
     }
-    else if (gamemode == retail && wbs->epsd == 3)
+    else if (gameversion >= exe_ultimate && wbs->epsd == 3)
     {
         M_StringCopy(name, DEH_String("INTERPIC"), sizeof(name));
     }
@@ -1781,7 +1781,7 @@ void WI_initVariables(wbstartstruct_t* wbstartstruct)
 #ifdef RANGECHECKING
     if (gamemode != commercial)
     {
-      if ( gamemode == retail )
+      if (gameversion >= exe_ultimate)
 	RNGCHECK(wbs->epsd, 0, 3);
       else
 	RNGCHECK(wbs->epsd, 0, 2);