shithub: choc

Download patch

ref: 232fba47e0a42af8c3ec0f934eaa855163c4ee35
parent: b457a1c95679a878e9508211117b11c53c9e90a4
author: Simon Howard <[email protected]>
date: Wed Jul 28 16:39:07 EDT 2010

Add config file parameter to set OPL I/O port.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1947

--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -154,9 +154,10 @@
 static int snd_sbdma = 0;
 static int snd_mport = 0;
 
-typedef enum 
+typedef enum
 {
     DEFAULT_INT,
+    DEFAULT_INT_HEX,
     DEFAULT_STRING,
     DEFAULT_FLOAT,
     DEFAULT_KEY,
@@ -269,6 +270,7 @@
     {"mouse_acceleration",          &mouse_acceleration, DEFAULT_FLOAT, 0, 0},
     {"mouse_threshold",             &mouse_threshold, DEFAULT_INT, 0, 0},
     {"snd_samplerate",              &snd_samplerate, DEFAULT_INT, 0, 0},
+    {"opl_io_port",                 &opl_io_port, DEFAULT_INT_HEX, 0, 0},
     {"show_endoom",                 &show_endoom, DEFAULT_INT, 0, 0},
     {"vanilla_savegame_limit",      &vanilla_savegame_limit, DEFAULT_INT, 0, 0},
     {"vanilla_demo_limit",          &vanilla_demo_limit, DEFAULT_INT, 0, 0},
@@ -435,6 +437,10 @@
 	        fprintf(f, "%i", v);
                 break;
 
+            case DEFAULT_INT_HEX:
+	        fprintf(f, "0x%x", * (int *) defaults[i].location);
+                break;
+
             case DEFAULT_INT:
 	        fprintf(f, "%i", * (int *) defaults[i].location);
                 break;
@@ -528,6 +534,7 @@
                     break;
 
                 case DEFAULT_INT:
+                case DEFAULT_INT_HEX:
                     * (int *) def->location = ParseIntParameter(strparm);
                     break;
 
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -65,6 +65,7 @@
 int musicVolume = 15;
 
 int snd_samplerate = 22050;
+int opl_io_port = 0x388;
 
 int use_libsamplerate = 0;
 
--- a/setup/sound.h
+++ b/setup/sound.h
@@ -44,6 +44,7 @@
 extern int musicVolume;
 
 extern int snd_samplerate;
+extern int opl_io_port;
 
 extern int use_libsamplerate;
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -191,6 +191,7 @@
 extern int snd_musicdevice;
 extern int snd_sfxdevice;
 extern int snd_samplerate;
+extern int opl_io_port;
 
 // controls whether to use libsamplerate for sample rate conversions
 
@@ -208,6 +209,7 @@
 typedef enum 
 {
     DEFAULT_INT,
+    DEFAULT_INT_HEX,
     DEFAULT_STRING,
     DEFAULT_FLOAT,
     DEFAULT_KEY,
@@ -243,14 +245,19 @@
     char      *filename;
 } default_collection_t;
 
+#define CONFIG_VARIABLE_GENERIC(name, variable, type) \
+    { #name, &variable, type, 0, 0 }
+
 #define CONFIG_VARIABLE_KEY(name, variable) \
-    { #name, &variable, DEFAULT_KEY, 0, 0 }
+    CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_KEY)
 #define CONFIG_VARIABLE_INT(name, variable) \
-    { #name, &variable, DEFAULT_INT, 0, 0 }
+    CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_INT)
+#define CONFIG_VARIABLE_INT_HEX(name, variable) \
+    CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_INT_HEX)
 #define CONFIG_VARIABLE_FLOAT(name, variable) \
-    { #name, &variable, DEFAULT_FLOAT, 0, 0 }
+    CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_FLOAT)
 #define CONFIG_VARIABLE_STRING(name, variable) \
-    { #name, &variable, DEFAULT_STRING, 0, 0 }
+    CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_STRING)
 
 //! @begin_config_file default.cfg
 
@@ -625,7 +632,7 @@
 
     //!
     // Mouse acceleration threshold.  When the speed of mouse movement
-    // exceeds this threshold value, the speed is multiplied by an 
+    // exceeds this threshold value, the speed is multiplied by an
     // acceleration factor (mouse_acceleration).
     //
 
@@ -632,7 +639,7 @@
     CONFIG_VARIABLE_INT(mouse_threshold,           mouse_threshold),
 
     //!
-    // Sound output sample rate, in Hz.  Typical values to use are 
+    // Sound output sample rate, in Hz.  Typical values to use are
     // 11025, 22050, 44100 and 48000.
     //
 
@@ -639,6 +646,13 @@
     CONFIG_VARIABLE_INT(snd_samplerate,            snd_samplerate),
 
     //!
+    // The I/O port to use to access the OPL chip.  Only relevant when
+    // using native OPL music playback.
+    //
+
+    CONFIG_VARIABLE_INT_HEX(opl_io_port,           opl_io_port),
+
+    //!
     // If non-zero, the ENDOOM screen is displayed when exiting the
     // game.  If zero, the ENDOOM screen is not displayed.
     //
@@ -1178,6 +1192,10 @@
 	        fprintf(f, "%i", * (int *) defaults[i].location);
                 break;
 
+            case DEFAULT_INT_HEX:
+	        fprintf(f, "0x%x", * (int *) defaults[i].location);
+                break;
+
             case DEFAULT_FLOAT:
                 fprintf(f, "%f", * (float *) defaults[i].location);
                 break;
@@ -1267,6 +1285,7 @@
                     break;
 
                 case DEFAULT_INT:
+                case DEFAULT_INT_HEX:
                     * (int *) def->location = ParseIntParameter(strparm);
                     break;