From 12f56d64a7d14b4bf68682e0588acf154939e242 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Oct 2020 10:35:24 -0400 Subject: [PATCH 1/4] Adds a simple white loading bar at the bottom of startup, instead of covering the cool reference with text Mockup of what it looks like, since the window's invisble when you try to print-scr it: https://cdn.discordapp.com/attachments/275750804227489794/769931098636943391/unknown.png --- src/console.c | 43 +++++++++++++++++++++++++++++++++++++++---- src/console.h | 6 ++++++ src/d_main.c | 22 +++++++++++++++++++--- 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/src/console.c b/src/console.c index c9df73ed4..fd4afe946 100644 --- a/src/console.c +++ b/src/console.c @@ -57,6 +57,9 @@ I_mutex con_mutex; static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing + + UINT8 con_startup_loadprogress = 0; // Progress for startup load bar + static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc; // set true when screen size has changed @@ -1517,16 +1520,17 @@ void CONS_Printf(const char *fmt, ...) if (startup && (!setrenderneeded)) { #ifdef _WINDOWS - patch_t *con_backpic = W_CachePatchName("KARTKREW", PU_CACHE); + patch_t *con_backpic = W_CachePatchName("STARTUP", PU_CACHE); // Jimita: CON_DrawBackpic just called V_DrawScaledPatch - V_DrawFixedPatch(0, 0, FRACUNIT/2, 0, con_backpic, NULL); + V_DrawScaledPatch(0, 0, 0, con_backpic); W_UnlockCachedPatch(con_backpic); - I_LoadingScreen(txt); // Win32/OS2 only + I_LoadingScreen(txt); // Win32/OS2 only #else // here we display the console text - CON_Drawer(); + //CON_Drawer(); + CON_DrawLoadBar(); I_FinishUpdate(); // page flip or blit buffer #endif } @@ -1902,3 +1906,34 @@ void CON_Drawer(void) Unlock_state(); } + +// +// Draws a simple white fill at the bottom of startup for load progress +// +void CON_DrawLoadBar(void) +{ + const INT16 barheight = 2; + INT16 barwidth = 0; + + Lock_state(); + + if (con_startup_loadprogress > CON_STARTUP_LOADSTEPS) + { + Unlock_state(); + I_Error("CON_STARTUP_LOADSTEPS has not been updated!\n"); + return; + } + + if (!con_started || !graphics_started) + { + Unlock_state(); + return; + } + + CON_DrawBackpic(); + + barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / CON_STARTUP_LOADSTEPS; + V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0); + + Unlock_state(); +} diff --git a/src/console.h b/src/console.h index 898290c39..d493ab1d8 100644 --- a/src/console.h +++ b/src/console.h @@ -27,6 +27,9 @@ extern boolean con_recalc; extern boolean con_startup; +extern UINT8 con_startup_loadprogress; +#define CON_STARTUP_LOADSTEPS 12 + // top clip value for view render: do not draw part of view hidden by console extern INT32 con_clipviewtop; @@ -62,3 +65,6 @@ void CON_ToggleOff(void); boolean CON_Ready(void); void CON_LogMessage(const char *msg); + +// Startup loading bar +void CON_DrawLoadBar(void); diff --git a/src/d_main.c b/src/d_main.c index 97523966d..b8a30aff3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -733,7 +733,6 @@ tic_t rendergametic; void D_SRB2Loop(void) { tic_t oldentertics = 0, entertic = 0, realtics = 0, rendertimeout = INFTICS; - static lumpnum_t gstartuplumpnum; if (dedicated) server = true; @@ -770,14 +769,17 @@ void D_SRB2Loop(void) LMFAO this was showing garbage under OpenGL because I_FinishUpdate was called afterward */ + +#if 0 /* Smells like a hack... Don't fade Sonic's ass into the title screen. */ if (gamestate != GS_TITLESCREEN) { - gstartuplumpnum = W_CheckNumForName("STARTUP"); + static lumpnum_t gstartuplumpnum = W_CheckNumForName("STARTUP"); if (gstartuplumpnum == LUMPERROR) gstartuplumpnum = W_GetNumForName("MISSING"); V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(gstartuplumpnum, PU_PATCH)); } +#endif for (;;) { @@ -1256,7 +1258,6 @@ void D_SRB2Main(void) configfile[sizeof configfile - 1] = '\0'; } - // Create addons dir snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); I_mkdir(addonsdir, 0755); @@ -1280,6 +1281,7 @@ void D_SRB2Main(void) CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n"); Z_Init(); + con_startup_loadprogress++; // Do this up here so that WADs loaded through the command line can use ExecCfg COM_Init(); @@ -1363,6 +1365,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupTimer()...\n"); I_StartupTimer(); + con_startup_loadprogress++; // Make backups of some SOCcable tables. P_BackupTables(); @@ -1426,6 +1429,8 @@ void D_SRB2Main(void) } } + con_startup_loadprogress++; // finished IWADs + CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n"); W_InitMultipleFiles(startuppwads, true); D_CleanFile(startuppwads); @@ -1463,6 +1468,8 @@ void D_SRB2Main(void) } } + con_startup_loadprogress++; // finished PWADs + cht_Init(); //---------------------------------------------------- READY SCREEN @@ -1470,6 +1477,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupGraphics()...\n"); I_StartupGraphics(); + con_startup_loadprogress++; #ifdef HWRENDER // Lactozilla: Add every hardware mode CVAR and CCMD. @@ -1495,6 +1503,7 @@ void D_SRB2Main(void) CONS_Printf("HU_LoadGraphics()...\n"); HU_LoadGraphics(); + con_startup_loadprogress++; //--------------------------------------------------------- CONFIG.CFG M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()" @@ -1525,6 +1534,7 @@ void D_SRB2Main(void) // check the renderer's state D_CheckRendererState(); } + con_startup_loadprogress++; wipegamestate = gamestate; @@ -1554,9 +1564,11 @@ void D_SRB2Main(void) CONS_Printf("M_Init(): Init miscellaneous info.\n"); M_Init(); + con_startup_loadprogress++; CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); + con_startup_loadprogress++; // setting up sound if (dedicated) @@ -1584,6 +1596,7 @@ void D_SRB2Main(void) digital_disabled = true; // WARNING: DOS version initmusic in I_StartupSound } } + if (!( sound_disabled && digital_disabled )) { CONS_Printf("S_InitSfxChannels(): Setting up sound channels.\n"); @@ -1591,11 +1604,13 @@ void D_SRB2Main(void) I_InitMusic(); S_InitSfxChannels(cv_soundvolume.value); } + con_startup_loadprogress++; S_InitMusicDefs(); CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); + con_startup_loadprogress++; // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) @@ -1613,6 +1628,7 @@ void D_SRB2Main(void) CONS_Printf("D_CheckNetGame(): Checking network game status.\n"); if (D_CheckNetGame()) autostart = true; + con_startup_loadprogress++; if (splitscreen && !M_CheckParm("-connect")) // Make sure multiplayer & autostart is set if you have splitscreen, even after D_CheckNetGame multiplayer = autostart = true; From 3469ab12ba84f63c60a6ccf90a6cdb7fff0b9586 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Oct 2020 10:48:32 -0400 Subject: [PATCH 2/4] Add extra warning for CON_STARTUP_LOADSTEPS being incorrect --- src/console.c | 2 +- src/d_main.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index fd4afe946..4341dd003 100644 --- a/src/console.c +++ b/src/console.c @@ -1920,7 +1920,7 @@ void CON_DrawLoadBar(void) if (con_startup_loadprogress > CON_STARTUP_LOADSTEPS) { Unlock_state(); - I_Error("CON_STARTUP_LOADSTEPS has not been updated!\n"); + I_Error("CON_STARTUP_LOADSTEPS is too low! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress); return; } diff --git a/src/d_main.c b/src/d_main.c index b8a30aff3..434d8c360 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1843,6 +1843,12 @@ void D_SRB2Main(void) DRPC_Init(); } #endif + + if (con_startup_loadprogress < CON_STARTUP_LOADSTEPS) + { + I_Error("CON_STARTUP_LOADSTEPS is too high! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress); + return; + } } const char *D_Home(void) From c93330bf207add0738d1cdfafa19bf34a3a84afe Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Oct 2020 11:34:15 -0400 Subject: [PATCH 3/4] Use enum for better maintainability & error checking --- src/console.c | 27 ++++++++++++++++++--------- src/console.h | 21 +++++++++++++++++++-- src/d_main.c | 28 ++++++++++++++-------------- src/f_finale.c | 1 - 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/console.c b/src/console.c index 4341dd003..e8e1fa541 100644 --- a/src/console.c +++ b/src/console.c @@ -58,7 +58,7 @@ I_mutex con_mutex; static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing - UINT8 con_startup_loadprogress = 0; // Progress for startup load bar + con_loadprogress_t con_startup_loadprogress = 0; // Progress for startup load bar static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc; // set true when screen size has changed @@ -1907,6 +1907,22 @@ void CON_Drawer(void) Unlock_state(); } +// +// Error handling for the loading bar, to ensure it doesn't skip any steps. +// +void CON_SetLoadingProgress(con_loadprogress_t newStep) +{ + const con_loadprogress_t expectedStep = con_startup_loadprogress + 1; + + if (newStep != expectedStep) + { + I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", newStep, expectedStep); + return; + } + + con_startup_loadprogress = newStep; +} + // // Draws a simple white fill at the bottom of startup for load progress // @@ -1917,13 +1933,6 @@ void CON_DrawLoadBar(void) Lock_state(); - if (con_startup_loadprogress > CON_STARTUP_LOADSTEPS) - { - Unlock_state(); - I_Error("CON_STARTUP_LOADSTEPS is too low! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress); - return; - } - if (!con_started || !graphics_started) { Unlock_state(); @@ -1932,7 +1941,7 @@ void CON_DrawLoadBar(void) CON_DrawBackpic(); - barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / CON_STARTUP_LOADSTEPS; + barwidth = (BASEVIDWIDTH * con_startup_loadprogress) / LOADED_ALLDONE; V_DrawFill(0, BASEVIDHEIGHT - barheight, barwidth, barheight, 0); Unlock_state(); diff --git a/src/console.h b/src/console.h index d493ab1d8..75f7c7bbd 100644 --- a/src/console.h +++ b/src/console.h @@ -27,8 +27,24 @@ extern boolean con_recalc; extern boolean con_startup; -extern UINT8 con_startup_loadprogress; -#define CON_STARTUP_LOADSTEPS 12 +typedef enum +{ + LOADED_ZINIT = 1, + LOADED_ISTARTUPTIMER, + LOADED_IWAD, + LOADED_PWAD, + LOADED_ISTARTUPGRAPHICS, + LOADED_HULOADGRAPHICS, + LOADED_RENDERER, + LOADED_MINIT, + LOADED_RINIT, + LOADED_SINITSFXCHANNELS, + LOADED_STINIT, + LOADED_DCHECKNETGAME, + LOADED_ALLDONE = LOADED_DCHECKNETGAME, +} con_loadprogress_t; + +extern con_loadprogress_t con_startup_loadprogress; // top clip value for view render: do not draw part of view hidden by console extern INT32 con_clipviewtop; @@ -67,4 +83,5 @@ boolean CON_Ready(void); void CON_LogMessage(const char *msg); // Startup loading bar +void CON_SetLoadingProgress(con_loadprogress_t newStep); void CON_DrawLoadBar(void); diff --git a/src/d_main.c b/src/d_main.c index 434d8c360..d52ded552 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1281,7 +1281,7 @@ void D_SRB2Main(void) CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n"); Z_Init(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_ZINIT); // Do this up here so that WADs loaded through the command line can use ExecCfg COM_Init(); @@ -1365,7 +1365,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupTimer()...\n"); I_StartupTimer(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_ISTARTUPTIMER); // Make backups of some SOCcable tables. P_BackupTables(); @@ -1429,7 +1429,7 @@ void D_SRB2Main(void) } } - con_startup_loadprogress++; // finished IWADs + CON_SetLoadingProgress(LOADED_IWAD); CONS_Printf("W_InitMultipleFiles(): Adding external PWADs.\n"); W_InitMultipleFiles(startuppwads, true); @@ -1468,7 +1468,7 @@ void D_SRB2Main(void) } } - con_startup_loadprogress++; // finished PWADs + CON_SetLoadingProgress(LOADED_PWAD); cht_Init(); @@ -1477,7 +1477,7 @@ void D_SRB2Main(void) CONS_Printf("I_StartupGraphics()...\n"); I_StartupGraphics(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS); #ifdef HWRENDER // Lactozilla: Add every hardware mode CVAR and CCMD. @@ -1503,7 +1503,7 @@ void D_SRB2Main(void) CONS_Printf("HU_LoadGraphics()...\n"); HU_LoadGraphics(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_HULOADGRAPHICS); //--------------------------------------------------------- CONFIG.CFG M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()" @@ -1534,7 +1534,7 @@ void D_SRB2Main(void) // check the renderer's state D_CheckRendererState(); } - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_RENDERER); wipegamestate = gamestate; @@ -1564,11 +1564,11 @@ void D_SRB2Main(void) CONS_Printf("M_Init(): Init miscellaneous info.\n"); M_Init(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_MINIT); CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_RINIT); // setting up sound if (dedicated) @@ -1604,13 +1604,13 @@ void D_SRB2Main(void) I_InitMusic(); S_InitSfxChannels(cv_soundvolume.value); } - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_SINITSFXCHANNELS); S_InitMusicDefs(); CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_STINIT); // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) @@ -1628,7 +1628,7 @@ void D_SRB2Main(void) CONS_Printf("D_CheckNetGame(): Checking network game status.\n"); if (D_CheckNetGame()) autostart = true; - con_startup_loadprogress++; + CON_SetLoadingProgress(LOADED_DCHECKNETGAME); if (splitscreen && !M_CheckParm("-connect")) // Make sure multiplayer & autostart is set if you have splitscreen, even after D_CheckNetGame multiplayer = autostart = true; @@ -1844,9 +1844,9 @@ void D_SRB2Main(void) } #endif - if (con_startup_loadprogress < CON_STARTUP_LOADSTEPS) + if (con_startup_loadprogress != LOADED_ALLDONE) { - I_Error("CON_STARTUP_LOADSTEPS is too high! (is %d, got %d)\n", CON_STARTUP_LOADSTEPS, con_startup_loadprogress); + I_Error("Something is wrong with the loading bar! (got %d, expected %d)\n", con_startup_loadprogress, LOADED_ALLDONE); return; } } diff --git a/src/f_finale.c b/src/f_finale.c index ed4024d0a..07813f46a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -38,7 +38,6 @@ #include "p_setup.h" #include "st_stuff.h" // hud hiding #include "fastcmp.h" -#include "console.h" #include "lua_hud.h" From 79a319ec02eba02d6de9e367cbdd08e50fbc6530 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 25 Oct 2020 11:34:58 -0400 Subject: [PATCH 4/4] Add a "title screen" --- src/f_finale.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/f_finale.c b/src/f_finale.c index ed4024d0a..ba861f37f 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1977,6 +1977,8 @@ void F_TitleScreenDrawer(void) V_DrawSmallScaledPatch(84, 36, transval<