2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2020-02-19 22:08:45 +00:00
|
|
|
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file s_sound.c
|
|
|
|
/// \brief System-independent sound and music routines
|
|
|
|
|
|
|
|
#ifdef MUSSERV
|
|
|
|
#include <sys/msg.h>
|
|
|
|
struct musmsg
|
|
|
|
{
|
|
|
|
long msg_type;
|
|
|
|
char msg_text[12];
|
|
|
|
};
|
|
|
|
extern INT32 msg_id;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "m_argv.h"
|
|
|
|
#include "r_main.h" // R_PointToAngle2() used to calc stereo sep.
|
2020-03-09 13:54:56 +00:00
|
|
|
#include "r_skins.h" // for skins
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "i_system.h"
|
|
|
|
#include "i_sound.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "z_zone.h"
|
|
|
|
#include "d_main.h"
|
|
|
|
#include "r_sky.h" // skyflatnum
|
|
|
|
#include "p_local.h" // camera info
|
2017-04-17 01:03:44 +00:00
|
|
|
#include "fastcmp.h"
|
2018-10-11 20:29:43 +00:00
|
|
|
#include "m_misc.h" // for tunes command
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
#include "m_cond.h" // for conditionsets
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2018-09-18 14:32:38 +00:00
|
|
|
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
|
2018-08-15 06:06:43 +00:00
|
|
|
#include "lua_hook.h" // MusicChange hook
|
|
|
|
#endif
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
#ifdef HW3SOUND
|
|
|
|
// 3D Sound Interface
|
|
|
|
#include "hardware/hw3sound.h"
|
|
|
|
#else
|
|
|
|
static INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}};
|
|
|
|
static void SetChannelsNum(void);
|
2018-10-11 20:29:43 +00:00
|
|
|
static void Command_Tunes_f(void);
|
|
|
|
static void Command_RestartAudio_f(void);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2018-11-25 19:22:52 +00:00
|
|
|
// Sound system toggles
|
|
|
|
static void GameMIDIMusic_OnChange(void);
|
|
|
|
static void GameSounds_OnChange(void);
|
|
|
|
static void GameDigiMusic_OnChange(void);
|
|
|
|
|
2019-12-31 03:19:17 +00:00
|
|
|
#ifdef HAVE_OPENMPT
|
2019-01-06 04:42:25 +00:00
|
|
|
static void ModFilter_OnChange(void);
|
2019-12-31 03:19:17 +00:00
|
|
|
#endif
|
2019-01-06 04:42:25 +00:00
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
static lumpnum_t S_GetMusicLumpNum(const char *mname);
|
|
|
|
|
2019-10-26 19:02:45 +00:00
|
|
|
static boolean S_CheckQueue(void);
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// commands for music and sound servers
|
|
|
|
#ifdef MUSSERV
|
|
|
|
consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t musserver_arg = {"musserver_arg", "-t 20 -f -u 0 -i music.dta", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
#endif
|
|
|
|
#ifdef SNDSERV
|
|
|
|
consvar_t sndserver_cmd = {"sndserver_cmd", "llsndserv", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t sndserver_arg = {"sndserver_arg", "-quiet", CV_SAVE, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (_WINDOWS) && !defined (SURROUND) //&& defined (_X86_)
|
|
|
|
#define SURROUND
|
|
|
|
#endif
|
|
|
|
|
2017-09-29 22:25:34 +00:00
|
|
|
#ifdef _WINDOWS
|
2014-03-15 16:59:03 +00:00
|
|
|
consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 44100, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
|
|
|
|
#else
|
|
|
|
consvar_t cv_samplerate = {"samplerate", "22050", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// stereo reverse
|
|
|
|
consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
|
|
|
|
// if true, all sounds are loaded at game startup
|
|
|
|
static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
|
|
|
|
// actual general (maximum) sound & music volume, saved into the config
|
2018-04-11 18:40:05 +00:00
|
|
|
consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
2014-03-15 16:59:03 +00:00
|
|
|
consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
2017-04-29 15:40:07 +00:00
|
|
|
|
|
|
|
static void Captioning_OnChange(void)
|
|
|
|
{
|
|
|
|
S_ResetCaptions();
|
|
|
|
if (cv_closedcaptioning.value)
|
|
|
|
S_StartSound(NULL, sfx_menu1);
|
|
|
|
}
|
|
|
|
|
|
|
|
consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_OnOff, Captioning_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// number of channels available
|
|
|
|
consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
|
|
|
|
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
2019-08-05 00:02:38 +00:00
|
|
|
|
|
|
|
consvar_t cv_resetmusic = {"resetmusic", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t cv_resetmusicbyheader = {"resetmusicbyheader", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-01-10 20:55:03 +00:00
|
|
|
static CV_PossibleValue_t cons_1upsound_t[] = {
|
|
|
|
{0, "Jingle"},
|
|
|
|
{1, "Sound"},
|
2020-01-16 17:05:21 +00:00
|
|
|
{0, NULL}
|
2020-01-10 20:55:03 +00:00
|
|
|
};
|
|
|
|
consvar_t cv_1upsound = {"1upsound", "Jingle", CV_SAVE, cons_1upsound_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
|
2018-11-25 19:22:52 +00:00
|
|
|
// Sound system toggles, saved into the config
|
2018-11-26 05:24:11 +00:00
|
|
|
consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
2018-11-25 19:22:52 +00:00
|
|
|
|
2019-10-24 00:21:09 +00:00
|
|
|
// Window focus sound sytem toggles
|
2019-10-26 04:36:10 +00:00
|
|
|
consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
|
|
consvar_t cv_playsoundsifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
2019-10-24 00:21:09 +00:00
|
|
|
|
2018-09-18 16:33:22 +00:00
|
|
|
#ifdef HAVE_OPENMPT
|
|
|
|
static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}};
|
2019-01-06 04:42:25 +00:00
|
|
|
consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
2018-09-18 16:33:22 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
#define S_MAX_VOLUME 127
|
|
|
|
|
|
|
|
// when to clip out sounds
|
|
|
|
// Does not fit the large outdoor areas.
|
|
|
|
// added 2-2-98 in 8 bit volume control (before (1200*0x10000))
|
|
|
|
#define S_CLIPPING_DIST (1536*0x10000)
|
|
|
|
|
|
|
|
// Distance to origin when sounds should be maxed out.
|
|
|
|
// This should relate to movement clipping resolution
|
|
|
|
// (see BLOCKMAP handling).
|
|
|
|
// Originally: (200*0x10000).
|
|
|
|
// added 2-2-98 in 8 bit volume control (before (160*0x10000))
|
|
|
|
#define S_CLOSE_DIST (160*0x10000)
|
|
|
|
|
|
|
|
// added 2-2-98 in 8 bit volume control (before remove the +4)
|
|
|
|
#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>(FRACBITS+4))
|
|
|
|
|
|
|
|
// Adjustable by menu.
|
|
|
|
#define NORM_VOLUME snd_MaxVolume
|
|
|
|
|
|
|
|
#define NORM_PITCH 128
|
|
|
|
#define NORM_PRIORITY 64
|
|
|
|
#define NORM_SEP 128
|
|
|
|
|
|
|
|
#define S_PITCH_PERTURB 1
|
|
|
|
#define S_STEREO_SWING (96*0x10000)
|
|
|
|
|
|
|
|
#ifdef SURROUND
|
|
|
|
#define SURROUND_SEP -128
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// percent attenuation from front to back
|
|
|
|
#define S_IFRACVOL 30
|
|
|
|
|
|
|
|
// the set of channels available
|
|
|
|
static channel_t *channels = NULL;
|
|
|
|
static INT32 numofchannels = 0;
|
|
|
|
|
2017-04-17 17:15:42 +00:00
|
|
|
caption_t closedcaptions[NUMCAPTIONS];
|
2017-04-17 00:09:47 +00:00
|
|
|
|
2017-04-29 15:40:07 +00:00
|
|
|
void S_ResetCaptions(void)
|
2017-04-17 00:09:47 +00:00
|
|
|
{
|
|
|
|
UINT8 i;
|
2017-04-17 17:15:42 +00:00
|
|
|
for (i = 0; i < NUMCAPTIONS; i++)
|
2017-04-17 00:09:47 +00:00
|
|
|
{
|
|
|
|
closedcaptions[i].c = NULL;
|
|
|
|
closedcaptions[i].s = NULL;
|
|
|
|
closedcaptions[i].t = 0;
|
2017-04-29 15:27:52 +00:00
|
|
|
closedcaptions[i].b = 0;
|
2017-04-17 00:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// Internals.
|
|
|
|
//
|
|
|
|
static void S_StopChannel(INT32 cnum);
|
|
|
|
|
|
|
|
//
|
|
|
|
// S_getChannel
|
|
|
|
//
|
|
|
|
// If none available, return -1. Otherwise channel #.
|
|
|
|
//
|
|
|
|
static INT32 S_getChannel(const void *origin, sfxinfo_t *sfxinfo)
|
|
|
|
{
|
|
|
|
// channel number to use
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
channel_t *c;
|
|
|
|
|
|
|
|
// Find an open channel
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
if (!channels[cnum].sfxinfo)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Now checks if same sound is being played, rather
|
|
|
|
// than just one sound per mobj
|
|
|
|
else if (sfxinfo == channels[cnum].sfxinfo && (sfxinfo->pitch & SF_NOMULTIPLESOUND))
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (sfxinfo == channels[cnum].sfxinfo && sfxinfo->singularity == true)
|
|
|
|
{
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (origin && channels[cnum].origin == origin && channels[cnum].sfxinfo == sfxinfo)
|
|
|
|
{
|
|
|
|
if (sfxinfo->pitch & SF_NOINTERRUPT)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
2014-11-12 00:55:07 +00:00
|
|
|
else if (origin && channels[cnum].origin == origin
|
|
|
|
&& channels[cnum].sfxinfo->name != sfxinfo->name
|
|
|
|
&& channels[cnum].sfxinfo->pitch == SF_TOTALLYSINGLE && sfxinfo->pitch == SF_TOTALLYSINGLE)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// None available
|
|
|
|
if (cnum == numofchannels)
|
|
|
|
{
|
|
|
|
// Look for lower priority
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
if (channels[cnum].sfxinfo->priority <= sfxinfo->priority)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (cnum == numofchannels)
|
|
|
|
{
|
|
|
|
// No lower priority. Sorry, Charlie.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Otherwise, kick out lower priority.
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c = &channels[cnum];
|
|
|
|
|
|
|
|
// channel is decided to be cnum.
|
|
|
|
c->sfxinfo = sfxinfo;
|
|
|
|
c->origin = origin;
|
|
|
|
|
|
|
|
return cnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
void S_RegisterSoundStuff(void)
|
|
|
|
{
|
|
|
|
if (dedicated)
|
|
|
|
{
|
2018-08-23 16:42:15 +00:00
|
|
|
sound_disabled = true;
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CV_RegisterVar(&stereoreverse);
|
|
|
|
CV_RegisterVar(&precachesound);
|
|
|
|
|
|
|
|
#ifdef SNDSERV
|
|
|
|
CV_RegisterVar(&sndserver_cmd);
|
|
|
|
CV_RegisterVar(&sndserver_arg);
|
|
|
|
#endif
|
|
|
|
#ifdef MUSSERV
|
|
|
|
CV_RegisterVar(&musserver_cmd);
|
|
|
|
CV_RegisterVar(&musserver_arg);
|
|
|
|
#endif
|
|
|
|
CV_RegisterVar(&surround);
|
|
|
|
CV_RegisterVar(&cv_samplerate);
|
2018-10-11 20:29:43 +00:00
|
|
|
CV_RegisterVar(&cv_resetmusic);
|
2019-08-05 00:02:38 +00:00
|
|
|
CV_RegisterVar(&cv_resetmusicbyheader);
|
2020-01-10 20:55:03 +00:00
|
|
|
CV_RegisterVar(&cv_1upsound);
|
2019-10-24 00:21:09 +00:00
|
|
|
CV_RegisterVar(&cv_playsoundsifunfocused);
|
|
|
|
CV_RegisterVar(&cv_playmusicifunfocused);
|
2018-11-25 19:22:52 +00:00
|
|
|
CV_RegisterVar(&cv_gamesounds);
|
|
|
|
CV_RegisterVar(&cv_gamedigimusic);
|
|
|
|
CV_RegisterVar(&cv_gamemidimusic);
|
2019-01-02 07:14:31 +00:00
|
|
|
#ifdef HAVE_OPENMPT
|
|
|
|
CV_RegisterVar(&cv_modfilter);
|
|
|
|
#endif
|
2019-08-04 11:03:57 +00:00
|
|
|
#ifdef HAVE_MIXERX
|
|
|
|
CV_RegisterVar(&cv_midiplayer);
|
|
|
|
CV_RegisterVar(&cv_midisoundfontpath);
|
|
|
|
CV_RegisterVar(&cv_miditimiditypath);
|
|
|
|
#endif
|
2018-11-13 19:34:28 +00:00
|
|
|
|
2018-10-11 20:29:43 +00:00
|
|
|
COM_AddCommand("tunes", Command_Tunes_f);
|
|
|
|
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2014-07-25 23:10:24 +00:00
|
|
|
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
INT32 i;
|
|
|
|
for (i = 0; i < PLAYLIST_LENGTH; i++)
|
|
|
|
{
|
|
|
|
user_songs[i].name = malloc(7);
|
|
|
|
if (!user_songs[i].name)
|
|
|
|
I_Error("No more free memory for mp3 playlist");
|
|
|
|
sprintf(user_songs[i].name, "song%d%d",i/10,i%10);
|
|
|
|
user_songs[i].defaultvalue = malloc(sizeof (char));
|
|
|
|
if (user_songs[i].defaultvalue)
|
|
|
|
I_Error("No more free memory for blank mp3 playerlist");
|
|
|
|
*user_songs[i].defaultvalue = 0;
|
|
|
|
user_songs[i].flags = CV_SAVE;
|
|
|
|
user_songs[i].PossibleValue = NULL;
|
|
|
|
CV_RegisterVar(&user_songs[i]);
|
|
|
|
}
|
|
|
|
CV_RegisterVar(&play_mode);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetChannelsNum(void)
|
|
|
|
{
|
|
|
|
INT32 i;
|
|
|
|
|
|
|
|
// Allocating the internal channels for mixing
|
|
|
|
// (the maximum number of sounds rendered
|
|
|
|
// simultaneously) within zone memory.
|
|
|
|
if (channels)
|
|
|
|
S_StopSounds();
|
|
|
|
|
|
|
|
Z_Free(channels);
|
|
|
|
channels = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (cv_numChannels.value == 999999999) //Alam_GBC: OH MY ROD!(ROD rimmiced with GOD!)
|
|
|
|
CV_StealthSet(&cv_numChannels,cv_numChannels.defaultvalue);
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_SetSourcesNum();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (cv_numChannels.value)
|
|
|
|
channels = (channel_t *)Z_Malloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL);
|
|
|
|
numofchannels = cv_numChannels.value;
|
|
|
|
|
|
|
|
// Free all channels for use
|
|
|
|
for (i = 0; i < numofchannels; i++)
|
|
|
|
channels[i].sfxinfo = 0;
|
2017-04-17 00:09:47 +00:00
|
|
|
|
2017-04-29 15:40:07 +00:00
|
|
|
S_ResetCaptions();
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the lump number of sfx
|
|
|
|
//
|
|
|
|
lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx)
|
|
|
|
{
|
|
|
|
char namebuf[9];
|
|
|
|
lumpnum_t sfxlump;
|
|
|
|
|
|
|
|
sprintf(namebuf, "ds%s", sfx->name);
|
|
|
|
|
|
|
|
sfxlump = W_CheckNumForName(namebuf);
|
|
|
|
if (sfxlump != LUMPERROR)
|
|
|
|
return sfxlump;
|
|
|
|
|
|
|
|
strlcpy(namebuf, sfx->name, sizeof namebuf);
|
|
|
|
|
|
|
|
sfxlump = W_CheckNumForName(namebuf);
|
|
|
|
if (sfxlump != LUMPERROR)
|
|
|
|
return sfxlump;
|
|
|
|
|
|
|
|
return W_GetNumForName("dsthok");
|
|
|
|
}
|
|
|
|
|
2019-10-24 00:21:09 +00:00
|
|
|
//
|
|
|
|
// Sound Status
|
|
|
|
//
|
|
|
|
|
|
|
|
boolean S_SoundDisabled(void)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
sound_disabled ||
|
|
|
|
( window_notinfocus && ! cv_playsoundsifunfocused.value )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// Stop all sounds, load level info, THEN start sounds.
|
|
|
|
void S_StopSounds(void)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_StopSounds();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// kill all playing sounds at start of level
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
if (channels[cnum].sfxinfo)
|
|
|
|
S_StopChannel(cnum);
|
2017-04-29 15:40:07 +00:00
|
|
|
|
|
|
|
S_ResetCaptions();
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void S_StopSoundByID(void *origin, sfxenum_t sfx_id)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
// Sounds without origin can have multiple sources, they shouldn't
|
|
|
|
// be stopped by new sounds.
|
|
|
|
if (!origin)
|
|
|
|
return;
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_StopSoundByID(origin, sfx_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
if (channels[cnum].sfxinfo == &S_sfx[sfx_id] && channels[cnum].origin == origin)
|
|
|
|
{
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void S_StopSoundByNum(sfxenum_t sfxnum)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_StopSoundByNum(sfxnum);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
if (channels[cnum].sfxinfo == &S_sfx[sfxnum])
|
|
|
|
{
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-29 15:27:52 +00:00
|
|
|
void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan)
|
|
|
|
{
|
|
|
|
UINT8 i, set, moveup, start;
|
2017-05-09 13:42:23 +00:00
|
|
|
boolean same = false;
|
2017-04-29 15:27:52 +00:00
|
|
|
sfxinfo_t *sfx;
|
|
|
|
|
|
|
|
if (!cv_closedcaptioning.value) // no captions at all
|
|
|
|
return;
|
|
|
|
|
|
|
|
// check for bogus sound #
|
2017-05-09 13:17:34 +00:00
|
|
|
// I_Assert(sfx_id >= 0); -- allowing sfx_None; this shouldn't be allowed directly if S_StartCaption is ever exposed to Lua by itself
|
2017-04-29 15:27:52 +00:00
|
|
|
I_Assert(sfx_id < NUMSFX);
|
|
|
|
|
|
|
|
sfx = &S_sfx[sfx_id];
|
|
|
|
|
|
|
|
if (sfx->caption[0] == '/') // no caption for this one
|
|
|
|
return;
|
|
|
|
|
|
|
|
start = ((closedcaptions[0].s && (closedcaptions[0].s-S_sfx == sfx_None)) ? 1 : 0);
|
|
|
|
|
|
|
|
if (sfx_id)
|
|
|
|
{
|
|
|
|
for (i = start; i < (set = NUMCAPTIONS-1); i++)
|
|
|
|
{
|
|
|
|
same = ((sfx == closedcaptions[i].s) || (closedcaptions[i].s && fastcmp(sfx->caption, closedcaptions[i].s->caption)));
|
|
|
|
if (same)
|
|
|
|
{
|
|
|
|
set = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set = 0;
|
|
|
|
same = (closedcaptions[0].s == sfx);
|
|
|
|
}
|
|
|
|
|
|
|
|
moveup = 255;
|
|
|
|
|
|
|
|
if (!same)
|
|
|
|
{
|
|
|
|
for (i = start; i < set; i++)
|
|
|
|
{
|
|
|
|
if (!(closedcaptions[i].c || closedcaptions[i].s) || (sfx->priority >= closedcaptions[i].s->priority))
|
|
|
|
{
|
|
|
|
set = i;
|
|
|
|
if (closedcaptions[i].s && (sfx->priority >= closedcaptions[i].s->priority))
|
|
|
|
moveup = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = NUMCAPTIONS-1; i > set; i--)
|
|
|
|
{
|
|
|
|
if (sfx == closedcaptions[i].s)
|
|
|
|
{
|
|
|
|
closedcaptions[i].c = NULL;
|
|
|
|
closedcaptions[i].s = NULL;
|
|
|
|
closedcaptions[i].t = 0;
|
|
|
|
closedcaptions[i].b = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moveup != 255)
|
|
|
|
{
|
|
|
|
for (i = moveup; i < NUMCAPTIONS-1; i++)
|
|
|
|
{
|
|
|
|
if (!(closedcaptions[i].c || closedcaptions[i].s))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (; i > set; i--)
|
|
|
|
{
|
|
|
|
closedcaptions[i].c = closedcaptions[i-1].c;
|
|
|
|
closedcaptions[i].s = closedcaptions[i-1].s;
|
|
|
|
closedcaptions[i].t = closedcaptions[i-1].t;
|
|
|
|
closedcaptions[i].b = closedcaptions[i-1].b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
closedcaptions[set].c = ((cnum == -1) ? NULL : &channels[cnum]);
|
|
|
|
closedcaptions[set].s = sfx;
|
|
|
|
closedcaptions[set].t = lifespan;
|
|
|
|
closedcaptions[set].b = 2; // bob
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
|
|
|
{
|
|
|
|
INT32 sep, pitch, priority, cnum;
|
2019-07-29 13:55:36 +00:00
|
|
|
const sfxenum_t actual_id = sfx_id;
|
2014-03-15 16:59:03 +00:00
|
|
|
sfxinfo_t *sfx;
|
|
|
|
|
|
|
|
const mobj_t *origin = (const mobj_t *)origin_p;
|
|
|
|
|
|
|
|
listener_t listener = {0,0,0,0};
|
|
|
|
listener_t listener2 = {0,0,0,0};
|
|
|
|
|
|
|
|
mobj_t *listenmobj = players[displayplayer].mo;
|
|
|
|
mobj_t *listenmobj2 = NULL;
|
|
|
|
|
2019-10-24 00:21:09 +00:00
|
|
|
if (S_SoundDisabled() || !sound_started)
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Don't want a sound? Okay then...
|
|
|
|
if (sfx_id == sfx_None)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (players[displayplayer].awayviewtics)
|
|
|
|
listenmobj = players[displayplayer].awayviewmobj;
|
|
|
|
|
|
|
|
if (splitscreen)
|
|
|
|
{
|
|
|
|
listenmobj2 = players[secondarydisplayplayer].mo;
|
|
|
|
if (players[secondarydisplayplayer].awayviewtics)
|
|
|
|
listenmobj2 = players[secondarydisplayplayer].awayviewmobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_StartSound(origin, sfx_id);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (camera.chase && !players[displayplayer].awayviewtics)
|
|
|
|
{
|
|
|
|
listener.x = camera.x;
|
|
|
|
listener.y = camera.y;
|
|
|
|
listener.z = camera.z;
|
|
|
|
listener.angle = camera.angle;
|
|
|
|
}
|
|
|
|
else if (listenmobj)
|
|
|
|
{
|
|
|
|
listener.x = listenmobj->x;
|
|
|
|
listener.y = listenmobj->y;
|
|
|
|
listener.z = listenmobj->z;
|
|
|
|
listener.angle = listenmobj->angle;
|
|
|
|
}
|
|
|
|
else if (origin)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (listenmobj2)
|
|
|
|
{
|
|
|
|
if (camera2.chase && !players[secondarydisplayplayer].awayviewtics)
|
|
|
|
{
|
|
|
|
listener2.x = camera2.x;
|
|
|
|
listener2.y = camera2.y;
|
|
|
|
listener2.z = camera2.z;
|
|
|
|
listener2.angle = camera2.angle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listener2.x = listenmobj2->x;
|
|
|
|
listener2.y = listenmobj2->y;
|
|
|
|
listener2.z = listenmobj2->z;
|
|
|
|
listener2.angle = listenmobj2->angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for bogus sound #
|
|
|
|
I_Assert(sfx_id >= 1);
|
|
|
|
I_Assert(sfx_id < NUMSFX);
|
|
|
|
|
|
|
|
sfx = &S_sfx[sfx_id];
|
|
|
|
|
|
|
|
if (sfx->skinsound != -1 && origin && origin->skin)
|
|
|
|
{
|
|
|
|
// redirect player sound to the sound in the skin table
|
|
|
|
sfx_id = ((skin_t *)origin->skin)->soundsid[sfx->skinsound];
|
|
|
|
sfx = &S_sfx[sfx_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize sound parameters
|
|
|
|
pitch = NORM_PITCH;
|
|
|
|
priority = NORM_PRIORITY;
|
|
|
|
|
|
|
|
if (splitscreen && listenmobj2) // Copy the sound for the split player
|
|
|
|
{
|
|
|
|
// Check to see if it is audible, and if not, modify the params
|
|
|
|
if (origin && origin != listenmobj2)
|
|
|
|
{
|
|
|
|
INT32 rc;
|
|
|
|
rc = S_AdjustSoundParams(listenmobj2, origin, &volume, &sep, &pitch, sfx);
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
goto dontplay; // Maybe the other player can hear it...
|
|
|
|
|
|
|
|
if (origin->x == listener2.x && origin->y == listener2.y)
|
|
|
|
sep = NORM_SEP;
|
|
|
|
}
|
|
|
|
else if (!origin)
|
|
|
|
// Do not play origin-less sounds for the second player.
|
|
|
|
// The first player will be able to hear it just fine,
|
|
|
|
// we really don't want it playing twice.
|
|
|
|
goto dontplay;
|
|
|
|
else
|
|
|
|
sep = NORM_SEP;
|
|
|
|
|
|
|
|
// try to find a channel
|
|
|
|
cnum = S_getChannel(origin, sfx);
|
|
|
|
|
|
|
|
if (cnum < 0)
|
|
|
|
return; // If there's no free channels, it's not gonna be free for player 1, either.
|
|
|
|
|
|
|
|
// This is supposed to handle the loading/caching.
|
|
|
|
// For some odd reason, the caching is done nearly
|
|
|
|
// each time the sound is needed?
|
|
|
|
|
|
|
|
// cache data if necessary
|
|
|
|
// NOTE: set sfx->data NULL sfx->lump -1 to force a reload
|
|
|
|
if (!sfx->data)
|
|
|
|
sfx->data = I_GetSfx(sfx);
|
|
|
|
|
|
|
|
// increase the usefulness
|
|
|
|
if (sfx->usefulness++ < 0)
|
|
|
|
sfx->usefulness = -1;
|
|
|
|
|
|
|
|
#ifdef SURROUND
|
|
|
|
// Avoid channel reverse if surround
|
|
|
|
if (stereoreverse.value && sep != SURROUND_SEP)
|
|
|
|
sep = (~sep) & 255;
|
|
|
|
#else
|
|
|
|
if (stereoreverse.value)
|
|
|
|
sep = (~sep) & 255;
|
|
|
|
#endif
|
|
|
|
|
2017-04-17 21:21:16 +00:00
|
|
|
// Handle closed caption input.
|
2019-07-29 13:55:36 +00:00
|
|
|
S_StartCaption(actual_id, cnum, MAXCAPTIONTICS);
|
2017-04-17 21:21:16 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// Assigns the handle to one of the channels in the
|
|
|
|
// mix/output buffer.
|
2018-10-13 22:01:11 +00:00
|
|
|
channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dontplay:
|
|
|
|
|
|
|
|
// Check to see if it is audible, and if not, modify the params
|
|
|
|
if (origin && origin != listenmobj)
|
|
|
|
{
|
|
|
|
INT32 rc;
|
|
|
|
rc = S_AdjustSoundParams(listenmobj, origin, &volume, &sep, &pitch, sfx);
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (origin->x == listener.x && origin->y == listener.y)
|
|
|
|
sep = NORM_SEP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sep = NORM_SEP;
|
|
|
|
|
|
|
|
// try to find a channel
|
|
|
|
cnum = S_getChannel(origin, sfx);
|
|
|
|
|
|
|
|
if (cnum < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// This is supposed to handle the loading/caching.
|
|
|
|
// For some odd reason, the caching is done nearly
|
|
|
|
// each time the sound is needed?
|
|
|
|
|
|
|
|
// cache data if necessary
|
|
|
|
// NOTE: set sfx->data NULL sfx->lump -1 to force a reload
|
|
|
|
if (!sfx->data)
|
|
|
|
sfx->data = I_GetSfx(sfx);
|
|
|
|
|
|
|
|
// increase the usefulness
|
|
|
|
if (sfx->usefulness++ < 0)
|
|
|
|
sfx->usefulness = -1;
|
|
|
|
|
|
|
|
#ifdef SURROUND
|
|
|
|
// Avoid channel reverse if surround
|
|
|
|
if (stereoreverse.value && sep != SURROUND_SEP)
|
|
|
|
sep = (~sep) & 255;
|
|
|
|
#else
|
|
|
|
if (stereoreverse.value)
|
|
|
|
sep = (~sep) & 255;
|
|
|
|
#endif
|
|
|
|
|
2017-04-17 00:09:47 +00:00
|
|
|
// Handle closed caption input.
|
2019-07-29 13:55:36 +00:00
|
|
|
S_StartCaption(actual_id, cnum, MAXCAPTIONTICS);
|
2017-04-17 00:09:47 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// Assigns the handle to one of the channels in the
|
|
|
|
// mix/output buffer.
|
2018-10-13 22:01:11 +00:00
|
|
|
channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum);
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void S_StartSound(const void *origin, sfxenum_t sfx_id)
|
|
|
|
{
|
2019-10-24 00:21:09 +00:00
|
|
|
if (S_SoundDisabled())
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mariomode) // Sounds change in Mario mode!
|
|
|
|
{
|
|
|
|
switch (sfx_id)
|
|
|
|
{
|
|
|
|
// case sfx_altow1:
|
|
|
|
// case sfx_altow2:
|
|
|
|
// case sfx_altow3:
|
|
|
|
// case sfx_altow4:
|
|
|
|
// sfx_id = sfx_mario8;
|
|
|
|
// break;
|
|
|
|
case sfx_thok:
|
2017-04-17 00:09:47 +00:00
|
|
|
case sfx_wepfir:
|
2014-03-15 16:59:03 +00:00
|
|
|
sfx_id = sfx_mario7;
|
|
|
|
break;
|
|
|
|
case sfx_pop:
|
|
|
|
sfx_id = sfx_mario5;
|
|
|
|
break;
|
|
|
|
case sfx_jump:
|
|
|
|
sfx_id = sfx_mario6;
|
|
|
|
break;
|
|
|
|
case sfx_shield:
|
2016-10-23 21:21:42 +00:00
|
|
|
case sfx_wirlsg:
|
|
|
|
case sfx_forcsg:
|
|
|
|
case sfx_elemsg:
|
|
|
|
case sfx_armasg:
|
2016-12-26 13:02:26 +00:00
|
|
|
case sfx_attrsg:
|
2016-10-23 21:21:42 +00:00
|
|
|
case sfx_s3k3e:
|
|
|
|
case sfx_s3k3f:
|
|
|
|
case sfx_s3k41:
|
2014-03-15 16:59:03 +00:00
|
|
|
sfx_id = sfx_mario3;
|
|
|
|
break;
|
|
|
|
case sfx_itemup:
|
|
|
|
sfx_id = sfx_mario4;
|
|
|
|
break;
|
|
|
|
// case sfx_tink:
|
|
|
|
// sfx_id = sfx_mario1;
|
|
|
|
// break;
|
|
|
|
// case sfx_cgot:
|
|
|
|
// sfx_id = sfx_mario9;
|
|
|
|
// break;
|
|
|
|
// case sfx_lose:
|
|
|
|
// sfx_id = sfx_mario2;
|
|
|
|
// break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (maptol & TOL_XMAS) // Some sounds change for xmas
|
|
|
|
{
|
|
|
|
switch (sfx_id)
|
|
|
|
{
|
|
|
|
case sfx_ideya:
|
|
|
|
case sfx_nbmper:
|
|
|
|
case sfx_ncitem:
|
|
|
|
case sfx_ngdone:
|
|
|
|
++sfx_id;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the volume is handled 8 bits
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
HW3S_StartSound(origin, sfx_id);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
S_StartSoundAtVolume(origin, sfx_id, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
void S_StopSound(void *origin)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
// Sounds without origin can have multiple sources, they shouldn't
|
|
|
|
// be stopped by new sounds.
|
|
|
|
if (!origin)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_StopSound(origin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
if (channels[cnum].sfxinfo && channels[cnum].origin == origin)
|
|
|
|
{
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Updates music & sounds
|
|
|
|
//
|
|
|
|
static INT32 actualsfxvolume; // check for change through console
|
|
|
|
static INT32 actualdigmusicvolume;
|
|
|
|
static INT32 actualmidimusicvolume;
|
|
|
|
|
|
|
|
void S_UpdateSounds(void)
|
|
|
|
{
|
|
|
|
INT32 audible, cnum, volume, sep, pitch;
|
|
|
|
channel_t *c;
|
|
|
|
|
|
|
|
listener_t listener;
|
|
|
|
listener_t listener2;
|
|
|
|
|
|
|
|
mobj_t *listenmobj = players[displayplayer].mo;
|
|
|
|
mobj_t *listenmobj2 = NULL;
|
|
|
|
|
|
|
|
memset(&listener, 0, sizeof(listener_t));
|
|
|
|
memset(&listener2, 0, sizeof(listener_t));
|
|
|
|
|
|
|
|
// Update sound/music volumes, if changed manually at console
|
|
|
|
if (actualsfxvolume != cv_soundvolume.value)
|
|
|
|
S_SetSfxVolume (cv_soundvolume.value);
|
|
|
|
if (actualdigmusicvolume != cv_digmusicvolume.value)
|
|
|
|
S_SetDigMusicVolume (cv_digmusicvolume.value);
|
|
|
|
if (actualmidimusicvolume != cv_midimusicvolume.value)
|
|
|
|
S_SetMIDIMusicVolume (cv_midimusicvolume.value);
|
|
|
|
|
|
|
|
// We're done now, if we're not in a level.
|
|
|
|
if (gamestate != GS_LEVEL)
|
|
|
|
{
|
|
|
|
#ifndef NOMUMBLE
|
|
|
|
// Stop Mumble cutting out. I'm sick of it.
|
|
|
|
I_UpdateMumble(NULL, listener);
|
|
|
|
#endif
|
|
|
|
|
2017-04-28 21:46:21 +00:00
|
|
|
goto notinlevel;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:42:15 +00:00
|
|
|
if (dedicated || sound_disabled)
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (players[displayplayer].awayviewtics)
|
|
|
|
listenmobj = players[displayplayer].awayviewmobj;
|
|
|
|
|
|
|
|
if (splitscreen)
|
|
|
|
{
|
|
|
|
listenmobj2 = players[secondarydisplayplayer].mo;
|
|
|
|
if (players[secondarydisplayplayer].awayviewtics)
|
|
|
|
listenmobj2 = players[secondarydisplayplayer].awayviewmobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (camera.chase && !players[displayplayer].awayviewtics)
|
|
|
|
{
|
|
|
|
listener.x = camera.x;
|
|
|
|
listener.y = camera.y;
|
|
|
|
listener.z = camera.z;
|
|
|
|
listener.angle = camera.angle;
|
|
|
|
}
|
|
|
|
else if (listenmobj)
|
|
|
|
{
|
|
|
|
listener.x = listenmobj->x;
|
|
|
|
listener.y = listenmobj->y;
|
|
|
|
listener.z = listenmobj->z;
|
|
|
|
listener.angle = listenmobj->angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef NOMUMBLE
|
|
|
|
I_UpdateMumble(players[consoleplayer].mo, listener);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
{
|
|
|
|
HW3S_UpdateSources();
|
2017-04-28 21:46:21 +00:00
|
|
|
goto notinlevel;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (listenmobj2)
|
|
|
|
{
|
|
|
|
if (camera2.chase && !players[secondarydisplayplayer].awayviewtics)
|
|
|
|
{
|
|
|
|
listener2.x = camera2.x;
|
|
|
|
listener2.y = camera2.y;
|
|
|
|
listener2.z = camera2.z;
|
|
|
|
listener2.angle = camera2.angle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listener2.x = listenmobj2->x;
|
|
|
|
listener2.y = listenmobj2->y;
|
|
|
|
listener2.z = listenmobj2->z;
|
|
|
|
listener2.angle = listenmobj2->angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
c = &channels[cnum];
|
|
|
|
|
|
|
|
if (c->sfxinfo)
|
|
|
|
{
|
|
|
|
if (I_SoundIsPlaying(c->handle))
|
|
|
|
{
|
|
|
|
// initialize parameters
|
|
|
|
volume = 255; // 8 bits internal volume precision
|
|
|
|
pitch = NORM_PITCH;
|
|
|
|
sep = NORM_SEP;
|
|
|
|
|
|
|
|
// check non-local sounds for distance clipping
|
|
|
|
// or modify their params
|
|
|
|
if (c->origin && ((c->origin != players[consoleplayer].mo) ||
|
|
|
|
(splitscreen && c->origin != players[secondarydisplayplayer].mo)))
|
|
|
|
{
|
|
|
|
// Whomever is closer gets the sound, but only in splitscreen.
|
|
|
|
if (listenmobj && listenmobj2 && splitscreen)
|
|
|
|
{
|
|
|
|
const mobj_t *soundmobj = c->origin;
|
|
|
|
|
|
|
|
fixed_t dist1, dist2;
|
|
|
|
dist1 = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y);
|
|
|
|
dist2 = P_AproxDistance(listener2.x-soundmobj->x, listener2.y-soundmobj->y);
|
|
|
|
|
|
|
|
if (dist1 <= dist2)
|
|
|
|
{
|
|
|
|
// Player 1 gets the sound
|
|
|
|
audible = S_AdjustSoundParams(listenmobj, c->origin, &volume, &sep, &pitch,
|
|
|
|
c->sfxinfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Player 2 gets the sound
|
|
|
|
audible = S_AdjustSoundParams(listenmobj2, c->origin, &volume, &sep, &pitch,
|
|
|
|
c->sfxinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audible)
|
|
|
|
I_UpdateSoundParams(c->handle, volume, sep, pitch);
|
|
|
|
else
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
}
|
|
|
|
else if (listenmobj && !splitscreen)
|
|
|
|
{
|
|
|
|
// In the case of a single player, he or she always should get updated sound.
|
|
|
|
audible = S_AdjustSoundParams(listenmobj, c->origin, &volume, &sep, &pitch,
|
|
|
|
c->sfxinfo);
|
|
|
|
|
|
|
|
if (audible)
|
|
|
|
I_UpdateSoundParams(c->handle, volume, sep, pitch);
|
|
|
|
else
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if channel is allocated but sound has stopped, free it
|
|
|
|
S_StopChannel(cnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-28 21:46:21 +00:00
|
|
|
notinlevel:
|
2014-03-15 16:59:03 +00:00
|
|
|
I_UpdateSound();
|
2019-11-25 23:16:17 +00:00
|
|
|
}
|
2017-04-28 21:46:21 +00:00
|
|
|
|
2019-11-25 23:16:17 +00:00
|
|
|
void S_UpdateClosedCaptions(void)
|
|
|
|
{
|
|
|
|
UINT8 i;
|
|
|
|
boolean gamestopped = (paused || P_AutoPause());
|
|
|
|
for (i = 0; i < NUMCAPTIONS; i++) // update captions
|
2017-04-28 21:46:21 +00:00
|
|
|
{
|
2019-11-25 23:16:17 +00:00
|
|
|
if (!closedcaptions[i].s)
|
|
|
|
continue;
|
2017-09-25 19:35:04 +00:00
|
|
|
|
2019-11-25 23:16:17 +00:00
|
|
|
if (i == 0 && (closedcaptions[0].s-S_sfx == sfx_None) && gamestopped)
|
|
|
|
continue;
|
2017-09-25 19:35:04 +00:00
|
|
|
|
2019-11-25 23:16:17 +00:00
|
|
|
if (!(--closedcaptions[i].t))
|
|
|
|
{
|
|
|
|
closedcaptions[i].c = NULL;
|
|
|
|
closedcaptions[i].s = NULL;
|
|
|
|
}
|
|
|
|
else if (closedcaptions[i].c && !I_SoundIsPlaying(closedcaptions[i].c->handle))
|
|
|
|
{
|
|
|
|
closedcaptions[i].c = NULL;
|
|
|
|
if (closedcaptions[i].t > CAPTIONFADETICS)
|
|
|
|
closedcaptions[i].t = CAPTIONFADETICS;
|
2017-04-28 21:46:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void S_SetSfxVolume(INT32 volume)
|
|
|
|
{
|
|
|
|
if (volume < 0 || volume > 31)
|
|
|
|
CONS_Alert(CONS_WARNING, "sfxvolume should be between 0-31\n");
|
|
|
|
|
|
|
|
CV_SetValue(&cv_soundvolume, volume&0x1F);
|
|
|
|
actualsfxvolume = cv_soundvolume.value; // check for change of var
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F);
|
|
|
|
#else
|
|
|
|
// now hardware volume
|
|
|
|
I_SetSfxVolume(volume&0x1F);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void S_ClearSfx(void)
|
|
|
|
{
|
|
|
|
#ifndef DJGPPDOS
|
|
|
|
size_t i;
|
|
|
|
for (i = 1; i < NUMSFX; i++)
|
|
|
|
I_FreeSfx(S_sfx + i);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_StopChannel(INT32 cnum)
|
|
|
|
{
|
|
|
|
INT32 i;
|
|
|
|
channel_t *c = &channels[cnum];
|
|
|
|
|
|
|
|
if (c->sfxinfo)
|
|
|
|
{
|
|
|
|
// stop the sound playing
|
|
|
|
if (I_SoundIsPlaying(c->handle))
|
|
|
|
I_StopSound(c->handle);
|
|
|
|
|
|
|
|
// check to see
|
|
|
|
// if other channels are playing the sound
|
|
|
|
for (i = 0; i < numofchannels; i++)
|
|
|
|
if (cnum != i && c->sfxinfo == channels[i].sfxinfo)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// degrade usefulness of sound data
|
|
|
|
c->sfxinfo->usefulness--;
|
|
|
|
|
|
|
|
c->sfxinfo = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// S_CalculateSoundDistance
|
|
|
|
//
|
|
|
|
// Calculates the distance between two points for a sound.
|
|
|
|
// Clips the distance to prevent overflow.
|
|
|
|
//
|
|
|
|
fixed_t S_CalculateSoundDistance(fixed_t sx1, fixed_t sy1, fixed_t sz1, fixed_t sx2, fixed_t sy2, fixed_t sz2)
|
|
|
|
{
|
|
|
|
fixed_t approx_dist, adx, ady;
|
|
|
|
|
|
|
|
// calculate the distance to sound origin and clip it if necessary
|
|
|
|
adx = abs((sx1>>FRACBITS) - (sx2>>FRACBITS));
|
|
|
|
ady = abs((sy1>>FRACBITS) - (sy2>>FRACBITS));
|
|
|
|
|
|
|
|
// From _GG1_ p.428. Approx. euclidian distance fast.
|
|
|
|
// Take Z into account
|
|
|
|
adx = adx + ady - ((adx < ady ? adx : ady)>>1);
|
|
|
|
ady = abs((sz1>>FRACBITS) - (sz2>>FRACBITS));
|
|
|
|
approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1);
|
|
|
|
|
|
|
|
if (approx_dist >= FRACUNIT/2)
|
|
|
|
approx_dist = FRACUNIT/2-1;
|
|
|
|
|
|
|
|
approx_dist <<= FRACBITS;
|
|
|
|
|
|
|
|
return approx_dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Changes volume, stereo-separation, and pitch variables
|
|
|
|
// from the norm of a sound effect to be played.
|
|
|
|
// If the sound is not audible, returns a 0.
|
|
|
|
// Otherwise, modifies parameters and returns 1.
|
|
|
|
//
|
|
|
|
INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch,
|
|
|
|
sfxinfo_t *sfxinfo)
|
|
|
|
{
|
|
|
|
fixed_t approx_dist;
|
|
|
|
angle_t angle;
|
|
|
|
|
|
|
|
listener_t listensource;
|
|
|
|
|
|
|
|
(void)pitch;
|
|
|
|
if (!listener)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (listener == players[displayplayer].mo && camera.chase)
|
|
|
|
{
|
|
|
|
listensource.x = camera.x;
|
|
|
|
listensource.y = camera.y;
|
|
|
|
listensource.z = camera.z;
|
|
|
|
listensource.angle = camera.angle;
|
|
|
|
}
|
|
|
|
else if (splitscreen && listener == players[secondarydisplayplayer].mo && camera2.chase)
|
|
|
|
{
|
|
|
|
listensource.x = camera2.x;
|
|
|
|
listensource.y = camera2.y;
|
|
|
|
listensource.z = camera2.z;
|
|
|
|
listensource.angle = camera2.angle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listensource.x = listener->x;
|
|
|
|
listensource.y = listener->y;
|
|
|
|
listensource.z = listener->z;
|
|
|
|
listensource.angle = listener->angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sfxinfo->pitch & SF_OUTSIDESOUND) // Rain special case
|
|
|
|
{
|
|
|
|
fixed_t x, y, yl, yh, xl, xh, newdist;
|
|
|
|
|
|
|
|
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
|
|
|
|
approx_dist = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Essentially check in a 1024 unit radius of the player for an outdoor area.
|
|
|
|
yl = listensource.y - 1024*FRACUNIT;
|
|
|
|
yh = listensource.y + 1024*FRACUNIT;
|
|
|
|
xl = listensource.x - 1024*FRACUNIT;
|
|
|
|
xh = listensource.x + 1024*FRACUNIT;
|
|
|
|
approx_dist = 1024*FRACUNIT;
|
|
|
|
for (y = yl; y <= yh; y += FRACUNIT*64)
|
|
|
|
for (x = xl; x <= xh; x += FRACUNIT*64)
|
|
|
|
{
|
|
|
|
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)
|
|
|
|
{
|
|
|
|
// Found the outdoors!
|
|
|
|
newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);
|
|
|
|
if (newdist < approx_dist)
|
|
|
|
{
|
|
|
|
approx_dist = newdist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
approx_dist = S_CalculateSoundDistance(listensource.x, listensource.y, listensource.z,
|
|
|
|
source->x, source->y, source->z);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ring loss, deaths, etc, should all be heard louder.
|
|
|
|
if (sfxinfo->pitch & SF_X8AWAYSOUND)
|
|
|
|
approx_dist = FixedDiv(approx_dist,8*FRACUNIT);
|
|
|
|
|
|
|
|
// Combine 8XAWAYSOUND with 4XAWAYSOUND and get.... 32XAWAYSOUND?
|
|
|
|
if (sfxinfo->pitch & SF_X4AWAYSOUND)
|
|
|
|
approx_dist = FixedDiv(approx_dist,4*FRACUNIT);
|
|
|
|
|
|
|
|
if (sfxinfo->pitch & SF_X2AWAYSOUND)
|
|
|
|
approx_dist = FixedDiv(approx_dist,2*FRACUNIT);
|
|
|
|
|
|
|
|
if (approx_dist > S_CLIPPING_DIST)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// angle of source to listener
|
|
|
|
angle = R_PointToAngle2(listensource.x, listensource.y, source->x, source->y);
|
|
|
|
|
|
|
|
if (angle > listensource.angle)
|
|
|
|
angle = angle - listensource.angle;
|
|
|
|
else
|
|
|
|
angle = angle + InvAngle(listensource.angle);
|
|
|
|
|
|
|
|
#ifdef SURROUND
|
|
|
|
// Produce a surround sound for angle from 105 till 255
|
|
|
|
if (surround.value == 1 && (angle > ANG105 && angle < ANG255 ))
|
|
|
|
*sep = SURROUND_SEP;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
angle >>= ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
// stereo separation
|
|
|
|
*sep = 128 - (FixedMul(S_STEREO_SWING, FINESINE(angle))>>FRACBITS);
|
|
|
|
}
|
|
|
|
|
|
|
|
// volume calculation
|
|
|
|
if (approx_dist < S_CLOSE_DIST)
|
|
|
|
{
|
|
|
|
// SfxVolume is now hardware volume
|
|
|
|
*vol = 255; // not snd_SfxVolume
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// distance effect
|
|
|
|
*vol = (15 * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (*vol > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Searches through the channels and checks if a sound is playing
|
|
|
|
// on the given origin.
|
|
|
|
INT32 S_OriginPlaying(void *origin)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
if (!origin)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
return HW3S_OriginPlaying(origin);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
if (channels[cnum].origin == origin)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Searches through the channels and checks if a given id
|
|
|
|
// is playing anywhere.
|
|
|
|
INT32 S_IdPlaying(sfxenum_t id)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
return HW3S_IdPlaying(id);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Searches through the channels and checks for
|
|
|
|
// origin x playing sound id y.
|
|
|
|
INT32 S_SoundPlaying(void *origin, sfxenum_t id)
|
|
|
|
{
|
|
|
|
INT32 cnum;
|
|
|
|
if (!origin)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#ifdef HW3SOUND
|
|
|
|
if (hws_mode != HWS_DEFAULT_MODE)
|
|
|
|
return HW3S_SoundPlaying(origin, id);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (cnum = 0; cnum < numofchannels; cnum++)
|
|
|
|
{
|
|
|
|
if (channels[cnum].origin == origin
|
|
|
|
&& (size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// S_StartSoundName
|
|
|
|
// Starts a sound using the given name.
|
|
|
|
#define MAXNEWSOUNDS 10
|
|
|
|
static sfxenum_t newsounds[MAXNEWSOUNDS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
|
|
|
void S_StartSoundName(void *mo, const char *soundname)
|
|
|
|
{
|
|
|
|
INT32 i, soundnum = 0;
|
|
|
|
// Search existing sounds...
|
|
|
|
for (i = sfx_None + 1; i < NUMSFX; i++)
|
|
|
|
{
|
|
|
|
if (!S_sfx[i].name)
|
|
|
|
continue;
|
|
|
|
if (!stricmp(S_sfx[i].name, soundname))
|
|
|
|
{
|
|
|
|
soundnum = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!soundnum)
|
|
|
|
{
|
|
|
|
for (i = 0; i < MAXNEWSOUNDS; i++)
|
|
|
|
{
|
|
|
|
if (newsounds[i] == 0)
|
|
|
|
break;
|
|
|
|
if (!S_IdPlaying(newsounds[i]))
|
|
|
|
{
|
|
|
|
S_RemoveSoundFx(newsounds[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == MAXNEWSOUNDS)
|
|
|
|
{
|
|
|
|
CONS_Debug(DBG_GAMELOGIC, "Cannot load another extra sound!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-18 17:56:54 +00:00
|
|
|
soundnum = S_AddSoundFx(soundname, false, 0, false);
|
2014-03-15 16:59:03 +00:00
|
|
|
newsounds[i] = soundnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
S_StartSound(mo, soundnum);
|
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
//
|
|
|
|
// Initializes sound stuff, including volume
|
|
|
|
// Sets channels, SFX volume,
|
|
|
|
// allocates channel buffer, sets S_sfx lookup.
|
|
|
|
//
|
|
|
|
void S_InitSfxChannels(INT32 sfxVolume)
|
|
|
|
{
|
|
|
|
INT32 i;
|
|
|
|
|
|
|
|
if (dedicated)
|
|
|
|
return;
|
|
|
|
|
|
|
|
S_SetSfxVolume(sfxVolume);
|
|
|
|
|
|
|
|
SetChannelsNum();
|
|
|
|
|
|
|
|
// Note that sounds have not been cached (yet).
|
|
|
|
for (i = 1; i < NUMSFX; i++)
|
|
|
|
{
|
|
|
|
S_sfx[i].usefulness = -1; // for I_GetSfx()
|
|
|
|
S_sfx[i].lumpnum = LUMPERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
// precache sounds if requested by cmdline, or precachesound var true
|
2018-08-23 16:42:15 +00:00
|
|
|
if (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value))
|
2018-08-23 16:30:47 +00:00
|
|
|
{
|
|
|
|
// Initialize external data (all sounds) at start, keep static.
|
|
|
|
CONS_Printf(M_GetText("Loading sounds... "));
|
|
|
|
|
|
|
|
for (i = 1; i < NUMSFX; i++)
|
|
|
|
if (S_sfx[i].name)
|
|
|
|
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
|
|
|
|
|
|
|
CONS_Printf(M_GetText(" pre-cached all sound data\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Music
|
|
|
|
/// ------------------------
|
|
|
|
|
2016-03-03 10:54:07 +00:00
|
|
|
#ifdef MUSICSLOT_COMPATIBILITY
|
|
|
|
const char *compat_special_music_slots[16] =
|
|
|
|
{
|
2019-08-04 11:03:57 +00:00
|
|
|
"_title", // 1036 title screen
|
|
|
|
"_intro", // 1037 intro
|
|
|
|
"_clear", // 1038 level clear
|
|
|
|
"_inv", // 1039 invincibility
|
|
|
|
"_shoes", // 1040 super sneakers
|
|
|
|
"_minv", // 1041 Mario invincibility
|
|
|
|
"_drown", // 1042 drowning
|
|
|
|
"_gover", // 1043 game over
|
|
|
|
"_1up", // 1044 extra life
|
|
|
|
"_conti", // 1045 continue screen
|
|
|
|
"_super", // 1046 Super Sonic
|
|
|
|
"_chsel", // 1047 character select
|
|
|
|
"_creds", // 1048 credits
|
|
|
|
"_inter", // 1049 Race Results
|
|
|
|
"_stjr", // 1050 Sonic Team Jr. Presents
|
2016-03-03 10:54:07 +00:00
|
|
|
""
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
static char music_name[7]; // up to 6-character name
|
2018-09-14 16:29:58 +00:00
|
|
|
static void *music_data;
|
2018-08-23 20:46:40 +00:00
|
|
|
static UINT16 music_flags;
|
|
|
|
static boolean music_looping;
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
static char queue_name[7];
|
|
|
|
static UINT16 queue_flags;
|
|
|
|
static boolean queue_looping;
|
|
|
|
static UINT32 queue_position;
|
|
|
|
static UINT32 queue_fadeinms;
|
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
static tic_t pause_starttic;
|
|
|
|
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Music Definitions
|
|
|
|
/// ------------------------
|
|
|
|
|
2020-01-19 07:12:30 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MUSICDEF_220,
|
|
|
|
MUSICDEF_221,
|
|
|
|
};
|
|
|
|
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
musicdef_t soundtestsfx = {
|
|
|
|
"_STSFX", // prevents exactly one valid track name from being used on the sound test
|
|
|
|
"Sound Effects",
|
|
|
|
"",
|
2019-11-13 15:02:06 +00:00
|
|
|
"SEGA, VAdaPEGA, other sources",
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
1, // show on soundtest page 1
|
|
|
|
0, // with no conditions
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
musicdef_t *musicdefstart = &soundtestsfx;
|
|
|
|
|
|
|
|
//
|
|
|
|
// search for music definition in wad
|
|
|
|
//
|
|
|
|
static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid)
|
|
|
|
{
|
|
|
|
UINT16 i;
|
|
|
|
lumpinfo_t *lump_p;
|
|
|
|
|
|
|
|
lump_p = wadfiles[wadid]->lumpinfo;
|
|
|
|
for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++)
|
|
|
|
if (memcmp(lump_p->name, "MUSICDEF", 8) == 0)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return INT16_MAX; // not found
|
|
|
|
}
|
|
|
|
|
2020-01-19 07:12:30 +00:00
|
|
|
static void
|
|
|
|
MusicDefStrcpy (char *p, const char *s, size_t n, int version)
|
|
|
|
{
|
|
|
|
strlcpy(p, s, n);
|
|
|
|
if (version == MUSICDEF_220)
|
|
|
|
{
|
|
|
|
while (( p = strchr(p, '_') ))
|
2020-01-20 23:36:27 +00:00
|
|
|
*p++ = ' '; // turn _ into spaces.
|
2020-01-19 07:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
static boolean
|
2020-01-19 07:12:30 +00:00
|
|
|
ReadMusicDefFields (UINT16 wadnum, int line, boolean fields, char *stoken,
|
|
|
|
musicdef_t **defp, int *versionp)
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
musicdef_t *def;
|
2020-01-19 07:12:30 +00:00
|
|
|
int version;
|
2020-01-19 06:13:34 +00:00
|
|
|
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
char *value;
|
2019-12-30 03:22:27 +00:00
|
|
|
char *textline;
|
2020-01-19 06:13:34 +00:00
|
|
|
int i;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
if (!stricmp(stoken, "lump"))
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
value = strtok(NULL, " ");
|
|
|
|
if (!value)
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
CONS_Alert(CONS_WARNING,
|
|
|
|
"MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
|
|
|
return false;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
2020-01-19 06:13:34 +00:00
|
|
|
else
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
musicdef_t *prev = NULL;
|
|
|
|
def = musicdefstart;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
// Search if this is a replacement
|
|
|
|
//CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n");
|
|
|
|
while (def)
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
if (!stricmp(def->name, value))
|
|
|
|
{
|
|
|
|
//CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev = def;
|
|
|
|
def = def->next;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
// Nothing found, add to the end.
|
|
|
|
if (!def)
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL);
|
|
|
|
STRBUFCPY(def->name, value);
|
|
|
|
strlwr(def->name);
|
|
|
|
def->bpm = TICRATE<<(FRACBITS-1); // FixedDiv((60*TICRATE)<<FRACBITS, 120<<FRACBITS)
|
|
|
|
if (prev != NULL)
|
|
|
|
prev->next = def;
|
|
|
|
//CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
(*defp) = def;
|
|
|
|
}
|
|
|
|
}
|
2020-01-19 07:12:30 +00:00
|
|
|
else if (!stricmp(stoken, "version"))
|
|
|
|
{
|
|
|
|
if (fields)/* is this not the first field? */
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_WARNING,
|
|
|
|
"MUSICDEF: Field '%s' must come first. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = strtok(NULL, " ");
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_WARNING,
|
|
|
|
"MUSICDEF: Field '%s' is missing version. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strcasecmp(value, "2.2.0"))
|
|
|
|
(*versionp) = MUSICDEF_221;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-19 06:13:34 +00:00
|
|
|
else
|
|
|
|
{
|
2020-01-19 07:12:30 +00:00
|
|
|
version = (*versionp);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 07:12:30 +00:00
|
|
|
if (version == MUSICDEF_220)
|
|
|
|
value = strtok(NULL, " =");
|
|
|
|
else
|
2020-01-19 06:13:34 +00:00
|
|
|
{
|
2020-01-19 07:12:30 +00:00
|
|
|
value = strtok(NULL, "");
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
// Find the equals sign.
|
|
|
|
value = strchr(value, '=');
|
|
|
|
}
|
2020-01-19 06:13:34 +00:00
|
|
|
}
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_WARNING,
|
|
|
|
"MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
|
|
|
return false;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
def = (*defp);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
if (!def)
|
2019-12-30 03:22:27 +00:00
|
|
|
{
|
2020-01-19 06:13:34 +00:00
|
|
|
CONS_Alert(CONS_ERROR,
|
|
|
|
"MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
|
|
|
return false;
|
2019-12-30 03:22:27 +00:00
|
|
|
}
|
|
|
|
|
2020-01-19 07:12:30 +00:00
|
|
|
if (version != MUSICDEF_220)
|
|
|
|
{
|
|
|
|
// Skip the equals sign.
|
|
|
|
value++;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 07:12:30 +00:00
|
|
|
// Now skip funny whitespace.
|
|
|
|
value += strspn(value, "\t ");
|
|
|
|
}
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
textline = value;
|
|
|
|
i = atoi(value);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
/* based ignored lumps */
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
if (!stricmp(stoken, "usage")) {
|
|
|
|
#if 0 // Ignore for now
|
2019-12-30 03:22:27 +00:00
|
|
|
STRBUFCPY(def->usage, textline);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
#endif
|
|
|
|
} else if (!stricmp(stoken, "source")) {
|
|
|
|
#if 0 // Ignore for now
|
2019-12-30 03:22:27 +00:00
|
|
|
STRBUFCPY(def->source, textline);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
#endif
|
|
|
|
} else if (!stricmp(stoken, "title")) {
|
2020-01-19 07:12:30 +00:00
|
|
|
MusicDefStrcpy(def->title, textline,
|
|
|
|
sizeof def->title, version);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
} else if (!stricmp(stoken, "alttitle")) {
|
2020-01-19 07:12:30 +00:00
|
|
|
MusicDefStrcpy(def->alttitle, textline,
|
|
|
|
sizeof def->alttitle, version);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
} else if (!stricmp(stoken, "authors")) {
|
2020-01-19 07:12:30 +00:00
|
|
|
MusicDefStrcpy(def->authors, textline,
|
|
|
|
sizeof def->authors, version);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
} else if (!stricmp(stoken, "soundtestpage")) {
|
|
|
|
def->soundtestpage = (UINT8)i;
|
|
|
|
} else if (!stricmp(stoken, "soundtestcond")) {
|
|
|
|
// Convert to map number
|
2019-12-30 03:22:27 +00:00
|
|
|
if (textline[0] >= 'A' && textline[0] <= 'Z' && textline[2] == '\0')
|
|
|
|
i = M_MapNumber(textline[0], textline[1]);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
def->soundtestcond = (INT16)i;
|
|
|
|
} else if (!stricmp(stoken, "stoppingtime")) {
|
2019-12-30 03:22:27 +00:00
|
|
|
double stoppingtime = atof(textline)*TICRATE;
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
def->stoppingtics = (tic_t)stoppingtime;
|
|
|
|
} else if (!stricmp(stoken, "bpm")) {
|
2019-12-30 03:22:27 +00:00
|
|
|
double bpm = atof(textline);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
fixed_t bpmf = FLOAT_TO_FIXED(bpm);
|
|
|
|
if (bpmf > 0)
|
|
|
|
def->bpm = FixedDiv((60*TICRATE)<<FRACBITS, bpmf);
|
|
|
|
} else {
|
2020-01-19 06:13:34 +00:00
|
|
|
CONS_Alert(CONS_WARNING,
|
|
|
|
"MUSICDEF: Invalid field '%s'. (file %s, line %d)\n",
|
|
|
|
stoken, wadfiles[wadnum]->filename, line);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
2020-01-19 06:13:34 +00:00
|
|
|
}
|
|
|
|
}
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-12-30 03:22:27 +00:00
|
|
|
|
2020-01-19 06:13:34 +00:00
|
|
|
void S_LoadMusicDefs(UINT16 wadnum)
|
|
|
|
{
|
|
|
|
UINT16 lumpnum;
|
|
|
|
char *lump;
|
|
|
|
char *musdeftext;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
char *lf;
|
|
|
|
char *stoken;
|
|
|
|
|
|
|
|
size_t nlf;
|
|
|
|
size_t ncr;
|
|
|
|
|
|
|
|
musicdef_t *def = NULL;
|
2020-01-19 07:12:30 +00:00
|
|
|
int version = MUSICDEF_220;
|
2020-01-19 06:13:34 +00:00
|
|
|
int line = 1; // for better error msgs
|
2020-01-19 07:12:30 +00:00
|
|
|
boolean fields = false;
|
2020-01-19 06:13:34 +00:00
|
|
|
|
|
|
|
lumpnum = W_CheckForMusicDefInPwad(wadnum);
|
|
|
|
if (lumpnum == INT16_MAX)
|
|
|
|
return;
|
|
|
|
|
|
|
|
lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
|
|
|
|
size = W_LumpLengthPwad(wadnum, lumpnum);
|
|
|
|
|
|
|
|
// Null-terminated MUSICDEF lump.
|
|
|
|
musdeftext = malloc(size+1);
|
|
|
|
if (!musdeftext)
|
|
|
|
I_Error("S_LoadMusicDefs: No more free memory for the parser\n");
|
|
|
|
M_Memcpy(musdeftext, lump, size);
|
|
|
|
musdeftext[size] = '\0';
|
|
|
|
|
|
|
|
// Find music def
|
|
|
|
stoken = musdeftext;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
lf = strpbrk(stoken, "\r\n");
|
|
|
|
if (lf)
|
|
|
|
{
|
|
|
|
if (*lf == '\n')
|
|
|
|
nlf = 1;
|
|
|
|
else
|
|
|
|
nlf = 0;
|
|
|
|
*lf++ = '\0';/* now we can delimit to here */
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
2020-01-19 06:13:34 +00:00
|
|
|
|
|
|
|
stoken = strtok(stoken, " ");
|
|
|
|
if (stoken)
|
|
|
|
{
|
2020-01-19 07:12:30 +00:00
|
|
|
if (! ReadMusicDefFields(wadnum, line, fields, stoken,
|
|
|
|
&def, &version))
|
2020-01-19 06:13:34 +00:00
|
|
|
break;
|
2020-01-19 07:12:30 +00:00
|
|
|
fields = true;
|
2020-01-19 06:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lf)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
line += nlf;
|
|
|
|
ncr = strspn(lf, "\r");/* skip CR */
|
|
|
|
lf += ncr;
|
|
|
|
nlf = strspn(lf, "\n");
|
|
|
|
lf += nlf;
|
|
|
|
}
|
|
|
|
while (nlf || ncr) ;
|
|
|
|
|
|
|
|
stoken = lf;/* now the next nonempty line */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;/* EOF */
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-30 05:07:39 +00:00
|
|
|
free(musdeftext);
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// S_InitMusicDefs
|
|
|
|
//
|
|
|
|
// Simply load music defs in all wads.
|
|
|
|
//
|
|
|
|
void S_InitMusicDefs(void)
|
|
|
|
{
|
|
|
|
UINT16 i;
|
|
|
|
for (i = 0; i < numwadfiles; i++)
|
|
|
|
S_LoadMusicDefs(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
musicdef_t **soundtestdefs = NULL;
|
|
|
|
INT32 numsoundtestdefs = 0;
|
|
|
|
UINT8 soundtestpage = 1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// S_PrepareSoundTest
|
|
|
|
//
|
|
|
|
// Prepare sound test. What am I, your butler?
|
|
|
|
//
|
|
|
|
boolean S_PrepareSoundTest(void)
|
|
|
|
{
|
|
|
|
musicdef_t *def;
|
|
|
|
INT32 pos = numsoundtestdefs = 0;
|
|
|
|
|
|
|
|
for (def = musicdefstart; def; def = def->next)
|
|
|
|
{
|
|
|
|
if (!(def->soundtestpage & soundtestpage))
|
|
|
|
continue;
|
|
|
|
def->allowed = false;
|
|
|
|
numsoundtestdefs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!numsoundtestdefs)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (soundtestdefs)
|
|
|
|
Z_Free(soundtestdefs);
|
|
|
|
|
|
|
|
if (!(soundtestdefs = Z_Malloc(numsoundtestdefs*sizeof(musicdef_t *), PU_STATIC, NULL)))
|
|
|
|
I_Error("S_PrepareSoundTest(): could not allocate soundtestdefs.");
|
|
|
|
|
|
|
|
for (def = musicdefstart; def /*&& i < numsoundtestdefs*/; def = def->next)
|
|
|
|
{
|
|
|
|
if (!(def->soundtestpage & soundtestpage))
|
|
|
|
continue;
|
|
|
|
soundtestdefs[pos++] = def;
|
|
|
|
if (def->soundtestcond > 0 && !(mapvisited[def->soundtestcond-1] & MV_BEATEN))
|
|
|
|
continue;
|
2019-11-21 13:12:54 +00:00
|
|
|
if (def->soundtestcond < 0 && !M_Achieved(-1-def->soundtestcond))
|
Sound test is cool now!
https://cdn.discordapp.com/attachments/405336003239477249/641295998395613224/srb20042.gif
* Port MUSICDEFs from Kart.
* Safe to modify without modifying game, so we can put it in music.dta eventually.
* "Title", "AltTitle", "Authors" fields are self-evident.
* "Soundtestpage" and "Soundtestcond" are used to determine which sound test unlockable can play them (set with Unlockable's variable, just like Level Select).
* "Stoppingtime" and "BPM" both accept floats, and are used for presentation stuff on the sound test.
* Ironically, we don't share a single field name with them. Such is the case of differing foci, though, and I expect they'll change their implementation to match (since this is necessary for a sound test).
* Change how S_AddSoundFx works to avoid iterating through all of them, and to allow cv_soundtest to only scroll through defined slots (instead of the infinite wall of thok sounds when scrolling to the left).
* Change V_DrawFixedPatch to allow scaling on two seperate axes.
* Now called "V_DrawStretchyFixedPatch".
* "V_DrawFixedPatch" is a macro to V_DrawStretchyFixedPatch now (same scale on both axes).
* Available to Lua under v.drawStretched!
* Even works in GL!
* Bugfix: Add SR_PLAYER to SOC's menutypes_list.
Stay tuned for the merge request, where I put the onus on the Music Team to finish this off...
2019-11-05 16:23:46 +00:00
|
|
|
continue;
|
|
|
|
def->allowed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Music Status
|
|
|
|
/// ------------------------
|
|
|
|
|
2018-08-23 16:42:15 +00:00
|
|
|
boolean S_DigMusicDisabled(void)
|
2018-08-23 15:51:23 +00:00
|
|
|
{
|
2018-08-23 16:42:15 +00:00
|
|
|
return digital_disabled;
|
2018-08-23 15:51:23 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:42:15 +00:00
|
|
|
boolean S_MIDIMusicDisabled(void)
|
2018-08-23 15:51:23 +00:00
|
|
|
{
|
2018-08-23 16:42:15 +00:00
|
|
|
return midi_disabled;
|
2018-08-23 15:51:23 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:42:15 +00:00
|
|
|
boolean S_MusicDisabled(void)
|
2018-08-23 15:51:23 +00:00
|
|
|
{
|
2018-08-23 16:42:15 +00:00
|
|
|
return (midi_disabled && digital_disabled);
|
2018-08-23 15:51:23 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
boolean S_MusicPlaying(void)
|
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
return I_SongPlaying();
|
2018-08-23 16:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_MusicPaused(void)
|
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
return I_SongPaused();
|
2018-08-23 16:30:47 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 00:21:09 +00:00
|
|
|
boolean S_MusicNotInFocus(void)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
( window_notinfocus && ! cv_playmusicifunfocused.value )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-08-23 16:51:45 +00:00
|
|
|
musictype_t S_MusicType(void)
|
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
return I_SongType();
|
2018-08-23 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 12:03:05 +00:00
|
|
|
const char *S_MusicName(void)
|
|
|
|
{
|
|
|
|
return music_name;
|
|
|
|
}
|
|
|
|
|
2018-08-23 20:46:40 +00:00
|
|
|
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
|
2018-08-23 16:30:47 +00:00
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
if (!I_SongPlaying())
|
2018-08-23 20:46:40 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
strncpy(mname, music_name, 7);
|
|
|
|
mname[6] = 0;
|
|
|
|
*mflags = music_flags;
|
|
|
|
*looping = music_looping;
|
|
|
|
|
|
|
|
return (boolean)mname[0];
|
2018-08-23 16:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|
|
|
|
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
/// ------------------------
|
2018-08-23 21:05:37 +00:00
|
|
|
/// Music Effects
|
2018-08-23 15:51:23 +00:00
|
|
|
/// ------------------------
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
boolean S_SpeedMusic(float speed)
|
|
|
|
{
|
|
|
|
return I_SetSongSpeed(speed);
|
|
|
|
}
|
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Music Seeking
|
|
|
|
/// ------------------------
|
|
|
|
|
|
|
|
UINT32 S_GetMusicLength(void)
|
|
|
|
{
|
|
|
|
return I_GetSongLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_SetMusicLoopPoint(UINT32 looppoint)
|
|
|
|
{
|
|
|
|
return I_SetSongLoopPoint(looppoint);
|
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
UINT32 S_GetMusicLoopPoint(void)
|
|
|
|
{
|
|
|
|
return I_GetSongLoopPoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_SetMusicPosition(UINT32 position)
|
|
|
|
{
|
|
|
|
return I_SetSongPosition(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT32 S_GetMusicPosition(void)
|
|
|
|
{
|
|
|
|
return I_GetSongPosition();
|
|
|
|
}
|
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
/// ------------------------
|
2019-08-04 11:03:57 +00:00
|
|
|
/// Music Stacking (Jingles)
|
|
|
|
/// In this section: mazmazz doesn't know how to do dynamic arrays or struct pointers!
|
2018-08-23 15:51:23 +00:00
|
|
|
/// ------------------------
|
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
static musicstack_t *music_stacks = NULL;
|
|
|
|
static musicstack_t *last_music_stack = NULL;
|
|
|
|
|
|
|
|
void S_SetStackAdjustmentStart(void)
|
2018-09-18 19:10:00 +00:00
|
|
|
{
|
2019-08-04 11:03:57 +00:00
|
|
|
if (!pause_starttic)
|
|
|
|
pause_starttic = gametic;
|
|
|
|
}
|
2018-09-18 19:10:00 +00:00
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
void S_AdjustMusicStackTics(void)
|
|
|
|
{
|
|
|
|
if (pause_starttic)
|
|
|
|
{
|
|
|
|
musicstack_t *mst;
|
|
|
|
for (mst = music_stacks; mst; mst = mst->next)
|
|
|
|
mst->tic += gametic - pause_starttic;
|
|
|
|
pause_starttic = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_ResetMusicStack(void)
|
|
|
|
{
|
|
|
|
musicstack_t *mst, *mst_next;
|
|
|
|
for (mst = music_stacks; mst; mst = mst_next)
|
|
|
|
{
|
|
|
|
mst_next = mst->next;
|
|
|
|
Z_Free(mst);
|
|
|
|
}
|
|
|
|
music_stacks = last_music_stack = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_RemoveMusicStackEntry(musicstack_t *entry)
|
|
|
|
{
|
|
|
|
musicstack_t *mst;
|
|
|
|
for (mst = music_stacks; mst; mst = mst->next)
|
|
|
|
{
|
|
|
|
if (mst == entry)
|
|
|
|
{
|
|
|
|
// Remove ourselves from the chain and link
|
|
|
|
// prev and next together
|
|
|
|
|
|
|
|
if (mst->prev)
|
|
|
|
mst->prev->next = mst->next;
|
|
|
|
else
|
|
|
|
music_stacks = mst->next;
|
|
|
|
|
|
|
|
if (mst->next)
|
|
|
|
mst->next->prev = mst->prev;
|
|
|
|
else
|
|
|
|
last_music_stack = mst->prev;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Z_Free(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_RemoveMusicStackEntryByStatus(UINT16 status)
|
|
|
|
{
|
|
|
|
musicstack_t *mst, *mst_next;
|
|
|
|
|
|
|
|
if (!status)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (mst = music_stacks; mst; mst = mst_next)
|
|
|
|
{
|
|
|
|
mst_next = mst->next;
|
|
|
|
if (mst->status == status)
|
|
|
|
S_RemoveMusicStackEntry(mst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_AddMusicStackEntry(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status)
|
|
|
|
{
|
|
|
|
musicstack_t *mst, *new_mst;
|
|
|
|
|
|
|
|
// if the first entry is empty, force master onto it
|
|
|
|
if (!music_stacks)
|
|
|
|
{
|
|
|
|
music_stacks = Z_Calloc(sizeof (*mst), PU_MUSIC, NULL);
|
2019-10-26 19:02:45 +00:00
|
|
|
strncpy(music_stacks->musname, (status == JT_MASTER ? mname : (S_CheckQueue() ? queue_name : mapmusname)), 7);
|
|
|
|
music_stacks->musflags = (status == JT_MASTER ? mflags : (S_CheckQueue() ? queue_flags : mapmusflags));
|
|
|
|
music_stacks->looping = (status == JT_MASTER ? looping : (S_CheckQueue() ? queue_looping : true));
|
|
|
|
music_stacks->position = (status == JT_MASTER ? position : (S_CheckQueue() ? queue_position : S_GetMusicPosition()));
|
2019-08-04 11:03:57 +00:00
|
|
|
music_stacks->tic = gametic;
|
|
|
|
music_stacks->status = JT_MASTER;
|
|
|
|
music_stacks->mlumpnum = S_GetMusicLumpNum(music_stacks->musname);
|
2019-10-26 19:02:45 +00:00
|
|
|
music_stacks->noposition = S_CheckQueue();
|
2019-08-04 11:03:57 +00:00
|
|
|
|
|
|
|
if (status == JT_MASTER)
|
|
|
|
return; // we just added the user's entry here
|
|
|
|
}
|
|
|
|
|
|
|
|
// look for an empty slot to park ourselves
|
|
|
|
for (mst = music_stacks; mst->next; mst = mst->next);
|
|
|
|
|
|
|
|
// create our new entry
|
|
|
|
new_mst = Z_Calloc(sizeof (*new_mst), PU_MUSIC, NULL);
|
|
|
|
strncpy(new_mst->musname, mname, 7);
|
|
|
|
new_mst->musname[6] = 0;
|
|
|
|
new_mst->musflags = mflags;
|
|
|
|
new_mst->looping = looping;
|
|
|
|
new_mst->position = position;
|
|
|
|
new_mst->tic = gametic;
|
|
|
|
new_mst->status = status;
|
|
|
|
new_mst->mlumpnum = S_GetMusicLumpNum(new_mst->musname);
|
2019-10-26 19:02:45 +00:00
|
|
|
new_mst->noposition = false;
|
2019-08-04 11:03:57 +00:00
|
|
|
|
|
|
|
mst->next = new_mst;
|
|
|
|
new_mst->prev = mst;
|
|
|
|
new_mst->next = NULL;
|
|
|
|
last_music_stack = new_mst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT16 startindex)
|
|
|
|
{
|
|
|
|
musicstack_t *mst, *start_mst = NULL, *mst_next;
|
|
|
|
|
|
|
|
// if the first entry is empty, force master onto it
|
|
|
|
// fixes a memory corruption bug
|
|
|
|
if (!music_stacks && status != JT_MASTER)
|
|
|
|
S_AddMusicStackEntry(mapmusname, mapmusflags, true, S_GetMusicPosition(), JT_MASTER);
|
|
|
|
|
|
|
|
if (startindex >= 0)
|
|
|
|
{
|
|
|
|
INT16 i = 0;
|
|
|
|
for (mst = music_stacks; mst && i <= startindex; mst = mst->next, i++)
|
|
|
|
start_mst = mst;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
start_mst = (fromfirst ? music_stacks : last_music_stack);
|
|
|
|
|
|
|
|
for (mst = start_mst; mst; mst = mst_next)
|
|
|
|
{
|
|
|
|
mst_next = (fromfirst ? mst->next : mst->prev);
|
|
|
|
|
|
|
|
if (!status || mst->status == status)
|
|
|
|
{
|
|
|
|
if (P_EvaluateMusicStatus(mst->status))
|
|
|
|
{
|
|
|
|
if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia
|
|
|
|
S_RemoveMusicStackEntry(mst); // then continue
|
|
|
|
else
|
|
|
|
return mst;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
S_RemoveMusicStackEntry(mst); // then continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void S_RetainMusic(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status)
|
|
|
|
{
|
|
|
|
musicstack_t *mst;
|
|
|
|
|
|
|
|
if (!status) // we use this as a null indicator, don't push
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_ERROR, "Music stack entry must have a nonzero status.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (status == JT_MASTER) // enforce only one JT_MASTER
|
|
|
|
{
|
|
|
|
for (mst = music_stacks; mst; mst = mst->next)
|
|
|
|
{
|
|
|
|
if (mst->status == JT_MASTER)
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_ERROR, "Music stack can only have one JT_MASTER entry.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // remove any existing status
|
|
|
|
S_RemoveMusicStackEntryByStatus(status);
|
|
|
|
|
|
|
|
S_AddMusicStackEntry(mname, mflags, looping, position, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_RecallMusic(UINT16 status, boolean fromfirst)
|
|
|
|
{
|
|
|
|
UINT32 newpos = 0;
|
|
|
|
boolean mapmuschanged = false;
|
|
|
|
musicstack_t *result;
|
|
|
|
musicstack_t *entry = Z_Calloc(sizeof (*result), PU_MUSIC, NULL);
|
|
|
|
|
|
|
|
if (status)
|
|
|
|
result = S_GetMusicStackEntry(status, fromfirst, -1);
|
|
|
|
else
|
|
|
|
result = S_GetMusicStackEntry(JT_NONE, false, -1);
|
|
|
|
|
|
|
|
if (result && !S_MusicExists(result->musname, !midi_disabled, !digital_disabled))
|
|
|
|
{
|
|
|
|
Z_Free(entry);
|
|
|
|
return false; // music doesn't exist, so don't do anything
|
|
|
|
}
|
|
|
|
|
|
|
|
// make a copy of result, since we make modifications to our copy
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
*entry = *result;
|
|
|
|
strncpy(entry->musname, result->musname, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
// no result, just grab mapmusname
|
|
|
|
if (!result || !entry->musname[0] || ((status == JT_MASTER || (music_stacks ? !music_stacks->status : false)) && !entry->status))
|
|
|
|
{
|
|
|
|
strncpy(entry->musname, mapmusname, 7);
|
|
|
|
entry->musflags = mapmusflags;
|
|
|
|
entry->looping = true;
|
|
|
|
entry->position = mapmusposition;
|
|
|
|
entry->tic = gametic;
|
|
|
|
entry->status = JT_MASTER;
|
|
|
|
entry->mlumpnum = S_GetMusicLumpNum(entry->musname);
|
2019-10-26 19:02:45 +00:00
|
|
|
entry->noposition = false; // don't set this until we do the mapmuschanged check, below. Else, this breaks some resumes.
|
2019-08-04 11:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entry->status == JT_MASTER)
|
|
|
|
{
|
|
|
|
mapmuschanged = strnicmp(entry->musname, mapmusname, 7);
|
2019-10-26 19:02:45 +00:00
|
|
|
if (mapmuschanged)
|
|
|
|
{
|
|
|
|
strncpy(entry->musname, mapmusname, 7);
|
|
|
|
entry->musflags = mapmusflags;
|
|
|
|
entry->looping = true;
|
|
|
|
entry->position = mapmusposition;
|
|
|
|
entry->tic = gametic;
|
|
|
|
entry->status = JT_MASTER;
|
|
|
|
entry->mlumpnum = S_GetMusicLumpNum(entry->musname);
|
|
|
|
entry->noposition = true;
|
|
|
|
}
|
2019-08-04 11:03:57 +00:00
|
|
|
S_ResetMusicStack();
|
|
|
|
}
|
|
|
|
else if (!entry->status)
|
|
|
|
{
|
|
|
|
Z_Free(entry);
|
2018-08-23 15:51:23 +00:00
|
|
|
return false;
|
2019-08-04 11:03:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-26 19:02:45 +00:00
|
|
|
if (strncmp(entry->musname, S_MusicName(), 7)) // don't restart music if we're already playing it
|
2019-08-04 11:03:57 +00:00
|
|
|
{
|
|
|
|
if (music_stack_fadeout)
|
|
|
|
S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, music_stack_fadeout, 0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, 0, music_stack_fadein);
|
|
|
|
|
2019-10-26 19:02:45 +00:00
|
|
|
if (!entry->noposition && !music_stack_noposition) // HACK: Global boolean to toggle position resuming, e.g., de-superize
|
2019-08-04 11:03:57 +00:00
|
|
|
{
|
|
|
|
UINT32 poslapse = 0;
|
|
|
|
|
|
|
|
// To prevent the game from jumping past the end of the music, we need
|
|
|
|
// to check if we can get the song's length. Otherwise, if the lapsed resume time goes
|
|
|
|
// over a LOOPPOINT, mixer_sound.c will be unable to calculate the new resume position.
|
|
|
|
if (S_GetMusicLength())
|
|
|
|
poslapse = (UINT32)((float)(gametic - entry->tic)/(float)TICRATE*(float)MUSICRATE);
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
newpos = entry->position + poslapse;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the newly recalled music lumpnum does not match the lumpnum that we stored in stack,
|
|
|
|
// then discard the new position. That way, we will not recall an invalid position
|
|
|
|
// when the music is replaced or digital/MIDI is toggled.
|
|
|
|
if (newpos > 0 && S_MusicPlaying() && S_GetMusicLumpNum(entry->musname) == entry->mlumpnum)
|
|
|
|
S_SetMusicPosition(newpos);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
S_StopFadingMusic();
|
|
|
|
S_SetInternalMusicVolume(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
music_stack_noposition = false;
|
|
|
|
music_stack_fadeout = 0;
|
|
|
|
music_stack_fadein = JINGLEPOSTFADE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Z_Free(entry);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// ------------------------
|
|
|
|
/// Music Playback
|
|
|
|
/// ------------------------
|
|
|
|
|
|
|
|
static lumpnum_t S_GetMusicLumpNum(const char *mname)
|
|
|
|
{
|
2018-08-23 16:51:45 +00:00
|
|
|
if (!S_DigMusicDisabled() && S_DigExists(mname))
|
2019-08-04 11:03:57 +00:00
|
|
|
return W_GetNumForName(va("o_%s", mname));
|
2018-08-23 16:51:45 +00:00
|
|
|
else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname))
|
2019-08-04 11:03:57 +00:00
|
|
|
return W_GetNumForName(va("d_%s", mname));
|
2018-08-23 13:02:14 +00:00
|
|
|
else
|
2019-08-04 11:03:57 +00:00
|
|
|
return LUMPERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static boolean S_LoadMusic(const char *mname)
|
|
|
|
{
|
|
|
|
lumpnum_t mlumpnum;
|
|
|
|
void *mdata;
|
|
|
|
|
|
|
|
if (S_MusicDisabled())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
mlumpnum = S_GetMusicLumpNum(mname);
|
|
|
|
|
|
|
|
if (mlumpnum == LUMPERROR)
|
2019-11-30 16:53:45 +00:00
|
|
|
{
|
|
|
|
CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: lump not found!\n", mname);
|
2019-08-04 11:03:57 +00:00
|
|
|
return false;
|
2019-11-30 16:53:45 +00:00
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
|
|
|
// load & register it
|
|
|
|
mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC);
|
|
|
|
|
2019-08-04 06:04:02 +00:00
|
|
|
#ifdef MUSSERV
|
|
|
|
if (msg_id != -1)
|
|
|
|
{
|
|
|
|
struct musmsg msg_buffer;
|
|
|
|
|
|
|
|
msg_buffer.msg_type = 6;
|
|
|
|
memset(msg_buffer.msg_text, 0, sizeof (msg_buffer.msg_text));
|
|
|
|
sprintf(msg_buffer.msg_text, "d_%s", mname);
|
|
|
|
msgsnd(msg_id, (struct msgbuf*)&msg_buffer, sizeof (msg_buffer.msg_text), IPC_NOWAIT);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-08-23 13:02:14 +00:00
|
|
|
if (I_LoadSong(mdata, W_LumpLength(mlumpnum)))
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2018-08-23 13:02:14 +00:00
|
|
|
strncpy(music_name, mname, 7);
|
|
|
|
music_name[6] = 0;
|
2018-09-14 16:29:58 +00:00
|
|
|
music_data = mdata;
|
2018-08-23 13:02:14 +00:00
|
|
|
return true;
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
2018-08-23 13:02:14 +00:00
|
|
|
else
|
2019-11-30 16:53:45 +00:00
|
|
|
{
|
|
|
|
CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: engine failure!\n", mname);
|
2016-01-08 03:48:20 +00:00
|
|
|
return false;
|
2019-11-30 16:53:45 +00:00
|
|
|
}
|
2018-08-23 13:02:14 +00:00
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 13:36:51 +00:00
|
|
|
static void S_UnloadMusic(void)
|
2018-08-23 13:02:14 +00:00
|
|
|
{
|
|
|
|
I_UnloadSong();
|
2018-09-14 16:47:33 +00:00
|
|
|
|
2018-09-14 16:29:58 +00:00
|
|
|
#ifndef HAVE_SDL //SDL uses RWOPS
|
|
|
|
Z_ChangeTag(music_data, PU_CACHE);
|
|
|
|
#endif
|
|
|
|
music_data = NULL;
|
2018-09-14 16:47:33 +00:00
|
|
|
|
2018-08-23 13:02:14 +00:00
|
|
|
music_name[0] = 0;
|
2018-08-23 20:46:40 +00:00
|
|
|
music_flags = 0;
|
|
|
|
music_looping = false;
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2018-08-23 16:51:45 +00:00
|
|
|
if (S_MusicDisabled())
|
|
|
|
return false;
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
if ((!fadeinms && !I_PlaySong(looping)) ||
|
|
|
|
(fadeinms && !I_FadeInPlaySong(fadeinms, looping)))
|
2018-08-23 13:02:14 +00:00
|
|
|
{
|
2019-11-30 16:53:45 +00:00
|
|
|
CONS_Alert(CONS_ERROR, "Music %.6s could not be played: engine failure!\n", music_name);
|
2018-08-23 13:36:51 +00:00
|
|
|
S_UnloadMusic();
|
2016-01-08 03:48:20 +00:00
|
|
|
return false;
|
2018-08-23 13:02:14 +00:00
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
S_InitMusicVolume(); // switch between digi and sequence volume
|
2019-10-24 00:21:09 +00:00
|
|
|
|
|
|
|
if (S_MusicNotInFocus())
|
|
|
|
S_PauseAudio();
|
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms)
|
|
|
|
{
|
|
|
|
strncpy(queue_name, mmusic, 7);
|
|
|
|
queue_flags = mflags;
|
|
|
|
queue_looping = looping;
|
|
|
|
queue_position = position;
|
|
|
|
queue_fadeinms = fadeinms;
|
|
|
|
}
|
|
|
|
|
2019-10-26 19:02:45 +00:00
|
|
|
static boolean S_CheckQueue(void)
|
|
|
|
{
|
|
|
|
return queue_name[0];
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
static void S_ClearQueue(void)
|
|
|
|
{
|
|
|
|
queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void S_ChangeMusicToQueue(void)
|
|
|
|
{
|
2018-09-17 03:10:23 +00:00
|
|
|
S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms);
|
2018-08-24 12:20:09 +00:00
|
|
|
S_ClearQueue();
|
|
|
|
}
|
|
|
|
|
2018-09-17 03:10:23 +00:00
|
|
|
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms)
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2018-09-19 23:19:18 +00:00
|
|
|
char newmusic[7];
|
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
if (S_MusicDisabled())
|
2016-01-08 03:48:20 +00:00
|
|
|
return;
|
|
|
|
|
2018-08-28 13:42:13 +00:00
|
|
|
strncpy(newmusic, mmusic, 7);
|
2018-08-15 07:37:11 +00:00
|
|
|
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
|
2018-08-28 13:42:13 +00:00
|
|
|
if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
|
2018-08-15 06:06:43 +00:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
newmusic[6] = 0;
|
|
|
|
|
2018-09-18 14:22:17 +00:00
|
|
|
// No Music (empty string)
|
2018-08-15 06:06:43 +00:00
|
|
|
if (newmusic[0] == 0)
|
2018-09-18 14:22:17 +00:00
|
|
|
{
|
2018-08-24 12:20:09 +00:00
|
|
|
if (prefadems)
|
|
|
|
I_FadeSong(0, prefadems, &S_StopMusic);
|
|
|
|
else
|
|
|
|
S_StopMusic();
|
2016-01-08 03:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-04 11:03:57 +00:00
|
|
|
if (prefadems) // queue music change for after fade // allow even if the music is the same
|
|
|
|
// && S_MusicPlaying() // Let the delay happen even if we're not playing music
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2018-08-24 12:20:09 +00:00
|
|
|
CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name);
|
|
|
|
S_QueueMusic(newmusic, mflags, looping, position, fadeinms);
|
|
|
|
I_FadeSong(0, prefadems, S_ChangeMusicToQueue);
|
|
|
|
return;
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
2018-08-26 01:42:39 +00:00
|
|
|
else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET))
|
2018-09-18 14:22:17 +00:00
|
|
|
{
|
2018-08-24 12:20:09 +00:00
|
|
|
CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic);
|
2018-08-20 02:49:53 +00:00
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
S_StopMusic();
|
2018-08-20 02:05:23 +00:00
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
if (!S_LoadMusic(newmusic))
|
2016-01-08 03:48:20 +00:00
|
|
|
return;
|
2018-08-23 14:18:38 +00:00
|
|
|
|
2018-08-23 20:46:40 +00:00
|
|
|
music_flags = mflags;
|
|
|
|
music_looping = looping;
|
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
if (!S_PlayMusic(looping, fadeinms))
|
2018-08-20 02:49:53 +00:00
|
|
|
return;
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-24 12:20:09 +00:00
|
|
|
if (position)
|
|
|
|
I_SetSongPosition(position);
|
|
|
|
|
|
|
|
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
|
|
|
|
}
|
|
|
|
else if (fadeinms) // let fades happen with same music
|
|
|
|
{
|
|
|
|
I_SetSongPosition(position);
|
|
|
|
I_FadeSong(100, fadeinms, NULL);
|
2018-09-18 14:22:17 +00:00
|
|
|
}
|
2019-03-14 03:17:35 +00:00
|
|
|
else // reset volume to 100 with same music
|
|
|
|
{
|
|
|
|
I_StopFadingSong();
|
2019-03-14 03:55:30 +00:00
|
|
|
I_FadeSong(100, 500, NULL);
|
2018-08-24 12:20:09 +00:00
|
|
|
}
|
2018-08-18 21:17:53 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
void S_StopMusic(void)
|
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
if (!I_SongPlaying())
|
2016-01-08 03:48:20 +00:00
|
|
|
return;
|
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
if (I_SongPaused())
|
2018-08-23 13:36:51 +00:00
|
|
|
I_ResumeSong();
|
2018-08-18 18:18:29 +00:00
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
S_SpeedMusic(1.0f);
|
2018-08-23 13:02:14 +00:00
|
|
|
I_StopSong();
|
2018-09-14 16:47:33 +00:00
|
|
|
S_UnloadMusic(); // for now, stopping also means you unload the song
|
2017-04-29 15:40:07 +00:00
|
|
|
|
|
|
|
if (cv_closedcaptioning.value)
|
|
|
|
{
|
|
|
|
if (closedcaptions[0].s-S_sfx == sfx_None)
|
A good and bad ending cutscene now exist.
Also:
* SPR2_XTRA - instead of defining lumpnames in S_SKIN, those kinds of assets can just be bundled into the spriteset. Required for ending cutscene stuff, I guess, but also done for HUD life icon and character select image (aside from Sonic&Tails, still SOC'd in).
* Minor oversights in SPR2 support corrected.
* Better evaluation, featuring ending assets.
* Intro has warping-in blackrock, reusing ending assets.
* Cutscene text now supports lowercase (intro and custom).
* Disable the asset-fucking "gamma correction" I put in over two years ago when implementing colour cube. (This is the only thing I could move into another branch if you MUST, but it's basically invisble in the diff so w/e.)
* Don't blank the screen if the top left pixel of a screen-covering patch is transparent. (Checked via nonzero topdelta for first column)
Bugs:
* OPENGL ONLY: The first ~20 frames of both endings are fucked. A little help here? Might be HWR_DrawFadeFill's fault, which I just created. OR it could be in f_finale, but I doubt it, since it doesn't appear in Software.
2019-07-27 23:32:57 +00:00
|
|
|
{
|
|
|
|
if (gamestate != wipegamestate)
|
|
|
|
{
|
|
|
|
closedcaptions[0].c = NULL;
|
|
|
|
closedcaptions[0].s = NULL;
|
|
|
|
closedcaptions[0].t = 0;
|
|
|
|
closedcaptions[0].b = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
closedcaptions[0].t = CAPTIONFADETICS;
|
|
|
|
}
|
2017-04-29 15:40:07 +00:00
|
|
|
}
|
2018-08-15 05:38:06 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
//
|
|
|
|
// Stop and resume music, during game PAUSE.
|
|
|
|
//
|
|
|
|
void S_PauseAudio(void)
|
2018-08-15 05:38:06 +00:00
|
|
|
{
|
2018-08-24 01:07:39 +00:00
|
|
|
if (I_SongPlaying() && !I_SongPaused())
|
2018-08-23 16:30:47 +00:00
|
|
|
I_PauseSong();
|
|
|
|
|
|
|
|
// pause cd music
|
|
|
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
|
|
|
I_PauseCD();
|
|
|
|
#else
|
|
|
|
I_StopCD();
|
|
|
|
#endif
|
2019-08-04 11:03:57 +00:00
|
|
|
|
|
|
|
S_SetStackAdjustmentStart();
|
2018-08-15 05:38:06 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
void S_ResumeAudio(void)
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2019-10-24 00:21:09 +00:00
|
|
|
if (S_MusicNotInFocus())
|
|
|
|
return;
|
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
if (I_SongPlaying() && I_SongPaused())
|
2018-08-23 16:30:47 +00:00
|
|
|
I_ResumeSong();
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
// resume cd music
|
|
|
|
I_ResumeCD();
|
2019-08-04 11:03:57 +00:00
|
|
|
|
|
|
|
S_AdjustMusicStackTics();
|
2018-08-23 16:30:47 +00:00
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 15:51:23 +00:00
|
|
|
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
2018-08-23 15:51:23 +00:00
|
|
|
if (digvolume < 0)
|
|
|
|
digvolume = cv_digmusicvolume.value;
|
|
|
|
if (seqvolume < 0)
|
|
|
|
seqvolume = cv_midimusicvolume.value;
|
|
|
|
|
|
|
|
if (digvolume < 0 || digvolume > 31)
|
|
|
|
CONS_Alert(CONS_WARNING, "digmusicvolume should be between 0-31\n");
|
|
|
|
CV_SetValue(&cv_digmusicvolume, digvolume&31);
|
2016-01-08 03:48:20 +00:00
|
|
|
actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var
|
|
|
|
|
2018-08-23 16:30:47 +00:00
|
|
|
if (seqvolume < 0 || seqvolume > 31)
|
2018-08-23 15:51:23 +00:00
|
|
|
CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n");
|
|
|
|
CV_SetValue(&cv_midimusicvolume, seqvolume&31);
|
2018-08-23 13:06:13 +00:00
|
|
|
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
|
2016-01-08 03:48:20 +00:00
|
|
|
|
2018-08-23 13:06:13 +00:00
|
|
|
#ifdef DJGPPDOS
|
2018-08-23 15:51:23 +00:00
|
|
|
digvolume = seqvolume = 31;
|
2016-01-08 03:48:20 +00:00
|
|
|
#endif
|
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
switch(I_SongType())
|
2017-04-29 15:40:07 +00:00
|
|
|
{
|
2018-08-23 15:51:23 +00:00
|
|
|
case MU_MID:
|
2019-08-04 11:03:57 +00:00
|
|
|
case MU_MID_EX:
|
2018-08-24 21:43:20 +00:00
|
|
|
//case MU_MOD:
|
|
|
|
//case MU_GME:
|
2018-08-23 15:51:23 +00:00
|
|
|
I_SetMusicVolume(seqvolume&31);
|
2018-08-24 21:43:20 +00:00
|
|
|
break;
|
2018-08-23 15:51:23 +00:00
|
|
|
default:
|
|
|
|
I_SetMusicVolume(digvolume&31);
|
2018-08-24 21:43:20 +00:00
|
|
|
break;
|
2017-04-29 15:40:07 +00:00
|
|
|
}
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 01:07:39 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Music Fading
|
|
|
|
/// ------------------------
|
|
|
|
|
2018-08-19 13:38:57 +00:00
|
|
|
void S_SetInternalMusicVolume(INT32 volume)
|
|
|
|
{
|
|
|
|
I_SetInternalMusicVolume(min(max(volume, 0), 100));
|
|
|
|
}
|
|
|
|
|
2018-08-19 20:19:48 +00:00
|
|
|
void S_StopFadingMusic(void)
|
|
|
|
{
|
2018-08-21 10:22:35 +00:00
|
|
|
I_StopFadingSong();
|
2018-08-19 20:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 12:53:51 +00:00
|
|
|
boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms)
|
2018-08-19 20:19:48 +00:00
|
|
|
{
|
2018-08-19 21:02:13 +00:00
|
|
|
if (source_volume < 0)
|
2018-08-24 12:20:09 +00:00
|
|
|
return I_FadeSong(target_volume, ms, NULL);
|
2018-08-19 21:02:13 +00:00
|
|
|
else
|
2018-09-19 23:46:57 +00:00
|
|
|
return I_FadeSongFromVolume(target_volume, source_volume, ms, NULL);
|
2018-08-20 02:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean S_FadeOutStopMusic(UINT32 ms)
|
|
|
|
{
|
2018-08-24 12:20:09 +00:00
|
|
|
return I_FadeSong(0, ms, &S_StopMusic);
|
2018-08-19 20:19:48 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 03:48:20 +00:00
|
|
|
/// ------------------------
|
|
|
|
/// Init & Others
|
|
|
|
/// ------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
// Per level startup code.
|
|
|
|
// Kills playing sounds at start of level,
|
|
|
|
// determines music if any, changes music.
|
|
|
|
//
|
2019-08-04 11:03:57 +00:00
|
|
|
void S_StartEx(boolean reset)
|
2016-01-08 03:48:20 +00:00
|
|
|
{
|
|
|
|
if (mapmusflags & MUSIC_RELOADRESET)
|
|
|
|
{
|
|
|
|
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
|
|
|
|
mapmusname[6] = 0;
|
|
|
|
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
|
2018-08-25 20:23:01 +00:00
|
|
|
mapmusposition = mapheaderinfo[gamemap-1]->muspos;
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
|
|
|
|
2019-08-05 00:02:38 +00:00
|
|
|
if (RESETMUSIC || reset)
|
2016-01-08 03:48:20 +00:00
|
|
|
S_StopMusic();
|
2018-09-17 03:10:23 +00:00
|
|
|
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
2019-08-04 11:03:57 +00:00
|
|
|
|
|
|
|
S_ResetMusicStack();
|
|
|
|
music_stack_noposition = false;
|
|
|
|
music_stack_fadeout = 0;
|
|
|
|
music_stack_fadein = JINGLEPOSTFADE;
|
2016-01-08 03:48:20 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 20:29:43 +00:00
|
|
|
static void Command_Tunes_f(void)
|
|
|
|
{
|
|
|
|
const char *tunearg;
|
|
|
|
UINT16 tunenum, track = 0;
|
2019-01-01 15:41:40 +00:00
|
|
|
UINT32 position = 0;
|
2018-10-11 20:29:43 +00:00
|
|
|
const size_t argc = COM_Argc();
|
|
|
|
|
|
|
|
if (argc < 2) //tunes slot ...
|
|
|
|
{
|
2019-01-01 15:41:40 +00:00
|
|
|
CONS_Printf("tunes <name/num> [track] [speed] [position] / <-show> / <-default> / <-none>:\n");
|
2018-10-11 20:29:43 +00:00
|
|
|
CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n"));
|
|
|
|
CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n"));
|
|
|
|
CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n"));
|
|
|
|
CONS_Printf(M_GetText("* With \"-default\", returns to the default music for the map.\n"));
|
|
|
|
CONS_Printf(M_GetText("* With \"-none\", any music playing will be stopped.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tunearg = COM_Argv(1);
|
|
|
|
tunenum = (UINT16)atoi(tunearg);
|
|
|
|
track = 0;
|
|
|
|
|
|
|
|
if (!strcasecmp(tunearg, "-show"))
|
|
|
|
{
|
|
|
|
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
|
|
|
|
mapmusname, (mapmusflags & MUSIC_TRACKMASK));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!strcasecmp(tunearg, "-none"))
|
|
|
|
{
|
|
|
|
S_StopMusic();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(tunearg, "-default"))
|
|
|
|
{
|
|
|
|
tunearg = mapheaderinfo[gamemap-1]->musname;
|
|
|
|
track = mapheaderinfo[gamemap-1]->mustrack;
|
|
|
|
}
|
|
|
|
else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z')
|
|
|
|
tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]);
|
|
|
|
|
|
|
|
if (tunenum && tunenum >= 1036)
|
|
|
|
{
|
|
|
|
CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case
|
|
|
|
CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n"));
|
|
|
|
|
|
|
|
if (argc > 2)
|
|
|
|
track = (UINT16)atoi(COM_Argv(2))-1;
|
|
|
|
|
|
|
|
if (tunenum)
|
|
|
|
snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum));
|
|
|
|
else
|
|
|
|
strncpy(mapmusname, tunearg, 7);
|
2019-01-01 15:41:40 +00:00
|
|
|
|
|
|
|
if (argc > 4)
|
|
|
|
position = (UINT32)atoi(COM_Argv(4));
|
|
|
|
|
2018-10-11 20:29:43 +00:00
|
|
|
mapmusname[6] = 0;
|
|
|
|
mapmusflags = (track & MUSIC_TRACKMASK);
|
2019-01-01 15:41:40 +00:00
|
|
|
mapmusposition = position;
|
2018-10-11 20:29:43 +00:00
|
|
|
|
2019-01-01 15:41:40 +00:00
|
|
|
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
2018-10-11 20:29:43 +00:00
|
|
|
|
|
|
|
if (argc > 3)
|
|
|
|
{
|
|
|
|
float speed = (float)atof(COM_Argv(3));
|
|
|
|
if (speed > 0.0f)
|
|
|
|
S_SpeedMusic(speed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Command_RestartAudio_f(void)
|
|
|
|
{
|
|
|
|
S_StopMusic();
|
2018-10-20 03:56:56 +00:00
|
|
|
S_StopSounds();
|
2018-10-11 20:29:43 +00:00
|
|
|
I_ShutdownMusic();
|
|
|
|
I_ShutdownSound();
|
|
|
|
I_StartupSound();
|
|
|
|
I_InitMusic();
|
|
|
|
|
|
|
|
// These must be called or no sound and music until manually set.
|
|
|
|
|
|
|
|
I_SetSfxVolume(cv_soundvolume.value);
|
2018-10-20 03:56:56 +00:00
|
|
|
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
|
2018-10-11 20:29:43 +00:00
|
|
|
if (Playing()) // Gotta make sure the player is in a level
|
|
|
|
P_RestoreMusic(&players[consoleplayer]);
|
2018-10-20 03:56:56 +00:00
|
|
|
}
|
2018-11-25 19:22:52 +00:00
|
|
|
|
|
|
|
void GameSounds_OnChange(void)
|
|
|
|
{
|
2019-04-19 06:50:29 +00:00
|
|
|
if (M_CheckParm("-nosound") || M_CheckParm("-noaudio"))
|
2018-11-26 03:39:11 +00:00
|
|
|
return;
|
|
|
|
|
2018-11-25 19:22:52 +00:00
|
|
|
if (sound_disabled)
|
|
|
|
{
|
2019-10-23 22:24:34 +00:00
|
|
|
sound_disabled = false;
|
2019-11-14 14:19:13 +00:00
|
|
|
I_StartupSound(); // will return early if initialised
|
2019-10-23 22:24:34 +00:00
|
|
|
S_InitSfxChannels(cv_soundvolume.value);
|
|
|
|
S_StartSound(NULL, sfx_strpst);
|
2018-11-25 19:22:52 +00:00
|
|
|
}
|
|
|
|
else
|
2019-10-23 22:24:34 +00:00
|
|
|
{
|
|
|
|
sound_disabled = true;
|
|
|
|
S_StopSounds();
|
|
|
|
}
|
2018-11-25 19:22:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameDigiMusic_OnChange(void)
|
|
|
|
{
|
2019-04-19 06:50:29 +00:00
|
|
|
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio"))
|
2018-11-26 03:39:11 +00:00
|
|
|
return;
|
|
|
|
else if (M_CheckParm("-nodigmusic"))
|
|
|
|
return;
|
|
|
|
|
2018-11-25 19:22:52 +00:00
|
|
|
if (digital_disabled)
|
|
|
|
{
|
|
|
|
digital_disabled = false;
|
2019-11-14 14:19:13 +00:00
|
|
|
I_StartupSound(); // will return early if initialised
|
2018-11-25 19:22:52 +00:00
|
|
|
I_InitMusic();
|
|
|
|
S_StopMusic();
|
|
|
|
if (Playing())
|
|
|
|
P_RestoreMusic(&players[consoleplayer]);
|
|
|
|
else
|
2019-01-07 22:56:43 +00:00
|
|
|
S_ChangeMusicInternal("_clear", false);
|
2018-11-25 19:22:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
digital_disabled = true;
|
|
|
|
if (S_MusicType() != MU_MID)
|
|
|
|
{
|
|
|
|
if (midi_disabled)
|
|
|
|
S_StopMusic();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char mmusic[7];
|
|
|
|
UINT16 mflags;
|
|
|
|
boolean looping;
|
|
|
|
|
|
|
|
if (S_MusicInfo(mmusic, &mflags, &looping) && S_MIDIExists(mmusic))
|
|
|
|
{
|
|
|
|
S_StopMusic();
|
|
|
|
S_ChangeMusic(mmusic, mflags, looping);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
S_StopMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameMIDIMusic_OnChange(void)
|
|
|
|
{
|
2019-04-19 06:50:29 +00:00
|
|
|
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio"))
|
2018-11-26 03:39:11 +00:00
|
|
|
return;
|
|
|
|
else if (M_CheckParm("-nomidimusic"))
|
|
|
|
return;
|
|
|
|
|
2018-11-25 19:22:52 +00:00
|
|
|
if (midi_disabled)
|
|
|
|
{
|
|
|
|
midi_disabled = false;
|
2019-11-14 14:19:13 +00:00
|
|
|
I_StartupSound(); // will return early if initialised
|
2018-11-25 19:22:52 +00:00
|
|
|
I_InitMusic();
|
|
|
|
if (Playing())
|
|
|
|
P_RestoreMusic(&players[consoleplayer]);
|
|
|
|
else
|
2019-01-07 22:56:43 +00:00
|
|
|
S_ChangeMusicInternal("_clear", false);
|
2018-11-25 19:22:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
midi_disabled = true;
|
2019-10-26 16:09:27 +00:00
|
|
|
if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)
|
2018-11-25 19:22:52 +00:00
|
|
|
{
|
|
|
|
if (digital_disabled)
|
|
|
|
S_StopMusic();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char mmusic[7];
|
|
|
|
UINT16 mflags;
|
|
|
|
boolean looping;
|
|
|
|
|
|
|
|
if (S_MusicInfo(mmusic, &mflags, &looping) && S_DigExists(mmusic))
|
|
|
|
{
|
|
|
|
S_StopMusic();
|
|
|
|
S_ChangeMusic(mmusic, mflags, looping);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
S_StopMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-25 19:24:50 +00:00
|
|
|
}
|
2019-01-06 04:42:25 +00:00
|
|
|
|
2019-07-29 23:02:45 +00:00
|
|
|
#ifdef HAVE_OPENMPT
|
2019-01-06 04:42:25 +00:00
|
|
|
void ModFilter_OnChange(void)
|
|
|
|
{
|
2019-05-21 03:22:23 +00:00
|
|
|
if (openmpt_mhandle)
|
|
|
|
openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
|
2019-07-29 23:02:45 +00:00
|
|
|
}
|
2019-08-07 16:39:51 +00:00
|
|
|
#endif
|