mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-24 17:02:35 +00:00
Merge master
This commit is contained in:
commit
fda698a290
19 changed files with 175 additions and 434 deletions
22
src/d_main.c
22
src/d_main.c
|
|
@ -122,9 +122,6 @@ INT32 postimgparam[MAXSPLITSCREENPLAYERS];
|
|||
// whether the respective sound system is disabled
|
||||
// or they're init'ed, but the player just toggled them
|
||||
|
||||
#ifndef NO_MIDI
|
||||
boolean midi_disabled = true;
|
||||
#endif
|
||||
boolean sound_disabled = false;
|
||||
boolean digital_disabled = false;
|
||||
|
||||
|
|
@ -1618,18 +1615,12 @@ void D_SRB2Main(void)
|
|||
{
|
||||
sound_disabled = true;
|
||||
digital_disabled = true;
|
||||
#ifndef NO_MIDI
|
||||
midi_disabled = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (M_CheckParm("-noaudio")) // combines -nosound and -nomusic
|
||||
{
|
||||
sound_disabled = true;
|
||||
digital_disabled = true;
|
||||
#ifndef NO_MIDI
|
||||
midi_disabled = true;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1638,25 +1629,14 @@ void D_SRB2Main(void)
|
|||
if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
|
||||
{
|
||||
digital_disabled = true;
|
||||
#ifndef NO_MIDI
|
||||
midi_disabled = true;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef NO_MIDI
|
||||
if (M_CheckParm("-nomidimusic"))
|
||||
midi_disabled = true; // WARNING: DOS version initmusic in I_StartupSound
|
||||
#endif
|
||||
if (M_CheckParm("-nodigmusic"))
|
||||
digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound
|
||||
}
|
||||
}
|
||||
if (!( sound_disabled && digital_disabled
|
||||
#ifndef NO_MIDI
|
||||
&& midi_disabled
|
||||
#endif
|
||||
))
|
||||
if (!( sound_disabled && digital_disabled ))
|
||||
{
|
||||
CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n");
|
||||
I_StartupSound();
|
||||
|
|
|
|||
|
|
@ -987,9 +987,6 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_soundvolume);
|
||||
CV_RegisterVar(&cv_closedcaptioning);
|
||||
CV_RegisterVar(&cv_digmusicvolume);
|
||||
#ifndef NO_MIDI
|
||||
CV_RegisterVar(&cv_midimusicvolume);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_numChannels);
|
||||
|
||||
// screen.c
|
||||
|
|
|
|||
|
|
@ -58,11 +58,7 @@ typedef enum
|
|||
//
|
||||
typedef enum
|
||||
{
|
||||
// Cvars
|
||||
PF_FLIPCAM = 1, // Flip camera angle with gravity flip prefrence.
|
||||
PF_ANALOGMODE = 1<<1, // Analog mode?
|
||||
PF_DIRECTIONCHAR = 1<<2, // Directional character sprites?
|
||||
PF_AUTOBRAKE = 1<<3, // Autobrake?
|
||||
PF_FAULT = 1,
|
||||
|
||||
// Cheats
|
||||
PF_GODMODE = 1<<4,
|
||||
|
|
@ -290,6 +286,25 @@ typedef enum
|
|||
NUMKARTSHIELDS
|
||||
} kartshields_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KSPIN_THRUST = (1<<0),
|
||||
KSPIN_IFRAMES = (1<<1),
|
||||
KSPIN_AIRTIMER = (1<<2),
|
||||
|
||||
KSPIN_TYPEBIT = (1<<3),
|
||||
KSPIN_TYPEMASK = ~( KSPIN_TYPEBIT - 1 ),
|
||||
|
||||
#define KSPIN_TYPE( type ) ( KSPIN_TYPEBIT << type )
|
||||
|
||||
KSPIN_SPINOUT = KSPIN_TYPE(0)|KSPIN_IFRAMES|KSPIN_THRUST,
|
||||
KSPIN_WIPEOUT = KSPIN_TYPE(1)|KSPIN_IFRAMES,
|
||||
KSPIN_STUNG = KSPIN_TYPE(2),
|
||||
KSPIN_EXPLOSION = KSPIN_TYPE(3)|KSPIN_IFRAMES|KSPIN_AIRTIMER,
|
||||
|
||||
#undef KSPIN_TYPE
|
||||
} kartspinoutflags_t;
|
||||
|
||||
//{ SRB2kart - kartstuff
|
||||
typedef enum
|
||||
{
|
||||
|
|
@ -303,7 +318,7 @@ typedef enum
|
|||
k_instashield, // Instashield no-damage animation timer
|
||||
|
||||
k_floorboost, // Prevents Sneaker sounds for a breif duration when triggered by a floor panel
|
||||
k_spinouttype, // Determines whether to thrust forward or not while spinning out; 0 = move forwards, 1 = stay still, 2 = stay still & no flashing tics
|
||||
k_spinouttype, // Determines the mode of spinout/wipeout, see kartspinoutflags_t
|
||||
|
||||
k_drift, // Drifting Left or Right, plus a bigger counter = sharper turn
|
||||
k_driftend, // Drift has ended, used to adjust character angle after drift
|
||||
|
|
|
|||
|
|
@ -10494,9 +10494,7 @@ static const char *const MAPTHINGFLAG_LIST[4] = {
|
|||
};
|
||||
|
||||
static const char *const PLAYERFLAG_LIST[] = {
|
||||
|
||||
// Cvars
|
||||
"FLIPCAM", // Flip camera angle with gravity flip prefrence.
|
||||
"FAULT",
|
||||
"ANALOGMODE", // Analog mode?
|
||||
"DIRECTIONCHAR", // Directional character sprites?
|
||||
"AUTOBRAKE", // Autobrake?
|
||||
|
|
@ -11599,6 +11597,19 @@ struct {
|
|||
{"KSHIELD_FLAME",KSHIELD_FLAME},
|
||||
{"NUMKARTSHIELDS",NUMKARTSHIELDS},
|
||||
|
||||
// kartspinoutflags_t
|
||||
{"KSPIN_THRUST",KSPIN_THRUST},
|
||||
{"KSPIN_IFRAMES",KSPIN_IFRAMES},
|
||||
{"KSPIN_AIRTIMER",KSPIN_AIRTIMER},
|
||||
|
||||
{"KSPIN_TYPEBIT",KSPIN_TYPEBIT},
|
||||
{"KSPIN_TYPEMASK",KSPIN_TYPEMASK},
|
||||
|
||||
{"KSPIN_SPINOUT",KSPIN_SPINOUT},
|
||||
{"KSPIN_WIPEOUT",KSPIN_WIPEOUT},
|
||||
{"KSPIN_STUNG",KSPIN_STUNG},
|
||||
{"KSPIN_EXPLOSION",KSPIN_EXPLOSION},
|
||||
|
||||
// translation colormaps
|
||||
{"TC_DEFAULT",TC_DEFAULT},
|
||||
{"TC_BOSS",TC_BOSS},
|
||||
|
|
|
|||
|
|
@ -631,6 +631,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
|||
/// OpenGL shaders
|
||||
#define GL_SHADERS
|
||||
|
||||
|
||||
/// Handle touching sector specials in P_PlayerAfterThink instead of P_PlayerThink.
|
||||
/// \note Required for proper collision with moving sloped surfaces that have sector specials on them.
|
||||
#define SECTORSPECIALSAFTERTHINK
|
||||
|
|
@ -655,8 +656,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
|||
/// Camera always has noclip.
|
||||
#define NOCLIPCAM
|
||||
|
||||
/// MIDI support is really shitty -- we don't use it anyway, so lets throw it behind a define
|
||||
#define NO_MIDI
|
||||
/// Divide volume of music and sounds by this much (loudest sounds on earth)
|
||||
#define VOLUME_DIVIDER 4
|
||||
#define USER_VOLUME_SCALE 2
|
||||
#define MAX_VOLUME ( 100 * VOLUME_DIVIDER / USER_VOLUME_SCALE )
|
||||
|
||||
#if defined (HAVE_CURL) && ! defined (NONET)
|
||||
#define MASTERSERVER
|
||||
|
|
|
|||
|
|
@ -130,11 +130,6 @@ extern boolean forceresetplayers, deferencoremode;
|
|||
// Internal parameters for sound rendering.
|
||||
// ========================================
|
||||
|
||||
#ifdef NO_MIDI
|
||||
#define midi_disabled true
|
||||
#else
|
||||
extern boolean midi_disabled;
|
||||
#endif
|
||||
extern boolean sound_disabled;
|
||||
extern boolean digital_disabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -2089,8 +2089,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
|||
splitscreenindex = players[player].splitscreenindex;
|
||||
spectator = players[player].spectator;
|
||||
|
||||
pflags = (players[player].pflags & (PF_WANTSTOJOIN|PF_GAMETYPEOVER));
|
||||
|
||||
pflags = (players[player].pflags & (PF_WANTSTOJOIN|PF_GAMETYPEOVER|PF_FAULT));
|
||||
playerangleturn = players[player].angleturn;
|
||||
|
||||
// As long as we're not in multiplayer, carry over cheatcodes from map to map
|
||||
|
|
@ -4394,7 +4393,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
|||
memset(&players[i].respawn, 0, sizeof (players[i].respawn));
|
||||
|
||||
// The latter two should clear by themselves, but just in case
|
||||
players[i].pflags &= ~(PF_GAMETYPEOVER|PF_FULLSTASIS);
|
||||
players[i].pflags &= ~(PF_GAMETYPEOVER|PF_FULLSTASIS|PF_FAULT);
|
||||
|
||||
// Clear cheatcodes too, just in case.
|
||||
players[i].pflags &= ~(PF_GODMODE|PF_NOCLIP|PF_INVIS);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch);
|
|||
|
||||
\return void
|
||||
*/
|
||||
void I_SetSfxVolume(UINT8 volume);
|
||||
void I_SetSfxVolume(int volume);
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SYSTEM
|
||||
|
|
@ -229,7 +229,7 @@ void I_ResumeSong(void);
|
|||
|
||||
\return void
|
||||
*/
|
||||
void I_SetMusicVolume(UINT8 volume);
|
||||
void I_SetMusicVolume(int volume);
|
||||
|
||||
boolean I_SetSongTrack(INT32 track);
|
||||
|
||||
|
|
|
|||
12
src/k_kart.c
12
src/k_kart.c
|
|
@ -2473,7 +2473,7 @@ void K_SpinPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 typ
|
|||
|
||||
player->kartstuff[k_spinouttype] = type;
|
||||
|
||||
if (player->kartstuff[k_spinouttype] <= 0) // type 0 is spinout, type 1 is wipeout, type 2 is no-invuln wipeout
|
||||
if (( player->kartstuff[k_spinouttype] & KSPIN_THRUST ))
|
||||
{
|
||||
// At spinout, player speed is increased to 1/4 their regular speed, moving them forward
|
||||
if (player->speed < K_GetKartSpeed(player, true)/4)
|
||||
|
|
@ -2536,7 +2536,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) // A b
|
|||
player->mo->momz = 18*mapobjectscale*P_MobjFlip(player->mo); // please stop forgetting mobjflip checks!!!!
|
||||
player->mo->momx = player->mo->momy = 0;
|
||||
|
||||
player->kartstuff[k_spinouttype] = 1;
|
||||
player->kartstuff[k_spinouttype] = KSPIN_EXPLOSION;
|
||||
player->kartstuff[k_spinouttimer] = (3*TICRATE/2)+2;
|
||||
|
||||
if (inflictor && !P_MobjWasRemoved(inflictor))
|
||||
|
|
@ -3378,7 +3378,7 @@ void K_DriftDustHandling(mobj_t *spawner)
|
|||
|
||||
if (spawner->player)
|
||||
{
|
||||
if (spawner->player->pflags & PF_WPNDOWN)
|
||||
if (spawner->player->pflags & PF_FAULT)
|
||||
{
|
||||
anglediff = abs((signed)(spawner->angle - spawner->player->drawangle));
|
||||
if (leveltime % 6 == 0)
|
||||
|
|
@ -5173,7 +5173,7 @@ void K_KartPlayerHUDUpdate(player_t *player)
|
|||
if (player->karthud[khud_tauntvoices])
|
||||
player->karthud[khud_tauntvoices]--;
|
||||
|
||||
if (!(player->pflags & PF_WPNDOWN))
|
||||
if (!(player->pflags & PF_FAULT))
|
||||
player->karthud[khud_fault] = 0;
|
||||
else if (player->karthud[khud_fault] > 0 && player->karthud[khud_fault] < 2*TICRATE)
|
||||
player->karthud[khud_fault]++;
|
||||
|
|
@ -5564,7 +5564,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
player->karthud[khud_timeovercam] = 0;
|
||||
|
||||
// Specific hack because it insists on setting flashing tics during this anyway...
|
||||
if (player->kartstuff[k_spinouttype] == 2)
|
||||
if (( player->kartstuff[k_spinouttype] & KSPIN_IFRAMES ) == 0)
|
||||
{
|
||||
player->powers[pw_flashing] = 0;
|
||||
}
|
||||
|
|
@ -5583,7 +5583,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
if (player->kartstuff[k_spinouttimer])
|
||||
{
|
||||
if ((P_IsObjectOnGround(player->mo)
|
||||
|| (player->kartstuff[k_spinouttype] != 0))
|
||||
|| ( player->kartstuff[k_spinouttype] & KSPIN_AIRTIMER ))
|
||||
&& (!player->kartstuff[k_sneakertimer]))
|
||||
{
|
||||
player->kartstuff[k_spinouttimer]--;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ void K_DoIngameRespawn(player_t *player)
|
|||
return;
|
||||
}
|
||||
|
||||
if (player->respawn.state != RESPAWNST_NONE)
|
||||
if (player->respawn.state != RESPAWNST_NONE &&
|
||||
( player->pflags & PF_FAULT ) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -110,7 +111,7 @@ void K_DoIngameRespawn(player_t *player)
|
|||
if (leveltime < starttime) // FAULT
|
||||
{
|
||||
player->powers[pw_nocontrol] = (starttime - leveltime) + 50;
|
||||
player->pflags |= PF_WPNDOWN; // cheeky pflag reuse
|
||||
player->pflags |= PF_FAULT;
|
||||
S_StartSound(player->mo, sfx_s3k83);
|
||||
player->karthud[khud_fault] = 1;
|
||||
}
|
||||
|
|
@ -191,6 +192,8 @@ void K_DoIngameRespawn(player_t *player)
|
|||
player->respawn.pointx = beststart->x << FRACBITS;
|
||||
player->respawn.pointy = beststart->y << FRACBITS;
|
||||
|
||||
player->mo->angle = ( beststart->angle * ANG1 );
|
||||
|
||||
s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector;
|
||||
|
||||
player->respawn.flip = (beststart->options & MTF_OBJECTFLIP);
|
||||
|
|
|
|||
|
|
@ -2455,8 +2455,6 @@ static int lib_sMusicName(lua_State *L)
|
|||
|
||||
static int lib_sMusicExists(lua_State *L)
|
||||
{
|
||||
boolean checkMIDI = lua_opttrueboolean(L, 2);
|
||||
boolean checkDigi = lua_opttrueboolean(L, 3);
|
||||
#ifdef MUSICSLOT_COMPATIBILITY
|
||||
const char *music_name;
|
||||
UINT32 music_num;
|
||||
|
|
@ -2485,7 +2483,7 @@ static int lib_sMusicExists(lua_State *L)
|
|||
const char *music_name = luaL_checkstring(L, 1);
|
||||
#endif
|
||||
NOHUD
|
||||
lua_pushboolean(L, S_MusicExists(music_name, checkMIDI, checkDigi));
|
||||
lua_pushboolean(L, S_MusicExists(music_name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/m_menu.c
12
src/m_menu.c
|
|
@ -2457,6 +2457,11 @@ static void M_ChangeCvar(INT32 choice)
|
|||
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER)
|
||||
||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD))
|
||||
{
|
||||
if (cv == &cv_digmusicvolume || cv == &cv_soundvolume)
|
||||
{
|
||||
choice *= 5;
|
||||
}
|
||||
|
||||
CV_SetValue(cv,cv->value+choice);
|
||||
}
|
||||
else if (cv->flags & CV_FLOAT)
|
||||
|
|
@ -6662,17 +6667,10 @@ static void M_DrawSkyRoom(void)
|
|||
(digital_disabled ? warningflags : highlightflags),
|
||||
(digital_disabled ? "OFF" : "ON"));
|
||||
|
||||
/*V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x,
|
||||
currentMenu->y+currentMenu->menuitems[5].alphaKey,
|
||||
(midi_disabled ? warningflags : highlightflags),
|
||||
(midi_disabled ? "OFF" : "ON"));*/
|
||||
|
||||
if (itemOn == 0)
|
||||
lengthstring = 8*(sound_disabled ? 3 : 2);
|
||||
else if (itemOn == 2)
|
||||
lengthstring = 8*(digital_disabled ? 3 : 2);
|
||||
/*else if (itemOn == 5)
|
||||
lengthstring = 8*(midi_disabled ? 3 : 2);*/
|
||||
}
|
||||
|
||||
for (i = 0; i < currentMenu->numitems; ++i)
|
||||
|
|
|
|||
|
|
@ -3479,7 +3479,7 @@ void A_BossDeath(mobj_t *mo)
|
|||
EV_DoElevator(&junk, elevateHighest, false);
|
||||
|
||||
if (mapheaderinfo[gamemap-1]->muspostbossname[0] &&
|
||||
S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname, !midi_disabled, !digital_disabled))
|
||||
S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname))
|
||||
{
|
||||
// Touching the egg trap button calls P_DoPlayerExit, which calls P_RestoreMusic.
|
||||
// So just park ourselves in the mapmus variables.
|
||||
|
|
|
|||
10
src/p_user.c
10
src/p_user.c
|
|
@ -2177,7 +2177,7 @@ void P_MovePlayer(player_t *player)
|
|||
else
|
||||
player->drawangle -= (ANGLE_11hh * speed);
|
||||
}
|
||||
else if (player->powers[pw_nocontrol] && player->pflags & PF_WPNDOWN)
|
||||
else if (player->pflags & PF_FAULT)
|
||||
{
|
||||
P_SetPlayerMobjState(player->mo, S_KART_SPINOUT);
|
||||
|
||||
|
|
@ -2542,6 +2542,12 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius)
|
|||
if (P_AproxDistance(P_AproxDistance(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius)
|
||||
continue;
|
||||
|
||||
if (mo->type == MT_SPB) // If you destroy a SPB, you don't get the luxury of a cooldown.
|
||||
{
|
||||
spbplace = -1;
|
||||
indirectitemcooldown = 0;
|
||||
}
|
||||
|
||||
if (mo->flags & MF_BOSS || mo->type == MT_PLAYER) //don't OHKO bosses nor players!
|
||||
P_DamageMobj(mo, inflictor, source, 1, DMG_NORMAL|DMG_CANTHURTSELF);
|
||||
else
|
||||
|
|
@ -4502,7 +4508,7 @@ void P_PlayerThink(player_t *player)
|
|||
if (player->powers[pw_nocontrol] & ((1<<15)-1) && player->powers[pw_nocontrol] < UINT16_MAX)
|
||||
{
|
||||
if (!(--player->powers[pw_nocontrol]))
|
||||
player->pflags &= ~PF_WPNDOWN;
|
||||
player->pflags &= ~PF_FAULT;
|
||||
}
|
||||
else
|
||||
player->powers[pw_nocontrol] = 0;
|
||||
|
|
|
|||
257
src/s_sound.c
257
src/s_sound.c
|
|
@ -38,20 +38,14 @@
|
|||
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}};
|
||||
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {MAX_VOLUME, "MAX"}, {0, NULL}};
|
||||
static void SetChannelsNum(void);
|
||||
static void Command_Tunes_f(void);
|
||||
static void Command_RestartAudio_f(void);
|
||||
|
||||
// Sound system toggles
|
||||
#ifndef NO_MIDI
|
||||
static void GameMIDIMusic_OnChange(void);
|
||||
#endif
|
||||
static void GameSounds_OnChange(void);
|
||||
static void GameDigiMusic_OnChange(void);
|
||||
#ifndef NO_MIDI
|
||||
static void MusicPref_OnChange(void);
|
||||
#endif
|
||||
|
||||
static void PlayMusicIfUnfocused_OnChange(void);
|
||||
static void PlaySoundIfUnfocused_OnChange(void);
|
||||
|
|
@ -81,12 +75,8 @@ consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, N
|
|||
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
|
||||
consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#ifndef NO_MIDI
|
||||
consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
consvar_t cv_soundvolume = {"soundvolume", "50", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_digmusicvolume = {"musicvolume", "50", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// number of channels available
|
||||
consvar_t cv_numChannels = {"snd_channels", "64", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
|
@ -104,21 +94,8 @@ consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_
|
|||
|
||||
// Sound system toggles, saved into the config
|
||||
consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
#ifndef NO_MIDI
|
||||
consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#ifndef NO_MIDI
|
||||
// Music preference
|
||||
static CV_PossibleValue_t cons_musicpref_t[] = {
|
||||
{0, "Digital"},
|
||||
{1, "MIDI"},
|
||||
{0, NULL}
|
||||
};
|
||||
consvar_t cv_musicpref = {"musicpref", "Digital", CV_SAVE|CV_CALL|CV_NOINIT, cons_musicpref_t, MusicPref_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
static CV_PossibleValue_t music_resync_threshold_cons_t[] = {
|
||||
{0, "MIN"},
|
||||
{1000, "MAX"},
|
||||
|
|
@ -290,10 +267,6 @@ void S_RegisterSoundStuff(void)
|
|||
CV_RegisterVar(&cv_playmusicifunfocused);
|
||||
CV_RegisterVar(&cv_gamesounds);
|
||||
CV_RegisterVar(&cv_gamedigimusic);
|
||||
#ifndef NO_MIDI
|
||||
CV_RegisterVar(&cv_gamemidimusic);
|
||||
CV_RegisterVar(&cv_musicpref);
|
||||
#endif
|
||||
|
||||
CV_RegisterVar(&cv_music_resync_threshold);
|
||||
CV_RegisterVar(&cv_music_resync_powerups_only);
|
||||
|
|
@ -301,11 +274,6 @@ void S_RegisterSoundStuff(void)
|
|||
#ifdef HAVE_OPENMPT
|
||||
CV_RegisterVar(&cv_modfilter);
|
||||
#endif
|
||||
#ifdef HAVE_MIXERX
|
||||
CV_RegisterVar(&cv_midiplayer);
|
||||
CV_RegisterVar(&cv_midisoundfontpath);
|
||||
CV_RegisterVar(&cv_miditimiditypath);
|
||||
#endif
|
||||
|
||||
COM_AddCommand("tunes", Command_Tunes_f);
|
||||
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
||||
|
|
@ -950,9 +918,6 @@ void S_StopSound(void *origin)
|
|||
//
|
||||
static INT32 actualsfxvolume; // check for change through console
|
||||
static INT32 actualdigmusicvolume;
|
||||
#ifndef NO_MIDI
|
||||
static INT32 actualmidimusicvolume;
|
||||
#endif
|
||||
|
||||
void S_UpdateSounds(void)
|
||||
{
|
||||
|
|
@ -979,10 +944,6 @@ void S_UpdateSounds(void)
|
|||
S_SetSfxVolume (cv_soundvolume.value);
|
||||
if (actualdigmusicvolume != cv_digmusicvolume.value)
|
||||
S_SetDigMusicVolume (cv_digmusicvolume.value);
|
||||
#ifndef NO_MIDI
|
||||
if (actualmidimusicvolume != cv_midimusicvolume.value)
|
||||
S_SetMIDIMusicVolume (cv_midimusicvolume.value);
|
||||
#endif
|
||||
|
||||
// We're done now, if we're not in a level.
|
||||
if (gamestate != GS_LEVEL)
|
||||
|
|
@ -1241,17 +1202,14 @@ void S_UpdateClosedCaptions(void)
|
|||
|
||||
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
|
||||
CV_SetValue(&cv_soundvolume, volume);
|
||||
actualsfxvolume = cv_soundvolume.value * USER_VOLUME_SCALE;
|
||||
|
||||
#ifdef HW3SOUND
|
||||
hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F);
|
||||
#else
|
||||
// now hardware volume
|
||||
I_SetSfxVolume(volume&0x1F);
|
||||
I_SetSfxVolume(volume);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1654,6 +1612,7 @@ enum
|
|||
|
||||
musicdef_t *musicdefstart = NULL;
|
||||
struct cursongcredit cursongcredit; // Currently displayed song credit info
|
||||
int musicdef_volume;
|
||||
|
||||
//
|
||||
// search for music definition in wad
|
||||
|
|
@ -1762,6 +1721,8 @@ void S_LoadMusicDefs(UINT16 wadnum)
|
|||
}
|
||||
}
|
||||
|
||||
def->volume = DEFAULT_MUSICDEF_VOLUME;
|
||||
|
||||
skip_lump:
|
||||
stoken = strtok(NULL, "\r\n ");
|
||||
line++;
|
||||
|
|
@ -1796,6 +1757,8 @@ skip_lump:
|
|||
for (value = def->source; *value; value++)
|
||||
if (*value == '_') *value = ' '; // turn _ into spaces.
|
||||
//CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source);
|
||||
} else if (!stricmp(stoken, "volume")) {
|
||||
def->volume = atoi(value);
|
||||
} else {
|
||||
CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line);
|
||||
}
|
||||
|
|
@ -1861,14 +1824,9 @@ boolean S_DigMusicDisabled(void)
|
|||
return digital_disabled;
|
||||
}
|
||||
|
||||
boolean S_MIDIMusicDisabled(void)
|
||||
{
|
||||
return midi_disabled; // SRB2Kart: defined as "true" w/ NO_MIDI
|
||||
}
|
||||
|
||||
boolean S_MusicDisabled(void)
|
||||
{
|
||||
return (midi_disabled && digital_disabled);
|
||||
return digital_disabled;
|
||||
}
|
||||
|
||||
boolean S_MusicPlaying(void)
|
||||
|
|
@ -1898,12 +1856,22 @@ const char *S_MusicName(void)
|
|||
return music_name;
|
||||
}
|
||||
|
||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
|
||||
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
|
||||
{
|
||||
return (
|
||||
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|
||||
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
|
||||
);
|
||||
if (!I_SongPlaying())
|
||||
return false;
|
||||
|
||||
strncpy(mname, music_name, 7);
|
||||
mname[6] = 0;
|
||||
*mflags = music_flags;
|
||||
*looping = music_looping;
|
||||
|
||||
return (boolean)mname[0];
|
||||
}
|
||||
|
||||
boolean S_MusicExists(const char *mname)
|
||||
{
|
||||
return W_CheckNumForName(va("O_%s", mname)) != LUMPERROR;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
|
@ -2093,7 +2061,7 @@ static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT1
|
|||
{
|
||||
if (P_EvaluateMusicStatus(mst->status, mst->musname))
|
||||
{
|
||||
if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia
|
||||
if (!S_MusicExists(mst->musname)) // paranoia
|
||||
S_RemoveMusicStackEntry(mst); // then continue
|
||||
else
|
||||
return mst;
|
||||
|
|
@ -2138,17 +2106,13 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
|
|||
boolean mapmuschanged = false;
|
||||
musicstack_t *result;
|
||||
musicstack_t *entry = Z_Calloc(sizeof (*result), PU_MUSIC, NULL);
|
||||
#ifndef NO_MIDI
|
||||
boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX);
|
||||
boolean midipref = cv_musicpref.value;
|
||||
#endif
|
||||
|
||||
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))
|
||||
if (result && !S_MusicExists(result->musname))
|
||||
{
|
||||
Z_Free(entry);
|
||||
return false; // music doesn't exist, so don't do anything
|
||||
|
|
@ -2196,11 +2160,7 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (strncmp(entry->musname, S_MusicName(), 7) // don't restart music if we're already playing it
|
||||
#ifndef NO_MIDI
|
||||
|| (midipref != currentmidi && S_PrefAvailable(midipref, entry->musname)) // but do if the user's preference has changed
|
||||
#endif
|
||||
)
|
||||
if (strncmp(entry->musname, S_MusicName(), 7)) // don't restart music if we're already playing it
|
||||
{
|
||||
if (music_stack_fadeout)
|
||||
S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, music_stack_fadeout, 0);
|
||||
|
|
@ -2247,17 +2207,8 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
|
|||
|
||||
static lumpnum_t S_GetMusicLumpNum(const char *mname)
|
||||
{
|
||||
#ifndef NO_MIDI
|
||||
boolean midipref = cv_musicpref.value;
|
||||
|
||||
if (S_PrefAvailable(midipref, mname))
|
||||
return W_GetNumForName(va(midipref ? "d_%s":"o_%s", mname));
|
||||
else if (S_PrefAvailable(!midipref, mname))
|
||||
return W_GetNumForName(va(midipref ? "o_%s":"d_%s", mname));
|
||||
#else
|
||||
if (S_DigExists(mname))
|
||||
if (S_MusicExists(mname))
|
||||
return W_GetNumForName(va("o_%s", mname));
|
||||
#endif
|
||||
else
|
||||
return LUMPERROR;
|
||||
}
|
||||
|
|
@ -2272,14 +2223,7 @@ static boolean S_LoadMusic(const char *mname)
|
|||
|
||||
mlumpnum = S_GetMusicLumpNum(mname);
|
||||
|
||||
if (!S_DigExists(mname) && S_MIDIExists(mname))
|
||||
{
|
||||
#ifdef NO_MIDI
|
||||
CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else if (mlumpnum == LUMPERROR)
|
||||
if (mlumpnum == LUMPERROR)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: lump not found!\n", mname);
|
||||
return false;
|
||||
|
|
@ -2288,7 +2232,6 @@ static boolean S_LoadMusic(const char *mname)
|
|||
// load & register it
|
||||
mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC);
|
||||
|
||||
|
||||
if (I_LoadSong(mdata, W_LumpLength(mlumpnum)))
|
||||
{
|
||||
strncpy(music_name, mname, 7);
|
||||
|
|
@ -2386,10 +2329,6 @@ static void S_ChangeMusicToQueue(void)
|
|||
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms)
|
||||
{
|
||||
char newmusic[7];
|
||||
#ifndef NO_MIDI
|
||||
boolean currentmidi = (I_SongType() == MU_MID || I_SongType() == MU_MID_EX);
|
||||
boolean midipref = cv_musicpref.value;
|
||||
#endif
|
||||
|
||||
if (S_MusicDisabled()
|
||||
|| demo.rewinding // Don't mess with music while rewinding!
|
||||
|
|
@ -2421,11 +2360,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
|||
I_FadeSong(0, prefadems, S_ChangeMusicToQueue);
|
||||
return;
|
||||
}
|
||||
else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)
|
||||
#ifndef NO_MIDI
|
||||
|| (midipref != currentmidi && S_PrefAvailable(midipref, newmusic))
|
||||
#endif
|
||||
)
|
||||
else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET))
|
||||
{
|
||||
CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic);
|
||||
|
||||
|
|
@ -2437,6 +2372,19 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
|||
music_flags = mflags;
|
||||
music_looping = looping;
|
||||
|
||||
musicdef_volume = DEFAULT_MUSICDEF_VOLUME;
|
||||
|
||||
{
|
||||
musicdef_t *def;
|
||||
for (def = musicdefstart; def; def = def->next)
|
||||
{
|
||||
if (strcasecmp(def->name, music_name) == 0)
|
||||
{
|
||||
musicdef_volume = def->volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!S_PlayMusic(looping, fadeinms))
|
||||
return;
|
||||
|
||||
|
|
@ -2539,44 +2487,14 @@ void S_EnableSound(void)
|
|||
}
|
||||
}
|
||||
|
||||
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
||||
void S_SetMusicVolume(INT32 digvolume)
|
||||
{
|
||||
if (digvolume < 0)
|
||||
digvolume = cv_digmusicvolume.value;
|
||||
|
||||
#ifdef NO_MIDI
|
||||
(void)seqvolume;
|
||||
#else
|
||||
if (seqvolume < 0)
|
||||
seqvolume = cv_midimusicvolume.value;
|
||||
#endif
|
||||
|
||||
if (digvolume < 0 || digvolume > 31)
|
||||
CONS_Alert(CONS_WARNING, "digmusicvolume should be between 0-31\n");
|
||||
CV_SetValue(&cv_digmusicvolume, digvolume&31);
|
||||
actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var
|
||||
|
||||
#ifndef NO_MIDI
|
||||
if (seqvolume < 0 || seqvolume > 31)
|
||||
CONS_Alert(CONS_WARNING, "midimusicvolume should be between 0-31\n");
|
||||
CV_SetValue(&cv_midimusicvolume, seqvolume&31);
|
||||
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
|
||||
#endif
|
||||
|
||||
switch(I_SongType())
|
||||
{
|
||||
#ifndef NO_MIDI
|
||||
case MU_MID:
|
||||
case MU_MID_EX:
|
||||
//case MU_MOD:
|
||||
//case MU_GME:
|
||||
I_SetMusicVolume(seqvolume&31);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
I_SetMusicVolume(digvolume&31);
|
||||
break;
|
||||
}
|
||||
CV_SetValue(&cv_digmusicvolume, digvolume);
|
||||
actualdigmusicvolume = cv_digmusicvolume.value * USER_VOLUME_SCALE;
|
||||
I_SetMusicVolume(digvolume);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -2759,11 +2677,7 @@ static void Command_RestartAudio_f(void)
|
|||
// These must be called or no sound and music until manually set.
|
||||
|
||||
I_SetSfxVolume(cv_soundvolume.value);
|
||||
#ifdef NO_MIDI
|
||||
S_SetMusicVolume(cv_digmusicvolume.value, -1);
|
||||
#else
|
||||
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
|
||||
#endif
|
||||
S_SetMusicVolume(cv_digmusicvolume.value);
|
||||
|
||||
S_StartSound(NULL, sfx_strpst);
|
||||
|
||||
|
|
@ -2809,11 +2723,7 @@ void GameDigiMusic_OnChange(void)
|
|||
{
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
}
|
||||
else if (
|
||||
#ifndef NO_MIDI
|
||||
(!cv_musicpref.value || midi_disabled) &&
|
||||
#endif
|
||||
S_DigExists("_title"))
|
||||
else if (S_MusicExists("_title"))
|
||||
{
|
||||
S_ChangeMusicInternal("_title", looptitle);
|
||||
}
|
||||
|
|
@ -2821,57 +2731,10 @@ void GameDigiMusic_OnChange(void)
|
|||
else
|
||||
{
|
||||
digital_disabled = true;
|
||||
if (S_MusicType() != MU_MID && S_MusicType() != MU_MID_EX)
|
||||
{
|
||||
S_StopMusic();
|
||||
if (!midi_disabled)
|
||||
{
|
||||
if (Playing())
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
else
|
||||
S_ChangeMusicInternal("_clear", false);
|
||||
}
|
||||
}
|
||||
S_StopMusic();
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_MIDI
|
||||
void GameMIDIMusic_OnChange(void)
|
||||
{
|
||||
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio"))
|
||||
return;
|
||||
else if (M_CheckParm("-nomidimusic"))
|
||||
return;
|
||||
|
||||
if (midi_disabled)
|
||||
{
|
||||
midi_disabled = false;
|
||||
I_StartupSound(); // will return early if initialised
|
||||
I_InitMusic();
|
||||
|
||||
if (Playing())
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
else if ((cv_musicpref.value || digital_disabled) && S_MIDIExists("_clear"))
|
||||
S_ChangeMusicInternal("_clear", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
midi_disabled = true;
|
||||
if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX)
|
||||
{
|
||||
S_StopMusic();
|
||||
if (!digital_disabled)
|
||||
{
|
||||
if (Playing())
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
else
|
||||
S_ChangeMusicInternal("_clear", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void PlayMusicIfUnfocused_OnChange(void)
|
||||
{
|
||||
if (window_notinfocus)
|
||||
|
|
@ -2897,20 +2760,6 @@ static void PlaySoundIfUnfocused_OnChange(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NO_MIDI
|
||||
void MusicPref_OnChange(void)
|
||||
{
|
||||
if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio") ||
|
||||
M_CheckParm("-nomidimusic") || M_CheckParm("-nodigmusic"))
|
||||
return;
|
||||
|
||||
if (Playing())
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
else if (S_PrefAvailable(cv_musicpref.value, "_clear"))
|
||||
S_ChangeMusicInternal("_clear", false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENMPT
|
||||
void ModFilter_OnChange(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,23 +28,20 @@ extern openmpt_module *openmpt_mhandle;
|
|||
// mask used to indicate sound origin is player item pickup
|
||||
#define PICKUP_SOUND 0x8000
|
||||
|
||||
//
|
||||
#define SOUND_VOLUME_RANGE 256
|
||||
#define MAX_SOUND_VOLUME 255
|
||||
|
||||
#define DEFAULT_MUSICDEF_VOLUME ( 100 / VOLUME_DIVIDER )
|
||||
|
||||
extern consvar_t stereoreverse;
|
||||
extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume;
|
||||
|
||||
#ifndef NO_MIDI
|
||||
extern consvar_t cv_midimusicvolume;
|
||||
#endif
|
||||
|
||||
extern consvar_t surround;
|
||||
extern consvar_t cv_numChannels;
|
||||
|
||||
extern consvar_t cv_gamedigimusic;
|
||||
|
||||
#ifndef NO_MIDI
|
||||
extern consvar_t cv_gamemidimusic;
|
||||
extern consvar_t cv_musicpref;
|
||||
#endif
|
||||
|
||||
extern consvar_t cv_gamesounds;
|
||||
extern consvar_t cv_playmusicifunfocused;
|
||||
extern consvar_t cv_playsoundifunfocused;
|
||||
|
|
@ -56,12 +53,6 @@ extern consvar_t cv_music_resync_powerups_only;
|
|||
extern consvar_t cv_modfilter;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
extern consvar_t cv_midiplayer;
|
||||
extern consvar_t cv_midisoundfontpath;
|
||||
extern consvar_t cv_miditimiditypath;
|
||||
#endif
|
||||
|
||||
extern CV_PossibleValue_t soundvolume_cons_t[];
|
||||
|
||||
typedef enum
|
||||
|
|
@ -156,26 +147,15 @@ void S_StopSound(void *origin);
|
|||
//
|
||||
|
||||
boolean S_DigMusicDisabled(void);
|
||||
boolean S_MIDIMusicDisabled(void);
|
||||
boolean S_MusicDisabled(void);
|
||||
boolean S_MusicPlaying(void);
|
||||
boolean S_MusicPaused(void);
|
||||
boolean S_MusicNotInFocus(void);
|
||||
musictype_t S_MusicType(void);
|
||||
const char *S_MusicName(void);
|
||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
|
||||
#define S_DigExists(a) S_MusicExists(a, false, true)
|
||||
#define S_MIDIExists(a) S_MusicExists(a, true, false)
|
||||
|
||||
// Returns whether the preferred format a (true = MIDI, false = Digital)
|
||||
// exists and is enabled for musicname b
|
||||
#ifdef NO_MIDI
|
||||
|
||||
#define S_PrefAvailable(a, b) (a ? \
|
||||
(!S_MIDIMusicDisabled() && S_MIDIExists(b)) : \
|
||||
(!S_DigMusicDisabled() && S_DigExists(b)))
|
||||
|
||||
#endif
|
||||
boolean S_MusicExists(const char *mname);
|
||||
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
|
||||
|
||||
|
||||
//
|
||||
|
|
@ -191,6 +171,7 @@ typedef struct musicdef_s
|
|||
char name[7];
|
||||
//char usage[256];
|
||||
char source[256];
|
||||
int volume;
|
||||
struct musicdef_s *next;
|
||||
} musicdef_t;
|
||||
|
||||
|
|
@ -203,6 +184,7 @@ extern struct cursongcredit
|
|||
} cursongcredit;
|
||||
|
||||
extern musicdef_t *musicdefstart;
|
||||
extern int musicdef_volume;
|
||||
|
||||
void S_LoadMusicDefs(UINT16 wadnum);
|
||||
void S_InitMusicDefs(void);
|
||||
|
|
@ -314,10 +296,9 @@ void S_UpdateClosedCaptions(void);
|
|||
FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2);
|
||||
|
||||
void S_SetSfxVolume(INT32 volume);
|
||||
void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume);
|
||||
#define S_SetDigMusicVolume(a) S_SetMusicVolume(a,-1)
|
||||
#define S_SetMIDIMusicVolume(a) S_SetMusicVolume(-1,a)
|
||||
#define S_InitMusicVolume() S_SetMusicVolume(-1,-1)
|
||||
void S_SetMusicVolume(INT32 digvolume);
|
||||
#define S_SetDigMusicVolume S_SetMusicVolume
|
||||
#define S_InitMusicVolume() S_SetMusicVolume(-1)
|
||||
|
||||
INT32 S_OriginPlaying(void *origin);
|
||||
INT32 S_IdPlaying(sfxenum_t id);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,9 @@ static UINT32 stutter_threshold_user;
|
|||
static UINT32 stutter_threshold;
|
||||
|
||||
static Mix_Music *music;
|
||||
static UINT8 music_volume, sfx_volume, internal_volume;
|
||||
static int music_volume;
|
||||
static int sfx_volume;
|
||||
static int internal_volume;
|
||||
static float loop_point;
|
||||
static float song_length; // length in seconds
|
||||
static boolean songpaused;
|
||||
|
|
@ -134,84 +136,6 @@ static size_t probesize;
|
|||
static int result;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
static void Midiplayer_Onchange(void)
|
||||
{
|
||||
boolean restart = false;
|
||||
|
||||
if (I_SongType() != MU_NONE && I_SongType() != MU_MID_EX && I_SongType() != MU_MID)
|
||||
return;
|
||||
|
||||
if (Mix_GetMidiPlayer() != cv_midiplayer.value)
|
||||
{
|
||||
if (Mix_SetMidiPlayer(cv_midiplayer.value)) // <> 0 means error
|
||||
CONS_Alert(CONS_ERROR, "Midi player error: %s", Mix_GetError());
|
||||
else
|
||||
restart = true;
|
||||
}
|
||||
|
||||
if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string))
|
||||
{
|
||||
if (!Mix_SetSoundFonts(cv_midisoundfontpath.string)) // == 0 means error
|
||||
CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError());
|
||||
else
|
||||
restart = true;
|
||||
}
|
||||
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
||||
|
||||
if (restart)
|
||||
S_StartEx(true);
|
||||
}
|
||||
|
||||
static void MidiSoundfontPath_Onchange(void)
|
||||
{
|
||||
if (Mix_GetMidiPlayer() != MIDI_Fluidsynth || (I_SongType() != MU_NONE && I_SongType() != MU_MID_EX))
|
||||
return;
|
||||
|
||||
if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string))
|
||||
{
|
||||
char *miditoken;
|
||||
char *source = strdup(cv_midisoundfontpath.string);
|
||||
boolean proceed = true;
|
||||
// check if file exists; menu calls this method at every keystroke
|
||||
|
||||
// get first token
|
||||
miditoken = strtok(source, ";");
|
||||
|
||||
while (miditoken != NULL)
|
||||
{
|
||||
SDL_RWops *rw = SDL_RWFromFile(miditoken, "r");
|
||||
if (rw != NULL)
|
||||
SDL_RWclose(rw);
|
||||
else
|
||||
{
|
||||
proceed = false;
|
||||
break;
|
||||
}
|
||||
miditoken = strtok(NULL, ";");
|
||||
}
|
||||
|
||||
free(source);
|
||||
|
||||
if (proceed)
|
||||
{
|
||||
if (!Mix_SetSoundFonts(cv_midisoundfontpath.string))
|
||||
CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError());
|
||||
else
|
||||
S_StartEx(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure that s_sound.c does not already verify these
|
||||
// which happens when: defined(HAVE_MIXERX) && !defined(HAVE_MIXER)
|
||||
static CV_PossibleValue_t midiplayer_cons_t[] = {{MIDI_OPNMIDI, "OPNMIDI"}, {MIDI_Fluidsynth, "Fluidsynth"}, {MIDI_Timidity, "Timidity"}, {MIDI_Native, "Native"}, {0, NULL}};
|
||||
consvar_t cv_midiplayer = {"midiplayer", "OPNMIDI" /*MIDI_OPNMIDI*/, CV_CALL|CV_NOINIT|CV_SAVE, midiplayer_cons_t, Midiplayer_Onchange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_midisoundfontpath = {"midisoundfont", "sf2/8bitsf.SF2", CV_CALL|CV_NOINIT|CV_SAVE, NULL, MidiSoundfontPath_Onchange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_miditimiditypath = {"midisoundbank", "./timidity", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
static void var_cleanup(void)
|
||||
{
|
||||
song_length = loop_point = 0.0f;
|
||||
|
|
@ -290,11 +214,6 @@ void I_StartupSound(void)
|
|||
music = NULL;
|
||||
music_volume = sfx_volume = 0;
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
Mix_SetMidiPlayer(cv_midiplayer.value);
|
||||
Mix_SetSoundFonts(cv_midisoundfontpath.string);
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string);
|
||||
#endif
|
||||
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
|
||||
Mix_Init(MIX_INIT_FLAC|MIX_INIT_MP3|MIX_INIT_OGG|MIX_INIT_MOD);
|
||||
#endif
|
||||
|
|
@ -347,6 +266,15 @@ void I_UpdateSound(void)
|
|||
/// SFX
|
||||
/// ------------------------
|
||||
|
||||
static int
|
||||
get_real_sfx_volume (int vol)
|
||||
{
|
||||
const int scale = SOUND_VOLUME_RANGE / MIX_MAX_VOLUME;
|
||||
const int divider = VOLUME_DIVIDER * scale;
|
||||
const int volume = ( vol + 1 ) / divider * sfx_volume / 100;
|
||||
return volume;
|
||||
}
|
||||
|
||||
// this is as fast as I can possibly make it.
|
||||
// sorry. more asm needed.
|
||||
static Mix_Chunk *ds2chunk(void *stream)
|
||||
|
|
@ -602,7 +530,8 @@ void I_FreeSfx(sfxinfo_t *sfx)
|
|||
|
||||
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel)
|
||||
{
|
||||
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
|
||||
//UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
|
||||
UINT8 volume = get_real_sfx_volume(vol);
|
||||
INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0);
|
||||
Mix_Volume(handle, volume);
|
||||
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
|
||||
|
|
@ -623,13 +552,14 @@ boolean I_SoundIsPlaying(INT32 handle)
|
|||
|
||||
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
|
||||
{
|
||||
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
|
||||
//UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
|
||||
UINT8 volume = get_real_sfx_volume(vol);
|
||||
Mix_Volume(handle, volume);
|
||||
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
|
||||
(void)pitch;
|
||||
}
|
||||
|
||||
void I_SetSfxVolume(UINT8 volume)
|
||||
void I_SetSfxVolume(int volume)
|
||||
{
|
||||
sfx_volume = volume;
|
||||
}
|
||||
|
|
@ -638,18 +568,17 @@ void I_SetSfxVolume(UINT8 volume)
|
|||
/// Music Utilities
|
||||
/// ------------------------
|
||||
|
||||
static UINT32 get_real_volume(UINT8 volume)
|
||||
static UINT32 get_real_volume(int volume)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (I_SongType() == MU_MID)
|
||||
// HACK: Until we stop using native MIDI,
|
||||
// disable volume changes
|
||||
return ((UINT32)31*128/31); // volume = 31
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// convert volume to mixer's 128 scale
|
||||
// then apply internal_volume as a percentage
|
||||
return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
|
||||
//return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
|
||||
return MIX_MAX_VOLUME
|
||||
* musicdef_volume / 100
|
||||
* internal_volume / 100
|
||||
* volume / 100;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 get_adjusted_position(UINT32 position)
|
||||
|
|
@ -709,7 +638,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata)
|
|||
(void)stream;
|
||||
(void)udata;
|
||||
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID)
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD)
|
||||
return;
|
||||
music_bytes += len;
|
||||
|
||||
|
|
@ -991,7 +920,7 @@ UINT32 I_GetSongLength(void)
|
|||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID || !is_looping)
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || !is_looping)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
|
|
@ -1027,7 +956,7 @@ UINT32 I_GetSongLoopPoint(void)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
|
||||
if (!music || I_SongType() == MU_MOD)
|
||||
return 0;
|
||||
else
|
||||
return (UINT32)(loop_point * 1000);
|
||||
|
|
@ -1247,14 +1176,6 @@ boolean I_LoadSong(char *data, size_t len)
|
|||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MIXERX
|
||||
if (Mix_GetMidiPlayer() != cv_midiplayer.value)
|
||||
Mix_SetMidiPlayer(cv_midiplayer.value);
|
||||
if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string))
|
||||
Mix_SetSoundFonts(cv_midisoundfontpath.string);
|
||||
Mix_Timidity_addToPathList(cv_miditimiditypath.string); // this overwrites previous custom path
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENMPT
|
||||
/*
|
||||
If the size of the data to be checked is bigger than the recommended size (> 2048 bytes)
|
||||
|
|
@ -1387,7 +1308,7 @@ boolean I_PlaySong(boolean looping)
|
|||
if (fpclassify(song_length) == FP_ZERO && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC))
|
||||
CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n");
|
||||
|
||||
if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1)
|
||||
if (I_SongType() != MU_MOD && Mix_PlayMusic(music, 0) == -1)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
|
||||
return false;
|
||||
|
|
@ -1444,10 +1365,9 @@ void I_StopSong(void)
|
|||
|
||||
void I_PauseSong(void)
|
||||
{
|
||||
if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI???
|
||||
return;
|
||||
// really, SRB2? why do you support MIDI???
|
||||
|
||||
if(I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
|
||||
if(I_SongType() != MU_GME && I_SongType() != MU_MOD)
|
||||
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
|
||||
|
||||
Mix_PauseMusic();
|
||||
|
|
@ -1456,15 +1376,12 @@ void I_PauseSong(void)
|
|||
|
||||
void I_ResumeSong(void)
|
||||
{
|
||||
if (I_SongType() == MU_MID)
|
||||
return;
|
||||
|
||||
if (I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
|
||||
if (I_SongType() != MU_GME && I_SongType() != MU_MOD)
|
||||
{
|
||||
while(Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes) != 0) { }
|
||||
// HACK: fixes issue of multiple effect callbacks being registered
|
||||
|
||||
if(music && I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
|
||||
if(music && I_SongType() != MU_MOD && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
|
||||
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
|
||||
}
|
||||
|
||||
|
|
@ -1472,19 +1389,12 @@ void I_ResumeSong(void)
|
|||
songpaused = false;
|
||||
}
|
||||
|
||||
void I_SetMusicVolume(UINT8 volume)
|
||||
void I_SetMusicVolume(int volume)
|
||||
{
|
||||
if (!I_SongPlaying())
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (I_SongType() == MU_MID)
|
||||
// HACK: Until we stop using native MIDI,
|
||||
// disable volume changes
|
||||
music_volume = 31;
|
||||
else
|
||||
#endif
|
||||
music_volume = volume;
|
||||
music_volume = volume;
|
||||
|
||||
Mix_VolumeMusic(get_real_volume(music_volume));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio call
|
|||
{
|
||||
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
|
||||
else if (sound_disabled) return;
|
||||
else if (midi_disabled && digital_disabled
|
||||
else if (digital_disabled
|
||||
#ifdef HW3SOUND
|
||||
&& hws_mode == HWS_DEFAULT_MODE
|
||||
#endif
|
||||
|
|
@ -210,7 +210,7 @@ static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio
|
|||
{
|
||||
if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex);
|
||||
else if (sound_disabled) return;
|
||||
else if (midi_disabled && digital_disabled
|
||||
else if (digital_disabled
|
||||
#ifdef HW3SOUND
|
||||
&& hws_mode == HWS_DEFAULT_MODE
|
||||
#endif
|
||||
|
|
@ -1154,7 +1154,7 @@ void I_ShutdownSound(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (midi_disabled && digital_disabled)
|
||||
if (digital_disabled)
|
||||
SDL_CloseAudio();
|
||||
CONS_Printf("%s", M_GetText("shut down\n"));
|
||||
sound_started = false;
|
||||
|
|
@ -1174,9 +1174,6 @@ void I_StartupSound(void)
|
|||
const char *sdrv_name = NULL;
|
||||
#endif
|
||||
#ifndef HAVE_MIXER
|
||||
#ifndef NO_MIDI
|
||||
midi_disabled =
|
||||
#endif
|
||||
digital_disabled = true;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -2083,7 +2083,6 @@ int W_VerifyNMUSlumps(const char *filename)
|
|||
{
|
||||
lumpchecklist_t NMUSlist[] =
|
||||
{
|
||||
{"D_", 2}, // MIDI music
|
||||
{"O_", 2}, // Digital music
|
||||
{"DS", 2}, // Sound effects
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue