shithub: choc

Download patch

ref: 614351cebaaf2b1a372c78639d2ede7d1d7091fc
parent: de66c6b9672e4a97af96938517a1d954f32966ec
author: Simon Howard <fraggle@gmail.com>
date: Mon Sep 28 16:44:20 EDT 2009

Change music enable/disable control in setup tool to a dropdown list, to
allow MIDI playback type to be selected.

Subversion-branch: /branches/opl-branch
Subversion-revision: 1695

--- a/OPL-TODO
+++ b/OPL-TODO
@@ -8,6 +8,7 @@
 
 Bad MIDIs:
 
+ * doom2.wad MAP01
  * deca.wad MAP01
  * gothicdm MAP05
  * tnt.wad MAP30
@@ -15,6 +16,5 @@
 
 Other tasks:
 
- * Add option to select MIDI type in setup tool
  * DMXOPTIONS opl3/phase option support.
 
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -49,6 +49,14 @@
     NUM_SFXMODES
 } sfxmode_t;
 
+typedef enum
+{
+    MUSMODE_DISABLED,
+    MUSMODE_OPL,
+    MUSMODE_NATIVE,
+    NUM_MUSMODES
+} musmode_t;
+
 static char *sfxmode_strings[] = 
 {
     "Disabled",
@@ -56,14 +64,14 @@
     "Digital",
 };
 
-// Disable MIDI music on OSX: there are problems with the native
-// MIDI code in SDL_mixer.
+static char *musmode_strings[] =
+{
+    "Disabled",
+    "OPL (Adlib/SB)",
+    "Native MIDI"
+};
 
-#ifdef __MACOSX__
-#define DEFAULT_MUSIC_DEVICE SNDDEVICE_NONE
-#else
 #define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB
-#endif
 
 int snd_sfxdevice = SNDDEVICE_SB;
 int numChannels = 8;
@@ -77,7 +85,7 @@
 int use_libsamplerate = 0;
 
 static int snd_sfxmode;
-static int snd_musicenabled;
+static int snd_musmode;
 
 static void UpdateSndDevices(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
 {
@@ -93,15 +101,19 @@
             snd_sfxdevice = SNDDEVICE_SB;
             break;
     }
-    
-    if (snd_musicenabled)
+
+    switch (snd_musmode)
     {
-        snd_musicdevice = SNDDEVICE_SB;
+        case MUSMODE_DISABLED:
+            snd_musicdevice = SNDDEVICE_NONE;
+            break;
+        case MUSMODE_OPL:
+            snd_musicdevice = SNDDEVICE_SB;
+            break;
+        case MUSMODE_NATIVE:
+            snd_musicdevice = SNDDEVICE_GENMIDI;
+            break;
     }
-    else
-    {
-        snd_musicdevice = SNDDEVICE_NONE;
-    }
 }
 
 void ConfigSound(void)
@@ -110,7 +122,7 @@
     txt_table_t *sfx_table;
     txt_table_t *music_table;
     txt_dropdown_list_t *sfx_mode_control;
-    txt_checkbox_t *music_enabled_control;
+    txt_dropdown_list_t *mus_mode_control;
 
     if (snd_sfxdevice == SNDDEVICE_PCSPEAKER)
     {
@@ -124,9 +136,22 @@
     {
         snd_sfxmode = SFXMODE_DISABLED;
     }
-    
-    snd_musicenabled = snd_musicdevice != SNDDEVICE_NONE;
 
+    if (snd_musicdevice == SNDDEVICE_GENMIDI)
+    {
+        snd_musmode = MUSMODE_NATIVE;
+    }
+    else if (snd_musicdevice == SNDDEVICE_SB
+          || snd_musicdevice == SNDDEVICE_ADLIB
+          || snd_musicdevice == SNDDEVICE_AWE32)
+    {
+        snd_musmode = MUSMODE_OPL;
+    }
+    else
+    {
+        snd_musmode = MUSMODE_DISABLED;
+    }
+
     window = TXT_NewWindow("Sound configuration");
 
     TXT_AddWidgets(window,
@@ -133,12 +158,10 @@
                TXT_NewSeparator("Sound effects"),
                sfx_table = TXT_NewTable(2),
                TXT_NewSeparator("Music"),
-               music_enabled_control = TXT_NewCheckBox("Music enabled", 
-                                                       &snd_musicenabled),
                music_table = TXT_NewTable(2),
                NULL);
 
-    TXT_SetColumnWidths(sfx_table, 20, 5);
+    TXT_SetColumnWidths(sfx_table, 20, 14);
 
     TXT_AddWidgets(sfx_table, 
                    TXT_NewLabel("Sound effects"),
@@ -151,17 +174,20 @@
                    TXT_NewSpinControl(&sfxVolume, 0, 15),
                    NULL);
 
-    TXT_SetColumnWidths(music_table, 20, 5);
+    TXT_SetColumnWidths(music_table, 20, 14);
 
     TXT_AddWidgets(music_table,
+                   TXT_NewLabel("Music playback"),
+                   mus_mode_control = TXT_NewDropdownList(&snd_musmode,
+                                                          musmode_strings,
+                                                          NUM_MUSMODES),
                    TXT_NewLabel("Music volume"),
                    TXT_NewSpinControl(&musicVolume, 0, 15),
                    NULL);
 
-    TXT_SignalConnect(sfx_mode_control, "changed", 
+    TXT_SignalConnect(sfx_mode_control, "changed",
                       UpdateSndDevices, NULL);
-    TXT_SignalConnect(music_enabled_control, "changed", 
+    TXT_SignalConnect(mus_mode_control, "changed",
                       UpdateSndDevices, NULL);
-
 }