ref: 307a78f61e4ba9d94e20b441f92cf30f21e70392
parent: a09682d46edae813700eb693d0e5d5dccc652cd7
author: Simon Howard <fraggle@soulsphere.org>
date: Wed May 27 18:03:25 EDT 2015
opl: Some minor tweaks to the last merge. Formatting, variable names, don't pollute global variable namespace.
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -297,7 +297,7 @@
124, 124, 125, 125, 126, 126, 127, 127
};
-opl_driver_ver_t opl_drv_ver = opl_v_new;
+static opl_driver_ver_t opl_drv_ver = opl_v_new;
static boolean music_initialized = false;
//static boolean musicpaused = false;
@@ -433,12 +433,12 @@
{
opl_voice_t **rover;
opl_voice_t *next;
- boolean doublev;
+ boolean double_voice;
voice->channel = NULL;
voice->note = 0;
- doublev = voice->current_instr_voice != 0;
+ double_voice = voice->current_instr_voice != 0;
next = voice->next;
// Remove from alloced list.
@@ -457,7 +457,7 @@
*rover = voice;
voice->next = NULL;
- if (next != NULL && doublev && opl_drv_ver == opl_v_old)
+ if (next != NULL && double_voice && opl_drv_ver == opl_v_old)
{
VoiceKeyOff(next);
ReleaseVoice(next);
@@ -684,7 +684,7 @@
rover = voice_alloced_list;
prev = NULL;
- while (rover!=NULL)
+ while (rover != NULL)
{
if (rover->channel == channel && rover->key == key)
{
@@ -744,6 +744,9 @@
ReleaseVoice(result);
}
+// Alternate version of ReplaceExistingVoice() used when emulating old
+// versions of the DMX library used in Heretic and Hexen.
+
static void ReplaceExistingVoiceOld(opl_channel_data_t *channel)
{
opl_voice_t *rover;
@@ -930,7 +933,7 @@
genmidi_instr_t *instrument;
opl_channel_data_t *channel;
unsigned int note, key, volume;
- boolean doublev;
+ boolean double_voice;
/*
printf("note on: channel %i, %i, %i\n",
@@ -973,15 +976,16 @@
{
instrument = channel->instrument;
}
- doublev = (SHORT(instrument->flags) & GENMIDI_FLAG_2VOICE) != 0;
- if (opl_drv_ver == opl_v_old)
+ double_voice = (SHORT(instrument->flags) & GENMIDI_FLAG_2VOICE) != 0;
+
+ if (opl_drv_ver == opl_v_old)
{
if (voice_alloced_num == OPL_NUM_VOICES)
{
ReplaceExistingVoiceOld(channel);
}
- if (voice_alloced_num == OPL_NUM_VOICES - 1 && doublev)
+ if (voice_alloced_num == OPL_NUM_VOICES - 1 && double_voice)
{
ReplaceExistingVoiceOld(channel);
}
@@ -989,7 +993,7 @@
// Find and program a voice for this instrument. If this
// is a double voice instrument, we must do this twice.
- if (doublev)
+ if (double_voice)
{
VoiceKeyOn(channel, instrument, 1, note, key, volume);
}
@@ -1008,7 +1012,7 @@
VoiceKeyOn(channel, instrument, 0, note, key, volume);
- if (doublev)
+ if (double_voice)
{
VoiceKeyOn(channel, instrument, 1, note, key, volume);
}
@@ -1625,6 +1629,11 @@
I_OPL_MusicIsPlaying,
NULL, // Poll
};
+
+void I_SetOPLDriverVer(opl_driver_ver_t ver)
+{
+ opl_drv_ver = ver;
+}
//----------------------------------------------------------------------
//
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -473,8 +473,3 @@
#endif
}
-void I_SetOPLDriverVer(opl_driver_ver_t ver)
-{
- opl_drv_ver = ver;
-}
-
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -234,9 +234,10 @@
void I_BindSoundVariables(void);
+// DMX version to emulate for OPL emulation:
typedef enum {
- opl_v_old, // hexen heretic
- opl_v_new // doom strife
+ opl_v_old, // Hexen, Heretic
+ opl_v_new // Doom, Strife
} opl_driver_ver_t;
void I_SetOPLDriverVer(opl_driver_ver_t ver);