From b9abe207461a1e8a2e59a60afe9338ff22f41f6e Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 14 Jul 2022 09:04:50 +0200 Subject: [PATCH] optional solid color status bar background for widescreen mode (#655) * optional solid-colored status bar background Fixes #651 * Update m_misc.c * parametrize "analyzation depth" * tune down to half saturation * minor clean-up --- src/m_menu.c | 4 ++ src/m_misc.c | 9 +++- src/st_stuff.c | 115 ++++++++++++++++++++++++++++++++++++------------- src/st_stuff.h | 2 + 4 files changed, 100 insertions(+), 30 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e3f8255a..09b866f7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3801,6 +3801,7 @@ enum { general_swirl, general_smoothlight, general_brightmaps, + general_solidbackground, general_stub2, general_diskicon, general_hom, @@ -3928,6 +3929,9 @@ setup_menu_t gen_settings2[] = { // General Settings screen2 {"Brightmaps for Textures and Sprites", S_YESNO, m_null, M_X, G_Y3 + general_brightmaps*M_SPC, {"brightmaps"}}, + {"Solid Status Bar Background", S_YESNO, m_null, M_X, + G_Y3 + general_solidbackground*M_SPC, {"st_solidbackground"}}, + {"", S_SKIP, m_null, M_X, M_Y + general_stub2*M_SPC}, {"Flash Icon During Disk IO", S_YESNO, m_null, M_X, diff --git a/src/m_misc.c b/src/m_misc.c index 295bce82..3a3b5953 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -255,7 +255,14 @@ default_t defaults[] = { {0}, {0,1}, number, ss_gen, wad_yes, "1 to enable brightmaps for textures and sprites" }, - + + { + "st_solidbackground", + (config_t *) &st_solidbackground, NULL, + {0}, {0,1}, number, ss_gen, wad_yes, + "1 for solid color status bar background in widescreen mode" + }, + { "gamma2", (config_t *) &gamma2, NULL, diff --git a/src/st_stuff.c b/src/st_stuff.c index c1590c05..ea7ac7d1 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -333,52 +333,109 @@ extern char *mapnames[]; void ST_Stop(void); +int st_solidbackground; + void ST_refreshBackground(boolean force) { if (st_classicstatusbar) { - // [crispy] this is our own local copy of R_FillBackScreen() to - // fill the entire background of st_backing_screen with the bezel pattern, - // so it appears to the left and right of the status bar in widescreen mode if (SCREENWIDTH != ST_WIDTH) { int x, y; - byte *src; - byte *dest; - const char *name = (gamemode == commercial) ? "GRNROCK" : "FLOOR7_2"; + byte *dest = screens[BG]; - src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE); - dest = screens[BG]; - - if (hires) + if (st_solidbackground) { - for (y = (SCREENHEIGHT-ST_HEIGHT)<<1; y < SCREENHEIGHT<<1; y++) - for (x = 0; x < SCREENWIDTH<<1; x += 2) - { - const byte dot = src[(((y>>1)&63)<<6) + ((x>>1)&63)]; + // [FG] calculate average color of the 16px left and right of the status bar + const int vstep[][2] = {{0, 1}, {1, 2}, {2, ST_HEIGHT}}; + const int hstep = hires ? (4 * SCREENWIDTH) : SCREENWIDTH; + const int w = SHORT(sbar->width); + const int depth = 16; + byte *pal = W_CacheLumpName("PLAYPAL", PU_STATIC); + int v; - *dest++ = dot; - *dest++ = dot; + // [FG] temporarily draw status bar to background buffer + V_DrawPatch(ST_X, 0, BG, sbar); + + // [FG] separate colors for the top rows + for (v = 0; v < arrlen(vstep); v++) + { + const int v0 = vstep[v][0], v1 = vstep[v][1]; + unsigned r = 0, g = 0, b = 0; + byte col; + + for (y = v0; y < v1; y++) + { + for (x = 0; x < depth; x++) + { + byte *c = dest + y * hstep + ((x + WIDESCREENDELTA) << hires); + r += pal[3 * c[0] + 0]; + g += pal[3 * c[0] + 1]; + b += pal[3 * c[0] + 2]; + + c += (w - 2 * x - 1) << hires; + r += pal[3 * c[0] + 0]; + g += pal[3 * c[0] + 1]; + b += pal[3 * c[0] + 2]; } + } + + r /= 2 * depth * (v1 - v0); + g /= 2 * depth * (v1 - v0); + b /= 2 * depth * (v1 - v0); + + // [FG] tune down to half saturation (for empiric reasons) + col = I_GetPaletteIndex(pal, r/2, g/2, b/2); + + // [FG] fill background buffer with average status bar color + for (y = (v0 << hires); y < (v1 << hires); y++) + { + memset(dest + y * (SCREENWIDTH << hires), col, (SCREENWIDTH << hires)); + } + } + + Z_ChangeTag (pal, PU_CACHE); } else { - for (y = SCREENHEIGHT-ST_HEIGHT; y < SCREENHEIGHT; y++) - for (x = 0; x < SCREENWIDTH; x++) - { - *dest++ = src[((y&63)<<6) + (x&63)]; - } - } + // [crispy] this is our own local copy of R_FillBackScreen() to + // fill the entire background of st_backing_screen with the bezel pattern, + // so it appears to the left and right of the status bar in widescreen mode + byte *src; + const char *name = (gamemode == commercial) ? "GRNROCK" : "FLOOR7_2"; - // [crispy] preserve bezel bottom edge - if (scaledviewwidth == SCREENWIDTH) - { - patch_t *const patch = W_CacheLumpName("brdr_b", PU_CACHE); + src = W_CacheLumpNum(firstflat + R_FlatNumForName(name), PU_CACHE); - for (x = 0; x < WIDESCREENDELTA; x += 8) + if (hires) { - V_DrawPatch(x - WIDESCREENDELTA, 0, BG, patch); - V_DrawPatch(ORIGWIDTH + WIDESCREENDELTA - x - 8, 0, BG, patch); + for (y = (SCREENHEIGHT-ST_HEIGHT)<<1; y < SCREENHEIGHT<<1; y++) + for (x = 0; x < SCREENWIDTH<<1; x += 2) + { + const byte dot = src[(((y>>1)&63)<<6) + ((x>>1)&63)]; + + *dest++ = dot; + *dest++ = dot; + } + } + else + { + for (y = SCREENHEIGHT-ST_HEIGHT; y < SCREENHEIGHT; y++) + for (x = 0; x < SCREENWIDTH; x++) + { + *dest++ = src[((y&63)<<6) + (x&63)]; + } + } + + // [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); + } } } } diff --git a/src/st_stuff.h b/src/st_stuff.h index 63bcbc35..254cb9d7 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -95,6 +95,8 @@ extern int sts_traditional_keys; // display keys the traditional way extern int hud_backpack_thresholds; // backpack changes thresholds extern int hud_armor_type; // color of armor depends on type +extern int st_solidbackground; + #endif //----------------------------------------------------------------------------