Skip to content

Commit

Permalink
Allocate status bar buffer based on sbar height (#1223)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ceski-1 authored Oct 13, 2023
1 parent 3c54649 commit 3e93db4
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2547,6 +2547,7 @@ void D_DoomMain(void)

I_Printf(VB_INFO, "ST_Init: Init status bar.");
ST_Init();
ST_Warnings();

I_PutChar(VB_INFO, '\n');

Expand Down
1 change: 1 addition & 0 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ static void I_ResetGraphicsMode(void)
SDL_RenderPresent(renderer);

V_Init();
ST_Init();

// [FG] create paletted frame buffer

Expand Down
81 changes: 76 additions & 5 deletions src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "dstrings.h"
#include "m_misc2.h"
#include "m_swap.h"
#include "i_printf.h"

// [crispy] immediately redraw status bar after help screens have been shown
extern boolean inhelpscreens;
Expand Down Expand Up @@ -234,6 +235,9 @@ static patch_t *faceback[MAXPLAYERS]; // killough 3/7/98: make array
// main bar right
static patch_t *armsbg;

// Bezel bottom edge for st_solidbackground.
static patch_t *bezel;

// weapon ownership patches
static patch_t *arms[6][2];

Expand Down Expand Up @@ -412,12 +416,10 @@ void ST_refreshBackground(boolean force)
// [crispy] preserve bezel bottom edge
if (scaledviewwidth == SCREENWIDTH)
{
patch_t *const patch = W_CacheLumpName("brdr_b", PU_CACHE);

for (x = 0; x < WIDESCREENDELTA; x += 8)
{
V_DrawPatch(x - WIDESCREENDELTA, 0, BG, patch);
V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, BG, patch);
V_DrawPatch(x - WIDESCREENDELTA, 0, BG, bezel);
V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, BG, bezel);
}
}
}
Expand Down Expand Up @@ -1080,6 +1082,9 @@ void ST_loadGraphics(void)
break;
}
have_xdthfaces = i;

// Bezel bottom edge for st_solidbackground.
bezel = W_CacheLumpName("BRDR_B", PU_STATIC);
}

void ST_loadData(void)
Expand Down Expand Up @@ -1297,11 +1302,77 @@ void ST_Stop(void)
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)
{
int st_height, size;

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
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)
Expand Down
1 change: 1 addition & 0 deletions src/st_stuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void ST_Start(void);

// Called by startup code.
void ST_Init(void);
void ST_Warnings(void);

// [crispy] forcefully initialize the status bar backing screen
extern void ST_refreshBackground(boolean force);
Expand Down

0 comments on commit 3e93db4

Please sign in to comment.