ref: 2c2e0d5ac8e9629f5abb66cf90efe4e2e7c0ad02
parent: 4af7ea5ba13f4f04ac9c505e0c0e20cef545b767
author: Simon Howard <fraggle@gmail.com>
date: Tue Dec 2 14:02:46 EST 2008
Fix setup to show the correct available sfx/music options, depending on the game type. Add CD music option for Hexen. Subversion-branch: /branches/raven-branch Subversion-revision: 1402
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -105,6 +105,7 @@
SNDDEVICE_SOUNDCANVAS = 7,
SNDDEVICE_GENMIDI = 8,
SNDDEVICE_AWE32 = 9,
+ SNDDEVICE_CD = 10,
} snddevice_t;
// Interface for sound modules
--- a/src/setup/mainmenu.c
+++ b/src/setup/mainmenu.c
@@ -132,6 +132,8 @@
TXT_AddWidgets(window,
TXT_NewButton2("Configure Display",
(TxtWidgetSignalFunc) ConfigDisplay, NULL),
+ TXT_NewButton2("Configure Sound",
+ (TxtWidgetSignalFunc) ConfigSound, NULL),
TXT_NewButton2("Configure Keyboard",
(TxtWidgetSignalFunc) ConfigKeyboard, NULL),
TXT_NewButton2("Configure Mouse",
@@ -138,8 +140,6 @@
(TxtWidgetSignalFunc) ConfigMouse, NULL),
TXT_NewButton2("Configure Joystick",
(TxtWidgetSignalFunc) ConfigJoystick, NULL),
- TXT_NewButton2("Configure Sound",
- (TxtWidgetSignalFunc) ConfigSound, NULL),
NULL);
// The compatibility window is only appropriate for Doom.
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -26,27 +26,15 @@
#include "textscreen.h"
#include "m_config.h"
+#include "i_sound.h"
+#include "mode.h"
#include "sound.h"
-enum
-{
- SNDDEVICE_NONE = 0,
- SNDDEVICE_PCSPEAKER = 1,
- SNDDEVICE_ADLIB = 2,
- SNDDEVICE_SB = 3,
- SNDDEVICE_PAS = 4,
- SNDDEVICE_GUS = 5,
- SNDDEVICE_WAVEBLASTER = 6,
- SNDDEVICE_SOUNDCANVAS = 7,
- SNDDEVICE_GENMIDI = 8,
- SNDDEVICE_AWE32 = 9,
-};
-
typedef enum
{
SFXMODE_DISABLED,
- SFXMODE_PCSPEAKER,
SFXMODE_DIGITAL,
+ SFXMODE_PCSPEAKER,
NUM_SFXMODES
} sfxmode_t;
@@ -53,10 +41,25 @@
static char *sfxmode_strings[] =
{
"Disabled",
- "PC speaker",
"Digital",
+ "PC speaker"
};
+typedef enum
+{
+ MUSICMODE_DISABLED,
+ MUSICMODE_MIDI,
+ MUSICMODE_CD,
+ NUM_MUSICMODES
+} musicmode_t;
+
+static char *musicmode_strings[] =
+{
+ "Disabled",
+ "MIDI",
+ "CD audio"
+};
+
// Disable MIDI music on OSX: there are problems with the native
// MIDI code in SDL_mixer.
@@ -66,21 +69,18 @@
#define DEFAULT_MUSIC_DEVICE SNDDEVICE_SB
#endif
-static int snd_sfxdevice = SNDDEVICE_SB;
+// Config file variables:
+
+int snd_sfxdevice = SNDDEVICE_SB;
+int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
+int snd_samplerate = 22050;
+
static int numChannels = 8;
static int sfxVolume = 15;
-
-static int snd_musicdevice = DEFAULT_MUSIC_DEVICE;
static int musicVolume = 15;
-
-static int snd_samplerate = 22050;
-
static int use_libsamplerate = 0;
-static int snd_sfxmode;
-static int snd_musicenabled;
-
-// DOS specific options: these are unused but should be maintained
+// DOS specific variables: these are unused but should be maintained
// so that the config file can be shared between chocolate
// doom and doom.exe
@@ -89,6 +89,11 @@
static int snd_sbdma = 0;
static int snd_mport = 0;
+// GUI variables:
+
+static int snd_sfxmode;
+static int snd_musicmode;
+
static void UpdateSndDevices(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
{
switch (snd_sfxmode)
@@ -103,15 +108,18 @@
snd_sfxdevice = SNDDEVICE_SB;
break;
}
-
- if (snd_musicenabled)
+
+ switch (snd_musicmode)
{
- snd_musicdevice = SNDDEVICE_SB;
+ case MUSICMODE_DISABLED:
+ snd_musicdevice = SNDDEVICE_NONE;
+ break;
+ case MUSICMODE_MIDI:
+ snd_musicdevice = SNDDEVICE_SB;
+ break;
+ case MUSICMODE_CD:
+ break;
}
- else
- {
- snd_musicdevice = SNDDEVICE_NONE;
- }
}
void ConfigSound(void)
@@ -120,8 +128,11 @@
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 *music_mode_control;
+ int num_sfx_modes, num_music_modes;
+ // Work out what sfx mode we are currently using:
+
if (snd_sfxdevice == SNDDEVICE_PCSPEAKER)
{
snd_sfxmode = SFXMODE_PCSPEAKER;
@@ -135,8 +146,45 @@
snd_sfxmode = SFXMODE_DISABLED;
}
- snd_musicenabled = snd_musicdevice != SNDDEVICE_NONE;
+ // Is music enabled?
+ if (snd_musicdevice == SNDDEVICE_NONE)
+ {
+ snd_musicmode = MUSICMODE_DISABLED;
+ }
+ else if (snd_musicmode == SNDDEVICE_CD)
+ {
+ snd_musicmode = MUSICMODE_CD;
+ }
+ else
+ {
+ snd_musicmode = MUSICMODE_MIDI;
+ }
+
+ // Doom has PC speaker sound effects, but others do not:
+
+ if (gamemission == doom)
+ {
+ num_sfx_modes = NUM_SFXMODES;
+ }
+ else
+ {
+ num_sfx_modes = NUM_SFXMODES - 1;
+ }
+
+ // Hexen has CD audio; others do not.
+
+ if (gamemission == hexen)
+ {
+ num_music_modes = NUM_MUSICMODES;
+ }
+ else
+ {
+ num_music_modes = NUM_MUSICMODES - 1;
+ }
+
+ // Build the window
+
window = TXT_NewWindow("Sound configuration");
TXT_AddWidgets(window,
@@ -143,8 +191,6 @@
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);
@@ -154,7 +200,7 @@
TXT_NewLabel("Sound effects"),
sfx_mode_control = TXT_NewDropdownList(&snd_sfxmode,
sfxmode_strings,
- NUM_SFXMODES),
+ num_sfx_modes),
TXT_NewLabel("Sound channels"),
TXT_NewSpinControl(&numChannels, 1, 8),
TXT_NewLabel("SFX volume"),
@@ -164,14 +210,16 @@
TXT_SetColumnWidths(music_table, 20, 5);
TXT_AddWidgets(music_table,
+ TXT_NewLabel("Music"),
+ music_mode_control = TXT_NewDropdownList(&snd_musicmode,
+ musicmode_strings,
+ num_music_modes),
TXT_NewLabel("Music volume"),
TXT_NewSpinControl(&musicVolume, 0, 15),
NULL);
- TXT_SignalConnect(sfx_mode_control, "changed",
- UpdateSndDevices, NULL);
- TXT_SignalConnect(music_enabled_control, "changed",
- UpdateSndDevices, NULL);
+ TXT_SignalConnect(sfx_mode_control, "changed", UpdateSndDevices, NULL);
+ TXT_SignalConnect(music_mode_control, "changed", UpdateSndDevices, NULL);
}