summaryrefslogtreecommitdiff
path: root/src/heretic
diff options
context:
space:
mode:
Diffstat (limited to 'src/heretic')
-rw-r--r--src/heretic/Makefile.am6
-rw-r--r--src/heretic/ct_chat.c2
-rw-r--r--src/heretic/d_main.c2
-rw-r--r--src/heretic/f_finale.c2
-rw-r--r--src/heretic/g_game.c2
-rw-r--r--src/heretic/i_header.h99
-rw-r--r--src/heretic/i_ibm.c594
-rw-r--r--src/heretic/i_sound.h45
-rw-r--r--src/heretic/in_lude.c2
-rw-r--r--src/heretic/m_misc.c2
-rw-r--r--src/heretic/mn_menu.c2
-rw-r--r--src/heretic/p_ceilng.c2
-rw-r--r--src/heretic/p_doors.c2
-rw-r--r--src/heretic/p_enemy.c2
-rw-r--r--src/heretic/p_floor.c2
-rw-r--r--src/heretic/p_inter.c2
-rw-r--r--src/heretic/p_map.c2
-rw-r--r--src/heretic/p_mobj.c2
-rw-r--r--src/heretic/p_plats.c2
-rw-r--r--src/heretic/p_pspr.c2
-rw-r--r--src/heretic/p_setup.c2
-rw-r--r--src/heretic/p_spec.c2
-rw-r--r--src/heretic/p_switch.c2
-rw-r--r--src/heretic/p_telept.c2
-rw-r--r--src/heretic/p_user.c2
-rw-r--r--src/heretic/s_sound.c576
-rw-r--r--src/heretic/s_sound.h (renamed from src/heretic/soundst.h)0
-rw-r--r--src/heretic/sb_bar.c2
-rw-r--r--src/heretic/sounds.c414
-rw-r--r--src/heretic/sounds.h4
30 files changed, 819 insertions, 963 deletions
diff --git a/src/heretic/Makefile.am b/src/heretic/Makefile.am
index d240bae3..a67b5f06 100644
--- a/src/heretic/Makefile.am
+++ b/src/heretic/Makefile.am
@@ -1,4 +1,6 @@
+AM_CFLAGS=-I..
+
noinst_LIBRARIES=libheretic.a
SOURCE_FILES= \
@@ -12,7 +14,6 @@ d_net.c \
dstrings.h \
f_finale.c \
g_game.c \
- i_header.h \
info.c info.h \
in_lude.c \
m_misc.c \
@@ -46,7 +47,7 @@ r_segs.c \
r_things.c \
sb_bar.c \
sounds.c sounds.h \
- soundst.h \
+s_sound.c s_sound.h \
v_video.c
EXTRA_DIST= \
@@ -55,5 +56,4 @@ i_cyber.c \
i_ibm.c
libheretic_a_SOURCES=$(SOURCE_FILES)
-libheretic_a_CFLAGS=-I..
diff --git a/src/heretic/ct_chat.c b/src/heretic/ct_chat.c
index 73a43fc1..d83325b4 100644
--- a/src/heretic/ct_chat.c
+++ b/src/heretic/ct_chat.c
@@ -28,7 +28,7 @@
#include <ctype.h>
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
#define QUEUESIZE 128
#define MESSAGESIZE 128
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 9d561013..283bd50d 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -33,7 +33,7 @@
#include <stdlib.h>
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
boolean shareware = false; // true if only episode 1 present
boolean ExtendedWAD = false; // true if episodes 4 and 5 present
diff --git a/src/heretic/f_finale.c b/src/heretic/f_finale.c
index 67e0516b..b723f731 100644
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -23,7 +23,7 @@
// F_finale.c
#include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
#include <ctype.h>
int finalestage; // 0 = text, 1 = art screen
diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c
index 252095a9..daaa8d74 100644
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -27,7 +27,7 @@
#include <string.h>
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/i_header.h b/src/heretic/i_header.h
deleted file mode 100644
index 2cf6af46..00000000
--- a/src/heretic/i_header.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-#ifndef __I_HEADER_H__
-#define __I_HEADER_H__
-
-#include "doomdef.h"
-
-//--------
-//SOUND IO
-//--------
-#define FREQ_LOW 0x40
-#define FREQ_NORM 0x80
-#define FREQ_HIGH 0xff
-
-void I_SetMasterVolume(int volume);
-
-void I_TurnOffSfx(void);
-void I_TurnOnSfx(void);
-void I_TurnOffMusic(void);
-void I_TurnOnMusic(void);
-
-// MUSIC I/O
-//
-
-int I_RegisterSong(void *songdata);
-// called by anything that wants to register a song lump with the sound lib
-// calls Paul's function of the similar name to register music only.
-// note that the song data is the same for any sound card and is paul's
-// MUS format. Returns a handle which will be passed to all other music
-// functions.
-
-void I_UnregisterSong(int handle);
-// called by anything which is finished with a song and no longer needs
-// the sound library to be aware of it. All songs should be stopped
-// before calling this, but it will double check and stop it if necessary.
-
-void I_LoopSong(int handle);
-// called by anything that wishes to start music.
-// plays a song, and when the song is done, starts playing it again in
-// an endless loop. the start is faded in over three seconds.
-
-void I_FadeOutSong(int handle, int fotime);
-// called by anything that wishes to stop music.
-// fades out the song over <fotime> milliseconds.
-
-void I_StopSong(int handle);
-// called by anything that wishes to stop music.
-// stops a song abruptly.
-
-// SFX I/O
-//
-
-void *I_GetSoundEffect(char *soundname);
-// called by routines which wish to play a sound effect at some later
-// time. Pass it the lump name of a sound effect WITHOUT the sfx
-// prefix. This means the maximum name length is 7 letters/digits.
-// The prefixes for different sound cards are 'S','M','A', and 'P'.
-// They refer to the card type. The routine will cache in the
-// appropriate sound effect when it is played.
-
-void I_UngetSoundEffect(void *soundset);
-// called by routines which wish to no longer use the sounds at all
-// frees up the associated structure. It stops any currently playing
-// sound effects.
-
-void I_StartSound(channel_t * c, int vol, int sep, int pitch, int priority);
-// Starts a sound in a particular sound channel
-
-void I_UpdateSoundParams(channel_t * c, int vol, int sep, int pitch);
-// Updates the volume, separation, and pitch of a sound channel
-
-void I_StopSound(channel_t * c);
-// Stops a sound channel
-
-int I_SoundIsPlaying(channel_t * c);
-// called by S_*()'s to see if a channel is still playing. Returns 0
-// if no longer playing, 1 if playing.
-
-#endif
diff --git a/src/heretic/i_ibm.c b/src/heretic/i_ibm.c
index fb667e90..5058bf7e 100644
--- a/src/heretic/i_ibm.c
+++ b/src/heretic/i_ibm.c
@@ -30,8 +30,6 @@
#include <graph.h>
#include "doomdef.h"
#include "r_local.h"
-#include "sounds.h"
-#include "i_sound.h"
#include "dmx.h"
// Macros
@@ -73,598 +71,6 @@ extern int usemouse, usejoystick;
extern void **lumpcache;
/*
-===============================================================================
-
- MUSIC & SFX API
-
-===============================================================================
-*/
-
-static channel_t channel[MAX_CHANNELS];
-
-static int rs; //the current registered song.
-int mus_song = -1;
-int mus_lumpnum;
-void *mus_sndptr;
-byte *soundCurve;
-
-extern sfxinfo_t S_sfx[];
-extern musicinfo_t S_music[];
-
-extern int snd_DesiredMusicDevice;
-extern int snd_DesiredSfxDevice;
-extern int snd_MaxVolume;
-extern int snd_MusicVolume;
-extern int snd_Channels;
-
-extern int startepisode;
-extern int startmap;
-
-int AmbChan;
-
-void S_Start(void)
-{
- int i;
-
- S_StartSong((gameepisode - 1) * 9 + gamemap - 1, true);
-
- //stop all sounds
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].handle)
- {
- S_StopSound(channel[i].mo);
- }
- }
- memset(channel, 0, 8 * sizeof(channel_t));
-}
-
-void S_StartSong(int song, boolean loop)
-{
- if (song == mus_song)
- { // don't replay an old song
- return;
- }
- if (rs)
- {
- I_StopSong(rs);
- I_UnRegisterSong(rs);
- Z_ChangeTag(lumpcache[mus_lumpnum], PU_CACHE);
-#ifdef __WATCOMC__
- _dpmi_unlockregion(mus_sndptr, lumpinfo[mus_lumpnum].size);
-#endif
- }
- if (song < mus_e1m1 || song > NUMMUSIC)
- {
- return;
- }
- mus_lumpnum = W_GetNumForName(S_music[song].name);
- mus_sndptr = W_CacheLumpNum(mus_lumpnum, PU_MUSIC);
-#ifdef __WATCOMC__
- _dpmi_lockregion(mus_sndptr, lumpinfo[mus_lumpnum].size);
-#endif
- rs = I_RegisterSong(mus_sndptr);
- I_PlaySong(rs, loop); //'true' denotes endless looping.
- mus_song = song;
-}
-
-void S_StartSound(mobj_t * origin, int sound_id)
-{
- int dist, vol;
- int i;
- int sound;
- int priority;
- int sep;
- int angle;
- int absx;
- int absy;
-
- static int sndcount = 0;
- int chan;
-
- if (sound_id == 0 || snd_MaxVolume == 0)
- return;
- if (origin == NULL)
- {
- origin = players[consoleplayer].mo;
- }
-
-// calculate the distance before other stuff so that we can throw out
-// sounds that are beyond the hearing range.
- absx = abs(origin->x - players[consoleplayer].mo->x);
- absy = abs(origin->y - players[consoleplayer].mo->y);
- dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
- dist >>= FRACBITS;
-// dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS;
-
- if (dist >= MAX_SND_DIST)
- {
-// dist = MAX_SND_DIST - 1;
- return; //sound is beyond the hearing range...
- }
- if (dist < 0)
- {
- dist = 0;
- }
- priority = S_sfx[sound_id].priority;
- priority *= (10 - (dist / 160));
- if (!S_StopSoundID(sound_id, priority))
- {
- return; // other sounds have greater priority
- }
- for (i = 0; i < snd_Channels; i++)
- {
- if (origin->player)
- {
- i = snd_Channels;
- break; // let the player have more than one sound.
- }
- if (origin == channel[i].mo)
- { // only allow other mobjs one sound
- S_StopSound(channel[i].mo);
- break;
- }
- }
- if (i >= snd_Channels)
- {
- if (sound_id >= sfx_wind)
- {
- if (AmbChan != -1 && S_sfx[sound_id].priority <=
- S_sfx[channel[AmbChan].sound_id].priority)
- {
- return; //ambient channel already in use
- }
- else
- {
- AmbChan = -1;
- }
- }
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].mo == NULL)
- {
- break;
- }
- }
- if (i >= snd_Channels)
- {
- //look for a lower priority sound to replace.
- sndcount++;
- if (sndcount >= snd_Channels)
- {
- sndcount = 0;
- }
- for (chan = 0; chan < snd_Channels; chan++)
- {
- i = (sndcount + chan) % snd_Channels;
- if (priority >= channel[i].priority)
- {
- chan = -1; //denote that sound should be replaced.
- break;
- }
- }
- if (chan != -1)
- {
- return; //no free channels.
- }
- else //replace the lower priority sound.
- {
- if (channel[i].handle)
- {
- if (I_SoundIsPlaying(channel[i].handle))
- {
- I_StopSound(channel[i].handle);
- }
- if (S_sfx[channel[i].sound_id].usefulness > 0)
- {
- S_sfx[channel[i].sound_id].usefulness--;
- }
-
- if (AmbChan == i)
- {
- AmbChan = -1;
- }
- }
- }
- }
- }
- if (S_sfx[sound_id].lumpnum == 0)
- {
- S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
- }
- if (S_sfx[sound_id].snd_ptr == NULL)
- {
- S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum,
- PU_SOUND);
-#ifdef __WATCOMC__
- _dpmi_lockregion(S_sfx[sound_id].snd_ptr,
- lumpinfo[S_sfx[sound_id].lumpnum].size);
-#endif
- }
-
- // calculate the volume based upon the distance from the sound origin.
-// vol = (snd_MaxVolume*16 + dist*(-snd_MaxVolume*16)/MAX_SND_DIST)>>9;
- vol = soundCurve[dist];
-
- if (origin == players[consoleplayer].mo)
- {
- sep = 128;
- }
- else
- {
- angle = R_PointToAngle2(players[consoleplayer].mo->x,
- players[consoleplayer].mo->y,
- channel[i].mo->x, channel[i].mo->y);
- angle = (angle - viewangle) >> 24;
- sep = angle * 2 - 128;
- if (sep < 64)
- sep = -sep;
- if (sep > 192)
- sep = 512 - sep;
- }
-
- channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
- channel[i].handle =
- I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, vol, sep,
- channel[i].pitch, 0);
- channel[i].mo = origin;
- channel[i].sound_id = sound_id;
- channel[i].priority = priority;
- if (sound_id >= sfx_wind)
- {
- AmbChan = i;
- }
- if (S_sfx[sound_id].usefulness == -1)
- {
- S_sfx[sound_id].usefulness = 1;
- }
- else
- {
- S_sfx[sound_id].usefulness++;
- }
-}
-
-void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
-{
- int dist;
- int i;
- int sep;
-
- static int sndcount;
- int chan;
-
- if (sound_id == 0 || snd_MaxVolume == 0)
- return;
- if (origin == NULL)
- {
- origin = players[consoleplayer].mo;
- }
-
- if (volume == 0)
- {
- return;
- }
- volume = (volume * (snd_MaxVolume + 1) * 8) >> 7;
-
-// no priority checking, as ambient sounds would be the LOWEST.
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].mo == NULL)
- {
- break;
- }
- }
- if (i >= snd_Channels)
- {
- return;
- }
- if (S_sfx[sound_id].lumpnum == 0)
- {
- S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
- }
- if (S_sfx[sound_id].snd_ptr == NULL)
- {
- S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum,
- PU_SOUND);
-#ifdef __WATCOMC__
- _dpmi_lockregion(S_sfx[sound_id].snd_ptr,
- lumpinfo[S_sfx[sound_id].lumpnum].size);
-#endif
- }
- channel[i].pitch = (byte) (127 - (M_Random() & 3) + (M_Random() & 3));
- channel[i].handle =
- I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, volume, 128,
- channel[i].pitch, 0);
- channel[i].mo = origin;
- channel[i].sound_id = sound_id;
- channel[i].priority = 1; //super low priority.
- if (S_sfx[sound_id].usefulness == -1)
- {
- S_sfx[sound_id].usefulness = 1;
- }
- else
- {
- S_sfx[sound_id].usefulness++;
- }
-}
-
-boolean S_StopSoundID(int sound_id, int priority)
-{
- int i;
- int lp; //least priority
- int found;
-
- if (S_sfx[sound_id].numchannels == -1)
- {
- return (true);
- }
- lp = -1; //denote the argument sound_id
- found = 0;
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].sound_id == sound_id && channel[i].mo)
- {
- found++; //found one. Now, should we replace it??
- if (priority >= channel[i].priority)
- { // if we're gonna kill one, then this'll be it
- lp = i;
- priority = channel[i].priority;
- }
- }
- }
- if (found < S_sfx[sound_id].numchannels)
- {
- return (true);
- }
- else if (lp == -1)
- {
- return (false); // don't replace any sounds
- }
- if (channel[lp].handle)
- {
- if (I_SoundIsPlaying(channel[lp].handle))
- {
- I_StopSound(channel[lp].handle);
- }
- if (S_sfx[channel[i].sound_id].usefulness > 0)
- {
- S_sfx[channel[i].sound_id].usefulness--;
- }
- channel[lp].mo = NULL;
- }
- return (true);
-}
-
-void S_StopSound(mobj_t * origin)
-{
- int i;
-
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].mo == origin)
- {
- I_StopSound(channel[i].handle);
- if (S_sfx[channel[i].sound_id].usefulness > 0)
- {
- S_sfx[channel[i].sound_id].usefulness--;
- }
- channel[i].handle = 0;
- channel[i].mo = NULL;
- if (AmbChan == i)
- {
- AmbChan = -1;
- }
- }
- }
-}
-
-void S_SoundLink(mobj_t * oldactor, mobj_t * newactor)
-{
- int i;
-
- for (i = 0; i < snd_Channels; i++)
- {
- if (channel[i].mo == oldactor)
- channel[i].mo = newactor;
- }
-}
-
-void S_PauseSound(void)
-{
- I_PauseSong(rs);
-}
-
-void S_ResumeSound(void)
-{
- I_ResumeSong(rs);
-}
-
-static int nextcleanup;
-
-void S_UpdateSounds(mobj_t * listener)
-{
- int i, dist, vol;
- int angle;
- int sep;
- int priority;
- int absx;
- int absy;
-
- listener = players[consoleplayer].mo;
- if (snd_MaxVolume == 0)
- {
- return;
- }
- if (nextcleanup < gametic)
- {
- for (i = 0; i < NUMSFX; i++)
- {
- if (S_sfx[i].usefulness == 0 && S_sfx[i].snd_ptr)
- {
- if (lumpcache[S_sfx[i].lumpnum])
- {
- if (((memblock_t
- *) ((byte *) (lumpcache[S_sfx[i].lumpnum]) -
- sizeof(memblock_t)))->id == 0x1d4a11)
- { // taken directly from the Z_ChangeTag macro
- Z_ChangeTag2(lumpcache[S_sfx[i].lumpnum], PU_CACHE);
-#ifdef __WATCOMC__
- _dpmi_unlockregion(S_sfx[i].snd_ptr,
- lumpinfo[S_sfx[i].lumpnum].size);
-#endif
- }
- }
- S_sfx[i].usefulness = -1;
- S_sfx[i].snd_ptr = NULL;
- }
- }
- nextcleanup = gametic + 35; //CLEANUP DEBUG cleans every second
- }
- for (i = 0; i < snd_Channels; i++)
- {
- if (!channel[i].handle || S_sfx[channel[i].sound_id].usefulness == -1)
- {
- continue;
- }
- if (!I_SoundIsPlaying(channel[i].handle))
- {
- if (S_sfx[channel[i].sound_id].usefulness > 0)
- {
- S_sfx[channel[i].sound_id].usefulness--;
- }
- channel[i].handle = 0;
- channel[i].mo = NULL;
- channel[i].sound_id = 0;
- if (AmbChan == i)
- {
- AmbChan = -1;
- }
- }
- if (channel[i].mo == NULL || channel[i].sound_id == 0
- || channel[i].mo == players[consoleplayer].mo)
- {
- continue;
- }
- else
- {
- absx = abs(channel[i].mo->x - players[consoleplayer].mo->x);
- absy = abs(channel[i].mo->y - players[consoleplayer].mo->y);
- dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
- dist >>= FRACBITS;
-// dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS;
-
- if (dist >= MAX_SND_DIST)
- {
- S_StopSound(channel[i].mo);
- continue;
- }
- if (dist < 0)
- dist = 0;
-
-// calculate the volume based upon the distance from the sound origin.
-// vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7;
- vol = soundCurve[dist];
-
- angle = R_PointToAngle2(players[consoleplayer].mo->x,
- players[consoleplayer].mo->y,
- channel[i].mo->x, channel[i].mo->y);
- angle = (angle - viewangle) >> 24;
- sep = angle * 2 - 128;
- if (sep < 64)
- sep = -sep;
- if (sep > 192)
- sep = 512 - sep;
- I_UpdateSoundParams(channel[i].handle, vol, sep,
- channel[i].pitch);
- priority = S_sfx[channel[i].sound_id].priority;
- priority *= (10 - (dist >> 8));
- channel[i].priority = priority;
- }
- }
-}
-
-void S_Init(void)
-{
- soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
- I_StartupSound();
- if (snd_Channels > 8)
- {
- snd_Channels = 8;
- }
- I_SetChannels(snd_Channels);
- I_SetMusicVolume(snd_MusicVolume);
- S_SetMaxVolume(true);
-}
-
-void S_GetChannelInfo(SoundInfo_t * s)
-{
- int i;
- ChanInfo_t *c;
-
- s->channelCount = snd_Channels;
- s->musicVolume = snd_MusicVolume;
- s->soundVolume = snd_MaxVolume;
- for (i = 0; i < snd_Channels; i++)
- {
- c = &s->chan[i];
- c->id = channel[i].sound_id;
- c->priority = channel[i].priority;
- c->name = S_sfx[c->id].name;
- c->mo = channel[i].mo;
- c->distance = P_AproxDistance(c->mo->x - viewx, c->mo->y - viewy)
- >> FRACBITS;
- }
-}
-
-void S_SetMaxVolume(boolean fullprocess)
-{
- int i;
-
- if (!fullprocess)
- {
- soundCurve[0] =
- (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE)) *
- (snd_MaxVolume * 8)) >> 7;
- }
- else
- {
- for (i = 0; i < MAX_SND_DIST; i++)
- {
- soundCurve[i] =
- (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE) + i) *
- (snd_MaxVolume * 8)) >> 7;
- }
- }
-}
-
-static boolean musicPaused;
-void S_SetMusicVolume(void)
-{
- I_SetMusicVolume(snd_MusicVolume);
- if (snd_MusicVolume == 0)
- {
- I_PauseSong(rs);
- musicPaused = true;
- }
- else if (musicPaused)
- {
- musicPaused = false;
- I_ResumeSong(rs);
- }
-}
-
-void S_ShutDown(void)
-{
- extern int tsm_ID;
- if (tsm_ID != -1)
- {
- I_StopSong(rs);
- I_UnRegisterSong(rs);
- I_ShutdownSound();
- }
-}
-
-/*
=============================================================================
CONSTANTS
diff --git a/src/heretic/i_sound.h b/src/heretic/i_sound.h
deleted file mode 100644
index efe3dadf..00000000
--- a/src/heretic/i_sound.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Emacs style mode select -*- C++ -*-
-//-----------------------------------------------------------------------------
-//
-// Copyright(C) 1993-1996 Id Software, Inc.
-// Copyright(C) 1993-2008 Raven Software
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
-//
-//-----------------------------------------------------------------------------
-#ifndef __SOUND__
-#define __SOUND__
-
-#define SND_TICRATE 140 // tic rate for updating sound
-#define SND_MAXSONGS 40 // max number of songs in game
-#define SND_SAMPLERATE 11025 // sample rate of sound effects
-
-typedef enum
-{
- snd_none,
- snd_PC,
- snd_Adlib,
- snd_SB,
- snd_PAS,
- snd_GUS,
- snd_MPU,
- snd_MPU2,
- snd_MPU3,
- snd_AWE,
- NUM_SCARDS
-} cardenum_t;
-
-#endif
diff --git a/src/heretic/in_lude.c b/src/heretic/in_lude.c
index 0d4e1a0e..8cd3c5da 100644
--- a/src/heretic/in_lude.c
+++ b/src/heretic/in_lude.c
@@ -29,7 +29,7 @@
*/
#include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
typedef enum
{
diff --git a/src/heretic/m_misc.c b/src/heretic/m_misc.c
index ff155419..dd39ec1e 100644
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -35,7 +35,7 @@
#include <ctype.h>
#include "doomdef.h"
-#include "soundst.h"
+#include "s_sound.h"
int myargc;
char **myargv;
diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c
index a56e2dc3..8d828daa 100644
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -27,7 +27,7 @@
#include "doomdef.h"
#include "p_local.h"
#include "r_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/p_ceilng.c b/src/heretic/p_ceilng.c
index 672b8adb..cc596500 100644
--- a/src/heretic/p_ceilng.c
+++ b/src/heretic/p_ceilng.c
@@ -23,7 +23,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
//==================================================================
//==================================================================
diff --git a/src/heretic/p_doors.c b/src/heretic/p_doors.c
index 7598440e..619f6ca6 100644
--- a/src/heretic/p_doors.c
+++ b/src/heretic/p_doors.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
//==================================================================
//==================================================================
diff --git a/src/heretic/p_enemy.c b/src/heretic/p_enemy.c
index b6c476f6..714ce724 100644
--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/p_floor.c b/src/heretic/p_floor.c
index c370f165..f00447e4 100644
--- a/src/heretic/p_floor.c
+++ b/src/heretic/p_floor.c
@@ -22,7 +22,7 @@
//-----------------------------------------------------------------------------
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
//==================================================================
//==================================================================
diff --git a/src/heretic/p_inter.c b/src/heretic/p_inter.c
index 85ee381a..82225c7c 100644
--- a/src/heretic/p_inter.c
+++ b/src/heretic/p_inter.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
#define BONUSADD 6
diff --git a/src/heretic/p_map.c b/src/heretic/p_map.c
index f189e798..4a61beae 100644
--- a/src/heretic/p_map.c
+++ b/src/heretic/p_map.c
@@ -26,7 +26,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
/*
===============================================================================
diff --git a/src/heretic/p_mobj.c b/src/heretic/p_mobj.c
index 1e4596d7..839e9744 100644
--- a/src/heretic/p_mobj.c
+++ b/src/heretic/p_mobj.c
@@ -26,7 +26,7 @@
#include "doomdef.h"
#include "p_local.h"
#include "sounds.h"
-#include "soundst.h"
+#include "s_sound.h"
void G_PlayerReborn(int player);
void P_SpawnMapThing(mapthing_t * mthing);
diff --git a/src/heretic/p_plats.c b/src/heretic/p_plats.c
index f42b9926..7c68233f 100644
--- a/src/heretic/p_plats.c
+++ b/src/heretic/p_plats.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
plat_t *activeplats[MAXPLATS];
diff --git a/src/heretic/p_pspr.c b/src/heretic/p_pspr.c
index 4c7b9811..79976b5c 100644
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/p_setup.c b/src/heretic/p_setup.c
index 7e775ce8..03b1a59c 100644
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
void P_SpawnMapThing(mapthing_t * mthing);
diff --git a/src/heretic/p_spec.c b/src/heretic/p_spec.c
index aff01e11..5be43eae 100644
--- a/src/heretic/p_spec.c
+++ b/src/heretic/p_spec.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/p_switch.c b/src/heretic/p_switch.c
index 7fd8e15b..29b057e7 100644
--- a/src/heretic/p_switch.c
+++ b/src/heretic/p_switch.c
@@ -23,7 +23,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
//==================================================================
//
diff --git a/src/heretic/p_telept.c b/src/heretic/p_telept.c
index 2d7c1049..287814f3 100644
--- a/src/heretic/p_telept.c
+++ b/src/heretic/p_telept.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
//----------------------------------------------------------------------------
//
diff --git a/src/heretic/p_user.c b/src/heretic/p_user.c
index ca587abb..67ae00d7 100644
--- a/src/heretic/p_user.c
+++ b/src/heretic/p_user.c
@@ -27,7 +27,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
void P_PlayerNextArtifact(player_t * player);
diff --git a/src/heretic/s_sound.c b/src/heretic/s_sound.c
new file mode 100644
index 00000000..2a53c314
--- /dev/null
+++ b/src/heretic/s_sound.c
@@ -0,0 +1,576 @@
+// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1993-2008 Raven Software
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+//-----------------------------------------------------------------------------
+
+#include <stdlib.h>
+
+#include "doomdef.h"
+#include "sounds.h"
+#include "s_sound.h"
+#include "i_sound.h"
+#include "r_local.h"
+#include "p_local.h"
+
+#include "w_wad.h"
+#include "z_zone.h"
+
+/*
+===============================================================================
+
+ MUSIC & SFX API
+
+===============================================================================
+*/
+
+boolean S_StopSoundID(int sound_id, int priority);
+
+static channel_t channel[MAX_CHANNELS];
+
+static void *rs; // Handle for the registered song
+int mus_song = -1;
+int mus_lumpnum;
+void *mus_sndptr;
+byte *soundCurve;
+
+extern sfxinfo_t S_sfx[];
+extern musicinfo_t S_music[];
+
+extern int snd_DesiredMusicDevice;
+extern int snd_DesiredSfxDevice;
+extern int snd_MaxVolume;
+extern int snd_MusicVolume;
+extern int snd_Channels;
+
+extern int startepisode;
+extern int startmap;
+
+int AmbChan;
+
+void S_Start(void)
+{
+ int i;
+
+ S_StartSong((gameepisode - 1) * 9 + gamemap - 1, true);
+
+ //stop all sounds
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].handle)
+ {
+ S_StopSound(channel[i].mo);
+ }
+ }
+ memset(channel, 0, 8 * sizeof(channel_t));
+}
+
+void S_StartSong(int song, boolean loop)
+{
+ int mus_len;
+
+ if (song == mus_song)
+ { // don't replay an old song
+ return;
+ }
+
+ if (rs != NULL)
+ {
+ I_StopSong();
+ I_UnRegisterSong(rs);
+ }
+
+ if (song < mus_e1m1 || song > NUMMUSIC)
+ {
+ return;
+ }
+ mus_lumpnum = W_GetNumForName(S_music[song].name);
+ mus_sndptr = W_CacheLumpNum(mus_lumpnum, PU_MUSIC);
+ mus_len = W_LumpLength(mus_lumpnum);
+ rs = I_RegisterSong(mus_sndptr, mus_len);
+ I_PlaySong(rs, loop); //'true' denotes endless looping.
+ mus_song = song;
+}
+
+void S_StartSound(mobj_t * origin, int sound_id)
+{
+ int dist, vol;
+ int i;
+ int priority;
+ int sep;
+ int angle;
+ int absx;
+ int absy;
+
+ static int sndcount = 0;
+ int chan;
+
+ if (sound_id == 0 || snd_MaxVolume == 0)
+ return;
+ if (origin == NULL)
+ {
+ origin = players[consoleplayer].mo;
+ }
+
+// calculate the distance before other stuff so that we can throw out
+// sounds that are beyond the hearing range.
+ absx = abs(origin->x - players[consoleplayer].mo->x);
+ absy = abs(origin->y - players[consoleplayer].mo->y);
+ dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
+ dist >>= FRACBITS;
+// dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS;
+
+ if (dist >= MAX_SND_DIST)
+ {
+// dist = MAX_SND_DIST - 1;
+ return; //sound is beyond the hearing range...
+ }
+ if (dist < 0)
+ {
+ dist = 0;
+ }
+ priority = S_sfx[sound_id].priority;
+ priority *= (10 - (dist / 160));
+ if (!S_StopSoundID(sound_id, priority))
+ {
+ return; // other sounds have greater priority
+ }
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (origin->player)
+ {
+ i = snd_Channels;
+ break; // let the player have more than one sound.
+ }
+ if (origin == channel[i].mo)
+ { // only allow other mobjs one sound
+ S_StopSound(channel[i].mo);
+ break;
+ }
+ }
+ if (i >= snd_Channels)
+ {
+ if (sound_id >= sfx_wind)
+ {
+ if (AmbChan != -1 && S_sfx[sound_id].priority <=
+ S_sfx[channel[AmbChan].sound_id].priority)
+ {
+ return; //ambient channel already in use
+ }
+ else
+ {
+ AmbChan = -1;
+ }
+ }
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].mo == NULL)
+ {
+ break;
+ }
+ }
+ if (i >= snd_Channels)
+ {
+ //look for a lower priority sound to replace.
+ sndcount++;
+ if (sndcount >= snd_Channels)
+ {
+ sndcount = 0;
+ }
+ for (chan = 0; chan < snd_Channels; chan++)
+ {
+ i = (sndcount + chan) % snd_Channels;
+ if (priority >= channel[i].priority)
+ {
+ chan = -1; //denote that sound should be replaced.
+ break;
+ }
+ }
+ if (chan != -1)
+ {
+ return; //no free channels.
+ }
+ else //replace the lower priority sound.
+ {
+ if (channel[i].handle)
+ {
+ if (I_SoundIsPlaying(channel[i].handle))
+ {
+ I_StopSound(channel[i].handle);
+ }
+ if (S_sfx[channel[i].sound_id].usefulness > 0)
+ {
+ S_sfx[channel[i].sound_id].usefulness--;
+ }
+
+ if (AmbChan == i)
+ {
+ AmbChan = -1;
+ }
+ }
+ }
+ }
+ }
+ if (S_sfx[sound_id].lumpnum == 0)
+ {
+ S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
+ }
+
+ // calculate the volume based upon the distance from the sound origin.
+// vol = (snd_MaxVolume*16 + dist*(-snd_MaxVolume*16)/MAX_SND_DIST)>>9;
+ vol = soundCurve[dist];
+
+ if (origin == players[consoleplayer].mo)
+ {
+ sep = 128;
+ }
+ else
+ {
+ angle = R_PointToAngle2(players[consoleplayer].mo->x,
+ players[consoleplayer].mo->y,
+ channel[i].mo->x, channel[i].mo->y);
+ angle = (angle - viewangle) >> 24;
+ sep = angle * 2 - 128;
+ if (sep < 64)
+ sep = -sep;
+ if (sep > 192)
+ sep = 512 - sep;
+ }
+
+ // TODO: Play pitch-shifted sounds as in Vanilla Heretic
+
+ channel[i].pitch = (byte) (127 + (M_Random() & 7) - (M_Random() & 7));
+ channel[i].handle = I_StartSound(&S_sfx[sound_id], i, vol, sep);
+ channel[i].mo = origin;
+ channel[i].sound_id = sound_id;
+ channel[i].priority = priority;
+ if (sound_id >= sfx_wind)
+ {
+ AmbChan = i;
+ }
+ if (S_sfx[sound_id].usefulness == -1)
+ {
+ S_sfx[sound_id].usefulness = 1;
+ }
+ else
+ {
+ S_sfx[sound_id].usefulness++;
+ }
+}
+
+void S_StartSoundAtVolume(mobj_t * origin, int sound_id, int volume)
+{
+ int i;
+
+ if (sound_id == 0 || snd_MaxVolume == 0)
+ return;
+ if (origin == NULL)
+ {
+ origin = players[consoleplayer].mo;
+ }
+
+ if (volume == 0)
+ {
+ return;
+ }
+ volume = (volume * (snd_MaxVolume + 1) * 8) >> 7;
+
+// no priority checking, as ambient sounds would be the LOWEST.
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].mo == NULL)
+ {
+ break;
+ }
+ }
+ if (i >= snd_Channels)
+ {
+ return;
+ }
+ if (S_sfx[sound_id].lumpnum == 0)
+ {
+ S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]);
+ }
+
+ // TODO: Pitch shifting.
+ channel[i].pitch = (byte) (127 - (M_Random() & 3) + (M_Random() & 3));
+ channel[i].handle = I_StartSound(&S_sfx[sound_id], i, volume, 128);
+ channel[i].mo = origin;
+ channel[i].sound_id = sound_id;
+ channel[i].priority = 1; //super low priority.
+ if (S_sfx[sound_id].usefulness == -1)
+ {
+ S_sfx[sound_id].usefulness = 1;
+ }
+ else
+ {
+ S_sfx[sound_id].usefulness++;
+ }
+}
+
+boolean S_StopSoundID(int sound_id, int priority)
+{
+ int i;
+ int lp; //least priority
+ int found;
+
+ if (S_sfx[sound_id].numchannels == -1)
+ {
+ return (true);
+ }
+ lp = -1; //denote the argument sound_id
+ found = 0;
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].sound_id == sound_id && channel[i].mo)
+ {
+ found++; //found one. Now, should we replace it??
+ if (priority >= channel[i].priority)
+ { // if we're gonna kill one, then this'll be it
+ lp = i;
+ priority = channel[i].priority;
+ }
+ }
+ }
+ if (found < S_sfx[sound_id].numchannels)
+ {
+ return (true);
+ }
+ else if (lp == -1)
+ {
+ return (false); // don't replace any sounds
+ }
+ if (channel[lp].handle)
+ {
+ if (I_SoundIsPlaying(channel[lp].handle))
+ {
+ I_StopSound(channel[lp].handle);
+ }
+ if (S_sfx[channel[i].sound_id].usefulness > 0)
+ {
+ S_sfx[channel[i].sound_id].usefulness--;
+ }
+ channel[lp].mo = NULL;
+ }
+ return (true);
+}
+
+void S_StopSound(mobj_t * origin)
+{
+ int i;
+
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].mo == origin)
+ {
+ I_StopSound(channel[i].handle);
+ if (S_sfx[channel[i].sound_id].usefulness > 0)
+ {
+ S_sfx[channel[i].sound_id].usefulness--;
+ }
+ channel[i].handle = 0;
+ channel[i].mo = NULL;
+ if (AmbChan == i)
+ {
+ AmbChan = -1;
+ }
+ }
+ }
+}
+
+void S_SoundLink(mobj_t * oldactor, mobj_t * newactor)
+{
+ int i;
+
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (channel[i].mo == oldactor)
+ channel[i].mo = newactor;
+ }
+}
+
+void S_PauseSound(void)
+{
+ I_PauseSong();
+}
+
+void S_ResumeSound(void)
+{
+ I_ResumeSong();
+}
+
+void S_UpdateSounds(mobj_t * listener)
+{
+ int i, dist, vol;
+ int angle;
+ int sep;
+ int priority;
+ int absx;
+ int absy;
+
+ listener = players[consoleplayer].mo;
+ if (snd_MaxVolume == 0)
+ {
+ return;
+ }
+
+ for (i = 0; i < snd_Channels; i++)
+ {
+ if (!channel[i].handle || S_sfx[channel[i].sound_id].usefulness == -1)
+ {
+ continue;
+ }
+ if (!I_SoundIsPlaying(channel[i].handle))
+ {
+ if (S_sfx[channel[i].sound_id].usefulness > 0)
+ {
+ S_sfx[channel[i].sound_id].usefulness--;
+ }
+ channel[i].handle = 0;
+ channel[i].mo = NULL;
+ channel[i].sound_id = 0;
+ if (AmbChan == i)
+ {
+ AmbChan = -1;
+ }
+ }
+ if (channel[i].mo == NULL || channel[i].sound_id == 0
+ || channel[i].mo == players[consoleplayer].mo)
+ {
+ continue;
+ }
+ else
+ {
+ absx = abs(channel[i].mo->x - players[consoleplayer].mo->x);
+ absy = abs(channel[i].mo->y - players[consoleplayer].mo->y);
+ dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1);
+ dist >>= FRACBITS;
+// dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS;
+
+ if (dist >= MAX_SND_DIST)
+ {
+ S_StopSound(channel[i].mo);
+ continue;
+ }
+ if (dist < 0)
+ dist = 0;
+
+// calculate the volume based upon the distance from the sound origin.
+// vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7;
+ vol = soundCurve[dist];
+
+ angle = R_PointToAngle2(players[consoleplayer].mo->x,
+ players[consoleplayer].mo->y,
+ channel[i].mo->x, channel[i].mo->y);
+ angle = (angle - viewangle) >> 24;
+ sep = angle * 2 - 128;
+ if (sep < 64)
+ sep = -sep;
+ if (sep > 192)
+ sep = 512 - sep;
+ // TODO: Pitch shifting.
+ I_UpdateSoundParams(channel[i].handle, vol, sep);
+ priority = S_sfx[channel[i].sound_id].priority;
+ priority *= (10 - (dist >> 8));
+ channel[i].priority = priority;
+ }
+ }
+}
+
+void S_Init(void)
+{
+ soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL);
+ I_InitSound();
+ if (snd_Channels > 8)
+ {
+ snd_Channels = 8;
+ }
+ I_SetMusicVolume(snd_MusicVolume);
+ S_SetMaxVolume(true);
+}
+
+void S_GetChannelInfo(SoundInfo_t * s)
+{
+ int i;
+ ChanInfo_t *c;
+
+ s->channelCount = snd_Channels;
+ s->musicVolume = snd_MusicVolume;
+ s->soundVolume = snd_MaxVolume;
+ for (i = 0; i < snd_Channels; i++)
+ {
+ c = &s->chan[i];
+ c->id = channel[i].sound_id;
+ c->priority = channel[i].priority;
+ c->name = S_sfx[c->id].name;
+ c->mo = channel[i].mo;
+ c->distance = P_AproxDistance(c->mo->x - viewx, c->mo->y - viewy)
+ >> FRACBITS;
+ }
+}
+
+void S_SetMaxVolume(boolean fullprocess)
+{
+ int i;
+
+ if (!fullprocess)
+ {
+ soundCurve[0] =
+ (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE)) *
+ (snd_MaxVolume * 8)) >> 7;
+ }
+ else
+ {
+ for (i = 0; i < MAX_SND_DIST; i++)
+ {
+ soundCurve[i] =
+ (*((byte *) W_CacheLumpName("SNDCURVE", PU_CACHE) + i) *
+ (snd_MaxVolume * 8)) >> 7;
+ }
+ }
+}
+
+static boolean musicPaused;
+void S_SetMusicVolume(void)
+{
+ I_SetMusicVolume(snd_MusicVolume);
+ if (snd_MusicVolume == 0)
+ {
+ I_PauseSong();
+ musicPaused = true;
+ }
+ else if (musicPaused)
+ {
+ musicPaused = false;
+ I_ResumeSong();
+ }
+}
+
+void S_ShutDown(void)
+{
+ extern int tsm_ID;
+ if (tsm_ID != -1)
+ {
+ I_StopSong();
+ I_UnRegisterSong(rs);
+ I_ShutdownSound();
+ }
+}
+
diff --git a/src/heretic/soundst.h b/src/heretic/s_sound.h
index fb63de08..fb63de08 100644
--- a/src/heretic/soundst.h
+++ b/src/heretic/s_sound.h
diff --git a/src/heretic/sb_bar.c b/src/heretic/sb_bar.c
index 9655837e..6414bb8f 100644
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -25,7 +25,7 @@
#include "doomdef.h"
#include "p_local.h"
-#include "soundst.h"
+#include "s_sound.h"
// Macros
diff --git a/src/heretic/sounds.c b/src/heretic/sounds.c
index 99dd102c..38c39210 100644
--- a/src/heretic/sounds.c
+++ b/src/heretic/sounds.c
@@ -25,216 +25,232 @@
// sounds.c
#include "doomdef.h"
+#include "i_sound.h"
#include "sounds.h"
// Music info
+#define MUSIC(name) \
+ { name, 0, NULL, NULL }
+
musicinfo_t S_music[] = {
- {"MUS_E1M1", 0}, // 1-1
- {"MUS_E1M2", 0},
- {"MUS_E1M3", 0},
- {"MUS_E1M4", 0},
- {"MUS_E1M5", 0},
- {"MUS_E1M6", 0},
- {"MUS_E1M7", 0},
- {"MUS_E1M8", 0},
- {"MUS_E1M9", 0},
-
- {"MUS_E2M1", 0}, // 2-1
- {"MUS_E2M2", 0},
- {"MUS_E2M3", 0},
- {"MUS_E2M4", 0},
- {"MUS_E1M4", 0},
- {"MUS_E2M6", 0},
- {"MUS_E2M7", 0},
- {"MUS_E2M8", 0},
- {"MUS_E2M9", 0},
-
- {"MUS_E1M1", 0}, // 3-1
- {"MUS_E3M2", 0},
- {"MUS_E3M3", 0},
- {"MUS_E1M6", 0},
- {"MUS_E1M3", 0},
- {"MUS_E1M2", 0},
- {"MUS_E1M5", 0},
- {"MUS_E1M9", 0},
- {"MUS_E2M6", 0},
-
- {"MUS_E1M6", 0}, // 4-1
- {"MUS_E1M2", 0},
- {"MUS_E1M3", 0},
- {"MUS_E1M4", 0},
- {"MUS_E1M5", 0},
- {"MUS_E1M1", 0},
- {"MUS_E1M7", 0},
- {"MUS_E1M8", 0},
- {"MUS_E1M9", 0},
-
- {"MUS_E2M1", 0}, // 5-1
- {"MUS_E2M2", 0},
- {"MUS_E2M3", 0},
- {"MUS_E2M4", 0},
- {"MUS_E1M4", 0},
- {"MUS_E2M6", 0},
- {"MUS_E2M7", 0},
- {"MUS_E2M8", 0},
- {"MUS_E2M9", 0},
-
- {"MUS_E3M2", 0}, // 6-1
- {"MUS_E3M3", 0}, // 6-2
- {"MUS_E1M6", 0}, // 6-3
-
- {"MUS_TITL", 0},
- {"MUS_INTR", 0},
- {"MUS_CPTD", 0}
+ MUSIC("MUS_E1M1"), // 1-1
+ MUSIC("MUS_E1M2"),
+ MUSIC("MUS_E1M3"),
+ MUSIC("MUS_E1M4"),
+ MUSIC("MUS_E1M5"),
+ MUSIC("MUS_E1M6"),
+ MUSIC("MUS_E1M7"),
+ MUSIC("MUS_E1M8"),
+ MUSIC("MUS_E1M9"),
+
+ MUSIC("MUS_E2M1"), // 2-1
+ MUSIC("MUS_E2M2"),
+ MUSIC("MUS_E2M3"),
+ MUSIC("MUS_E2M4"),
+ MUSIC("MUS_E1M4"),
+ MUSIC("MUS_E2M6"),
+ MUSIC("MUS_E2M7"),
+ MUSIC("MUS_E2M8"),
+ MUSIC("MUS_E2M9"),
+
+ MUSIC("MUS_E1M1"), // 3-1
+ MUSIC("MUS_E3M2"),
+ MUSIC("MUS_E3M3"),
+ MUSIC("MUS_E1M6"),
+ MUSIC("MUS_E1M3"),
+ MUSIC("MUS_E1M2"),
+ MUSIC("MUS_E1M5"),
+ MUSIC("MUS_E1M9"),
+ MUSIC("MUS_E2M6"),
+
+ MUSIC("MUS_E1M6"), // 4-1
+ MUSIC("MUS_E1M2"),
+ MUSIC("MUS_E1M3"),
+ MUSIC("MUS_E1M4"),
+ MUSIC("MUS_E1M5"),
+ MUSIC("MUS_E1M1"),
+ MUSIC("MUS_E1M7"),
+ MUSIC("MUS_E1M8"),
+ MUSIC("MUS_E1M9"),
+
+ MUSIC("MUS_E2M1"), // 5-1
+ MUSIC("MUS_E2M2"),
+ MUSIC("MUS_E2M3"),
+ MUSIC("MUS_E2M4"),
+ MUSIC("MUS_E1M4"),
+ MUSIC("MUS_E2M6"),
+ MUSIC("MUS_E2M7"),
+ MUSIC("MUS_E2M8"),
+ MUSIC("MUS_E2M9"),
+
+ MUSIC("MUS_E3M2"), // 6-1
+ MUSIC("MUS_E3M3"), // 6-2
+ MUSIC("MUS_E1M6"), // 6-3
+
+ MUSIC("MUS_TITL"),
+ MUSIC("MUS_INTR"),
+ MUSIC("MUS_CPTD")
};
// Sound info
+ /* Macro for original heretic sfxinfo_t
+#define SOUND(name, priority, numchannels) \
+ { name, NULL, priority, -1, NULL, 0, numchannels }
+#define SOUND_LINK(name, link_id, priority, numchannels) \
+ { name, &S_sfx[link_id], priority, -1, NULL, 0, numchannels }
+ */
+
+#define SOUND(name, priority, numchannels) \
+ { name, priority, NULL, -1, -1, -1, 0, numchannels, NULL }
+#define SOUND_LINK(name, link_id, priority, numchannels) \
+ { name, priority, &S_sfx[link_id], 0, 0, -1, 0, numchannels, NULL }
+
sfxinfo_t S_sfx[] = {
- {{0, 0, 0, 0, 0, 0, 0, 0}, NULL, 0, -1, NULL, 0, 0},
- {"gldhit", NULL, 32, -1, NULL, 0, 2},
- {"gntful", NULL, 32, -1, NULL, 0, -1},
- {"gnthit", NULL, 32, -1, NULL, 0, -1},
- {"gntpow", NULL, 32, -1, NULL, 0, -1},
- {"gntact", NULL, 32, -1, NULL, 0, -1},
- {"gntuse", NULL, 32, -1, NULL, 0, -1},
- {"phosht", NULL, 32, -1, NULL, 0, 2},
- {"phohit", NULL, 32, -1, NULL, 0, -1},
- {"-phopow", &S_sfx[sfx_hedat1], 32, -1, NULL, 0, 1},
- {"lobsht", NULL, 20, -1, NULL, 0, 2},
- {"lobhit", NULL, 20, -1, NULL, 0, 2},
- {"lobpow", NULL, 20, -1, NULL, 0, 2},
- {"hrnsht", NULL, 32, -1, NULL, 0, 2},
- {"hrnhit", NULL, 32, -1, NULL, 0, 2},
- {"hrnpow", NULL, 32, -1, NULL, 0, 2},
- {"ramphit", NULL, 32, -1, NULL, 0, 2},
- {"ramrain", NULL, 10, -1, NULL, 0, 2},
- {"bowsht", NULL, 32, -1, NULL, 0, 2},
- {"stfhit", NULL, 32, -1, NULL, 0, 2},
- {"stfpow", NULL, 32, -1, NULL, 0, 2},
- {"stfcrk", NULL, 32, -1, NULL, 0, 2},
- {"impsit", NULL, 32, -1, NULL, 0, 2},
- {"impat1", NULL, 32, -1, NULL, 0, 2},
- {"impat2", NULL, 32, -1, NULL, 0, 2},
- {"impdth", NULL, 80, -1, NULL, 0, 2},
- {"-impact", &S_sfx[sfx_impsit], 20, -1, NULL, 0, 2},
- {"imppai", NULL, 32, -1, NULL, 0, 2},
- {"mumsit", NULL, 32, -1, NULL, 0, 2},
- {"mumat1", NULL, 32, -1, NULL, 0, 2},
- {"mumat2", NULL, 32, -1, NULL, 0, 2},
- {"mumdth", NULL, 80, -1, NULL, 0, 2},
- {"-mumact", &S_sfx[sfx_mumsit], 20, -1, NULL, 0, 2},
- {"mumpai", NULL, 32, -1, NULL, 0, 2},
- {"mumhed", NULL, 32, -1, NULL, 0, 2},
- {"bstsit", NULL, 32, -1, NULL, 0, 2},
- {"bstatk", NULL, 32, -1, NULL, 0, 2},
- {"bstdth", NULL, 80, -1, NULL, 0, 2},
- {"bstact", NULL, 20, -1, NULL, 0, 2},
- {"bstpai", NULL, 32, -1, NULL, 0, 2},
- {"clksit", NULL, 32, -1, NULL, 0, 2},
- {"clkatk", NULL, 32, -1, NULL, 0, 2},
- {"clkdth", NULL, 80, -1, NULL, 0, 2},
- {"clkact", NULL, 20, -1, NULL, 0, 2},
- {"clkpai", NULL, 32, -1, NULL, 0, 2},
- {"snksit", NULL, 32, -1, NULL, 0, 2},
- {"snkatk", NULL, 32, -1, NULL, 0, 2},
- {"snkdth", NULL, 80, -1, NULL, 0, 2},
- {"snkact", NULL, 20, -1, NULL, 0, 2},
- {"snkpai", NULL, 32, -1, NULL, 0, 2},
- {"kgtsit", NULL, 32, -1, NULL, 0, 2},
- {"kgtatk", NULL, 32, -1, NULL, 0, 2},
- {"kgtat2", NULL, 32, -1, NULL, 0, 2},
- {"kgtdth", NULL, 80, -1, NULL, 0, 2},
- {"-kgtact", &S_sfx[sfx_kgtsit], 20, -1, NULL, 0, 2},
- {"kgtpai", NULL, 32, -1, NULL, 0, 2},
- {"wizsit", NULL, 32, -1, NULL, 0, 2},
- {"wizatk", NULL, 32, -1, NULL, 0, 2},
- {"wizdth", NULL, 80, -1, NULL, 0, 2},
- {"wizact", NULL, 20, -1, NULL, 0, 2},
- {"wizpai", NULL, 32, -1, NULL, 0, 2},
- {"minsit", NULL, 32, -1, NULL, 0, 2},
- {"minat1", NULL, 32, -1, NULL, 0, 2},
- {"minat2", NULL, 32, -1, NULL, 0, 2},
- {"minat3", NULL, 32, -1, NULL, 0, 2},
- {"mindth", NULL, 80, -1, NULL, 0, 2},
- {"minact", NULL, 20, -1, NULL, 0, 2},
- {"minpai", NULL, 32, -1, NULL, 0, 2},
- {"hedsit", NULL, 32, -1, NULL, 0, 2},
- {"hedat1", NULL, 32, -1, NULL, 0, 2},
- {"hedat2", NULL, 32, -1, NULL, 0, 2},
- {"hedat3", NULL, 32, -1, NULL, 0, 2},
- {"heddth", NULL, 80, -1, NULL, 0, 2},
- {"hedact", NULL, 20, -1, NULL, 0, 2},
- {"hedpai", NULL, 32, -1, NULL, 0, 2},
- {"sorzap", NULL, 32, -1, NULL, 0, 2},
- {"sorrise", NULL, 32, -1, NULL, 0, 2},
- {"sorsit", NULL, 200, -1, NULL, 0, 2},
- {"soratk", NULL, 32, -1, NULL, 0, 2},
- {"soract", NULL, 200, -1, NULL, 0, 2},
- {"sorpai", NULL, 200, -1, NULL, 0, 2},
- {"sordsph", NULL, 200, -1, NULL, 0, 2},
- {"sordexp", NULL, 200, -1, NULL, 0, 2},
- {"sordbon", NULL, 200, -1, NULL, 0, 2},
- {"-sbtsit", &S_sfx[sfx_bstsit], 32, -1, NULL, 0, 2},
- {"-sbtatk", &S_sfx[sfx_bstatk], 32, -1, NULL, 0, 2},
- {"sbtdth", NULL, 80, -1, NULL, 0, 2},
- {"sbtact", NULL, 20, -1, NULL, 0, 2},
- {"sbtpai", NULL, 32, -1, NULL, 0, 2},
- {"plroof", NULL, 32, -1, NULL, 0, 2},
- {"plrpai", NULL, 32, -1, NULL, 0, 2},
- {"plrdth", NULL, 80, -1, NULL, 0, 2},
- {"gibdth", NULL, 100, -1, NULL, 0, 2},
- {"plrwdth", NULL, 80, -1, NULL, 0, 2},
- {"plrcdth", NULL, 100, -1, NULL, 0, 2},
- {"itemup", NULL, 32, -1, NULL, 0, 2},
- {"wpnup", NULL, 32, -1, NULL, 0, 2},
- {"telept", NULL, 50, -1, NULL, 0, 2},
- {"doropn", NULL, 40, -1, NULL, 0, 2},
- {"dorcls", NULL, 40, -1, NULL, 0, 2},
- {"dormov", NULL, 40, -1, NULL, 0, 2},
- {"artiup", NULL, 32, -1, NULL, 0, 2},
- {"switch", NULL, 40, -1, NULL, 0, 2},
- {"pstart", NULL, 40, -1, NULL, 0, 2},
- {"pstop", NULL, 40, -1, NULL, 0, 2},
- {"stnmov", NULL, 40, -1, NULL, 0, 2},
- {"chicpai", NULL, 32, -1, NULL, 0, 2},
- {"chicatk", NULL, 32, -1, NULL, 0, 2},
- {"chicdth", NULL, 40, -1, NULL, 0, 2},
- {"chicact", NULL, 32, -1, NULL, 0, 2},
- {"chicpk1", NULL, 32, -1, NULL, 0, 2},
- {"chicpk2", NULL, 32, -1, NULL, 0, 2},
- {"chicpk3", NULL, 32, -1, NULL, 0, 2},
- {"keyup", NULL, 50, -1, NULL, 0, 2},
- {"ripslop", NULL, 16, -1, NULL, 0, 2},
- {"newpod", NULL, 16, -1, NULL, 0, -1},
- {"podexp", NULL, 40, -1, NULL, 0, -1},
- {"bounce", NULL, 16, -1, NULL, 0, 2},
- {"-volsht", &S_sfx[sfx_bstatk], 16, -1, NULL, 0, 2},
- {"-volhit", &S_sfx[sfx_lobhit], 16, -1, NULL, 0, 2},
- {"burn", NULL, 10, -1, NULL, 0, 2},
- {"splash", NULL, 10, -1, NULL, 0, 1},
- {"gloop", NULL, 10, -1, NULL, 0, 2},
- {"respawn", NULL, 10, -1, NULL, 0, 1},
- {"blssht", NULL, 32, -1, NULL, 0, 2},
- {"blshit", NULL, 32, -1, NULL, 0, 2},
- {"chat", NULL, 100, -1, NULL, 0, 1},
- {"artiuse", NULL, 32, -1, NULL, 0, 1},
- {"gfrag", NULL, 100, -1, NULL, 0, 1},
- {"waterfl", NULL, 16, -1, NULL, 0, 2},
+ SOUND("", 0, 0),
+ SOUND("gldhit", 32, 2),
+ SOUND("gntful", 32, -1),
+ SOUND("gnthit", 32, -1),
+ SOUND("gntpow", 32, -1),
+ SOUND("gntact", 32, -1),
+ SOUND("gntuse", 32, -1),
+ SOUND("phosht", 32, 2),
+ SOUND("phohit", 32, -1),
+ SOUND_LINK("-phopow", sfx_hedat1, 32, 1),
+ SOUND("lobsht", 20, 2),
+ SOUND("lobhit", 20, 2),
+ SOUND("lobpow", 20, 2),
+ SOUND("hrnsht", 32, 2),
+ SOUND("hrnhit", 32, 2),
+ SOUND("hrnpow", 32, 2),
+ SOUND("ramphit", 32, 2),
+ SOUND("ramrain", 10, 2),
+ SOUND("bowsht", 32, 2),
+ SOUND("stfhit", 32, 2),
+ SOUND("stfpow", 32, 2),
+ SOUND("stfcrk", 32, 2),
+ SOUND("impsit", 32, 2),
+ SOUND("impat1", 32, 2),
+ SOUND("impat2", 32, 2),
+ SOUND("impdth", 80, 2),
+ SOUND_LINK("-impact", sfx_impsit, 20, 2),
+ SOUND("imppai", 32, 2),
+ SOUND("mumsit", 32, 2),
+ SOUND("mumat1", 32, 2),
+ SOUND("mumat2", 32, 2),
+ SOUND("mumdth", 80, 2),
+ SOUND_LINK("-mumact", sfx_mumsit, 20, 2),
+ SOUND("mumpai", 32, 2),
+ SOUND("mumhed", 32, 2),
+ SOUND("bstsit", 32, 2),
+ SOUND("bstatk", 32, 2),
+ SOUND("bstdth", 80, 2),
+ SOUND("bstact", 20, 2),
+ SOUND("bstpai", 32, 2),
+ SOUND("clksit", 32, 2),
+ SOUND("clkatk", 32, 2),
+ SOUND("clkdth", 80, 2),
+ SOUND("clkact", 20, 2),
+ SOUND("clkpai", 32, 2),
+ SOUND("snksit", 32, 2),
+ SOUND("snkatk", 32, 2),
+ SOUND("snkdth", 80, 2),
+ SOUND("snkact", 20, 2),
+ SOUND("snkpai", 32, 2),
+ SOUND("kgtsit", 32, 2),
+ SOUND("kgtatk", 32, 2),
+ SOUND("kgtat2", 32, 2),
+ SOUND("kgtdth", 80, 2),
+ SOUND_LINK("-kgtact", sfx_kgtsit, 20, 2),
+ SOUND("kgtpai", 32, 2),
+ SOUND("wizsit", 32, 2),
+ SOUND("wizatk", 32, 2),
+ SOUND("wizdth", 80, 2),
+ SOUND("wizact", 20, 2),
+ SOUND("wizpai", 32, 2),
+ SOUND("minsit", 32, 2),
+ SOUND("minat1", 32, 2),
+ SOUND("minat2", 32, 2),
+ SOUND("minat3", 32, 2),
+ SOUND("mindth", 80, 2),
+ SOUND("minact", 20, 2),
+ SOUND("minpai", 32, 2),
+ SOUND("hedsit", 32, 2),
+ SOUND("hedat1", 32, 2),
+ SOUND("hedat2", 32, 2),
+ SOUND("hedat3", 32, 2),
+ SOUND("heddth", 80, 2),
+ SOUND("hedact", 20, 2),
+ SOUND("hedpai", 32, 2),
+ SOUND("sorzap", 32, 2),
+ SOUND("sorrise", 32, 2),
+ SOUND("sorsit", 200, 2),
+ SOUND("soratk", 32, 2),
+ SOUND("soract", 200, 2),
+ SOUND("sorpai", 200, 2),
+ SOUND("sordsph", 200, 2),
+ SOUND("sordexp", 200, 2),
+ SOUND("sordbon", 200, 2),
+ SOUND_LINK("-sbtsit", sfx_bstsit, 32, 2),
+ SOUND_LINK("-sbtatk", sfx_bstatk, 32, 2),
+ SOUND("sbtdth", 80, 2),
+ SOUND("sbtact", 20, 2),
+ SOUND("sbtpai", 32, 2),
+ SOUND("plroof", 32, 2),
+ SOUND("plrpai", 32, 2),
+ SOUND("plrdth", 80, 2),
+ SOUND("gibdth", 100, 2),
+ SOUND("plrwdth", 80, 2),
+ SOUND("plrcdth", 100, 2),
+ SOUND("itemup", 32, 2),
+ SOUND("wpnup", 32, 2),
+ SOUND("telept", 50, 2),
+ SOUND("doropn", 40, 2),
+ SOUND("dorcls", 40, 2),
+ SOUND("dormov", 40, 2),
+ SOUND("artiup", 32, 2),
+ SOUND("switch", 40, 2),
+ SOUND("pstart", 40, 2),
+ SOUND("pstop", 40, 2),
+ SOUND("stnmov", 40, 2),
+ SOUND("chicpai", 32, 2),
+ SOUND("chicatk", 32, 2),
+ SOUND("chicdth", 40, 2),
+ SOUND("chicact", 32, 2),
+ SOUND("chicpk1", 32, 2),
+ SOUND("chicpk2", 32, 2),
+ SOUND("chicpk3", 32, 2),
+ SOUND("keyup", 50, 2),
+ SOUND("ripslop", 16, 2),
+ SOUND("newpod", 16, -1),
+ SOUND("podexp", 40, -1),
+ SOUND("bounce", 16, 2),
+ SOUND_LINK("-volsht", sfx_bstatk, 16, 2),
+ SOUND_LINK("-volhit", sfx_lobhit, 16, 2),
+ SOUND("burn", 10, 2),
+ SOUND("splash", 10, 1),
+ SOUND("gloop", 10, 2),
+ SOUND("respawn", 10, 1),
+ SOUND("blssht", 32, 2),
+ SOUND("blshit", 32, 2),
+ SOUND("chat", 100, 1),
+ SOUND("artiuse", 32, 1),
+ SOUND("gfrag", 100, 1),
+ SOUND("waterfl", 16, 2),
// Monophonic sounds
- {"wind", NULL, 16, -1, NULL, 0, 1},
- {"amb1", NULL, 1, -1, NULL, 0, 1},
- {"amb2", NULL, 1, -1, NULL, 0, 1},
- {"amb3", NULL, 1, -1, NULL, 0, 1},
- {"amb4", NULL, 1, -1, NULL, 0, 1},
- {"amb5", NULL, 1, -1, NULL, 0, 1},
- {"amb6", NULL, 1, -1, NULL, 0, 1},
- {"amb7", NULL, 1, -1, NULL, 0, 1},
- {"amb8", NULL, 1, -1, NULL, 0, 1},
- {"amb9", NULL, 1, -1, NULL, 0, 1},
- {"amb10", NULL, 1, -1, NULL, 0, 1},
- {"amb11", NULL, 1, -1, NULL, 0, 0}
+ SOUND("wind", 16, 1),
+ SOUND("amb1", 1, 1),
+ SOUND("amb2", 1, 1),
+ SOUND("amb3", 1, 1),
+ SOUND("amb4", 1, 1),
+ SOUND("amb5", 1, 1),
+ SOUND("amb6", 1, 1),
+ SOUND("amb7", 1, 1),
+ SOUND("amb8", 1, 1),
+ SOUND("amb9", 1, 1),
+ SOUND("amb10", 1, 1),
+ SOUND("amb11", 1, 0)
};
diff --git a/src/heretic/sounds.h b/src/heretic/sounds.h
index ce97abb0..67cc377c 100644
--- a/src/heretic/sounds.h
+++ b/src/heretic/sounds.h
@@ -93,10 +93,10 @@ typedef enum
NUMMUSIC
} musicenum_t;
+#if 0
typedef struct
{
char name[8];
- int p1;
} musicinfo_t;
typedef struct sfxinfo_s
@@ -110,6 +110,8 @@ typedef struct sfxinfo_s
int numchannels; // total number of channels a sound type may occupy
} sfxinfo_t;
+#endif
+
typedef struct
{
mobj_t *mo;