ref: e81997d7571cbe9372c4fe66b644d0d9a5059b6f
parent: e986a93409fd717fd01c93199c84ac5788bafebe
author: Simon Howard <fraggle@soulsphere.org>
date: Mon Jun 8 16:58:48 EDT 2015
Replace "opl_type" config variable with DMXOPTION. Vanilla Doom used the DMXOPTION environment variable to control whether OPL3 output was generated. Emulate this, and use a config file variable that can set DMXOPTION without needing to configure it via an environment variable.
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -349,8 +349,8 @@
// Configuration file variable, containing the port number for the
// adlib chip.
+char *snd_dmxoption = "";
int opl_io_port = 0x388;
-int opl_type = 0;
// Load instrument table from GENMIDI lump:
@@ -1650,6 +1650,7 @@
static boolean I_OPL_InitMusic(void)
{
+ char *dmxoption;
int opl_chip_type;
OPL_SetSampleRate(snd_samplerate);
@@ -1661,7 +1662,15 @@
return false;
}
- if (opl_chip_type == 2 && opl_type)
+ // The DMXOPTION variable must be set to enable OPL3 support.
+ // As an extension, we also allow it to be set from the config file.
+ dmxoption = getenv("DMXOPTION");
+ if (dmxoption == NULL)
+ {
+ dmxoption = snd_dmxoption != NULL ? snd_dmxoption : "";
+ }
+
+ if (opl_chip_type == 2 && strstr(dmxoption, "-opl3") != NULL)
{
opl_opl3mode = 1;
num_opl_voices = OPL_NUM_VOICES * 2;
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -68,7 +68,6 @@
extern opl_driver_ver_t opl_drv_ver;
extern int opl_io_port;
-extern int opl_type;
// For native music module:
@@ -433,6 +432,7 @@
void I_BindSoundVariables(void)
{
+ extern char *snd_dmxoption;
extern int use_libsamplerate;
extern float libsamplerate_scale;
@@ -444,10 +444,10 @@
M_BindIntVariable("snd_mport", &snd_mport);
M_BindIntVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
M_BindStringVariable("snd_musiccmd", &snd_musiccmd);
+ M_BindStringVariable("snd_dmxoption", &snd_dmxoption);
M_BindIntVariable("snd_samplerate", &snd_samplerate);
M_BindIntVariable("snd_cachesize", &snd_cachesize);
M_BindIntVariable("opl_io_port", &opl_io_port);
- M_BindIntVariable("opl_type", &opl_type);
M_BindStringVariable("timidity_cfg_path", &timidity_cfg_path);
M_BindStringVariable("gus_patch_path", &gus_patch_path);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -817,16 +817,18 @@
CONFIG_VARIABLE_STRING(snd_musiccmd),
//!
+ // Value to set for the DMXOPTION environment variable. If this contains
+ // "-opl3", output for an OPL3 chip is generated when in OPL MIDI
+ // playback mode.
+ //
+ CONFIG_VARIABLE_STRING(snd_dmxoption),
+
+ //!
// 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 chip type.
- //
- CONFIG_VARIABLE_INT(opl_type),
//!
// @game doom heretic strife
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -61,6 +61,13 @@
"CD audio"
};
+typedef enum
+{
+ OPLMODE_OPL2,
+ OPLMODE_OPL3,
+ NUM_OPLMODES,
+} oplmode_t;
+
static char *opltype_strings[] =
{
"OPL2",
@@ -87,10 +94,10 @@
static int use_libsamplerate = 0;
static float libsamplerate_scale = 0.65;
+static char *snd_dmxoption = "";
static char *timidity_cfg_path = NULL;
static char *gus_patch_path = NULL;
static int gus_ram_kb = 1024;
-static int opl_type = 0;
// DOS specific variables: these are unused but should be maintained
// so that the config file can be shared between chocolate
@@ -105,6 +112,7 @@
static int snd_sfxmode;
static int snd_musicmode;
+static int snd_oplmode;
static void UpdateSndDevices(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
{
@@ -139,8 +147,40 @@
snd_musicdevice = SNDDEVICE_CD;
break;
}
+
+ switch (snd_oplmode)
+ {
+ default:
+ case OPLMODE_OPL2:
+ snd_dmxoption = "";
+ break;
+
+ case OPLMODE_OPL3:
+ snd_dmxoption = "-opl3";
+ break;
+ }
}
+static txt_dropdown_list_t *OPLTypeSelector(void)
+{
+ txt_dropdown_list_t *result;
+
+ if (snd_dmxoption != NULL && strstr(snd_dmxoption, "-opl3") != NULL)
+ {
+ snd_oplmode = OPLMODE_OPL3;
+ }
+ else
+ {
+ snd_oplmode = OPLMODE_OPL2;
+ }
+
+ result = TXT_NewDropdownList(&snd_oplmode, opltype_strings, 2);
+
+ TXT_SignalConnect(result, "changed", UpdateSndDevices, NULL);
+
+ return result;
+}
+
static void UpdateExtraTable(TXT_UNCAST_ARG(widget),
TXT_UNCAST_ARG(extra_table))
{
@@ -153,7 +193,7 @@
TXT_SetColumnWidths(extra_table, 19, 4);
TXT_AddWidgets(extra_table,
TXT_NewLabel("OPL type"),
- TXT_NewDropdownList(&opl_type, opltype_strings, 2),
+ OPLTypeSelector(),
NULL);
break;
@@ -335,10 +375,10 @@
M_BindIntVariable("snd_mport", &snd_mport);
M_BindIntVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
M_BindStringVariable("snd_musiccmd", &snd_musiccmd);
+ M_BindStringVariable("snd_dmxoption", &snd_dmxoption);
M_BindIntVariable("snd_cachesize", &snd_cachesize);
M_BindIntVariable("opl_io_port", &opl_io_port);
- M_BindIntVariable("opl_type", &opl_type);
if (gamemission == strife)
{