diff options
Diffstat (limited to 'src/i_pcsound.c')
-rw-r--r-- | src/i_pcsound.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/src/i_pcsound.c b/src/i_pcsound.c index c2c77fe7..36d4873e 100644 --- a/src/i_pcsound.c +++ b/src/i_pcsound.c @@ -24,13 +24,12 @@ //----------------------------------------------------------------------------- #include "SDL.h" +#include <string.h> -#include "doomdef.h" #include "doomtype.h" -#include "deh_main.h" -#include "s_sound.h" -#include "sounds.h" +#include "deh_str.h" +#include "i_sound.h" #include "w_wad.h" #include "z_zone.h" @@ -40,6 +39,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; @@ -103,7 +103,7 @@ static void PCSCallbackFunc(int *duration, int *freq) SDL_UnlockMutex(sound_lock); } -static boolean CachePCSLump(int sound_id) +static boolean CachePCSLump(sfxinfo_t *sfxinfo) { int lumplen; int headerlen; @@ -118,8 +118,8 @@ static boolean CachePCSLump(int sound_id) // Load from WAD - current_sound_lump = W_CacheLumpNum(S_sfx[sound_id].lumpnum, PU_STATIC); - lumplen = W_LumpLength(S_sfx[sound_id].lumpnum); + current_sound_lump = W_CacheLumpNum(sfxinfo->lumpnum, PU_STATIC); + lumplen = W_LumpLength(sfxinfo->lumpnum); // Read header @@ -139,12 +139,39 @@ static boolean CachePCSLump(int sound_id) current_sound_remaining = headerlen; current_sound_pos = current_sound_lump + 4; - current_sound_lump_num = S_sfx[sound_id].lumpnum; + current_sound_lump_num = sfxinfo->lumpnum; return true; } -static int I_PCS_StartSound(int id, +// These Doom PC speaker sounds are not played - this can be seen in the +// Heretic source code, where there are remnants of this left over +// from Doom. + +static boolean IsDisabledSound(sfxinfo_t *sfxinfo) +{ + int i; + const char *disabled_sounds[] = { + "posact", + "bgact", + "dmact", + "dmpain", + "popain", + "sawidl", + }; + + for (i=0; i<arrlen(disabled_sounds); ++i) + { + if (!strcmp(sfxinfo->name, disabled_sounds[i])) + { + return true; + } + } + + return false; +} + +static int I_PCS_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep) @@ -156,12 +183,7 @@ static int I_PCS_StartSound(int id, return -1; } - // These PC speaker sounds are not played - this can be seen in the - // Heretic source code, where there are remnants of this left over - // from Doom. - - if (id == sfx_posact || id == sfx_bgact || id == sfx_dmact - || id == sfx_dmpain || id == sfx_popain || id == sfx_sawidl) + if (IsDisabledSound(sfxinfo)) { return -1; } @@ -171,7 +193,7 @@ static int I_PCS_StartSound(int id, return -1; } - result = CachePCSLump(id); + result = CachePCSLump(sfxinfo); if (result) { @@ -221,8 +243,15 @@ static int I_PCS_GetSfxLumpNum(sfxinfo_t* sfx) { 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); } @@ -242,8 +271,10 @@ static boolean I_PCS_SoundIsPlaying(int handle) 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); |