ref: 6ebcafd7003cce44d1edd1115e737f1aa826ba1c
parent: facc2f70b1bfac51ddaefb78fcbef04a8d5c8e2b
author: Simon Howard <fraggle@gmail.com>
date: Thu Sep 25 14:14:46 EDT 2008
Add option to low-level sound API to disable the DS prefix for sound effects, for Heretic. Fix sound links. Subversion-branch: /branches/raven-branch Subversion-revision: 1281
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -122,7 +122,7 @@
{
int i;
- I_InitSound();
+ I_InitSound(true);
I_InitMusic();
I_PrecacheSounds(S_sfx, NUMSFX);
--- a/src/heretic/s_sound.c
+++ b/src/heretic/s_sound.c
@@ -493,7 +493,7 @@
void S_Init(void)
{
soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
- I_InitSound();
+ I_InitSound(false);
if (snd_Channels > 8)
{
snd_Channels = 8;
--- a/src/i_pcsound.c
+++ b/src/i_pcsound.c
@@ -38,6 +38,7 @@
static boolean pcs_initialised = false;
static SDL_mutex *sound_lock;
+static boolean use_sfx_prefix;
static uint8_t *current_sound_lump = NULL;
static uint8_t *current_sound_pos = NULL;
@@ -241,8 +242,15 @@
{
char namebuf[9];
- sprintf(namebuf, "dp%s", DEH_String(sfx->name));
-
+ if (use_sfx_prefix)
+ {
+ sprintf(namebuf, "dp%s", DEH_String(sfx->name));
+ }
+ else
+ {
+ strcpy(namebuf, DEH_String(sfx->name));
+ }
+
return W_GetNumForName(namebuf);
}
@@ -262,8 +270,10 @@
return current_sound_lump != NULL && current_sound_remaining > 0;
}
-static boolean I_PCS_InitSound(void)
+static boolean I_PCS_InitSound(boolean _use_sfx_prefix)
{
+ use_sfx_prefix = _use_sfx_prefix;
+
// Use the sample rate from the configuration file
PCSound_SetSampleRate(snd_samplerate);
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -57,6 +57,7 @@
static int mixer_freq;
static Uint16 mixer_format;
static int mixer_channels;
+static boolean use_sfx_prefix;
static void (*ExpandSoundData)(sfxinfo_t *sfxinfo,
byte *data,
int samplerate,
@@ -462,7 +463,7 @@
fflush(stdout);
}
- sprintf(namebuf, "ds%s", DEH_String(sounds[i].name));
+ GetSfxLumpName(&sounds[i], namebuf);
sounds[i].lumpnum = W_CheckNumForName(namebuf);
@@ -512,18 +513,39 @@
return true;
}
+static void GetSfxLumpName(sfxinfo_t *sfx, char *buf)
+{
+ // Linked sfx lumps? Get the lump number for the sound linked to.
+ if (sfx->link != NULL)
+ {
+ sfx = sfx->link;
+ }
+
+ // Doom adds a DS* prefix to sound lumps; Heretic and Hexen don't
+ // do this.
+
+ if (use_sfx_prefix)
+ {
+ sprintf(buf, "ds%s", DEH_String(sfx->name));
+ }
+ else
+ {
+ strcpy(buf, DEH_String(sfx->name));
+ }
+}
+
//
// Retrieve the raw data lump index
// for a given SFX name.
//
-static int I_SDL_GetSfxLumpNum(sfxinfo_t* sfx)
+static int I_SDL_GetSfxLumpNum(sfxinfo_t *sfx)
{
char namebuf[9];
- sprintf(namebuf, "ds%s", DEH_String(sfx->name));
-
+ GetSfxLumpName(sfx, namebuf);
+
return W_GetNumForName(namebuf);
}
@@ -654,10 +676,12 @@
}
-static boolean I_SDL_InitSound(void)
+static boolean I_SDL_InitSound(boolean _use_sfx_prefix)
{
int i;
+ use_sfx_prefix = _use_sfx_prefix;
+
// No sounds yet
for (i=0; i<NUM_CHANNELS; ++i)
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -112,7 +112,7 @@
// Find and initialise a sound_module_t appropriate for the setting
// in snd_sfxdevice.
-static void InitSfxModule(void)
+static void InitSfxModule(boolean use_sfx_prefix)
{
int i;
@@ -129,7 +129,7 @@
{
// Initialise the module
- if (sound_modules[i]->Init())
+ if (sound_modules[i]->Init(use_sfx_prefix))
{
sound_module = sound_modules[i];
return;
@@ -172,7 +172,7 @@
// allocates channel buffer, sets S_sfx lookup.
//
-void I_InitSound(void)
+void I_InitSound(boolean use_sfx_prefix)
{
boolean nosound, nosfx, nomusic;
@@ -206,7 +206,7 @@
{
if (!nosfx)
{
- InitSfxModule();
+ InitSfxModule(use_sfx_prefix);
}
if (!nomusic)
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -114,7 +114,7 @@
// Initialise sound module
// Returns true if successfully initialised
- boolean (*Init)(void);
+ boolean (*Init)(boolean use_sfx_prefix);
// Shutdown sound module
@@ -151,7 +151,7 @@
} sound_module_t;
-void I_InitSound(void);
+void I_InitSound(boolean use_sfx_prefix);
void I_ShutdownSound(void);
int I_GetSfxLumpNum(sfxinfo_t *sfxinfo);
void I_UpdateSound(void);