Merge branch 'just-sound-code-things' into 'master'

Consolidate sound/music volume functions; kill HW3SOUND off the face of the game code

See merge request KartKrew/Kart!1518
This commit is contained in:
Sal 2023-09-24 19:00:14 +00:00
commit 7dafacaf7d
8 changed files with 21 additions and 175 deletions

View file

@ -92,10 +92,6 @@
#include "hardware/hw_main.h" // 3D View Rendering #include "hardware/hw_main.h" // 3D View Rendering
#endif #endif
#ifdef HW3SOUND
#include "hardware/hw3sound.h"
#endif
#include "lua_script.h" #include "lua_script.h"
/* Manually defined asset hashes /* Manually defined asset hashes
@ -838,10 +834,6 @@ void D_SRB2Loop(void)
interp = R_UsingFrameInterpolation() && !dedicated; interp = R_UsingFrameInterpolation() && !dedicated;
doDisplay = false; doDisplay = false;
#ifdef HW3SOUND
HW3S_BeginFrameUpdate();
#endif
if (realtics > 0 || singletics) if (realtics > 0 || singletics)
{ {
// don't skip more than 10 frames at a time // don't skip more than 10 frames at a time
@ -932,10 +924,6 @@ void D_SRB2Loop(void)
S_TickSoundTest(); S_TickSoundTest();
} }
#ifdef HW3SOUND
HW3S_EndFrameUpdate();
#endif
LUA_Step(); LUA_Step();
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
@ -1671,8 +1659,8 @@ void D_SRB2Main(void)
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
I_StartupSound(); I_StartupSound();
I_InitMusic(); I_InitMusic();
S_InitSfxChannels(cv_soundvolume.value); S_InitSfxChannels();
S_InitMusicVolume(); S_SetMusicVolume();
} }
Music_Init(); Music_Init();

View file

@ -15,46 +15,6 @@
#ifndef __DOOMDEF__ #ifndef __DOOMDEF__
#define __DOOMDEF__ #define __DOOMDEF__
// Sound system select
// This should actually be in the makefile,
// but I can't stand that gibberish. D:
#define SOUND_DUMMY 0
#define SOUND_SDL 1
#define SOUND_MIXER 2
#define SOUND_FMOD 3
#ifndef SOUND
#ifdef HAVE_SDL
// Use Mixer interface?
#ifdef HAVE_MIXER
#define SOUND SOUND_MIXER
#ifdef HW3SOUND
#undef HW3SOUND
#endif
#endif
// Use generic SDL interface.
#ifndef SOUND
#define SOUND SOUND_SDL
#endif
#else // No SDL.
// Use FMOD?
#ifdef HAVE_FMOD
#define SOUND SOUND_FMOD
#ifdef HW3SOUND
#undef HW3SOUND
#endif
#else
// No more interfaces. :(
#define SOUND SOUND_DUMMY
#endif
#endif
#endif
#ifdef _WIN32 #ifdef _WIN32
#define ASMCALL __cdecl #define ASMCALL __cdecl
#else #else

View file

@ -36,10 +36,6 @@
#include "k_objects.h" #include "k_objects.h"
#include "k_roulette.h" #include "k_roulette.h"
#ifdef HW3SOUND
#include "hardware/hw3sound.h"
#endif
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
player_t *stplyr; player_t *stplyr;

View file

@ -48,10 +48,6 @@
#include "k_terrain.h" #include "k_terrain.h"
#include "acs/interface.h" #include "acs/interface.h"
#ifdef HW3SOUND
#include "hardware/hw3sound.h"
#endif
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
#include <errno.h> #include <errno.h>

View file

@ -67,10 +67,6 @@
#include "music.h" #include "music.h"
#include "k_tally.h" #include "k_tally.h"
#ifdef HW3SOUND
#include "hardware/hw3sound.h"
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_light.h" #include "hardware/hw_light.h"
#include "hardware/hw_main.h" #include "hardware/hw_main.h"

View file

@ -37,12 +37,7 @@
#include "v_video.h" // V_ThinStringWidth #include "v_video.h" // V_ThinStringWidth
#include "music.h" #include "music.h"
#ifdef HW3SOUND
// 3D Sound Interface
#include "hardware/hw3sound.h"
#else
static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo); static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
#endif
static void Command_Tunes_f(void); static void Command_Tunes_f(void);
static void Command_RestartAudio_f(void); static void Command_RestartAudio_f(void);
@ -213,13 +208,6 @@ void SetChannelsNum(void)
if (cv_numChannels.value == 999999999) //Alam_GBC: OH MY ROD!(ROD rimmiced with GOD!) if (cv_numChannels.value == 999999999) //Alam_GBC: OH MY ROD!(ROD rimmiced with GOD!)
CV_StealthSet(&cv_numChannels,cv_numChannels.defaultvalue); CV_StealthSet(&cv_numChannels,cv_numChannels.defaultvalue);
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_SetSourcesNum();
return;
}
#endif
if (cv_numChannels.value) if (cv_numChannels.value)
channels = (channel_t *)Z_Calloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); channels = (channel_t *)Z_Calloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL);
numofchannels = (channels ? cv_numChannels.value : 0); numofchannels = (channels ? cv_numChannels.value : 0);
@ -267,14 +255,6 @@ void S_StopSounds(void)
{ {
INT32 cnum; INT32 cnum;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_StopSounds();
return;
}
#endif
// kill all playing sounds at start of level // kill all playing sounds at start of level
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
if (channels[cnum].sfxinfo) if (channels[cnum].sfxinfo)
@ -294,13 +274,6 @@ void S_StopSoundByID(void *origin, sfxenum_t sfx_id)
#if 0 #if 0
if (!origin) if (!origin)
return; return;
#endif
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_StopSoundByID(origin, sfx_id);
return;
}
#endif #endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
{ {
@ -315,13 +288,6 @@ void S_StopSoundByNum(sfxenum_t sfxnum)
{ {
INT32 cnum; INT32 cnum;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_StopSoundByNum(sfxnum);
return;
}
#endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
{ {
if (channels[cnum].sfxinfo == &S_sfx[sfxnum]) if (channels[cnum].sfxinfo == &S_sfx[sfxnum])
@ -484,14 +450,6 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
} }
} }
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_StartSound(origin, sfx_id);
return;
};
#endif
for (i = 0; i <= r_splitscreen; i++) for (i = 0; i <= r_splitscreen; i++)
{ {
player_t *player = &players[displayplayers[i]]; player_t *player = &players[displayplayers[i]];
@ -649,12 +607,7 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id)
return; return;
// the volume is handled 8 bits // the volume is handled 8 bits
#ifdef HW3SOUND S_StartSoundAtVolume(origin, sfx_id, 255);
if (hws_mode != HWS_DEFAULT_MODE)
HW3S_StartSound(origin, sfx_id);
else
#endif
S_StartSoundAtVolume(origin, sfx_id, 255);
} }
void S_ReducedVFXSoundAtVolume(const void *origin, sfxenum_t sfx_id, INT32 volume, player_t *owner) void S_ReducedVFXSoundAtVolume(const void *origin, sfxenum_t sfx_id, INT32 volume, player_t *owner)
@ -687,13 +640,6 @@ void S_StopSound(void *origin)
if (!origin) if (!origin)
return; return;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_StopSound(origin);
return;
}
#endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
{ {
if (channels[cnum].sfxinfo && channels[cnum].origin == origin) if (channels[cnum].sfxinfo && channels[cnum].origin == origin)
@ -721,9 +667,9 @@ void S_UpdateSounds(void)
// Update sound/music volumes, if changed manually at console // Update sound/music volumes, if changed manually at console
if (actualsfxvolume != cv_soundvolume.value) if (actualsfxvolume != cv_soundvolume.value)
S_SetSfxVolume (cv_soundvolume.value); S_SetSfxVolume();
if (actualdigmusicvolume != cv_digmusicvolume.value) if (actualdigmusicvolume != cv_digmusicvolume.value)
S_SetDigMusicVolume (cv_digmusicvolume.value); S_SetMusicVolume();
// We're done now, if we're not in a level. // We're done now, if we're not in a level.
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
@ -765,14 +711,6 @@ void S_UpdateSounds(void)
I_UpdateMumble(players[consoleplayer].mo, listener[0]); I_UpdateMumble(players[consoleplayer].mo, listener[0]);
#endif #endif
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
{
HW3S_UpdateSources();
goto notinlevel;
}
#endif
for (i = 0; i <= r_splitscreen; i++) for (i = 0; i <= r_splitscreen; i++)
{ {
player_t *player = &players[displayplayers[i]]; player_t *player = &players[displayplayers[i]];
@ -914,17 +852,12 @@ void S_UpdateClosedCaptions(void)
} }
} }
void S_SetSfxVolume(INT32 volume) void S_SetSfxVolume(void)
{ {
//CV_SetValue(&cv_soundvolume, volume); actualsfxvolume = cv_soundvolume.value;
actualsfxvolume = volume;
#ifdef HW3SOUND
hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F);
#else
// now hardware volume // now hardware volume
I_SetSfxVolume(volume); I_SetSfxVolume(actualsfxvolume);
#endif
} }
void S_ClearSfx(void) void S_ClearSfx(void)
@ -1128,11 +1061,6 @@ INT32 S_OriginPlaying(void *origin)
if (!origin) if (!origin)
return false; return false;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
return HW3S_OriginPlaying(origin);
#endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
if (channels[cnum].origin == origin) if (channels[cnum].origin == origin)
return 1; return 1;
@ -1145,11 +1073,6 @@ INT32 S_IdPlaying(sfxenum_t id)
{ {
INT32 cnum; INT32 cnum;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
return HW3S_IdPlaying(id);
#endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id)
return 1; return 1;
@ -1164,11 +1087,6 @@ INT32 S_SoundPlaying(void *origin, sfxenum_t id)
if (!origin) if (!origin)
return 0; return 0;
#ifdef HW3SOUND
if (hws_mode != HWS_DEFAULT_MODE)
return HW3S_SoundPlaying(origin, id);
#endif
for (cnum = 0; cnum < numofchannels; cnum++) for (cnum = 0; cnum < numofchannels; cnum++)
{ {
if (channels[cnum].origin == origin if (channels[cnum].origin == origin
@ -1230,7 +1148,7 @@ void S_StartSoundName(void *mo, const char *soundname)
// Sets channels, SFX volume, // Sets channels, SFX volume,
// allocates channel buffer, sets S_sfx lookup. // allocates channel buffer, sets S_sfx lookup.
// //
void S_InitSfxChannels(INT32 sfxVolume) void S_InitSfxChannels(void)
{ {
extern consvar_t precachesound; extern consvar_t precachesound;
@ -1239,7 +1157,7 @@ void S_InitSfxChannels(INT32 sfxVolume)
if (dedicated) if (dedicated)
return; return;
S_SetSfxVolume(sfxVolume); S_SetSfxVolume();
SetChannelsNum(); SetChannelsNum();
@ -2091,14 +2009,10 @@ void S_ResumeAudio(void)
Music_UnPauseAll(); Music_UnPauseAll();
} }
void S_SetMusicVolume(INT32 digvolume) void S_SetMusicVolume(void)
{ {
if (digvolume < 0) actualdigmusicvolume = cv_digmusicvolume.value;
digvolume = cv_digmusicvolume.value; I_SetMusicVolume(actualdigmusicvolume);
//CV_SetValue(&cv_digmusicvolume, digvolume);
actualdigmusicvolume = digvolume;
I_SetMusicVolume(digvolume);
} }
/// ------------------------ /// ------------------------
@ -2219,8 +2133,8 @@ static void Command_RestartAudio_f(void)
// These must be called or no sound and music until manually set. // These must be called or no sound and music until manually set.
I_SetSfxVolume(cv_soundvolume.value); S_SetSfxVolume();
S_SetMusicVolume(cv_digmusicvolume.value); S_SetMusicVolume();
S_StartSound(NULL, sfx_strpst); S_StartSound(NULL, sfx_strpst);
@ -2392,7 +2306,7 @@ void GameSounds_OnChange(void)
{ {
sound_disabled = false; sound_disabled = false;
I_StartupSound(); // will return early if initialised I_StartupSound(); // will return early if initialised
S_InitSfxChannels(cv_soundvolume.value); S_InitSfxChannels();
S_StartSound(NULL, sfx_strpst); S_StartSound(NULL, sfx_strpst);
} }
else else
@ -2431,7 +2345,7 @@ void PlayMusicIfUnfocused_OnChange(void)
if (cv_playmusicifunfocused.value) if (cv_playmusicifunfocused.value)
I_SetMusicVolume(0); I_SetMusicVolume(0);
else else
S_InitMusicVolume(); S_SetMusicVolume();
} }
} }

View file

@ -98,7 +98,7 @@ void S_RegisterSoundStuff(void);
// Initializes sound stuff, including volume // Initializes sound stuff, including volume
// Sets channels, SFX, allocates channel buffer, sets S_sfx lookup. // Sets channels, SFX, allocates channel buffer, sets S_sfx lookup.
// //
void S_InitSfxChannels(INT32 sfxVolume); void S_InitSfxChannels(void);
// //
// Per level startup code. // Per level startup code.
@ -237,10 +237,8 @@ FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1,
INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume); INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume);
void S_SetSfxVolume(INT32 volume); void S_SetSfxVolume(void);
void S_SetMusicVolume(INT32 digvolume); void S_SetMusicVolume(void);
#define S_SetDigMusicVolume S_SetMusicVolume
#define S_InitMusicVolume() S_SetMusicVolume(-1)
INT32 S_OriginPlaying(void *origin); INT32 S_OriginPlaying(void *origin);
INT32 S_IdPlaying(sfxenum_t id); INT32 S_IdPlaying(sfxenum_t id);
@ -251,10 +249,8 @@ void S_StartSoundName(void *mo, const char *soundname);
void S_StopSoundByID(void *origin, sfxenum_t sfx_id); void S_StopSoundByID(void *origin, sfxenum_t sfx_id);
void S_StopSoundByNum(sfxenum_t sfxnum); void S_StopSoundByNum(sfxenum_t sfxnum);
#ifndef HW3SOUND
#define S_StartAttackSound S_StartSound #define S_StartAttackSound S_StartSound
#define S_StartScreamSound S_StartSound #define S_StartScreamSound S_StartSound
#endif
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"

View file

@ -513,7 +513,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
// Tell game we got focus back, resume music if necessary // Tell game we got focus back, resume music if necessary
window_notinfocus = false; window_notinfocus = false;
S_InitMusicVolume(); S_SetMusicVolume();
if (!firsttimeonmouse) if (!firsttimeonmouse)
{ {