Merge branch 'stereo-dx' into 'master'

Stereo DX

Closes #510

See merge request KartKrew/Kart!1140
This commit is contained in:
toaster 2023-04-08 11:41:48 +00:00
commit ef382feba9
8 changed files with 157 additions and 71 deletions

View file

@ -1047,7 +1047,7 @@ void D_ClearState(void)
if (rendermode != render_none)
V_SetPaletteLump("PLAYPAL");
cursongcredit.def = NULL;
S_StopMusicCredit();
S_StopSounds();
if (gamedata && gamedata->deferredsave)

View file

@ -3003,6 +3003,10 @@ void readmaincfg(MYFILE *f, boolean mainfile)
G_ClearRecords();
M_ClearStats();
M_ClearSecrets();
// Don't softlock the Stereo on if you won't be able to access it anymore!?
if (soundtest.playing && M_SecretUnlocked(SECRET_SOUNDTEST, true) == false)
S_SoundTestStop();
}
#ifndef DEVELOP
else if (!mainfile && !gamedataadded)

View file

@ -310,7 +310,7 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset
void F_StartIntro(void)
{
cursongcredit.def = NULL;
S_StopMusicCredit();
if (gamestate)
{

View file

@ -5997,15 +5997,15 @@ void M_DrawSoundTest(void)
titletext = soundtest.current->title;
V_DrawThinString(x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, titletext);
V_DrawThinString(x+1, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, titletext);
if (soundtest.current->numtracks > 1)
V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("Track %c", 'A'+soundtest.currenttrack));
V_DrawThinString(x+1, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, va("Track %c", 'A'+soundtest.currenttrack));
if (soundtest.current->author)
V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->author);
V_DrawThinString(x+1, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->author);
if (soundtest.current->source)
V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->source);
V_DrawThinString(x+1, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->source);
if (soundtest.current->composers)
V_DrawThinString(x, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->composers);
V_DrawThinString(x+1, (y += 10), V_ALLOWLOWERCASE|V_6WIDTHSPACE, soundtest.current->composers);
}
else
{
@ -6013,9 +6013,9 @@ void M_DrawSoundTest(void)
titletext = "Sound Test";
V_DrawThinString(x, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, "Track ");
V_DrawThinString(x+1, y, V_ALLOWLOWERCASE|V_6WIDTHSPACE, "Track ");
V_DrawThinString(
x + V_ThinStringWidth("Track ", V_ALLOWLOWERCASE|V_6WIDTHSPACE),
x+1 + V_ThinStringWidth("Track ", V_ALLOWLOWERCASE|V_6WIDTHSPACE),
y,
V_6WIDTHSPACE,
va("%04X - %s", cv_soundtest.value, sfxstr)
@ -6046,7 +6046,7 @@ void M_DrawSoundTest(void)
UINT32 exittime = soundtest.sequencemaxtime;
if (soundtest.dosequencefadeout == true)
{
exittime += 3*TICRATE;
exittime += SOUNDTEST_FADEOUTSECONDS*TICRATE;
}
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
@ -6141,12 +6141,31 @@ void M_DrawSoundTest(void)
else if (currentMenu->menuitems[i].mvar2 == stereospecial_vol) // Vol
{
consvar_t *voltoadjust = M_GetSoundTestVolumeCvar();
INT32 j, vol = 0;
INT32 j = 0, vol = 0;
const INT32 barheight = 22;
patch_t *knob = NULL;
INT32 knobflags = 0;
V_DrawFixedPatch((x+1) << FRACBITS, y << FRACBITS,
FRACUNIT, 0,
W_CachePatchName("STER_KNB", PU_CACHE),
if (i == itemOn)
{
if ((menucmd[pid].dpad_ud < 0 && (soundtest.menutick & 2)) || M_MenuConfirmPressed(pid))
{
knob = W_CachePatchName("STER_KNT", PU_CACHE);
knobflags = V_FLIP;
j = 24;
}
else if (menucmd[pid].dpad_ud > 0 && (soundtest.menutick & 2))
{
knob = W_CachePatchName("STER_KNT", PU_CACHE);
}
}
if (knob == NULL)
knob = W_CachePatchName("STER_KNB", PU_CACHE);
V_DrawFixedPatch((x+1+j) << FRACBITS, y << FRACBITS,
FRACUNIT, knobflags,
knob,
NULL
);
@ -6184,7 +6203,7 @@ void M_DrawSoundTest(void)
{
if (i == itemOn)
{
if (menucmd[pid].dpad_ud < 0 || M_MenuConfirmHeld(pid))
if (menucmd[pid].dpad_ud < 0 || M_MenuConfirmPressed(pid))
{
y--;
}

View file

@ -376,7 +376,7 @@ void M_PlayMenuJam(void)
if (challengesmenu.pending)
{
S_StopMusic();
cursongcredit.def = NULL;
S_StopMusicCredit();
loserclubpermitted = true;
return;
@ -390,7 +390,7 @@ void M_PlayMenuJam(void)
if (refMenu->music[0] == '.' && refMenu->music[1] == '\0')
{
S_StopMusic();
cursongcredit.def = NULL;
S_StopMusicCredit();
return;
}
else if (!loserclub)

View file

@ -69,6 +69,10 @@ static void M_EraseDataResponse(INT32 ch)
M_UpdateUnlockablesAndExtraEmblems(false, true);
// Don't softlock the Stereo on if you won't be able to access it anymore!?
if (soundtest.playing && M_SecretUnlocked(SECRET_SOUNDTEST, true) == false)
S_SoundTestStop();
F_StartIntro();
M_ClearMenus(true);
}

View file

@ -34,6 +34,7 @@
#include "k_menu.h" // M_PlayMenuJam
#include "m_random.h" // P_RandomKey
#include "i_time.h"
#include "v_video.h" // V_ThinStringWidth
#ifdef HW3SOUND
// 3D Sound Interface
@ -1480,7 +1481,8 @@ void S_PopulateSoundTestSequence(void)
S_InsertMapIntoSoundTestSequence(i, &tail);
}
// Finally, we insert all other musicdefstart at the head.
// Finally, we insert all important musicdefs at the head,
// and all others at the tail.
// It's being added to the sequence in reverse order...
// but because musicdefstart is ALSO populated in reverse,
// the reverse of the reverse is the right way around!
@ -1492,12 +1494,27 @@ void S_PopulateSoundTestSequence(void)
if (def->sequence.id == soundtest.sequence.id)
continue;
if (def->important == false)
continue;
def->sequence.id = soundtest.sequence.id;
def->sequence.map = NEXTMAP_INVALID;
def->sequence.next = soundtest.sequence.next;
soundtest.sequence.next = def;
}
for (def = musicdefstart; def; def = def->next)
{
if (def->sequence.id == soundtest.sequence.id)
continue;
def->sequence.id = soundtest.sequence.id;
def->sequence.map = NEXTMAP_INVALID;
def->sequence.next = *tail;
*tail = def;
}
}
}
@ -1618,30 +1635,39 @@ void S_SoundTestPlay(void)
S_ChangeMusicInternal(soundtest.current->name[soundtest.currenttrack],
!soundtest.current->basenoloop[soundtest.currenttrack]);
S_ShowMusicCredit();
soundtest.currenttime = 0;
soundtest.sequencemaxtime = S_GetMusicLength();
soundtest.sequencefadeout = 0;
if (soundtest.sequencemaxtime)
if (soundtest.sequencemaxtime == 0)
{
// Does song have default loop?
if (soundtest.current->basenoloop[soundtest.currenttrack] == false)
S_SoundTestStop(); // This sets soundtest.privilegedrequest to false
return;
}
S_ShowMusicCredit();
// ensure default is always set
soundtest.sequencefadeout = 0;
soundtest.dosequencefadeout = false;
// Does song have default loop?
if (soundtest.current->basenoloop[soundtest.currenttrack] == false)
{
if (soundtest.sequencemaxtime < 3*60*1000)
{
soundtest.dosequencefadeout = (soundtest.currenttrack == soundtest.current->numtracks-1);
soundtest.sequencemaxtime *= 2; // Two loops by default.
soundtest.sequencemaxtime -= S_GetMusicLoopPoint(); // Otherwise the intro is counted twice.
}
else
{
soundtest.dosequencefadeout = false;
// I'd personally like songs in sequence to last between 3 and 6 minutes.
const UINT32 loopduration = (soundtest.sequencemaxtime - S_GetMusicLoopPoint());
soundtest.sequencemaxtime += loopduration;
}
// ms to TICRATE conversion
soundtest.sequencemaxtime = (TICRATE*soundtest.sequencemaxtime)/1000;
// Only fade out if we're the last track for this song.
soundtest.dosequencefadeout = (soundtest.currenttrack == soundtest.current->numtracks-1);
}
// ms to TICRATE conversion
soundtest.sequencemaxtime = (TICRATE*soundtest.sequencemaxtime)/1000;
soundtest.privilegedrequest = false;
}
@ -1659,7 +1685,7 @@ void S_SoundTestStop(void)
soundtest.autosequence = false;
S_StopMusic();
cursongcredit.def = NULL;
S_StopMusicCredit();
soundtest.currenttime = 0;
soundtest.sequencemaxtime = 0;
@ -1694,66 +1720,75 @@ void S_TickSoundTest(void)
{
static UINT32 storetime = 0;
UINT32 lasttime = storetime;
boolean donext = false;
storetime = I_GetTime();
if (soundtest.playing == false || soundtest.current == NULL)
{
// Nothing worth discussing.
return;
}
if (I_SongPlaying() == false)
{
S_SoundTestStop();
return;
// We stopped for some reason. Accomodate this.
goto handlenextsong;
}
if (I_SongPaused() == false)
{
// Increment the funny little timer.
soundtest.currenttime += (storetime - lasttime);
}
if (soundtest.sequencefadeout > 0)
if (soundtest.sequencefadeout != 0)
{
if (soundtest.currenttime >= soundtest.sequencefadeout)
// Are we done fading out?
if (soundtest.currenttime > soundtest.sequencefadeout)
{
donext = true;
goto handlenextsong;
}
}
else if (soundtest.currenttime >= soundtest.sequencemaxtime)
{
if (soundtest.autosequence == false)
{
if (soundtest.current->basenoloop[soundtest.currenttrack] == true)
{
S_SoundTestStop();
}
return;
}
else if (soundtest.dosequencefadeout == false)
{
donext = true;
}
else
{
if (soundtest.sequencemaxtime > 0)
{
soundtest.privilegedrequest = true;
S_FadeMusic(0, 3000);
soundtest.privilegedrequest = false;
}
soundtest.sequencefadeout = soundtest.currenttime + 3*TICRATE;
}
}
if (donext == false)
{
return;
}
if (soundtest.autosequence == false)
{
// There's nothing else for us here.
return;
}
if (soundtest.currenttime >= soundtest.sequencemaxtime)
{
if (soundtest.dosequencefadeout == false)
{
// Handle the immediate progression.
goto handlenextsong;
}
if (soundtest.sequencemaxtime > 0)
{
// Handle the fade.
soundtest.privilegedrequest = true;
S_FadeMusic(0, SOUNDTEST_FADEOUTSECONDS*1000);
soundtest.privilegedrequest = false;
}
// Set the conclusion.
soundtest.sequencefadeout = soundtest.currenttime + SOUNDTEST_FADEOUTSECONDS*TICRATE;
}
return;
handlenextsong:
// If the song's stopped while not in autosequence, stop visibly playing.
if (soundtest.autosequence == false)
{
S_SoundTestStop();
return;
}
// Okay, this is autosequence in action.
S_UpdateSoundTestDef(false, true, true);
}
@ -1946,6 +1981,11 @@ ReadMusicDefFields
{
def->volume = atoi(textline);
}
else if (!stricmp(stoken, "important"))
{
textline[0] = toupper(textline[0]);
def->important = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1');
}
else
{
MusicDefError(CONS_WARNING,
@ -2065,6 +2105,7 @@ void S_ShowMusicCredit(void)
char credittext[128] = "";
char *work = NULL;
size_t len = 128, worklen;
INT32 widthused = BASEVIDWIDTH, workwidth;
if (!cv_songcredits.value || S_PlaysimMusicDisabled())
return;
@ -2095,6 +2136,8 @@ void S_ShowMusicCredit(void)
}
}
widthused -= V_ThinStringWidth(credittext, V_ALLOWLOWERCASE|V_6WIDTHSPACE);
#define MUSICCREDITAPPEND(field)\
if (field)\
{\
@ -2102,8 +2145,13 @@ void S_ShowMusicCredit(void)
worklen = strlen(work);\
if (worklen <= len)\
{\
strncat(credittext, work, len);\
len -= worklen;\
workwidth = V_ThinStringWidth(work, V_ALLOWLOWERCASE|V_6WIDTHSPACE);\
if (widthused >= workwidth)\
{\
strncat(credittext, work, len);\
len -= worklen;\
widthused -= workwidth;\
}\
}\
}
@ -2124,6 +2172,14 @@ void S_ShowMusicCredit(void)
cursongcredit.trans = NUMTRANSMAPS;
}
void S_StopMusicCredit(void)
{
if (S_PlaysimMusicDisabled())
return;
cursongcredit.def = NULL;
}
/// ------------------------
/// Music Status
/// ------------------------

View file

@ -196,6 +196,7 @@ struct musicdef_t
char *composers;
int volume;
int debug_volume;
boolean important;
musicdef_t *next;
soundtestsequence_t sequence;
};
@ -237,6 +238,7 @@ void S_SoundTestPlay(void);
void S_SoundTestStop(void);
void S_SoundTestTogglePause(void);
void S_TickSoundTest(void);
#define SOUNDTEST_FADEOUTSECONDS 5
boolean S_PlaysimMusicDisabled(void);
@ -246,6 +248,7 @@ void S_LoadMusicDefs(UINT16 wadnum);
void S_InitMusicDefs(void);
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i);
void S_ShowMusicCredit(void);
void S_StopMusicCredit(void);
//
// Music Seeking