shithub: choc

Download patch

ref: 0ec3d826f0b0f2b25f8652287f2c1027c8229e34
parent: 7e9d6e29bae68f9b9971660f7b59ddd5731e4d22
author: Simon Howard <fraggle@gmail.com>
date: Wed Oct 1 19:56:09 EDT 2014

hexen: Add workaround for Mac Hexen IWAD.

The Mac version of hexen.wad is slightly different from the normal
DOS one: it contains a bunch of extra lumps but more importantly,
the GENMIDI and DMXGUS lumps are missing. This means that Chocolate
Hexen would crash on startup with the default settings (as OPL is
the default music output).

To work around this problem and allow the game to start up properly,
detect if the required lump is missing and adjust the music settings,
printing a helpful message to stdout to inform the user.

--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -186,6 +186,40 @@
     }
 }
 
+// The Mac version of the Hexen IWAD is different to the "normal" DOS
+// version - it doesn't include lumps used by the DOS DMX library.
+// This means that we can't do GUS or OPL emulation and need to apply
+// a workaround.
+static void AdjustForMacIWAD(void)
+{
+    boolean adjust_music = false;
+
+    switch (snd_musicdevice)
+    {
+        case SNDDEVICE_ADLIB:
+        case SNDDEVICE_SB:
+            adjust_music = W_CheckNumForName("GENMIDI") < 0;
+            break;
+
+        case SNDDEVICE_GUS:
+            adjust_music = W_CheckNumForName("DMXGUS") < 0;
+            break;
+
+        default:
+            break;
+    }
+
+    if (adjust_music)
+    {
+        printf("** Note: You appear to be using the Mac version of the Hexen\n"
+               "** IWAD file. This is missing the lumps required for OPL or\n"
+               "** GUS emulation. Your music configuration is being adjusted\n"
+               "** to a different setting that won't cause the game to "
+               "crash.\n");
+        snd_musicdevice = SNDDEVICE_GENMIDI;
+    }
+}
+
 //
 // D_GrabMouseCallback
 //
@@ -297,6 +331,7 @@
 
     D_AddFile(iwadfile);
     W_CheckCorrectIWAD(hexen);
+    AdjustForMacIWAD();
 
     HandleArgs();