From 3332c22801e85c1c4400ad7a7b90f77f3c31ae63 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 5 Aug 2020 05:06:02 -0700 Subject: [PATCH 01/13] Fault again if you spectate then respawn during a fault --- src/d_player.h | 2 +- src/dehacked.c | 2 +- src/g_game.c | 11 +++-------- src/k_respawn.c | 7 +++++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b9c44ed0e..d51f23601 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -57,7 +57,7 @@ typedef enum typedef enum { // Flip camera angle with gravity flip prefrence. - PF_FLIPCAM = 1, + PF_FAULT = 1, // Cheats PF_GODMODE = 1<<1, diff --git a/src/dehacked.c b/src/dehacked.c index 0443d7ef3..7a97920cd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8513,7 +8513,7 @@ static const char *const MAPTHINGFLAG_LIST[4] = { static const char *const PLAYERFLAG_LIST[] = { // Flip camera angle with gravity flip prefrence. - "FLIPCAM", + "FAULT", // Cheats "GODMODE", diff --git a/src/g_game.c b/src/g_game.c index 4f52cf317..1dcb8c7cb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2599,7 +2599,7 @@ void G_PlayerReborn(INT32 player) jointime = players[player].jointime; splitscreenindex = players[player].splitscreenindex; spectator = players[player].spectator; - pflags = (players[player].pflags & (PF_TIMEOVER|PF_TAGIT|PF_TAGGED|PF_WANTSTOJOIN)); + pflags = (players[player].pflags & (PF_TIMEOVER|PF_TAGIT|PF_TAGGED|PF_WANTSTOJOIN|PF_FAULT)); // As long as we're not in multiplayer, carry over cheatcodes from map to map if (!(netgame || multiplayer)) @@ -2771,11 +2771,6 @@ void G_PlayerReborn(INT32 player) if (songcredit) S_ShowMusicCredit(); - if (leveltime > (starttime + (TICRATE/2)) && !p->spectator) - { - K_DoIngameRespawn(p); - } - if (gametype == GT_COOP) P_FindEmerald(); // scan for emeralds to hunt for @@ -2874,7 +2869,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) P_SpawnPlayer(playernum); - if (starpost) //Don't even bother with looking for a place to spawn. + if (starpost || ( players[playernum].pflags & PF_FAULT )) //Don't even bother with looking for a place to spawn. { P_MovePlayerToStarpost(playernum); #ifdef HAVE_BLUA @@ -4625,7 +4620,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_TAGIT|PF_TAGGED|PF_FULLSTASIS); + players[i].pflags &= ~(PF_FAULT|PF_TAGIT|PF_TAGGED|PF_FULLSTASIS); // Clear cheatcodes too, just in case. players[i].pflags &= ~(PF_GODMODE|PF_NOCLIP|PF_INVIS); diff --git a/src/k_respawn.c b/src/k_respawn.c index be55e2389..fc2093c83 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -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_SKIDDOWN; // cheeky pflag reuse + player->pflags |= PF_SKIDDOWN|PF_FAULT; // cheeky pflag reuse S_StartSound(player->mo, sfx_s3k83); player->karthud[khud_fault] = 1; } @@ -192,6 +193,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); From 66c7cd4844d2a24018d0832ed6de6290ff1c55e3 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 5 Aug 2020 02:12:07 -0700 Subject: [PATCH 02/13] k_spinouttype magic numbers begone Fixes wipeout running out in the air. It was really only intended for explosions. --- src/d_player.h | 21 ++++++++++++++++++++- src/k_collide.c | 4 ++-- src/k_kart.c | 20 ++++++++++---------- src/p_inter.c | 6 +++--- src/p_map.c | 12 ++++++------ src/p_user.c | 2 +- 6 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b9c44ed0e..402baeebf 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -257,6 +257,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 { @@ -270,7 +289,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 diff --git a/src/k_collide.c b/src/k_collide.c index 1921e3d38..641fc5bb6 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -148,7 +148,7 @@ boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2) else { // Player Damage - K_SpinPlayer(t2->player, t1->target, 0, t1, (t1->type == MT_BANANA || t1->type == MT_BANANA_SHIELD)); + K_SpinPlayer(t2->player, t1->target, KSPIN_SPINOUT, t1, (t1->type == MT_BANANA || t1->type == MT_BANANA_SHIELD)); } damageitem = true; @@ -332,7 +332,7 @@ boolean K_MineExplosionCollide(mobj_t *t1, mobj_t *t2) if (t1->state == &states[S_MINEEXPLOSION1]) K_ExplodePlayer(t2->player, t1->target, t1); else - K_SpinPlayer(t2->player, t1->target, 0, t1, false); + K_SpinPlayer(t2->player, t1->target, KSPIN_SPINOUT, t1, false); } else if (t2->flags & MF_SHOOTABLE) { diff --git a/src/k_kart.c b/src/k_kart.c index ce092fa43..cc5904929 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1060,7 +1060,7 @@ static void K_DebtStingPlayer(player_t *player, INT32 length) player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_pogospring] = 0; - player->kartstuff[k_spinouttype] = 2; + player->kartstuff[k_spinouttype] = KSPIN_STUNG; player->kartstuff[k_spinouttimer] = length; player->kartstuff[k_wipeoutslow] = min(length-1, wipeoutslowtime+1); @@ -2415,7 +2415,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto if (player->health <= 0) return; - if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinouttype] != 2) + if (player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && ( player->kartstuff[k_spinouttype] & KSPIN_IFRAMES )) || player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_hyudorotimer] > 0 || (G_BattleGametype() && ((player->kartstuff[k_bumper] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1))) { @@ -2487,7 +2487,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto 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) @@ -2718,7 +2718,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b player->kartstuff[k_pogospring] = 0; // This is the only part that SHOULDN'T combo :VVVVV - if (G_BattleGametype() && !(player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && player->kartstuff[k_spinouttype] != 2))) + if (G_BattleGametype() && !(player->powers[pw_flashing] > 0 || player->kartstuff[k_squishedtimer] > 0 || (player->kartstuff[k_spinouttimer] > 0 && ( player->kartstuff[k_spinouttype] & KSPIN_IFRAMES )))) { if (source && source->player && player != source->player) { @@ -2757,7 +2757,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b K_CheckBumpers(); } - player->kartstuff[k_spinouttype] = 1; + player->kartstuff[k_spinouttype] = KSPIN_EXPLOSION; player->kartstuff[k_spinouttimer] = (3*TICRATE/2)+2; player->powers[pw_flashing] = K_GetKartFlashing(player); @@ -2808,7 +2808,7 @@ void K_StealBumper(player_t *player, player_t *victim, boolean force) if (player->kartstuff[k_squishedtimer] > 0 || player->kartstuff[k_spinouttimer] > 0) return; - if (victim->powers[pw_flashing] > 0 || victim->kartstuff[k_squishedtimer] > 0 || (victim->kartstuff[k_spinouttimer] > 0 && victim->kartstuff[k_spinouttype] != 2) + if (victim->powers[pw_flashing] > 0 || victim->kartstuff[k_squishedtimer] > 0 || (victim->kartstuff[k_spinouttimer] > 0 && ( victim->kartstuff[k_spinouttype] & KSPIN_IFRAMES )) || victim->kartstuff[k_invincibilitytimer] > 0 || victim->kartstuff[k_growshrinktimer] > 0 || victim->kartstuff[k_hyudorotimer] > 0) { K_DoInstashield(victim); @@ -5712,7 +5712,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; } @@ -5731,7 +5731,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]--; @@ -5888,7 +5888,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->kartstuff[k_killfield]++; if (player->kartstuff[k_killfield] > 4*TICRATE) { - K_SpinPlayer(player, NULL, 0, NULL, false); + K_SpinPlayer(player, NULL, KSPIN_SPINOUT, NULL, false); //player->kartstuff[k_killfield] = 1; } } @@ -7000,7 +7000,7 @@ static void K_KartSpindash(player_t *player) } } else if (chargetime < -TICRATE) - K_SpinPlayer(player, NULL, 0, NULL, false); + K_SpinPlayer(player, NULL, KSPIN_SPINOUT, NULL, false); else { if (player->kartstuff[k_spindash] % 4 == 0) diff --git a/src/p_inter.c b/src/p_inter.c index 135067753..a10e5eddc 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -557,7 +557,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_RemoveMobj(special); } else - K_SpinPlayer(player, special->target, 0, special, false); + K_SpinPlayer(player, special->target, KSPIN_SPINOUT, special, false); return; /*case MT_EERIEFOG: special->frame &= ~FF_TRANS80; @@ -3234,14 +3234,14 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da player->kartstuff[k_sneakertimer] = 0; player->kartstuff[k_numsneakers] = 0; - K_SpinPlayer(player, source, 1, inflictor, false); + K_SpinPlayer(player, source, KSPIN_WIPEOUT, inflictor, false); K_KartPainEnergyFling(player); if (P_IsDisplayPlayer(player)) P_StartQuake(32<player, thing, 0, ((thing->type == MT_BUBBLESHIELD) ? thing->target : thing), false); + K_SpinPlayer(tmthing->player, thing, KSPIN_SPINOUT, ((thing->type == MT_BUBBLESHIELD) ? thing->target : thing), false); S_StartSound(thing, sfx_s3k44); } else @@ -843,7 +843,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // Player Damage - K_SpinPlayer(thing->player, tmthing, 0, ((tmthing->type == MT_BUBBLESHIELD) ? tmthing->target : tmthing), false); + K_SpinPlayer(thing->player, tmthing, KSPIN_SPINOUT, ((tmthing->type == MT_BUBBLESHIELD) ? tmthing->target : tmthing), false); S_StartSound(tmthing, sfx_s3k44); } else @@ -1437,7 +1437,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (G_BattleGametype() && tmthing->player->kartstuff[k_pogospring]) { K_StealBumper(tmthing->player, thing->player, false); - K_SpinPlayer(thing->player, tmthing, 0, tmthing, false); + K_SpinPlayer(thing->player, tmthing, KSPIN_SPINOUT, tmthing, false); } } else if (P_IsObjectOnGround(tmthing) && thing->momz < 0) @@ -1447,7 +1447,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (G_BattleGametype() && thing->player->kartstuff[k_pogospring]) { K_StealBumper(thing->player, tmthing->player, false); - K_SpinPlayer(tmthing->player, thing, 0, thing, false); + K_SpinPlayer(tmthing->player, thing, KSPIN_SPINOUT, thing, false); } } @@ -1456,12 +1456,12 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->player->kartstuff[k_sneakertimer] && !(tmthing->player->kartstuff[k_sneakertimer]) && !(thing->player->powers[pw_flashing])) // Don't steal bumpers while intangible { K_StealBumper(thing->player, tmthing->player, false); - K_SpinPlayer(tmthing->player, thing, 0, tmthing, false); + K_SpinPlayer(tmthing->player, thing, KSPIN_SPINOUT, tmthing, false); } else if (tmthing->player->kartstuff[k_sneakertimer] && !(thing->player->kartstuff[k_sneakertimer]) && !(tmthing->player->powers[pw_flashing])) { K_StealBumper(tmthing->player, thing->player, false); - K_SpinPlayer(thing->player, tmthing, 0, thing, false); + K_SpinPlayer(thing->player, tmthing, KSPIN_SPINOUT, thing, false); } } diff --git a/src/p_user.c b/src/p_user.c index 8d6014926..800f4f37c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6876,7 +6876,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) continue; if (mo->type == MT_PLAYER) // Players wipe out in Kart - K_SpinPlayer(mo->player, source, 0, inflictor, false); + K_SpinPlayer(mo->player, source, KSPIN_SPINOUT, inflictor, false); //} else P_DamageMobj(mo, inflictor, source, 1000); From 97eac1c594680bddc966e7e1d5af27d1138eab3b Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 5 Aug 2020 02:19:58 -0700 Subject: [PATCH 03/13] Lua --- src/dehacked.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 0443d7ef3..a81357f42 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9429,6 +9429,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}, From 11a4ca28d79dc3e63c1ef90beaee8c6f930a3889 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 6 Aug 2020 17:59:09 -0700 Subject: [PATCH 04/13] Remove PF_SKIDDOWN, just use PF_FAULT --- src/d_player.h | 3 ++- src/dehacked.c | 3 ++- src/k_kart.c | 4 ++-- src/k_respawn.c | 2 +- src/p_user.c | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index d51f23601..3d17350c2 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -113,7 +113,8 @@ typedef enum // Spill rings after falling PF_NIGHTSFALL = 1<<24, PF_DRILLING = 1<<25, - PF_SKIDDOWN = 1<<26, + + // free: 1<<26 /*** TAG STUFF ***/ PF_TAGGED = 1<<27, // Player has been tagged and awaits the next round in hide and seek. diff --git a/src/dehacked.c b/src/dehacked.c index 7a97920cd..ffe234c51 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8569,7 +8569,8 @@ static const char *const PLAYERFLAG_LIST[] = { // Spill rings after falling "NIGHTSFALL", "DRILLING", - "SKIDDOWN", + + "\x01", // free: 1<<26 (name un-matchable) /*** TAG STUFF ***/ "TAGGED", // Player has been tagged and awaits the next round in hide and seek. diff --git a/src/k_kart.c b/src/k_kart.c index eac90b665..493ffc035 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3605,7 +3605,7 @@ void K_DriftDustHandling(mobj_t *spawner) if (spawner->player) { - if (spawner->player->pflags & PF_SKIDDOWN) + if (spawner->player->pflags & PF_FAULT) { anglediff = abs((signed)(spawner->angle - spawner->player->frameangle)); if (leveltime % 6 == 0) @@ -5316,7 +5316,7 @@ void K_KartPlayerHUDUpdate(player_t *player) if (player->karthud[khud_tauntvoices]) player->karthud[khud_tauntvoices]--; - if (!(player->pflags & PF_SKIDDOWN)) + 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]++; diff --git a/src/k_respawn.c b/src/k_respawn.c index fc2093c83..a6543d425 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -111,7 +111,7 @@ void K_DoIngameRespawn(player_t *player) if (leveltime < starttime) // FAULT { player->powers[pw_nocontrol] = (starttime - leveltime) + 50; - player->pflags |= PF_SKIDDOWN|PF_FAULT; // cheeky pflag reuse + player->pflags |= PF_FAULT; S_StartSound(player->mo, sfx_s3k83); player->karthud[khud_fault] = 1; } diff --git a/src/p_user.c b/src/p_user.c index 8d6014926..b7f12fb53 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5859,7 +5859,7 @@ static void P_MovePlayer(player_t *player) else player->frameangle -= (ANGLE_11hh * speed); } - else if (player->powers[pw_nocontrol] && player->pflags & PF_SKIDDOWN) + else if (player->powers[pw_nocontrol] && player->pflags & PF_FAULT) { if (player->mo->state != &states[S_KART_SPIN]) P_SetPlayerMobjState(player->mo, S_KART_SPIN); @@ -9047,7 +9047,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_SKIDDOWN; + player->pflags &= ~PF_FAULT; } else player->powers[pw_nocontrol] = 0; From 7adf2159f66513d61460819a29976910d3ee3909 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 6 Aug 2020 21:24:41 -0700 Subject: [PATCH 05/13] Reduce songs and sounds to 1/4 volume, add a musicdef option for volume --- src/doomdef.h | 4 ++++ src/s_sound.c | 18 ++++++++++++++++++ src/s_sound.h | 2 ++ src/sdl/mixer_sound.c | 7 +++++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 3a49cccd4..26072b705 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -676,4 +676,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Hardware renderer: OpenGL #define GL_SHADERS +/// Default volume for songs that don't have "volume" set via musicdef +/// TODO: Remove this once all songs are ported +#define DEFAULT_MUSICDEF_VOLUME 25 + #endif // __DOOMDEF__ diff --git a/src/s_sound.c b/src/s_sound.c index 9b49784ec..0bff2e028 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1578,6 +1578,7 @@ static UINT32 queue_fadeinms; musicdef_t *musicdefstart = NULL; // First music definition struct cursongcredit cursongcredit; // Currently displayed song credit info +int musicdef_volume; // // search for music definition in wad @@ -1686,6 +1687,8 @@ void S_LoadMusicDefs(UINT16 wadnum) } } + def->volume = DEFAULT_MUSICDEF_VOLUME; + skip_lump: stoken = strtok(NULL, "\r\n "); line++; @@ -1720,6 +1723,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); } @@ -2047,6 +2052,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)) { CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", newmusic); diff --git a/src/s_sound.h b/src/s_sound.h index c433aa974..332f93324 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -139,6 +139,7 @@ typedef struct musicdef_s char name[7]; //char usage[256]; char source[256]; + int volume; struct musicdef_s *next; } musicdef_t; @@ -151,6 +152,7 @@ extern struct cursongcredit } cursongcredit; extern musicdef_t *musicdefstart; +extern int musicdef_volume; void S_LoadMusicDefs(UINT16 wadnum); void S_InitMusicDefs(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 77fcc0914..0821a22c9 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -493,7 +493,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 + int volume = ( vol + 1 ) / 8;/* reduce to 1/4, 256 / 8 = 128 / 4 = 32 */ 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)); @@ -531,6 +532,7 @@ void I_SetSfxVolume(UINT8 volume) static UINT32 get_real_volume(UINT8 volume) { + (void)volume; #ifdef _WIN32 if (I_SongType() == MU_MID) // HACK: Until we stop using native MIDI, @@ -540,7 +542,8 @@ static UINT32 get_real_volume(UINT8 volume) #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; } static UINT32 get_adjusted_position(UINT32 position) From 374d032a6b63347f4a81e0f029412a336511cc43 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 12:28:15 -0700 Subject: [PATCH 06/13] Clean up stuff, make volume work again --- src/doomdef.h | 5 ++--- src/i_sound.h | 4 ++-- src/s_sound.h | 6 ++++++ src/sdl/mixer_sound.c | 22 +++++++++++++++------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 26072b705..fbea62c7e 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -676,8 +676,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Hardware renderer: OpenGL #define GL_SHADERS -/// Default volume for songs that don't have "volume" set via musicdef -/// TODO: Remove this once all songs are ported -#define DEFAULT_MUSICDEF_VOLUME 25 +/// Divide volume of music and sounds by this much (loudest sounds on earth) +#define VOLUME_DIVIDER 4 #endif // __DOOMDEF__ diff --git a/src/i_sound.h b/src/i_sound.h index 93e3f6dd0..f418b598f 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -118,7 +118,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 @@ -227,7 +227,7 @@ void I_ResumeSong(void); \return void */ -void I_SetMusicVolume(UINT8 volume); +void I_SetMusicVolume(int volume); boolean I_SetSongTrack(INT32 track); diff --git a/src/s_sound.h b/src/s_sound.h index 332f93324..1fccd97fc 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -23,6 +23,12 @@ // 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_digmusicvolume;//, cv_midimusicvolume; extern consvar_t cv_numChannels; diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 0821a22c9..54e63f8fe 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -84,7 +84,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; @@ -494,7 +496,9 @@ 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 - int volume = ( vol + 1 ) / 8;/* reduce to 1/4, 256 / 8 = 128 / 4 = 32 */ + const int scale = SOUND_VOLUME_RANGE / MIX_MAX_VOLUME; + const int divider = VOLUME_DIVIDER * scale; + const int volume = ( vol + 1 ) / divider * sfx_volume / 100; 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)); @@ -521,7 +525,7 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch) (void)pitch; } -void I_SetSfxVolume(UINT8 volume) +void I_SetSfxVolume(int volume) { sfx_volume = volume; } @@ -530,9 +534,8 @@ void I_SetSfxVolume(UINT8 volume) /// Music Utilities /// ------------------------ -static UINT32 get_real_volume(UINT8 volume) +static UINT32 get_real_volume(int volume) { - (void)volume; #ifdef _WIN32 if (I_SongType() == MU_MID) // HACK: Until we stop using native MIDI, @@ -540,10 +543,15 @@ static UINT32 get_real_volume(UINT8 volume) 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 MIX_MAX_VOLUME * musicdef_volume / 100 * internal_volume / 100; + return MIX_MAX_VOLUME + * musicdef_volume / 100 + * internal_volume / 100 + * volume / 100; + } } static UINT32 get_adjusted_position(UINT32 position) @@ -1237,7 +1245,7 @@ void I_ResumeSong(void) songpaused = false; } -void I_SetMusicVolume(UINT8 volume) +void I_SetMusicVolume(int volume) { if (!I_SongPlaying()) return; From 9077a4ff03e196d79522d52b422432c9f67a1cdd Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 12:38:55 -0700 Subject: [PATCH 07/13] Kill MIDI --- src/d_main.c | 25 +--------- src/d_netcmd.c | 3 -- src/doomdef.h | 3 -- src/doomstat.h | 5 -- src/s_sound.c | 119 ++------------------------------------------ src/s_sound.h | 10 ++-- src/sdl/sdl_sound.c | 3 -- 7 files changed, 8 insertions(+), 160 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index fe7e312ee..0b37e3aac 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -126,15 +126,9 @@ INT32 postimgparam[MAXSPLITSCREENPLAYERS]; // whether the respective sound system is disabled // or they're init'ed, but the player just toggled them #ifdef _XBOX -#ifndef NO_MIDI -boolean midi_disabled = true; -#endif boolean sound_disabled = true; boolean digital_disabled = true; #else -#ifndef NO_MIDI -boolean midi_disabled = false; -#endif boolean sound_disabled = false; boolean digital_disabled = false; #endif @@ -1350,17 +1344,11 @@ 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 { @@ -1369,25 +1357,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(); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a106530cf..52a3247a4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1098,9 +1098,6 @@ void D_RegisterClientCommands(void) // s_sound.c CV_RegisterVar(&cv_soundvolume); CV_RegisterVar(&cv_digmusicvolume); -#ifndef NO_MIDI - CV_RegisterVar(&cv_midimusicvolume); -#endif CV_RegisterVar(&cv_numChannels); // i_cdmus.c diff --git a/src/doomdef.h b/src/doomdef.h index fbea62c7e..ec887b075 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -663,9 +663,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// SRB2Kart: Camera always has noclip. #define NOCLIPCAM -/// SRB2Kart: MIDI support is shitty and busted and we don't want it, lets throw it behind a define -#define NO_MIDI - /// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up /// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down) /// on the bright side it fixes some weird issues with translucent walls diff --git a/src/doomstat.h b/src/doomstat.h index e678886a8..bf4f64497 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -110,11 +110,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; diff --git a/src/s_sound.c b/src/s_sound.c index 0bff2e028..790468284 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -55,9 +55,6 @@ 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); @@ -97,9 +94,6 @@ static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NUL // 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 // number of channels available #if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; @@ -112,9 +106,6 @@ consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, // 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}; consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, PlayMusicIfUnfocused_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -286,9 +277,6 @@ void S_RegisterSoundStuff(void) //CV_RegisterVar(&cv_resetmusic); CV_RegisterVar(&cv_gamesounds); CV_RegisterVar(&cv_gamedigimusic); -#ifndef NO_MIDI - CV_RegisterVar(&cv_gamemidimusic); -#endif CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_playsoundifunfocused); @@ -902,9 +890,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) { @@ -931,10 +916,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) @@ -1790,11 +1771,6 @@ 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); @@ -1900,15 +1876,6 @@ static boolean S_LoadMusic(const char *mname) CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n"); return false; } - else if (S_MIDIMusicDisabled() && 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); -#else - CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n"); -#endif - return false; - } else { CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname); @@ -2158,50 +2125,19 @@ 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); + CV_SetValue(&cv_digmusicvolume, digvolume); 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 - #ifdef DJGPPDOS digvolume = 31; -#ifndef NO_MIDI - seqvolume = 31; -#endif #endif - switch(I_SongType()) - { -#ifndef NO_MIDI - case MU_MID: - //case MU_MOD: - //case MU_GME: - I_SetMusicVolume(seqvolume&31); - break; -#endif - default: - I_SetMusicVolume(digvolume&31); - break; - } + I_SetMusicVolume(digvolume); } void @@ -2378,11 +2314,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); @@ -2448,49 +2380,6 @@ void GameDigiMusic_OnChange(void) } } -#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_InitMusic(); - if (Playing()) - P_RestoreMusic(&players[consoleplayer]); - else - S_ChangeMusicInternal("titles", looptitle); - } - else - { - midi_disabled = true; - if (S_MusicType() == MU_MID) - { - 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(); - } - } - } -} -#endif - static void PlayMusicIfUnfocused_OnChange(void) { if (window_notinfocus) diff --git a/src/s_sound.h b/src/s_sound.h index 1fccd97fc..c4b4deef7 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -35,9 +35,6 @@ extern consvar_t cv_numChannels; extern consvar_t surround; //extern consvar_t cv_resetmusic; extern consvar_t cv_gamedigimusic; -#ifndef NO_MIDI -extern consvar_t cv_gamemidimusic; -#endif extern consvar_t cv_gamesounds; extern consvar_t cv_playmusicifunfocused; extern consvar_t cv_playsoundifunfocused; @@ -240,10 +237,9 @@ void S_UpdateSounds(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); diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 4bb1b5676..ad3486219 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1173,9 +1173,6 @@ void I_StartupSound(void) const char *sdrv_name = NULL; #endif #ifndef HAVE_MIXER -#ifndef NO_MIDI - midi_disabled = -#endif digital_disabled = true; #endif From 72e225f8c9afae5e4bba09b25a3d96b7e4c9918b Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 12:43:59 -0700 Subject: [PATCH 08/13] Rename digmusicvolume to musicvolume, default soundvolume and musicvolume to 100% --- src/doomdef.h | 1 + src/s_sound.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index ec887b075..d84aaa4e9 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -675,5 +675,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Divide volume of music and sounds by this much (loudest sounds on earth) #define VOLUME_DIVIDER 4 +#define MAX_VOLUME ( 100 * VOLUME_DIVIDER ) #endif // __DOOMDEF__ diff --git a/src/s_sound.c b/src/s_sound.c index 790468284..ec1f53e1f 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -49,7 +49,7 @@ extern INT32 msg_id; 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); @@ -92,8 +92,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}; +consvar_t cv_soundvolume = {"soundvolume", "100", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_digmusicvolume = {"musicvolume", "100", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // number of channels available #if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; @@ -121,8 +121,6 @@ consvar_t cv_music_resync_threshold = {"music_resync_threshold", "100", CV_SAVE| consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagConditions, 0, NULL, NULL, 0, 0, NULL}; -#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)) From aedc5ae7af5689572184673ad3dee9531cfb0d78 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 12:50:59 -0700 Subject: [PATCH 09/13] Kill MIDI more >:) --- src/i_sound.h | 1 - src/lua_baselib.c | 4 +--- src/s_sound.c | 31 ++++----------------------- src/s_sound.h | 6 ++---- src/sdl/mixer_sound.c | 50 +++++++++++++------------------------------ src/sdl/sdl_sound.c | 6 +++--- src/w_wad.c | 1 - 7 files changed, 25 insertions(+), 74 deletions(-) diff --git a/src/i_sound.h b/src/i_sound.h index f418b598f..28cab0c54 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -24,7 +24,6 @@ typedef enum { MU_CMD, MU_WAV, MU_MOD, - MU_MID, MU_OGG, MU_MP3, MU_MP3_MAD_UNUSED, // use MU_MP3 instead diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9916ceab8..3914b4c1e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1959,8 +1959,6 @@ static int lib_sMusicInfo(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; @@ -1989,7 +1987,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; } diff --git a/src/s_sound.c b/src/s_sound.c index ec1f53e1f..e9bd96cc4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1771,7 +1771,7 @@ boolean S_DigMusicDisabled(void) boolean S_MusicDisabled(void) { - return (midi_disabled && digital_disabled); + return digital_disabled; } boolean S_MusicPlaying(void) @@ -1807,12 +1807,9 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) return (boolean)mname[0]; } -boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi) +boolean S_MusicExists(const char *mname) { - return ( - (checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false) - || (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false) - ); + return W_CheckNumForName(va("O_%s", mname)) != LUMPERROR; } /// ------------------------ @@ -1867,8 +1864,6 @@ static boolean S_LoadMusic(const char *mname) if (!S_DigMusicDisabled() && S_DigExists(mname)) mlumpnum = W_GetNumForName(va("o_%s", mname)); - else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) - mlumpnum = W_GetNumForName(va("d_%s", mname)); else if (S_DigMusicDisabled() && S_DigExists(mname)) { CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n"); @@ -2356,25 +2351,7 @@ void GameDigiMusic_OnChange(void) 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(); - } - } + S_StopMusic(); } } diff --git a/src/s_sound.h b/src/s_sound.h index c4b4deef7..d2ea6b4d4 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -118,16 +118,14 @@ 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); musictype_t S_MusicType(void); const char *S_MusicName(void); boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); -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) +boolean S_MusicExists(const char *mname); +#define S_DigExists S_MusicExists // // Music Effects diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 54e63f8fe..dc088185c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -536,13 +536,6 @@ void I_SetSfxVolume(int 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 @@ -611,7 +604,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; @@ -714,8 +707,6 @@ musictype_t I_SongType(void) #endif if (!music) return MU_NONE; - else if (Mix_GetMusicType(music) == MUS_MID) - return MU_MID; else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG) return MU_MOD; else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD) @@ -798,7 +789,7 @@ UINT32 I_GetSongLength(void) } else #endif - if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID) + if (!music || I_SongType() == MU_MOD) return 0; else { @@ -813,7 +804,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 { @@ -849,7 +840,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); @@ -883,7 +874,7 @@ boolean I_SetSongPosition(UINT32 position) } else #endif - if (!music || I_SongType() == MU_MID) + if (!music) return false; else if (I_SongType() == MU_MOD) return Mix_SetMusicPosition(position); // Goes by channels @@ -942,7 +933,7 @@ UINT32 I_GetSongPosition(void) } else #endif - if (!music || I_SongType() == MU_MID) + if (!music) return 0; else return music_bytes/44100.0L*1000.0L/4; //assume 44.1khz @@ -1170,12 +1161,12 @@ 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; } - else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever + else if (I_SongType() == MU_MOD && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false; @@ -1185,10 +1176,10 @@ boolean I_PlaySong(boolean looping) I_SetMusicVolume(music_volume); - if (I_SongType() != MU_MOD && I_SongType() != MU_MID) + if (I_SongType() != MU_MOD) Mix_HookMusicFinished(music_loop); // don't bother counting if MOD - if(I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL)) + if(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()); return true; @@ -1217,10 +1208,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(); @@ -1229,15 +1219,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()); } @@ -1250,14 +1237,7 @@ 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)); } diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index ad3486219..6cee7161b 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -195,7 +195,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 @@ -209,7 +209,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 @@ -1153,7 +1153,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; diff --git a/src/w_wad.c b/src/w_wad.c index 54ae7fb26..89802d23a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1707,7 +1707,6 @@ int W_VerifyNMUSlumps(const char *filename) { lumpchecklist_t NMUSlist[] = { - {"D_", 2}, // MIDI music {"O_", 2}, // Digital music {"DS", 2}, // Sound effects From 0e0015cb444f339a8461501e311bb410231f7f91 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 13:02:35 -0700 Subject: [PATCH 10/13] And remove the limit on S_SetSfxVolume :V --- src/s_sound.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index e9bd96cc4..6b810dc7a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1148,17 +1148,14 @@ void S_UpdateSounds(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); + CV_SetValue(&cv_soundvolume, volume); 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); + I_SetSfxVolume(volume); #endif } From 559029511bf2242544a591ed489a0a6ac52f696d Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 7 Aug 2020 13:10:13 -0700 Subject: [PATCH 11/13] Update sounds with correct volume --- src/sdl/mixer_sound.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index dc088185c..7c997e2e0 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -200,6 +200,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) @@ -496,9 +505,7 @@ 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 - const int scale = SOUND_VOLUME_RANGE / MIX_MAX_VOLUME; - const int divider = VOLUME_DIVIDER * scale; - const int volume = ( vol + 1 ) / divider * sfx_volume / 100; + 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)); @@ -519,7 +526,8 @@ 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; From 922f6aa9f8bb16ba6ce679bd511326fb8cef039f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 25 Sep 2020 02:23:44 -0700 Subject: [PATCH 12/13] Scale volume cvars by half, 200% max and 50% default --- src/doomdef.h | 3 ++- src/s_sound.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 3a6875a57..a3f7cacd2 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -648,7 +648,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Divide volume of music and sounds by this much (loudest sounds on earth) #define VOLUME_DIVIDER 4 -#define MAX_VOLUME ( 100 * VOLUME_DIVIDER ) +#define USER_VOLUME_SCALE 2 +#define MAX_VOLUME ( 100 * VOLUME_DIVIDER / USER_VOLUME_SCALE ) #if defined (HAVE_CURL) && ! defined (NONET) #define MASTERSERVER diff --git a/src/s_sound.c b/src/s_sound.c index ac58d7c4e..1bb554dfe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -92,8 +92,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", "100", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_digmusicvolume = {"musicvolume", "100", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +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 #if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; @@ -1154,7 +1154,7 @@ void S_UpdateSounds(void) void S_SetSfxVolume(INT32 volume) { CV_SetValue(&cv_soundvolume, volume); - actualsfxvolume = cv_soundvolume.value; // check for change of var + actualsfxvolume = cv_soundvolume.value * USER_VOLUME_SCALE; #ifdef HW3SOUND hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F); @@ -2123,7 +2123,7 @@ void S_SetMusicVolume(INT32 digvolume) digvolume = cv_digmusicvolume.value; CV_SetValue(&cv_digmusicvolume, digvolume); - actualdigmusicvolume = cv_digmusicvolume.value; //check for change of var + actualdigmusicvolume = cv_digmusicvolume.value * USER_VOLUME_SCALE; #ifdef DJGPPDOS digvolume = 31; From ce4dc9fbc92a9435bcf76910c1cf19ab0e0d2603 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 25 Sep 2020 02:29:07 -0700 Subject: [PATCH 13/13] Adjust volumes by 5% in menu --- src/m_menu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index dcadc6d21..785200d83 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2379,6 +2379,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)