From d41c7bedd8c6c41e8f8ff63b54ac0d988da16077 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 13:23:53 +0100 Subject: [PATCH 01/16] port musictest from srb2 + making it not crash thing is super ugly, also replaces current sound test for now, which needs to be fixed --- src/d_netcmd.c | 5 +- src/m_menu.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++-- src/s_sound.c | 57 +++++++- src/s_sound.h | 17 ++- src/sounds.c | 48 ++++--- src/sounds.h | 1 + 6 files changed, 458 insertions(+), 35 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 67b875617..b507edd99 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5347,13 +5347,14 @@ static void Gravity_OnChange(void) static void SoundTest_OnChange(void) { + INT32 sfxfreeint = (INT32)sfxfree; if (cv_soundtest.value < 0) { - CV_SetValue(&cv_soundtest, NUMSFX-1); + CV_SetValue(&cv_soundtest, sfxfreeint-1); return; } - if (cv_soundtest.value >= NUMSFX) + if (cv_soundtest.value >= sfxfreeint) { CV_SetValue(&cv_soundtest, 0); return; diff --git a/src/m_menu.c b/src/m_menu.c index d22d29494..9e147af8f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -224,6 +224,7 @@ static void M_GetAllEmeralds(INT32 choice); static void M_DestroyRobots(INT32 choice); //static void M_LevelSelectWarp(INT32 choice); static void M_Credits(INT32 choice); +static void M_SoundTest(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); static char *M_GetConditionString(condition_t cond); @@ -393,6 +394,7 @@ static void M_DrawCenteredMenu(void); static void M_DrawAddons(void); static void M_DrawSkyRoom(void); static void M_DrawChecklist(void); +static void M_DrawSoundTest(void); static void M_DrawEmblemHints(void); static void M_DrawPauseMenu(void); static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade); @@ -858,6 +860,12 @@ static menuitem_t SR_UnlockChecklistMenu[] = {IT_SUBMENU | IT_STRING, NULL, "NEXT", &MainDef, 192}, }; +static menuitem_t SR_SoundTestMenu[] = +{ + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleSoundTest, 0}, +}; + + static menuitem_t SR_EmblemHintMenu[] = { {IT_STRING|IT_CVAR, NULL, "Medal Radar", &cv_itemfinder, 10}, @@ -1568,7 +1576,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 110}, + {IT_STRING|IT_CALL, NULL, "Sound Test", M_SoundTest, 110}, {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, @@ -2476,6 +2484,20 @@ menu_t SR_UnlockChecklistDef = NULL, NULL }; + +menu_t SR_SoundTestDef = +{ + NULL, + sizeof (SR_SoundTestMenu)/sizeof (menuitem_t), + &SR_MainDef, + SR_SoundTestMenu, + M_DrawSoundTest, + 60, 150, + 0, + NULL, + NULL +}; + menu_t SR_EmblemHintDef = { NULL, @@ -7988,7 +8010,7 @@ static void M_DrawSkyRoom(void) lengthstring = 8*(midi_disabled ? 3 : 2);*/ } - for (i = 0; i < currentMenu->numitems; ++i) + /*for (i = 0; i < currentMenu->numitems; ++i) { if (currentMenu->menuitems[i].itemaction == M_HandleSoundTest) { @@ -8007,7 +8029,7 @@ static void M_DrawSkyRoom(void) if (i == itemOn) lengthstring = V_StringWidth(cv_soundtest.string, 0); - } + }*/ if (lengthstring) { @@ -8018,6 +8040,261 @@ static void M_DrawSkyRoom(void) } } +static musicdef_t *curplaying = NULL; +static INT32 st_sel = 0; +static tic_t st_time = 0; +//static patch_t* st_radio[9]; +//static patch_t* st_launchpad[4]; + +static void M_SoundTest(INT32 choice) +{ + INT32 ul = skyRoomMenuTranslations[choice-1]; + UINT8 i; + char buf[8]; + + //soundtestpage = (UINT8)(unlockables[ul].variable); + if (!soundtestpage) + soundtestpage = 1; + + if (!S_PrepareSoundTest()) + { + M_StartMessage(M_GetText("No selectable tracks found.\n"),NULL,MM_NOTHING); + return; + } + + /*STRBUFCPY(buf, "M_RADIOn"); + for (i = 0; i < 9; i++) + { + if (st_radio[i]) + W_UnlockCachedPatch(st_radio[i]); + buf[7] = (char)('0'+i); + st_radio[i] = W_CachePatchName(buf, PU_STATIC); + } + + STRBUFCPY(buf, "M_LPADn"); + for (i = 0; i < 4; i++) + { + if (st_launchpad[i]) + W_UnlockCachedPatch(st_launchpad[i]); + buf[6] = (char)('0'+i); + st_launchpad[i] = W_CachePatchName(buf, PU_STATIC); + }*/ + + curplaying = NULL; + st_time = 0; + + st_sel = 0; + + M_SetupNextMenu(&SR_SoundTestDef); +} + +static void M_DrawSoundTest(void) +{ + INT32 x, y, i; + fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; + UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; + + // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... + if (curplaying) + { + if (curplaying == &soundtestsfx) + { + if (cv_soundtest.value) + { + frame[1] = (2-st_time); + frame[2] = ((cv_soundtest.value - 1) % 9); + frame[3] += (((cv_soundtest.value - 1) / 9) % (MAXSKINCOLORS - frame[3])); + if (st_time < 2) + st_time++; + } + } + else + { + if (curplaying->stoppingtics && st_time >= curplaying->stoppingtics) + { + curplaying = NULL; + st_time = 0; + } + else + { + fixed_t work; + angle_t ang; + //bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach + st_time = (work>>FRACBITS); + + //work = FixedDiv(work*180, bpm); + frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; + bounce = (FINESINE(ang) - FRACUNIT/2); + hscale -= bounce/16; + vscale += bounce/16; + + st_time++; + } + } + } + + x = 90<source); + } + else + titl = "NONE - "; + + i = V_LevelNameWidth(titl); + + if (++st_scroll >= i) + st_scroll %= i; + + x -= st_scroll; + + while (x < BASEVIDWIDTH-y) + x += i; + while (x > y) + { + x -= i; + V_DrawLevelTitle(x, 24, 0, titl); + } + + if (curplaying) + V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); + } + + V_DrawFill(165, 60, 140, 112, 159); + + { + INT32 t, b, q, m = 112; + + if (numsoundtestdefs <= 7) + { + t = 0; + b = numsoundtestdefs - 1; + i = 0; + } + else + { + q = m; + m = (5*m)/numsoundtestdefs; + if (st_sel < 3) + { + t = 0; + b = 6; + i = 0; + } + else if (st_sel >= numsoundtestdefs-4) + { + t = numsoundtestdefs - 7; + b = numsoundtestdefs - 1; + i = q-m; + } + else + { + t = st_sel - 3; + b = st_sel + 3; + i = (t * (q-m))/(numsoundtestdefs - 7); + } + } + + V_DrawFill(165+140-1, 60 + i, 1, m, 0); + + if (t != 0) + V_DrawString(165+140+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + + if (b != numsoundtestdefs - 1) + V_DrawString(165+140+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + + x = 169; + y = 64; + + while (t <= b) + { + if (t == st_sel) + V_DrawFill(165, y-4, 140-1, 16, 155); + if (!soundtestdefs[t]->allowed) + { + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, "???"); + } + else if (soundtestdefs[t] == &soundtestsfx) + { + const char *sfxstr = va("SFX %s", cv_soundtest.string); + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0), sfxstr); + if (t == st_sel) + { + V_DrawCharacter(x - 10 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(x + 2 + V_StringWidth(sfxstr, 0) + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + + if (curplaying == soundtestdefs[t]) + { + sfxstr = (cv_soundtest.value) ? S_sfx[cv_soundtest.value].name : "N/A"; + i = V_StringWidth(sfxstr, 0); + V_DrawFill(165+140-9-i, y-4, i+8, 16, 150); + V_DrawRightAlignedString(165+140-5, y, V_YELLOWMAP, sfxstr); + } + } + else + { + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, soundtestdefs[t]->source); + if (curplaying == soundtestdefs[t]) + { + V_DrawFill(165+140-9, y-4, 8, 16, 150); + //V_DrawCharacter(165+140-8, y, '\x19' | V_YELLOWMAP, false); + //V_DrawFixedPatch((165+140-9)<= numsoundtestdefs-1) + st_sel = 0; + { + S_StartSound(NULL, sfx_menu1); + } break; case KEY_UPARROW: - M_PrevOpt(); - S_StartSound(NULL, sfx_menu1); + if (!st_sel--) + st_sel = numsoundtestdefs-1; + { + S_StartSound(NULL, sfx_menu1); + } + break; + case KEY_PGDN: + if (st_sel < numsoundtestdefs-1) + { + st_sel += 3; + if (st_sel >= numsoundtestdefs-1) + st_sel = numsoundtestdefs-1; + S_StartSound(NULL, sfx_menu1); + } + break; + case KEY_PGUP: + if (st_sel) + { + st_sel -= 3; + if (st_sel < 0) + st_sel = 0; + S_StartSound(NULL, sfx_menu1); + } break; case KEY_BACKSPACE: + if (curplaying) + { + S_StopSounds(); + S_StopMusic(); + curplaying = NULL; + st_time = 0; + S_StartSound(NULL, sfx_skid); + } + break; case KEY_ESCAPE: exitmenu = true; break; case KEY_RIGHTARROW: - CV_AddValue(&cv_soundtest, 1); + if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) + { + S_StopSounds(); + S_StopMusic(); + curplaying = soundtestdefs[st_sel]; + st_time = 0; + CV_AddValue(&cv_soundtest, 1); + } break; case KEY_LEFTARROW: - CV_AddValue(&cv_soundtest, -1); + if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) + { + S_StopSounds(); + S_StopMusic(); + curplaying = soundtestdefs[st_sel]; + st_time = 0; + CV_AddValue(&cv_soundtest, -1); + } break; case KEY_ENTER: S_StopSounds(); - S_StartSound(NULL, cv_soundtest.value); + S_StopMusic(); + st_time = 0; + if (soundtestdefs[st_sel]->allowed) + { + curplaying = soundtestdefs[st_sel]; + if (curplaying == &soundtestsfx) + { + // S_StopMusic() -- is this necessary? + if (cv_soundtest.value) + S_StartSound(NULL, cv_soundtest.value); + } + else + S_ChangeMusicInternal(curplaying->name, !curplaying->stoppingtics); + } + else + { + curplaying = NULL; + S_StartSound(NULL, sfx_lose); + } break; default: @@ -8053,6 +8395,9 @@ static void M_HandleSoundTest(INT32 choice) } if (exitmenu) { + Z_Free(soundtestdefs); + soundtestdefs = NULL; + if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else diff --git a/src/s_sound.c b/src/s_sound.c index bbbd7a6d3..4b54d8128 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -27,6 +27,7 @@ #include "r_sky.h" // skyflatnum #include "p_local.h" // camera info #include "m_misc.h" // for tunes command +#include "m_cond.h" // for conditionsets #ifdef HAVE_BLUA #include "lua_hook.h" // MusicChange hook @@ -1297,6 +1298,19 @@ static UINT32 queue_fadeinms; musicdef_t *musicdefstart = NULL; // First music definition struct cursongcredit cursongcredit; // Currently displayed song credit info +musicdef_t soundtestsfx = { + "_STSFX", // prevents exactly one valid track name from being used on the sound test + "Sound Effects", + "", + "SEGA, Sonic Team Jr, other sources", + 1, // show on soundtest page 1 + 0, // with no conditions + 0, + 0, + false, + NULL +}; + // // search for music definition in wad // @@ -1425,7 +1439,7 @@ skip_lump: free(buf2); return; } - + if (!stricmp(stoken, "usage")) { #if 0 // Ignore for now STRBUFCPY(def->usage, value); @@ -1463,8 +1477,6 @@ void S_InitMusicDefs(void) for (i = 0; i < numwadfiles; i++) S_LoadMusicDefs(i); } - - // // S_FindMusicCredit // @@ -1525,6 +1537,45 @@ void S_ShowMusicCredit(void) S_ShowSpecifiedMusicCredit(music_name); } +musicdef_t **soundtestdefs = NULL; +INT32 numsoundtestdefs = 0; +UINT8 soundtestpage = 1; + +// +// S_PrepareSoundTest +// +// Prepare sound test. What am I, your butler? +// +boolean S_PrepareSoundTest(void) +{ + musicdef_t *def; + INT32 pos = numsoundtestdefs = 0; + + for (def = musicdefstart; def; def = def->next) + { + def->allowed = false; + numsoundtestdefs++; + } + + if (!numsoundtestdefs) + return false; + + if (soundtestdefs) + Z_Free(soundtestdefs); + + if (!(soundtestdefs = Z_Malloc(numsoundtestdefs*sizeof(musicdef_t *), PU_STATIC, NULL))) + I_Error("S_PrepareSoundTest(): could not allocate soundtestdefs."); + + for (def = musicdefstart; def /*&& i < numsoundtestdefs*/; def = def->next) + { + soundtestdefs[pos++] = def; + def->allowed = true; + } + + return true; +} + + /// ------------------------ /// Music Status /// ------------------------ diff --git a/src/s_sound.h b/src/s_sound.h index 19ce89037..8ebc6fde4 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -145,11 +145,25 @@ boolean S_SpeedMusic(float speed); typedef struct musicdef_s { char name[7]; + char title[32]; + char alttitle[64]; //char usage[256]; char source[256]; + char authors[256]; + UINT8 soundtestpage; + INT16 soundtestcond; // +ve for map, -ve for conditionset, 0 for already here + tic_t stoppingtics; + fixed_t bpm; + boolean allowed; // question marks or listenable on sound test? struct musicdef_s *next; } musicdef_t; +extern musicdef_t soundtestsfx; +extern musicdef_t *musicdefstart; +extern musicdef_t **soundtestdefs; +extern INT32 numsoundtestdefs; +extern UINT8 soundtestpage; + extern struct cursongcredit { musicdef_t *def; @@ -158,7 +172,6 @@ extern struct cursongcredit UINT8 trans; } cursongcredit; -extern musicdef_t *musicdefstart; void S_LoadMusicDefs(UINT16 wadnum); void S_InitMusicDefs(void); @@ -166,6 +179,8 @@ musicdef_t *S_FindMusicCredit(const char *musname); void S_ShowSpecifiedMusicCredit(const char *musname); void S_ShowMusicCredit(void); +boolean S_PrepareSoundTest(void); + // // Music Seeking // diff --git a/src/sounds.c b/src/sounds.c index d949c27ab..820e75cd1 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1007,35 +1007,45 @@ void S_InitRuntimeSounds (void) } } +sfxenum_t sfxfree = sfx_freeslot0; + // Add a new sound fx into a free sfx slot. // sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound) { - sfxenum_t i, slot; + sfxenum_t i; if (skinsound) - slot = sfx_skinsoundslot0; - else - slot = sfx_freeslot0; - - for (i = slot; i < NUMSFX; i++) { - if (!S_sfx[i].priority) + for (i = sfx_skinsoundslot0; i < NUMSFX; i++) { - strncpy(freeslotnames[i-sfx_freeslot0], name, 6); - S_sfx[i].singularity = singular; - S_sfx[i].priority = 60; - S_sfx[i].pitch = flags; - S_sfx[i].volume = -1; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].skinsound = -1; - S_sfx[i].usefulness = -1; - - /// \todo if precached load it here - S_sfx[i].data = NULL; - return i; + if (S_sfx[i].priority) + continue; + break; } } + else + i = sfxfree; + + if (i < NUMSFX) + { + strncpy(freeslotnames[i-sfx_freeslot0], name, 6); + S_sfx[i].singularity = singular; + S_sfx[i].priority = 60; + S_sfx[i].pitch = flags; + S_sfx[i].volume = -1; + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].skinsound = -1; + S_sfx[i].usefulness = -1; + + /// \todo if precached load it here + S_sfx[i].data = NULL; + + if (!skinsound) + sfxfree++; + + return i; + } I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; } diff --git a/src/sounds.h b/src/sounds.h index 6621dc6bf..a8f683e32 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1057,6 +1057,7 @@ typedef enum void S_InitRuntimeSounds(void); sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound); +extern sfxenum_t sfxfree; // sound test and slotting void S_RemoveSoundFx(sfxenum_t id); #endif -- 2.54.0 From d6702be08bdfe784c027d769984c6776ce8d820d Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 13:58:35 +0100 Subject: [PATCH 02/16] make it its own thing, add back normal sound test --- src/m_menu.c | 143 ++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 77 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9e147af8f..1da3936a3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -224,7 +224,7 @@ static void M_GetAllEmeralds(INT32 choice); static void M_DestroyRobots(INT32 choice); //static void M_LevelSelectWarp(INT32 choice); static void M_Credits(INT32 choice); -static void M_SoundTest(INT32 choice); +static void M_MusicTest(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); static char *M_GetConditionString(condition_t cond); @@ -394,7 +394,7 @@ static void M_DrawCenteredMenu(void); static void M_DrawAddons(void); static void M_DrawSkyRoom(void); static void M_DrawChecklist(void); -static void M_DrawSoundTest(void); +static void M_DrawMusicTest(void); static void M_DrawEmblemHints(void); static void M_DrawPauseMenu(void); static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade); @@ -429,6 +429,7 @@ static boolean M_ExitPandorasBox(void); static boolean M_QuitMultiPlayerMenu(void); static void M_HandleAddons(INT32 choice); static void M_HandleSoundTest(INT32 choice); +static void M_HandleMusicTest(INT32 choice); static void M_HandleImageDef(INT32 choice); //static void M_HandleLoadSave(INT32 choice); static void M_HandleLevelStats(INT32 choice); @@ -860,9 +861,9 @@ static menuitem_t SR_UnlockChecklistMenu[] = {IT_SUBMENU | IT_STRING, NULL, "NEXT", &MainDef, 192}, }; -static menuitem_t SR_SoundTestMenu[] = +static menuitem_t SR_MusicTestMenu[] = { - {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleSoundTest, 0}, + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleMusicTest, 0}, }; @@ -1575,8 +1576,9 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, - - {IT_STRING|IT_CALL, NULL, "Sound Test", M_SoundTest, 110}, + + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, @@ -1596,6 +1598,7 @@ static const char* OP_SoundTooltips[] = "Frequency of character voice lines.", "Should the powerup warning be a sound effect or music?", "Testing sounds...", + "Testing music...", "Should the games music play while unfocused?", "Should the games sound play while unfocused?", "Options for advanced sound settings.", @@ -2485,13 +2488,13 @@ menu_t SR_UnlockChecklistDef = NULL }; -menu_t SR_SoundTestDef = +menu_t SR_MusicTestDef = { NULL, - sizeof (SR_SoundTestMenu)/sizeof (menuitem_t), + sizeof (SR_MusicTestMenu)/sizeof (menuitem_t), &SR_MainDef, - SR_SoundTestMenu, - M_DrawSoundTest, + SR_MusicTestMenu, + M_DrawMusicTest, 60, 150, 0, NULL, @@ -8010,7 +8013,7 @@ static void M_DrawSkyRoom(void) lengthstring = 8*(midi_disabled ? 3 : 2);*/ } - /*for (i = 0; i < currentMenu->numitems; ++i) + for (i = 0; i < currentMenu->numitems; ++i) { if (currentMenu->menuitems[i].itemaction == M_HandleSoundTest) { @@ -8029,7 +8032,7 @@ static void M_DrawSkyRoom(void) if (i == itemOn) lengthstring = V_StringWidth(cv_soundtest.string, 0); - }*/ + } if (lengthstring) { @@ -8040,13 +8043,55 @@ static void M_DrawSkyRoom(void) } } +static void M_HandleSoundTest(INT32 choice) +{ + boolean exitmenu = false; // exit to previous menu + + switch (choice) + { + case KEY_DOWNARROW: + M_NextOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_UPARROW: + M_PrevOpt(); + S_StartSound(NULL, sfx_menu1); + break; + case KEY_BACKSPACE: + case KEY_ESCAPE: + exitmenu = true; + break; + + case KEY_RIGHTARROW: + CV_AddValue(&cv_soundtest, 1); + break; + case KEY_LEFTARROW: + CV_AddValue(&cv_soundtest, -1); + break; + case KEY_ENTER: + S_StopSounds(); + S_StartSound(NULL, cv_soundtest.value); + break; + + default: + break; + } + if (exitmenu) + { + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + } +} + static musicdef_t *curplaying = NULL; static INT32 st_sel = 0; static tic_t st_time = 0; //static patch_t* st_radio[9]; //static patch_t* st_launchpad[4]; -static void M_SoundTest(INT32 choice) +static void M_MusicTest(INT32 choice) { INT32 ul = skyRoomMenuTranslations[choice-1]; UINT8 i; @@ -8085,10 +8130,10 @@ static void M_SoundTest(INT32 choice) st_sel = 0; - M_SetupNextMenu(&SR_SoundTestDef); + M_SetupNextMenu(&SR_MusicTestDef); } -static void M_DrawSoundTest(void) +static void M_DrawMusicTest(void) { INT32 x, y, i; fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; @@ -8097,18 +8142,6 @@ static void M_DrawSoundTest(void) // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... if (curplaying) { - if (curplaying == &soundtestsfx) - { - if (cv_soundtest.value) - { - frame[1] = (2-st_time); - frame[2] = ((cv_soundtest.value - 1) % 9); - frame[3] += (((cv_soundtest.value - 1) / 9) % (MAXSKINCOLORS - frame[3])); - if (st_time < 2) - st_time++; - } - } - else { if (curplaying->stoppingtics && st_time >= curplaying->stoppingtics) { @@ -8130,7 +8163,7 @@ static void M_DrawSoundTest(void) //work = FixedDiv(work*180, bpm); frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; - bounce = (FINESINE(ang) - FRACUNIT/2); + //bounce = (FINESINE(ang) - FRACUNIT/2); hscale -= bounce/16; vscale += bounce/16; @@ -8200,8 +8233,8 @@ static void M_DrawSoundTest(void) V_DrawLevelTitle(x, 24, 0, titl); } - if (curplaying) - V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); + //if (curplaying) + //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); } V_DrawFill(165, 60, 140, 112, 159); @@ -8258,26 +8291,6 @@ static void M_DrawSoundTest(void) { V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, "???"); } - else if (soundtestdefs[t] == &soundtestsfx) - { - const char *sfxstr = va("SFX %s", cv_soundtest.string); - V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0), sfxstr); - if (t == st_sel) - { - V_DrawCharacter(x - 10 - (skullAnimCounter/5), y, - '\x1C' | V_YELLOWMAP, false); - V_DrawCharacter(x + 2 + V_StringWidth(sfxstr, 0) + (skullAnimCounter/5), y, - '\x1D' | V_YELLOWMAP, false); - } - - if (curplaying == soundtestdefs[t]) - { - sfxstr = (cv_soundtest.value) ? S_sfx[cv_soundtest.value].name : "N/A"; - i = V_StringWidth(sfxstr, 0); - V_DrawFill(165+140-9-i, y-4, i+8, 16, 150); - V_DrawRightAlignedString(165+140-5, y, V_YELLOWMAP, sfxstr); - } - } else { V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, soundtestdefs[t]->source); @@ -8295,7 +8308,7 @@ static void M_DrawSoundTest(void) } -static void M_HandleSoundTest(INT32 choice) +static void M_HandleMusicTest(INT32 choice) { boolean exitmenu = false; // exit to previous menu @@ -8348,25 +8361,7 @@ static void M_HandleSoundTest(INT32 choice) break; case KEY_RIGHTARROW: - if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) - { - S_StopSounds(); - S_StopMusic(); - curplaying = soundtestdefs[st_sel]; - st_time = 0; - CV_AddValue(&cv_soundtest, 1); - } - break; case KEY_LEFTARROW: - if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) - { - S_StopSounds(); - S_StopMusic(); - curplaying = soundtestdefs[st_sel]; - st_time = 0; - CV_AddValue(&cv_soundtest, -1); - } - break; case KEY_ENTER: S_StopSounds(); S_StopMusic(); @@ -8374,14 +8369,8 @@ static void M_HandleSoundTest(INT32 choice) if (soundtestdefs[st_sel]->allowed) { curplaying = soundtestdefs[st_sel]; - if (curplaying == &soundtestsfx) - { - // S_StopMusic() -- is this necessary? - if (cv_soundtest.value) - S_StartSound(NULL, cv_soundtest.value); - } - else - S_ChangeMusicInternal(curplaying->name, !curplaying->stoppingtics); + + S_ChangeMusicInternal(curplaying->name, !curplaying->stoppingtics); } else { -- 2.54.0 From 0fc3d9d4d644e21e26811a7467bfc89ec3b8c2af Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 14:03:54 +0100 Subject: [PATCH 03/16] do NOT change how sound freeslotting works reasons --- src/d_netcmd.c | 5 ++--- src/sounds.c | 46 ++++++++++++++++++---------------------------- src/sounds.h | 1 - 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b507edd99..67b875617 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5347,14 +5347,13 @@ static void Gravity_OnChange(void) static void SoundTest_OnChange(void) { - INT32 sfxfreeint = (INT32)sfxfree; if (cv_soundtest.value < 0) { - CV_SetValue(&cv_soundtest, sfxfreeint-1); + CV_SetValue(&cv_soundtest, NUMSFX-1); return; } - if (cv_soundtest.value >= sfxfreeint) + if (cv_soundtest.value >= NUMSFX) { CV_SetValue(&cv_soundtest, 0); return; diff --git a/src/sounds.c b/src/sounds.c index 820e75cd1..d949c27ab 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1007,44 +1007,34 @@ void S_InitRuntimeSounds (void) } } -sfxenum_t sfxfree = sfx_freeslot0; - // Add a new sound fx into a free sfx slot. // sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound) { - sfxenum_t i; + sfxenum_t i, slot; if (skinsound) - { - for (i = sfx_skinsoundslot0; i < NUMSFX; i++) - { - if (S_sfx[i].priority) - continue; - break; - } - } + slot = sfx_skinsoundslot0; else - i = sfxfree; + slot = sfx_freeslot0; - if (i < NUMSFX) + for (i = slot; i < NUMSFX; i++) { - strncpy(freeslotnames[i-sfx_freeslot0], name, 6); - S_sfx[i].singularity = singular; - S_sfx[i].priority = 60; - S_sfx[i].pitch = flags; - S_sfx[i].volume = -1; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].skinsound = -1; - S_sfx[i].usefulness = -1; + if (!S_sfx[i].priority) + { + strncpy(freeslotnames[i-sfx_freeslot0], name, 6); + S_sfx[i].singularity = singular; + S_sfx[i].priority = 60; + S_sfx[i].pitch = flags; + S_sfx[i].volume = -1; + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].skinsound = -1; + S_sfx[i].usefulness = -1; - /// \todo if precached load it here - S_sfx[i].data = NULL; - - if (!skinsound) - sfxfree++; - - return i; + /// \todo if precached load it here + S_sfx[i].data = NULL; + return i; + } } I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; diff --git a/src/sounds.h b/src/sounds.h index a8f683e32..6621dc6bf 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1057,7 +1057,6 @@ typedef enum void S_InitRuntimeSounds(void); sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound); -extern sfxenum_t sfxfree; // sound test and slotting void S_RemoveSoundFx(sfxenum_t id); #endif -- 2.54.0 From 2769847c90a7f7ee52753350c72a58f7513a3737 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Mon, 27 Nov 2023 14:13:15 +0100 Subject: [PATCH 04/16] remove unused things + move stuff around e --- src/m_menu.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1da3936a3..56a07b58f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8136,8 +8136,8 @@ static void M_MusicTest(INT32 choice) static void M_DrawMusicTest(void) { INT32 x, y, i; - fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; - UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; + //fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; + //UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... if (curplaying) @@ -8151,7 +8151,7 @@ static void M_DrawMusicTest(void) else { fixed_t work; - angle_t ang; + //angle_t ang; //bpm = FixedDiv((60*TICRATE)<>FRACBITS); //work = FixedDiv(work*180, bpm); - frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; + //frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; //bounce = (FINESINE(ang) - FRACUNIT/2); - hscale -= bounce/16; - vscale += bounce/16; + //hscale -= bounce/16; + //vscale += bounce/16; st_time++; } @@ -8237,7 +8237,7 @@ static void M_DrawMusicTest(void) //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); } - V_DrawFill(165, 60, 140, 112, 159); + V_DrawFill(40, 60, 240, 112, 159); { INT32 t, b, q, m = 112; @@ -8272,21 +8272,21 @@ static void M_DrawMusicTest(void) } } - V_DrawFill(165+140-1, 60 + i, 1, m, 0); + V_DrawFill(40+240-1, 60 + i, 1, m, 0); if (t != 0) - V_DrawString(165+140+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + V_DrawString(40+240+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); if (b != numsoundtestdefs - 1) - V_DrawString(165+140+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + V_DrawString(40+240+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); - x = 169; + x = 49; y = 64; while (t <= b) { if (t == st_sel) - V_DrawFill(165, y-4, 140-1, 16, 155); + V_DrawFill(40, y-4, 240-1, 16, 155); if (!soundtestdefs[t]->allowed) { V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, "???"); @@ -8296,7 +8296,7 @@ static void M_DrawMusicTest(void) V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, soundtestdefs[t]->source); if (curplaying == soundtestdefs[t]) { - V_DrawFill(165+140-9, y-4, 8, 16, 150); + V_DrawFill(40+240-9, y-4, 8, 16, 150); //V_DrawCharacter(165+140-8, y, '\x19' | V_YELLOWMAP, false); //V_DrawFixedPatch((165+140-9)< Date: Mon, 27 Nov 2023 14:25:26 +0100 Subject: [PATCH 05/16] musictest should return you to music options menu --- src/m_menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 56a07b58f..ee40629fe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2492,7 +2492,7 @@ menu_t SR_MusicTestDef = { NULL, sizeof (SR_MusicTestMenu)/sizeof (menuitem_t), - &SR_MainDef, + &OP_SoundOptionsDef, SR_MusicTestMenu, M_DrawMusicTest, 60, 150, @@ -8307,7 +8307,6 @@ static void M_DrawMusicTest(void) } } - static void M_HandleMusicTest(INT32 choice) { boolean exitmenu = false; // exit to previous menu -- 2.54.0 From 2abb65403f7f27aac432734396bd06a980be3a69 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 27 Nov 2023 16:49:48 +0300 Subject: [PATCH 06/16] Make music names in music test scroll --- src/m_menu.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 1da3936a3..6dbba6dd4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8088,6 +8088,8 @@ static void M_HandleSoundTest(INT32 choice) static musicdef_t *curplaying = NULL; static INT32 st_sel = 0; static tic_t st_time = 0; +static size_t st_namescroll = 0; +static size_t st_namescrollstate = 0; //static patch_t* st_radio[9]; //static patch_t* st_launchpad[4]; @@ -8283,6 +8285,8 @@ static void M_DrawMusicTest(void) x = 169; y = 64; + if (renderisnewtic) ++st_namescroll; + while (t <= b) { if (t == st_sel) @@ -8293,7 +8297,75 @@ static void M_DrawMusicTest(void) } else { - V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, soundtestdefs[t]->source); + const size_t MAXLENGTH = 17; + const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter + size_t nameoffset = 0; + size_t namelength = strlen(soundtestdefs[t]->source); + + char buf[MAXLENGTH+1]; + + if (t == st_sel && namelength > MAXLENGTH) + { + switch (st_namescrollstate) + { + case 0: + { + // Scroll forward + nameoffset = (st_namescroll/SCROLLSPEED) % (namelength - MAXLENGTH + 1); + + if (nameoffset == namelength - MAXLENGTH) + { + st_namescroll = 0; + st_namescrollstate++; + } + } + break; + + case 1: + { + nameoffset = namelength - MAXLENGTH; + + // Show name end for 1 second, then start scrolling back + if (st_namescroll == TICRATE) + { + st_namescroll = 0; + st_namescrollstate++; + } + } + break; + + case 2: + { + // Scroll back + nameoffset = (namelength - MAXLENGTH - 1) - (st_namescroll/SCROLLSPEED) % (namelength - MAXLENGTH); + + if (nameoffset == 0) + { + st_namescroll = 0; + st_namescrollstate++; + } + } + break; + + case 3: + { + nameoffset = 0; + + // Show name beginning for 1 second, then start scrolling forward again + if (st_namescroll == TICRATE) + { + st_namescroll = 0; + st_namescrollstate = 0; + } + } + break; + } + } + + strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); + buf[MAXLENGTH+1] = 0; + + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); if (curplaying == soundtestdefs[t]) { V_DrawFill(165+140-9, y-4, 8, 16, 150); @@ -8320,6 +8392,8 @@ static void M_HandleMusicTest(INT32 choice) { S_StartSound(NULL, sfx_menu1); } + st_namescroll = 0; + st_namescrollstate = 0; break; case KEY_UPARROW: if (!st_sel--) @@ -8327,6 +8401,8 @@ static void M_HandleMusicTest(INT32 choice) { S_StartSound(NULL, sfx_menu1); } + st_namescroll = 0; + st_namescrollstate = 0; break; case KEY_PGDN: if (st_sel < numsoundtestdefs-1) @@ -8336,6 +8412,8 @@ static void M_HandleMusicTest(INT32 choice) st_sel = numsoundtestdefs-1; S_StartSound(NULL, sfx_menu1); } + st_namescroll = 0; + st_namescrollstate = 0; break; case KEY_PGUP: if (st_sel) @@ -8345,6 +8423,8 @@ static void M_HandleMusicTest(INT32 choice) st_sel = 0; S_StartSound(NULL, sfx_menu1); } + st_namescroll = 0; + st_namescrollstate = 0; break; case KEY_BACKSPACE: if (curplaying) @@ -8358,6 +8438,8 @@ static void M_HandleMusicTest(INT32 choice) break; case KEY_ESCAPE: exitmenu = true; + st_namescroll = 0; + st_namescrollstate = 0; break; case KEY_RIGHTARROW: -- 2.54.0 From 0907c219af62ac3443be65994376453435d53759 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 27 Nov 2023 16:57:38 +0300 Subject: [PATCH 07/16] Change maximum string length for name in music test --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 73b2e65b2..dfd641d67 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8297,7 +8297,7 @@ static void M_DrawMusicTest(void) } else { - const size_t MAXLENGTH = 17; + const size_t MAXLENGTH = 28; const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter size_t nameoffset = 0; size_t namelength = strlen(soundtestdefs[t]->source); -- 2.54.0 From 7599d9ddd48d23d0c936ad3b6f9ba1d2cc2d9e2a Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 27 Nov 2023 17:06:38 +0300 Subject: [PATCH 08/16] Fix assigning null character out of string bounds --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index dfd641d67..984a9e0f6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8363,7 +8363,7 @@ static void M_DrawMusicTest(void) } strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); - buf[MAXLENGTH+1] = 0; + buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); if (curplaying == soundtestdefs[t]) -- 2.54.0 From 2009ed38f033917c1761d1015ddd25f0adbd30dc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Nov 2023 15:19:21 +0100 Subject: [PATCH 09/16] we dont have that stuff so remove it --- src/m_menu.c | 59 +++++++++++++++------------------------------------ src/s_sound.c | 3 --- src/s_sound.h | 8 ------- 3 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 984a9e0f6..b9b4f597f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8099,10 +8099,6 @@ static void M_MusicTest(INT32 choice) UINT8 i; char buf[8]; - //soundtestpage = (UINT8)(unlockables[ul].variable); - if (!soundtestpage) - soundtestpage = 1; - if (!S_PrepareSoundTest()) { M_StartMessage(M_GetText("No selectable tracks found.\n"),NULL,MM_NOTHING); @@ -8145,32 +8141,24 @@ static void M_DrawMusicTest(void) if (curplaying) { { - if (curplaying->stoppingtics && st_time >= curplaying->stoppingtics) - { - curplaying = NULL; - st_time = 0; - } - else - { - fixed_t work; - //angle_t ang; - //bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach - st_time = (work>>FRACBITS); + if (st_time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach + st_time = (work>>FRACBITS); - //work = FixedDiv(work*180, bpm); - //frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; - //bounce = (FINESINE(ang) - FRACUNIT/2); - //hscale -= bounce/16; - //vscale += bounce/16; + //work = FixedDiv(work*180, bpm); + //frame[0] = 8-(work/(20<>ANGLETOFINESHIFT) & FINEMASK; + //bounce = (FINESINE(ang) - FRACUNIT/2); + //hscale -= bounce/16; + //vscale += bounce/16; - st_time++; - } + st_time++; } } @@ -8291,11 +8279,7 @@ static void M_DrawMusicTest(void) { if (t == st_sel) V_DrawFill(40, y-4, 240-1, 16, 155); - if (!soundtestdefs[t]->allowed) - { - V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, "???"); - } - else + { const size_t MAXLENGTH = 28; const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter @@ -8447,17 +8431,8 @@ static void M_HandleMusicTest(INT32 choice) S_StopSounds(); S_StopMusic(); st_time = 0; - if (soundtestdefs[st_sel]->allowed) - { - curplaying = soundtestdefs[st_sel]; - - S_ChangeMusicInternal(curplaying->name, !curplaying->stoppingtics); - } - else - { - curplaying = NULL; - S_StartSound(NULL, sfx_lose); - } + curplaying = soundtestdefs[st_sel]; + S_ChangeMusicInternal(curplaying->name, true); break; default: diff --git a/src/s_sound.c b/src/s_sound.c index 4b54d8128..4b08c81dd 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1539,7 +1539,6 @@ void S_ShowMusicCredit(void) musicdef_t **soundtestdefs = NULL; INT32 numsoundtestdefs = 0; -UINT8 soundtestpage = 1; // // S_PrepareSoundTest @@ -1553,7 +1552,6 @@ boolean S_PrepareSoundTest(void) for (def = musicdefstart; def; def = def->next) { - def->allowed = false; numsoundtestdefs++; } @@ -1569,7 +1567,6 @@ boolean S_PrepareSoundTest(void) for (def = musicdefstart; def /*&& i < numsoundtestdefs*/; def = def->next) { soundtestdefs[pos++] = def; - def->allowed = true; } return true; diff --git a/src/s_sound.h b/src/s_sound.h index 8ebc6fde4..c16b05d64 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -145,16 +145,8 @@ boolean S_SpeedMusic(float speed); typedef struct musicdef_s { char name[7]; - char title[32]; - char alttitle[64]; //char usage[256]; char source[256]; - char authors[256]; - UINT8 soundtestpage; - INT16 soundtestcond; // +ve for map, -ve for conditionset, 0 for already here - tic_t stoppingtics; - fixed_t bpm; - boolean allowed; // question marks or listenable on sound test? struct musicdef_s *next; } musicdef_t; -- 2.54.0 From a256e170ab8fb1f10d04e12fa50647bbb18af7c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Nov 2023 15:37:22 +0100 Subject: [PATCH 10/16] fix interpolation speeding things up + make box wider --- src/m_menu.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b9b4f597f..f4bb9dd13 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8145,11 +8145,11 @@ static void M_DrawMusicTest(void) //angle_t ang; //bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach - st_time = (work>>FRACBITS); + if (st_time >= (FRACUNIT << (FRACBITS - 2))) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach + st_time = work; //work = FixedDiv(work*180, bpm); //frame[0] = 8-(work/(20<= i) - st_scroll %= i; + st_scroll += renderdeltatics; - x -= st_scroll; + while (st_scroll >= (i << FRACBITS)) + st_scroll -= i << FRACBITS; + + x -= st_scroll >> FRACBITS; while (x < BASEVIDWIDTH-y) x += i; @@ -8227,7 +8229,7 @@ static void M_DrawMusicTest(void) //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); } - V_DrawFill(40, 60, 240, 112, 159); + V_DrawFill(20, 60, 280, 112, 159); { INT32 t, b, q, m = 112; @@ -8262,15 +8264,15 @@ static void M_DrawMusicTest(void) } } - V_DrawFill(40+240-1, 60 + i, 1, m, 0); + V_DrawFill(20+280-1, 60 + i, 1, m, 0); if (t != 0) - V_DrawString(40+240+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + V_DrawString(20+280+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); if (b != numsoundtestdefs - 1) - V_DrawString(40+240+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + V_DrawString(20+280+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); - x = 49; + x = 24; y = 64; if (renderisnewtic) ++st_namescroll; @@ -8278,10 +8280,10 @@ static void M_DrawMusicTest(void) while (t <= b) { if (t == st_sel) - V_DrawFill(40, y-4, 240-1, 16, 155); + V_DrawFill(20, y-4, 280-1, 16, 155); { - const size_t MAXLENGTH = 28; + const size_t MAXLENGTH = 34; const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter size_t nameoffset = 0; size_t namelength = strlen(soundtestdefs[t]->source); @@ -8352,7 +8354,7 @@ static void M_DrawMusicTest(void) V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); if (curplaying == soundtestdefs[t]) { - V_DrawFill(40+240-9, y-4, 8, 16, 150); + V_DrawFill(20+280-9, y-4, 8, 16, 150); //V_DrawCharacter(165+140-8, y, '\x19' | V_YELLOWMAP, false); //V_DrawFixedPatch((165+140-9)< Date: Mon, 27 Nov 2023 15:45:44 +0100 Subject: [PATCH 11/16] fix small gap on some resolutions --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index f4bb9dd13..bfa55ae0c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8195,7 +8195,7 @@ static void M_DrawMusicTest(void) y = (BASEVIDWIDTH-(vid.width/vid.dupx))/2; - V_DrawFill(y, 20, vid.width/vid.dupx, 24, 159); + V_DrawFill(y-1, 20, vid.width/vid.dupx+1, 24, 159); { static fixed_t st_scroll = -FRACUNIT; const char* titl; -- 2.54.0 From a27dc33e255c95196caaa41bc3f7158d44638b33 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Nov 2023 15:58:13 +0100 Subject: [PATCH 12/16] 1 extra row hope this right lul --- src/m_menu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index bfa55ae0c..bd0f76ce7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8229,12 +8229,12 @@ static void M_DrawMusicTest(void) //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); } - V_DrawFill(20, 60, 280, 112, 159); + V_DrawFill(20, 60, 280, 127, 159); { INT32 t, b, q, m = 112; - if (numsoundtestdefs <= 7) + if (numsoundtestdefs <= 8) { t = 0; b = numsoundtestdefs - 1; @@ -8247,20 +8247,20 @@ static void M_DrawMusicTest(void) if (st_sel < 3) { t = 0; - b = 6; + b = 7; i = 0; } else if (st_sel >= numsoundtestdefs-4) { - t = numsoundtestdefs - 7; + t = numsoundtestdefs - 8; b = numsoundtestdefs - 1; i = q-m; } else { t = st_sel - 3; - b = st_sel + 3; - i = (t * (q-m))/(numsoundtestdefs - 7); + b = st_sel + 4; + i = (t * (q-m))/(numsoundtestdefs - 8); } } -- 2.54.0 From 88e8c0541b7d0486166638575ebd717c0847c687 Mon Sep 17 00:00:00 2001 From: alufolie91 Date: Tue, 28 Nov 2023 07:33:41 +0100 Subject: [PATCH 13/16] show some music info on bottom right when playing in music test also allows the game to read "usage" from musicdefs --- src/m_menu.c | 9 +++++++++ src/s_sound.c | 2 -- src/s_sound.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index bd0f76ce7..67a82a62d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8199,6 +8199,7 @@ static void M_DrawMusicTest(void) { static fixed_t st_scroll = -FRACUNIT; const char* titl; + x = 16; V_DrawString(x, 10, 0, "NOW PLAYING:"); if (curplaying) @@ -8227,6 +8228,14 @@ static void M_DrawMusicTest(void) //if (curplaying) //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); + + if (curplaying) + { + if (!curplaying->usage[0]) + V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s", curplaying->name)); + else + V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s - %.255s\n", curplaying->name, curplaying->usage)); + } } V_DrawFill(20, 60, 280, 127, 159); diff --git a/src/s_sound.c b/src/s_sound.c index 4b08c81dd..93d65aecd 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1441,12 +1441,10 @@ skip_lump: } if (!stricmp(stoken, "usage")) { -#if 0 // Ignore for now STRBUFCPY(def->usage, value); for (value = def->usage; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage); -#endif } else if (!stricmp(stoken, "source")) { STRBUFCPY(def->source, value); for (value = def->source; *value; value++) diff --git a/src/s_sound.h b/src/s_sound.h index c16b05d64..15ff9b250 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -145,7 +145,7 @@ boolean S_SpeedMusic(float speed); typedef struct musicdef_s { char name[7]; - //char usage[256]; + char usage[256]; char source[256]; struct musicdef_s *next; } musicdef_t; -- 2.54.0 From e57ad130049d31731481d57271b27635d3ddc300 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Nov 2023 09:39:02 +0100 Subject: [PATCH 14/16] align stuff proper + make it kart menu blue --- src/m_menu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 67a82a62d..d83d1ba34 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8195,7 +8195,7 @@ static void M_DrawMusicTest(void) y = (BASEVIDWIDTH-(vid.width/vid.dupx))/2; - V_DrawFill(y-1, 20, vid.width/vid.dupx+1, 24, 159); + V_DrawFill(y-1, 20, vid.width/vid.dupx+1, 24, 239); { static fixed_t st_scroll = -FRACUNIT; const char* titl; @@ -8238,10 +8238,10 @@ static void M_DrawMusicTest(void) } } - V_DrawFill(20, 60, 280, 127, 159); + V_DrawFill(20, 60, 280, 128, 239); { - INT32 t, b, q, m = 112; + INT32 t, b, q, m = 128; if (numsoundtestdefs <= 8) { @@ -8279,7 +8279,7 @@ static void M_DrawMusicTest(void) V_DrawString(20+280+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); if (b != numsoundtestdefs - 1) - V_DrawString(20+280+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + V_DrawString(20+280+4, 60+128-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); x = 24; y = 64; @@ -8289,7 +8289,7 @@ static void M_DrawMusicTest(void) while (t <= b) { if (t == st_sel) - V_DrawFill(20, y-4, 280-1, 16, 155); + V_DrawFill(20, y-4, 280-1, 16, 237); { const size_t MAXLENGTH = 34; @@ -8363,7 +8363,7 @@ static void M_DrawMusicTest(void) V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); if (curplaying == soundtestdefs[t]) { - V_DrawFill(20+280-9, y-4, 8, 16, 150); + V_DrawFill(20+280-9, y-4, 8, 16, 230); //V_DrawCharacter(165+140-8, y, '\x19' | V_YELLOWMAP, false); //V_DrawFixedPatch((165+140-9)< Date: Tue, 28 Nov 2023 11:42:46 +0100 Subject: [PATCH 15/16] show file of where the music comes from + toggle ty indev c: --- src/d_netcmd.c | 1 + src/m_menu.c | 7 ++++++- src/m_menu.h | 1 + src/s_sound.c | 2 ++ src/s_sound.h | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 67b875617..cd9f1af24 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1122,6 +1122,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_lastserver); CV_RegisterVar(&cv_showallmaps); + CV_RegisterVar(&cv_showmusicfilename); // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); diff --git a/src/m_menu.c b/src/m_menu.c index d83d1ba34..1a8cc57ce 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -470,7 +470,9 @@ CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; consvar_t cv_newgametype = {"newgametype", "Race", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showallmaps = {"showallmaps", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; +consvar_t cv_showallmaps = {"showallmaps", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_showmusicfilename = {"showmusicfilename", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t serversort_cons_t[] = { {0,"Ping"}, @@ -8235,6 +8237,9 @@ static void M_DrawMusicTest(void) V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s", curplaying->name)); else V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s - %.255s\n", curplaying->name, curplaying->usage)); + + if (cv_showmusicfilename.value) + V_DrawSmallString(0, 0, V_SNAPTOTOP|V_SNAPTOLEFT|V_ALLOWLOWERCASE, curplaying->filename); } } diff --git a/src/m_menu.h b/src/m_menu.h index d8726623b..e3b042294 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -245,6 +245,7 @@ extern description_t description[MAXSKINS]; extern consvar_t cv_showfocuslost; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; extern consvar_t cv_showallmaps; +extern consvar_t cv_showmusicfilename; extern CV_PossibleValue_t gametype_cons_t[]; extern char dummystaffname[22]; diff --git a/src/s_sound.c b/src/s_sound.c index 93d65aecd..d622f724d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1417,6 +1417,8 @@ void S_LoadMusicDefs(UINT16 wadnum) //CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name); } } + + strncpy(def->filename, wadfiles[wadnum]->filename, 256); skip_lump: stoken = strtok(NULL, "\r\n "); diff --git a/src/s_sound.h b/src/s_sound.h index 15ff9b250..44267bc21 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -147,6 +147,7 @@ typedef struct musicdef_s char name[7]; char usage[256]; char source[256]; + char filename[256]; struct musicdef_s *next; } musicdef_t; -- 2.54.0 From a92f05b8642583b5a83b6e8c9cb1c79a2e00f8b1 Mon Sep 17 00:00:00 2001 From: hayaunderscore Date: Sun, 3 Dec 2023 09:15:22 +0800 Subject: [PATCH 16/16] MUSCINFO separate lump for music test stuff --- src/d_main.c | 1 + src/m_menu.c | 24 +++++-- src/p_setup.c | 5 ++ src/s_sound.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/s_sound.h | 9 +++ src/w_wad.c | 3 +- 6 files changed, 214 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f4de2d32a..4f95049ab 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1504,6 +1504,7 @@ void D_SRB2Main(void) I_InitMusic(); S_InitSfxChannels(cv_soundvolume.value); S_InitMusicDefs(); + S_InitMTDefs(); } CONS_Printf("ST_Init(): Init status bar.\n"); diff --git a/src/m_menu.c b/src/m_menu.c index bb0c9d3e6..70e4424c7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8165,6 +8165,7 @@ static void M_MusicTest(INT32 choice) static void M_DrawMusicTest(void) { INT32 x, y, i; + char* title; //fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; //UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; @@ -8235,7 +8236,12 @@ static void M_DrawMusicTest(void) V_DrawString(x, 10, 0, "NOW PLAYING:"); if (curplaying) { - titl = va("%s - ", curplaying->source); + if (curplaying->title[0] && curplaying->alttitle[0]) + titl = va("%s - %s - ", curplaying->title, curplaying->alttitle); + else if (curplaying->title[0]) + titl = va("%s - ", curplaying->title); + else + titl = va("%s - ", curplaying->source); } else titl = "NONE - "; @@ -8257,15 +8263,16 @@ static void M_DrawMusicTest(void) V_DrawLevelTitle(x, 24, 0, titl); } - //if (curplaying) - //V_DrawRightAlignedString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->source); + if (curplaying && curplaying->authors[0]) + V_DrawRightAlignedThinString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->authors); if (curplaying) { if (!curplaying->usage[0]) V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s", curplaying->name)); - else - V_DrawString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s - %.255s\n", curplaying->name, curplaying->usage)); + else { + V_DrawSmallString(vid.dupx, vid.height - 5*vid.dupy, V_NOSCALESTART|V_ALLOWLOWERCASE, va("%.6s - %.255s\n", curplaying->name, curplaying->usage)); + } if (cv_showmusicfilename.value) V_DrawSmallString(0, 0, V_SNAPTOTOP|V_SNAPTOLEFT|V_ALLOWLOWERCASE, curplaying->filename); @@ -8330,6 +8337,8 @@ static void M_DrawMusicTest(void) const tic_t SCROLLSPEED = TICRATE/5; // Number of tics for name being scrolled by 1 letter size_t nameoffset = 0; size_t namelength = strlen(soundtestdefs[t]->source); + if (soundtestdefs[t]->title[0]) + namelength = strlen(soundtestdefs[t]->title); char buf[MAXLENGTH+1]; @@ -8391,7 +8400,10 @@ static void M_DrawMusicTest(void) } } - strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); + if (soundtestdefs[t]->title[0]) + strncpy(buf, soundtestdefs[t]->title + nameoffset, MAXLENGTH); + else + strncpy(buf, soundtestdefs[t]->source + nameoffset, MAXLENGTH); buf[MAXLENGTH] = 0; V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); diff --git a/src/p_setup.c b/src/p_setup.c index ee87f8657..d85488c9f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3551,6 +3551,11 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // S_LoadMusicDefs(wadnum); + // + // edit music defs for stuff like musictest + // + S_LoadMTDefs(wadnum); + // // search for maps // diff --git a/src/s_sound.c b/src/s_sound.c index 0aeaa9f4e..db3e0c7d3 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1477,6 +1477,22 @@ 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, "title")) { + def->use_info = true; + STRBUFCPY(def->title, value); + for (value = def->title; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + } else if (!stricmp(stoken, "alttitle")) { + STRBUFCPY(def->alttitle, value); + for (value = def->alttitle; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + } else if (!stricmp(stoken, "authors")) { + STRBUFCPY(def->authors, value); + for (value = def->authors; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); } else { CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } @@ -1502,6 +1518,169 @@ void S_InitMusicDefs(void) for (i = 0; i < numwadfiles; i++) S_LoadMusicDefs(i); } + +// +// search for music definition in wad +// +static UINT16 W_CheckForMusicInfoInPwad(UINT16 wadid) +{ + UINT16 i; + lumpinfo_t *lump_p; + + lump_p = wadfiles[wadid]->lumpinfo; + for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name, "MUSCINFO", 8) == 0) + return i; + + return INT16_MAX; // not found +} + +void S_LoadMTDefs(UINT16 wadnum) +{ + UINT16 lump; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + musicdef_t *def, *prev; + UINT16 line = 1; // for better error msgs + + lump = W_CheckForMusicInfoInPwad(wadnum); + if (lump == INT16_MAX) + return; + + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("S_LoadMTDefs: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + def = prev = NULL; + + stoken = strtok (buf2, "\r\n "); + // Find music def + while (stoken) + { + /*if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#')) // skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + if (def) + stoken = strtok(NULL, "\r\n= "); + else + stoken = strtok(NULL, "\r\n "); + line++; + } + else*/ if (!stricmp(stoken, "lump")) + { + value = strtok(NULL, "\r\n "); + + if (!value) + { + CONS_Alert(CONS_WARNING, "MUSICDEF: Lump '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + stoken = strtok(NULL, "\r\n"); // skip end of line + goto skip_lump; + } + + // No existing musicdefs + if (!musicdefstart) + { + musicdefstart = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); + STRBUFCPY(musicdefstart->name, value); + strlwr(musicdefstart->name); + def = musicdefstart; + //CONS_Printf("S_LoadMusicDefs: Initialized musicdef w/ song '%s'\n", def->name); + } + else + { + def = musicdefstart; + + // Search if this is a replacement + //CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n"); + while (def) + { + if (!stricmp(def->name, value)) + { + //CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name); + break; + } + + prev = def; + def = def->next; + } + + // Nothing found, abort. + if (!def) + { + CONS_Alert(CONS_WARNING, "MUSCINFO: Music def for '%s' does not exist. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + free(buf2); + return; + } + } + +skip_lump: + stoken = strtok(NULL, "\r\n "); + line++; + } + else + { + value = strtok(NULL, "\r\n= "); + + if (!value) + { + CONS_Alert(CONS_WARNING, "MUSCINFO: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + stoken = strtok(NULL, "\r\n"); // skip end of line + goto skip_field; + } + + if (!def) + { + CONS_Alert(CONS_ERROR, "MUSCINFO: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + free(buf2); + return; + } + + if (!stricmp(stoken, "title")) { + def->use_info = true; + STRBUFCPY(def->title, value); + for (value = def->title; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + } else if (!stricmp(stoken, "alttitle")) { + STRBUFCPY(def->alttitle, value); + for (value = def->alttitle; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + } else if (!stricmp(stoken, "authors")) { + STRBUFCPY(def->authors, value); + for (value = def->authors; *value; value++) + if (*value == '_') *value = ' '; // turn _ into spaces. + //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); + } else { + CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); + } + +skip_field: + stoken = strtok(NULL, "\r\n= "); + line++; + } + } + + free(buf2); + return; +} + +void S_InitMTDefs(void) +{ + UINT16 i; + for (i = 0; i < numwadfiles; i++) + S_LoadMTDefs(i); +} // // S_FindMusicCredit // diff --git a/src/s_sound.h b/src/s_sound.h index fb57665e2..5cfe937ea 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -162,6 +162,13 @@ typedef struct musicdef_s char usage[256]; char source[256]; char filename[256]; + // for the music test stuff + // generally if these are present on vanilla the game would throw up a warning + // a sacrifice i suppose + char title[256]; + char alttitle[256]; + char authors[256]; + boolean use_info; struct musicdef_s *next; } musicdef_t; @@ -182,6 +189,8 @@ extern struct cursongcredit void S_LoadMusicDefs(UINT16 wadnum); void S_InitMusicDefs(void); +void S_LoadMTDefs(UINT16 wadnum); +void S_InitMTDefs(void); musicdef_t *S_FindMusicCredit(const char *musname); void S_ShowSpecifiedMusicCredit(const char *musname); void S_ShowMusicCredit(void); diff --git a/src/w_wad.c b/src/w_wad.c index a856042b9..79af50e21 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2138,8 +2138,9 @@ int W_VerifyNMUSlumps(const char *filename) {"K_", 2}, // Kart graphic changes {"MUSICDEF", 8}, // Kart song definitions {"SP_", 3}, // Speedometer changes do not count either. - {"SC_", 3}, // No idea what the SC_SMSTC thing does, ask nepdisk idk + {"SC_", 3}, // Colored speedometer stuff too. {"SPRTINFO", 8}, // Sprite info + {"MUSCINFO", 8}, // Music test definitions #ifdef HWRENDER {"SHADERS", 7}, -- 2.54.0