Allocate status bar buffer based on sbar height (#1223)

* Allocate status bar buffer based on sbar height

* Add warning

* Handle status bar for Doom versions prior to 1.2

* Don't handle Doom versions prior to 1.2

* Prep for additional lumps

* Handle `STARMS`

* Handle bezel `BRDR_B`

* Handle `STFB*`

* Refactor warnings
This commit is contained in:
ceski 2023-10-13 07:02:29 -07:00 committed by GitHub
parent 3c54649711
commit 3e93db48da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 5 deletions

View File

@ -2547,6 +2547,7 @@ void D_DoomMain(void)
I_Printf(VB_INFO, "ST_Init: Init status bar."); I_Printf(VB_INFO, "ST_Init: Init status bar.");
ST_Init(); ST_Init();
ST_Warnings();
I_PutChar(VB_INFO, '\n'); I_PutChar(VB_INFO, '\n');

View File

@ -1118,6 +1118,7 @@ static void I_ResetGraphicsMode(void)
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
V_Init(); V_Init();
ST_Init();
// [FG] create paletted frame buffer // [FG] create paletted frame buffer

View File

@ -36,6 +36,7 @@
#include "dstrings.h" #include "dstrings.h"
#include "m_misc2.h" #include "m_misc2.h"
#include "m_swap.h" #include "m_swap.h"
#include "i_printf.h"
// [crispy] immediately redraw status bar after help screens have been shown // [crispy] immediately redraw status bar after help screens have been shown
extern boolean inhelpscreens; extern boolean inhelpscreens;
@ -234,6 +235,9 @@ static patch_t *faceback[MAXPLAYERS]; // killough 3/7/98: make array
// main bar right // main bar right
static patch_t *armsbg; static patch_t *armsbg;
// Bezel bottom edge for st_solidbackground.
static patch_t *bezel;
// weapon ownership patches // weapon ownership patches
static patch_t *arms[6][2]; static patch_t *arms[6][2];
@ -412,12 +416,10 @@ void ST_refreshBackground(boolean force)
// [crispy] preserve bezel bottom edge // [crispy] preserve bezel bottom edge
if (scaledviewwidth == SCREENWIDTH) if (scaledviewwidth == SCREENWIDTH)
{ {
patch_t *const patch = W_CacheLumpName("brdr_b", PU_CACHE);
for (x = 0; x < WIDESCREENDELTA; x += 8) for (x = 0; x < WIDESCREENDELTA; x += 8)
{ {
V_DrawPatch(x - WIDESCREENDELTA, 0, BG, patch); V_DrawPatch(x - WIDESCREENDELTA, 0, BG, bezel);
V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, BG, patch); V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, BG, bezel);
} }
} }
} }
@ -1080,6 +1082,9 @@ void ST_loadGraphics(void)
break; break;
} }
have_xdthfaces = i; have_xdthfaces = i;
// Bezel bottom edge for st_solidbackground.
bezel = W_CacheLumpName("BRDR_B", PU_STATIC);
} }
void ST_loadData(void) void ST_loadData(void)
@ -1297,11 +1302,77 @@ void ST_Stop(void)
st_stopped = true; st_stopped = true;
} }
static int StatusBarBufferHeight(void)
{
int i;
int st_height = ST_HEIGHT;
if (sbar && sbar->height > st_height)
st_height = sbar->height;
if (armsbg && armsbg->height > st_height)
st_height = armsbg->height;
if (bezel && bezel->height > st_height)
st_height = bezel->height;
for (i = 0; i < MAXPLAYERS; i++)
{
if (faceback[i] && faceback[i]->height > st_height)
st_height = faceback[i]->height;
}
return st_height;
}
void ST_Init(void) void ST_Init(void)
{ {
int st_height, size;
ST_loadData(); ST_loadData();
st_height = StatusBarBufferHeight();
size = SCREENWIDTH * (st_height << (2 * hires));
if (screens[4])
{
Z_Free(screens[4]);
}
// killough 11/98: allocate enough for hires // killough 11/98: allocate enough for hires
screens[4] = Z_Malloc(MAX_SCREENWIDTH*ST_HEIGHT*4, PU_STATIC, 0); screens[4] = Z_Malloc(size, PU_STATIC, 0);
}
void ST_Warnings(void)
{
int i;
if (sbar && sbar->height != ST_HEIGHT)
{
I_Printf(VB_WARNING, "ST_Init: Non-standard STBAR height of %d. "
"Expected %d.", sbar->height, ST_HEIGHT);
}
if (armsbg && armsbg->height > ST_HEIGHT)
{
I_Printf(VB_WARNING, "ST_Init: Non-standard STARMS height of %d. "
"Expected <= %d.", armsbg->height, ST_HEIGHT);
}
if (bezel && bezel->height > ST_HEIGHT)
{
I_Printf(VB_WARNING, "ST_Init: Non-standard BRDR_B height of %d. "
"Expected <= %d.", bezel->height, ST_HEIGHT);
}
for (i = 0; i < MAXPLAYERS; i++)
{
if (faceback[i] && faceback[i]->height > ST_HEIGHT)
{
I_Printf(VB_WARNING, "ST_Init: Non-standard STFB%d height of %d. "
"Expected <= %d.", i, faceback[i]->height, ST_HEIGHT);
}
}
} }
void ST_ResetPalette(void) void ST_ResetPalette(void)

View File

@ -50,6 +50,7 @@ void ST_Start(void);
// Called by startup code. // Called by startup code.
void ST_Init(void); void ST_Init(void);
void ST_Warnings(void);
// [crispy] forcefully initialize the status bar backing screen // [crispy] forcefully initialize the status bar backing screen
extern void ST_refreshBackground(boolean force); extern void ST_refreshBackground(boolean force);