From 8b1d3a7429d35634e123d61a0fe9645efff45922 Mon Sep 17 00:00:00 2001 From: pvictress <185700473+pvictress@users.noreply.github.com> Date: Sat, 30 Nov 2024 23:33:39 +0300 Subject: [PATCH] Implement contrast adjustment feature in display options --- src/doom/m_menu.c | 161 +++++++++++++++++++++--------------------- src/doom/r_data.c | 16 ++++- src/heretic/mn_menu.c | 107 +++++++++++++++++----------- src/heretic/r_data.c | 37 ++++++++-- src/heretic/sb_bar.c | 2 +- src/hexen/mn_menu.c | 107 +++++++++++++++++----------- src/hexen/r_data.c | 15 +++- src/hexen/sb_bar.c | 71 ++++++++++++------- src/id_vars.c | 2 + src/id_vars.h | 1 + src/m_config.c | 1 + 11 files changed, 323 insertions(+), 197 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index 0311f265..e52732d2 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -244,7 +244,6 @@ static void M_DrawSave(void); static void M_DrawSaveLoadBorder(int x,int y); static void M_SetupNextMenu(menu_t *menudef); static void M_DrawThermo(int x,int y,int thermWidth,int thermDot,int itemPos); -static void M_DrawGammaThermo(int x, int y, int width, int dot, int itemPos); static int M_StringHeight(const char *string); static void M_StartMessage(const char *string, void (*routine)(int), boolean input); static void M_ClearMenus (void); @@ -557,17 +556,18 @@ static void M_ID_ShowENDOOM (int choice); static void M_Choose_ID_Display (int choice); static void M_Draw_ID_Display (void); -static void M_ID_Gamma (int choice); static void M_ID_FOV (int choice); static void M_ID_MenuShading (int choice); static void M_ID_LevelBrightness (int choice); -static void M_ID_MessagesAlignment (int choice); -static void M_ID_TextShadows (int choice); -static void M_ID_LocalTime (int choice); +static void M_ID_Gamma (int choice); static void M_ID_Saturation (int choice); +static void M_ID_Contrast (int choice); static void M_ID_R_Intensity (int choice); static void M_ID_G_Intensity (int choice); static void M_ID_B_Intensity (int choice); +static void M_ID_MessagesAlignment (int choice); +static void M_ID_TextShadows (int choice); +static void M_ID_LocalTime (int choice); static void M_Choose_ID_Sound (int choice); static void M_Draw_ID_Sound (void); @@ -1589,14 +1589,13 @@ static void M_ID_ShowENDOOM (int choice) static menuitem_t ID_Menu_Display[]= { - { M_LFRT, "GAMMA-CORRECTION", M_ID_Gamma, 'g' }, - { M_SKIP, "", 0, '\0' }, - { M_SKIP, "", 0, '\0' }, { M_LFRT, "FIELD OF VIEW", M_ID_FOV, 'f' }, { M_LFRT, "MENU BACKGROUND SHADING", M_ID_MenuShading, 'm' }, { M_LFRT, "EXTRA LEVEL BRIGHTNESS", M_ID_LevelBrightness, 'e' }, { M_SKIP, "", 0, '\0' }, + { M_LFRT, "GAMMA-CORRECTION", M_ID_Gamma, 'g' }, { M_LFRT, "SATURATION", M_ID_Saturation, 's' }, + { M_LFRT, "CONTRAST", M_ID_Contrast, 'c' }, { M_LFRT, "RED INTENSITY", M_ID_R_Intensity, 'r' }, { M_LFRT, "GREEN INTENSITY", M_ID_G_Intensity, 'g' }, { M_LFRT, "BLUE INTENSITY", M_ID_B_Intensity, 'b' }, @@ -1609,7 +1608,7 @@ static menuitem_t ID_Menu_Display[]= static menu_t ID_Def_Display = { - 16, + 15, &ID_Def_Main, ID_Menu_Display, M_Draw_ID_Display, @@ -1629,74 +1628,89 @@ static void M_Draw_ID_Display (void) M_WriteTextCentered(9, "DISPLAY OPTIONS", cr[CR_YELLOW]); - // Gamma-correction slider and num - M_DrawGammaThermo(46, 27, 16, vid_gamma, 0); - M_WriteText (192, 30, gammalvls[vid_gamma][1], - M_Item_Glow(0, GLOW_UNCOLORED)); - // Field of View sprintf(str, "%d", vid_fov); - M_WriteText (M_ItemRightAlign(str), 45, str, - M_Item_Glow(3, vid_fov == 135 || vid_fov == 45 ? GLOW_YELLOW : + M_WriteText (M_ItemRightAlign(str), 18, str, + M_Item_Glow(0, vid_fov == 135 || vid_fov == 45 ? GLOW_YELLOW : vid_fov == 90 ? GLOW_DARKRED : GLOW_GREEN)); // Background shading sprintf(str, dp_menu_shading ? "%d" : "OFF", dp_menu_shading); - M_WriteText (M_ItemRightAlign(str), 54, str, - M_Item_Glow(4, dp_menu_shading == 12 ? GLOW_YELLOW : + M_WriteText (M_ItemRightAlign(str), 27, str, + M_Item_Glow(1, dp_menu_shading == 12 ? GLOW_YELLOW : dp_menu_shading > 0 ? GLOW_GREEN : GLOW_DARKRED)); // Extra level brightness sprintf(str, dp_level_brightness ? "%d" : "OFF", dp_level_brightness); - M_WriteText (M_ItemRightAlign(str), 63, str, - M_Item_Glow(5, dp_level_brightness == 8 ? GLOW_YELLOW : + M_WriteText (M_ItemRightAlign(str), 36, str, + M_Item_Glow(2, dp_level_brightness == 8 ? GLOW_YELLOW : dp_level_brightness > 0 ? GLOW_GREEN : GLOW_DARKRED)); - M_WriteTextCentered(72, "COLOR SETTINGS", cr[CR_YELLOW]); + M_WriteTextCentered(45, "COLOR SETTINGS", cr[CR_YELLOW]); + + // Gamma-correction + sprintf(str, "%s", gammalvls[vid_gamma][1]); + M_WriteText (M_ItemRightAlign(str), 54, str, + M_Item_Glow(4, GLOW_UNCOLORED)); // Saturation M_snprintf(str, 6, "%d%%", vid_saturation); - M_WriteText (M_ItemRightAlign(str), 81, str, - M_Item_Glow(7, GLOW_LIGHTGRAY)); + M_WriteText (M_ItemRightAlign(str), 63, str, + M_Item_Glow(5, GLOW_LIGHTGRAY)); + + // Contrast + M_snprintf(str, 6, "%3f", vid_contrast); + M_WriteText (M_ItemRightAlign(str), 72, str, + M_Item_Glow(6, GLOW_YELLOW)); // RED intensity M_snprintf(str, 6, "%3f", vid_r_intensity); - M_WriteText (M_ItemRightAlign(str), 90, str, - M_Item_Glow(8, GLOW_RED)); + M_WriteText (M_ItemRightAlign(str), 81, str, + M_Item_Glow(7, GLOW_RED)); // GREEN intensity M_snprintf(str, 6, "%3f", vid_g_intensity); - M_WriteText (M_ItemRightAlign(str), 99, str, - M_Item_Glow(9, GLOW_GREEN)); + M_WriteText (M_ItemRightAlign(str), 90, str, + M_Item_Glow(8, GLOW_GREEN)); // BLUE intensity M_snprintf(str, 6, "%3f", vid_b_intensity); - M_WriteText (M_ItemRightAlign(str), 108, str, - M_Item_Glow(10, GLOW_BLUE)); + M_WriteText (M_ItemRightAlign(str), 99, str, + M_Item_Glow(9, GLOW_BLUE)); - M_WriteTextCentered(117, "MESSAGES SETTINGS", cr[CR_YELLOW]); + M_WriteTextCentered(108, "MESSAGES SETTINGS", cr[CR_YELLOW]); // Messages enabled sprintf(str, msg_show ? "ON" : "OFF"); - M_WriteText (M_ItemRightAlign(str), 126, str, - M_Item_Glow(12, msg_show ? GLOW_DARKRED : GLOW_GREEN)); + M_WriteText (M_ItemRightAlign(str), 117, str, + M_Item_Glow(11, msg_show ? GLOW_DARKRED : GLOW_GREEN)); // Messages alignment sprintf(str, msg_alignment == 1 ? "STATUS BAR" : msg_alignment == 2 ? "CENTERED" : "LEFT"); - M_WriteText (M_ItemRightAlign(str), 135, str, - M_Item_Glow(13, msg_alignment ? GLOW_GREEN : GLOW_DARKRED)); + M_WriteText (M_ItemRightAlign(str), 126, str, + M_Item_Glow(12, msg_alignment ? GLOW_GREEN : GLOW_DARKRED)); // Text casts shadows sprintf(str, msg_text_shadows ? "ON" : "OFF"); - M_WriteText (M_ItemRightAlign(str), 144, str, - M_Item_Glow(14, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); + M_WriteText (M_ItemRightAlign(str), 135, str, + M_Item_Glow(13, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); // Local time sprintf(str, msg_local_time == 1 ? "12-HOUR FORMAT" : msg_local_time == 2 ? "24-HOUR FORMAT" : "OFF"); - M_WriteText (M_ItemRightAlign(str), 153, str, - M_Item_Glow(15, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); + M_WriteText (M_ItemRightAlign(str), 144, str, + M_Item_Glow(14, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); +} + +static void M_ID_FOV (int choice) +{ + vid_fov = M_INT_Slider(vid_fov, 45, 135, choice, true); + + // [crispy] re-calculate the zlight[][] array + R_InitLightTables(); + // [crispy] re-calculate the scalelight[][] array + R_ExecuteSetViewSize(); } static void M_ID_MenuShading (int choice) @@ -1724,35 +1738,25 @@ static void M_ID_Gamma (int choice) #endif } -static void M_ID_FOV (int choice) -{ - vid_fov = M_INT_Slider(vid_fov, 45, 135, choice, true); - - // [crispy] re-calculate the zlight[][] array - R_InitLightTables(); - // [crispy] re-calculate the scalelight[][] array - R_ExecuteSetViewSize(); -} - -static void M_ID_MessagesAlignment (int choice) -{ - msg_alignment = M_INT_Slider(msg_alignment, 0, 2, choice, false); -} - -static void M_ID_TextShadows (int choice) +static void M_ID_Saturation (int choice) { - msg_text_shadows ^= 1; -} + shade_wait = I_GetTime() + TICRATE; + vid_saturation = M_INT_Slider(vid_saturation, 0, 100, choice, true); -static void M_ID_LocalTime (int choice) -{ - msg_local_time = M_INT_Slider(msg_local_time, 0, 2, choice, false); +#ifndef CRISPY_TRUECOLOR + I_SetPalette ((byte *)W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE) + st_palette * 768); +#else + R_InitColormaps(); + R_FillBackScreen(); + AM_Init(); + st_fullupdate = true; +#endif } -static void M_ID_Saturation (int choice) +static void M_ID_Contrast (int choice) { shade_wait = I_GetTime() + TICRATE; - vid_saturation = M_INT_Slider(vid_saturation, 0, 100, choice, true); + vid_contrast = M_FLOAT_Slider(vid_contrast, 0.000000f, 2.000000f, 0.025000f, choice, true); #ifndef CRISPY_TRUECOLOR I_SetPalette ((byte *)W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE) + st_palette * 768); @@ -1809,6 +1813,21 @@ static void M_ID_B_Intensity (int choice) #endif } +static void M_ID_MessagesAlignment (int choice) +{ + msg_alignment = M_INT_Slider(msg_alignment, 0, 2, choice, false); +} + +static void M_ID_TextShadows (int choice) +{ + msg_text_shadows ^= 1; +} + +static void M_ID_LocalTime (int choice) +{ + msg_local_time = M_INT_Slider(msg_local_time, 0, 2, choice, false); +} + // ----------------------------------------------------------------------------- // Sound options // ----------------------------------------------------------------------------- @@ -4512,6 +4531,7 @@ static void M_ID_ApplyResetHook (void) dp_level_brightness = 0; // Color settings vid_saturation = 100; + vid_contrast = 1.000000; vid_r_intensity = 1.000000; vid_g_intensity = 1.000000; vid_b_intensity = 1.000000; @@ -5385,25 +5405,6 @@ M_DrawThermo dp_translation = NULL; } -static void M_DrawGammaThermo (int x, int y, int width, int dot, int itemPos) -{ - int xx = x; - - // [JN] Highlight active slider and gem. - dp_translation = M_SaveLoad_Glow(itemPos == itemOn, 0, saveload_slider); - - V_DrawShadowedPatchOptional(xx, y, 0, W_CacheLumpName("M_THERML", PU_CACHE)); - xx += 8; - for (int i = 0 ; i < width ; i++) - { - V_DrawShadowedPatchOptional(xx, y, 0, W_CacheLumpName("M_THERMM", PU_CACHE)); - xx += 8; - } - V_DrawShadowedPatchOptional(xx, y, 0, W_CacheLumpName("M_THERMR", PU_CACHE)); - V_DrawPatch((x + 8) + dot * 3, y, W_CacheLumpName("M_THERMO", PU_CACHE)); - dp_translation = NULL; -} - static void M_StartMessage ( const char* string, diff --git a/src/doom/r_data.c b/src/doom/r_data.c index 9f375704..a129dd37 100644 --- a/src/doom/r_data.c +++ b/src/doom/r_data.c @@ -1112,7 +1112,12 @@ void R_InitSpriteLumps (void) // [PN] Macros to optimize and standardize color calculations in the R_InitColormaps. // CALC_INTENSITY calculates the RGB components from playpal based on intensity settings. // CALC_SATURATION applies saturation correction using values from CALC_INTENSITY along -// with the a_hi and a_lo coefficients. Also, thanks Alaux! +// with the a_hi and a_lo coefficients. +// CALC_CONTRAST adjusts the contrast of the red, green, and blue channels +// based on the vid_contrast variable. A value of 1.0 preserves the original contrast, +// while values below 1.0 reduce it, and values above 1.0 enhance it. The calculation +// ensures that channel values remain within the valid range [0, 255]. +// Also, thanks Alaux! #define CALC_INTENSITY(pal, playpal, index) \ { pal[0] = playpal[3 * (index) + 0] * vid_r_intensity; \ @@ -1123,6 +1128,11 @@ void R_InitSpriteLumps (void) { channels[0] = (byte)((1 - a_hi) * pal[0] + a_lo * (pal[1] + pal[2])); \ channels[1] = (byte)((1 - a_hi) * pal[1] + a_lo * (pal[0] + pal[2])); \ channels[2] = (byte)((1 - a_hi) * pal[2] + a_lo * (pal[0] + pal[1])); } + +#define CALC_CONTRAST(channels, contrast) \ + { channels[0] = (int)BETWEEN(0, 255, (int)(128 + (channels[0] - 128) * contrast)); \ + channels[1] = (int)BETWEEN(0, 255, (int)(128 + (channels[1] - 128) * contrast)); \ + channels[2] = (int)BETWEEN(0, 255, (int)(128 + (channels[2] - 128) * contrast)); } #endif @@ -1179,6 +1189,7 @@ void R_InitColormaps (void) CALC_INTENSITY(pal, playpal, k); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] * (1. - scale) + gammatable[vid_gamma][0] * scale; g = gammatable[vid_gamma][channels[1]] * (1. - scale) + gammatable[vid_gamma][0] * scale; @@ -1200,6 +1211,7 @@ void R_InitColormaps (void) CALC_INTENSITY(pal, playpal, colormap[c * 256 + i]); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] & ~3; g = gammatable[vid_gamma][channels[1]] & ~3; @@ -1251,6 +1263,7 @@ void R_InitColormaps (void) CALC_INTENSITY(pal, playpal, colormap[32 * 256 + i]); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] & ~3; g = gammatable[vid_gamma][channels[1]] & ~3; @@ -1276,6 +1289,7 @@ void R_InitColormaps (void) CALC_INTENSITY(pal, playpal, i); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]]; g = gammatable[vid_gamma][channels[1]]; diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c index 0611bdcc..b3bca4d0 100644 --- a/src/heretic/mn_menu.c +++ b/src/heretic/mn_menu.c @@ -424,10 +424,11 @@ static void M_ID_ScreenWipe (int choice); static void M_ID_EndText (int choice); static void M_Draw_ID_Display (void); -static void M_ID_Gamma (int choice); static void M_ID_FOV (int choice); static void M_ID_MenuShading (int choice); static void M_ID_LevelBrightness (int choice); +static void M_ID_Gamma (int choice); +static void M_ID_Contrast (int choice); static void M_ID_Saturation (int choice); static void M_ID_R_Intensity (int choice); static void M_ID_G_Intensity (int choice); @@ -1429,12 +1430,13 @@ static void M_ID_EndText (int option) // ----------------------------------------------------------------------------- static MenuItem_t ID_Menu_Display[] = { - { ITT_LRFUNC, "GAMMA-CORRECTION", M_ID_Gamma, 0, MENU_NONE }, { ITT_LRFUNC, "FIELD OF VIEW", M_ID_FOV, 0, MENU_NONE }, { ITT_LRFUNC, "MENU BACKGROUND SHADING", M_ID_MenuShading, 0, MENU_NONE }, { ITT_LRFUNC, "EXTRA LEVEL BRIGHTNESS", M_ID_LevelBrightness, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }, + { ITT_LRFUNC, "GAMMA-CORRECTION", M_ID_Gamma, 0, MENU_NONE }, { ITT_LRFUNC, "SATURATION", M_ID_Saturation, 0, MENU_NONE }, + { ITT_LRFUNC, "CONTRAST", M_ID_Contrast, 0, MENU_NONE }, { ITT_LRFUNC, "RED INTENSITY", M_ID_R_Intensity, 0, MENU_NONE }, { ITT_LRFUNC, "GREEN INTENSITY", M_ID_G_Intensity, 0, MENU_NONE }, { ITT_LRFUNC, "BLUE INTENSITY", M_ID_B_Intensity, 0, MENU_NONE }, @@ -1447,7 +1449,7 @@ static MenuItem_t ID_Menu_Display[] = { static Menu_t ID_Def_Display = { ID_MENU_LEFTOFFSET, ID_MENU_TOPOFFSET, M_Draw_ID_Display, - 13, ID_Menu_Display, + 14, ID_Menu_Display, 0, SmallFont, false, false, MENU_ID_MAIN @@ -1459,82 +1461,73 @@ static void M_Draw_ID_Display (void) MN_DrTextACentered("DISPLAY OPTIONS", 10, cr[CR_YELLOW]); - // Gamma-correction num - MN_DrTextA(gammalvls[vid_gamma][1], M_ItemRightAlign(gammalvls[vid_gamma][1]), 20, - M_Item_Glow(0, GLOW_LIGHTGRAY)); - // Field of View sprintf(str, "%d", vid_fov); - MN_DrTextA(str, M_ItemRightAlign(str), 30, - M_Item_Glow(1, vid_fov == 135 || vid_fov == 70 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 20, + M_Item_Glow(0, vid_fov == 135 || vid_fov == 70 ? GLOW_YELLOW : vid_fov == 90 ? GLOW_DARKRED : GLOW_GREEN)); // Background shading sprintf(str, dp_menu_shading ? "%d" : "OFF", dp_menu_shading); - MN_DrTextA(str, M_ItemRightAlign(str), 40, - M_Item_Glow(2, dp_menu_shading == 12 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 30, + M_Item_Glow(1, dp_menu_shading == 12 ? GLOW_YELLOW : dp_menu_shading > 0 ? GLOW_GREEN : GLOW_DARKRED)); // Extra level brightness sprintf(str, dp_level_brightness ? "%d" : "OFF", dp_level_brightness); - MN_DrTextA(str, M_ItemRightAlign(str), 50, - M_Item_Glow(3, dp_level_brightness == 8 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 40, + M_Item_Glow(2, dp_level_brightness == 8 ? GLOW_YELLOW : dp_level_brightness > 0 ? GLOW_GREEN : GLOW_DARKRED)); - MN_DrTextACentered("COLOR SETTINGS", 60, cr[CR_YELLOW]); + MN_DrTextACentered("COLOR SETTINGS", 50, cr[CR_YELLOW]); + + // Gamma-correction num + sprintf(str, "%s", gammalvls[vid_gamma][1]); + MN_DrTextA(str, M_ItemRightAlign(str), 60, + M_Item_Glow(4, GLOW_LIGHTGRAY)); // Saturation M_snprintf(str, 6, "%d%%", vid_saturation); MN_DrTextA(str, M_ItemRightAlign(str), 70, M_Item_Glow(5, GLOW_LIGHTGRAY)); + // Contrast + M_snprintf(str, 6, "%3f", vid_contrast); + MN_DrTextA(str, M_ItemRightAlign(str), 80, + M_Item_Glow(6, GLOW_YELLOW)); + // RED intensity M_snprintf(str, 6, "%3f", vid_r_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 80, - M_Item_Glow(6, GLOW_RED)); + MN_DrTextA(str, M_ItemRightAlign(str), 90, + M_Item_Glow(7, GLOW_RED)); // GREEN intensity M_snprintf(str, 6, "%3f", vid_g_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 90, - M_Item_Glow(7, GLOW_GREEN)); + MN_DrTextA(str, M_ItemRightAlign(str), 100, + M_Item_Glow(8, GLOW_GREEN)); // BLUE intensity M_snprintf(str, 6, "%3f", vid_b_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 100, - M_Item_Glow(8, GLOW_BLUE)); + MN_DrTextA(str, M_ItemRightAlign(str), 110, + M_Item_Glow(9, GLOW_BLUE)); - MN_DrTextACentered("MESSAGES SETTINGS", 110, cr[CR_YELLOW]); + MN_DrTextACentered("MESSAGES SETTINGS", 120, cr[CR_YELLOW]); // Messages enabled sprintf(str, msg_show ? "ON" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 120, - M_Item_Glow(10, msg_show ? GLOW_DARKRED : GLOW_GREEN)); + MN_DrTextA(str, M_ItemRightAlign(str), 130, + M_Item_Glow(11, msg_show ? GLOW_DARKRED : GLOW_GREEN)); // Text casts shadows sprintf(str, msg_text_shadows ? "ON" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 130, - M_Item_Glow(11, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); + MN_DrTextA(str, M_ItemRightAlign(str), 140, + M_Item_Glow(12, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); // Local time sprintf(str, msg_local_time == 1 ? "12-HOUR FORMAT" : msg_local_time == 2 ? "24-HOUR FORMAT" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 140, - M_Item_Glow(12, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); -} - -static void M_ID_Gamma (int choice) -{ - shade_wait = I_GetTime() + TICRATE; - vid_gamma = M_INT_Slider(vid_gamma, 0, MAXGAMMA-1, choice, true); - -#ifndef CRISPY_TRUECOLOR - I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); -#else - I_SetPalette(sb_palette); - R_InitColormaps(); - R_FillBackScreen(); - SB_ForceRedraw(); -#endif + MN_DrTextA(str, M_ItemRightAlign(str), 150, + M_Item_Glow(13, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); } static void M_ID_FOV (int choice) @@ -1557,6 +1550,21 @@ static void M_ID_LevelBrightness (int choice) dp_level_brightness = M_INT_Slider(dp_level_brightness, 0, 8, choice, true); } +static void M_ID_Gamma (int choice) +{ + shade_wait = I_GetTime() + TICRATE; + vid_gamma = M_INT_Slider(vid_gamma, 0, MAXGAMMA-1, choice, true); + +#ifndef CRISPY_TRUECOLOR + I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); +#else + I_SetPalette(sb_palette); + R_InitColormaps(); + R_FillBackScreen(); + SB_ForceRedraw(); +#endif +} + static void M_ID_Saturation (int choice) { shade_wait = I_GetTime() + TICRATE; @@ -1571,6 +1579,20 @@ static void M_ID_Saturation (int choice) #endif } +static void M_ID_Contrast (int choice) +{ + shade_wait = I_GetTime() + TICRATE; + vid_contrast = M_FLOAT_Slider(vid_contrast, 0.000000f, 2.000000f, 0.025000f, choice, true); + +#ifndef CRISPY_TRUECOLOR + I_SetPalette ((byte *)W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE) + sb_palette * 768); +#else + R_InitColormaps(); + R_FillBackScreen(); + SB_ForceRedraw(); +#endif +} + static void M_ID_R_Intensity (int choice) { shade_wait = I_GetTime() + TICRATE; @@ -4400,6 +4422,7 @@ static void M_ID_ApplyResetHook (void) dp_level_brightness = 0; // Color settings vid_saturation = 100; + vid_contrast = 1.000000; vid_r_intensity = 1.000000; vid_g_intensity = 1.000000; vid_b_intensity = 1.000000; diff --git a/src/heretic/r_data.c b/src/heretic/r_data.c index bc0f4086..0cdd3c02 100644 --- a/src/heretic/r_data.c +++ b/src/heretic/r_data.c @@ -760,7 +760,12 @@ void R_InitSpriteLumps(void) // [PN] Macros to optimize and standardize color calculations in the R_InitColormaps. // CALC_INTENSITY calculates the RGB components from playpal based on intensity settings. // CALC_SATURATION applies saturation correction using values from CALC_INTENSITY along -// with the a_hi and a_lo coefficients. Also, thanks Alaux! +// with the a_hi and a_lo coefficients. +// CALC_CONTRAST adjusts the contrast of the red, green, and blue channels +// based on the vid_contrast variable. A value of 1.0 preserves the original contrast, +// while values below 1.0 reduce it, and values above 1.0 enhance it. The calculation +// ensures that channel values remain within the valid range [0, 255]. +// Also, thanks Alaux! #define CALC_INTENSITY(pal, playpal, index) \ { pal[0] = playpal[3 * (index) + 0] * vid_r_intensity; \ @@ -771,6 +776,11 @@ void R_InitSpriteLumps(void) { channels[0] = (byte)((1 - a_hi) * pal[0] + a_lo * (pal[1] + pal[2])); \ channels[1] = (byte)((1 - a_hi) * pal[1] + a_lo * (pal[0] + pal[2])); \ channels[2] = (byte)((1 - a_hi) * pal[2] + a_lo * (pal[0] + pal[1])); } + +#define CALC_CONTRAST(channels, contrast) \ + { channels[0] = (int)BETWEEN(0, 255, (int)(128 + (channels[0] - 128) * contrast)); \ + channels[1] = (int)BETWEEN(0, 255, (int)(128 + (channels[1] - 128) * contrast)); \ + channels[2] = (int)BETWEEN(0, 255, (int)(128 + (channels[2] - 128) * contrast)); } #endif @@ -831,6 +841,7 @@ void R_InitColormaps(void) CALC_INTENSITY(pal, playpal, k); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] * (1. - scale) + gammatable[vid_gamma][0] * scale; g = gammatable[vid_gamma][channels[1]] * (1. - scale) + gammatable[vid_gamma][0] * scale; @@ -852,6 +863,7 @@ void R_InitColormaps(void) CALC_INTENSITY(pal, playpal, colormap[c * 256 + i]); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] & ~3; g = gammatable[vid_gamma][channels[1]] & ~3; @@ -885,6 +897,7 @@ void R_InitColormaps(void) CALC_INTENSITY(pal, playpal, colormap[32 * 256 + i]); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] & ~3; g = gammatable[vid_gamma][channels[1]] & ~3; @@ -909,6 +922,7 @@ void R_InitColormaps(void) CALC_INTENSITY(pal, playpal, i); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]]; g = gammatable[vid_gamma][channels[1]]; @@ -967,11 +981,26 @@ void R_SetUnderwaterPalette(byte *palette) int i, j = 0; byte r, g, b; + // [JN] Saturation floats, high and low. + // If saturation has been modified (< 100), set high and low + // values according to saturation level. Sum of r,g,b channels + // and floats must be 1.0 to get proper colors. + const float a_hi = vid_saturation < 100 ? I_SaturationPercent[vid_saturation] : 0; + const float a_lo = vid_saturation < 100 ? (a_hi / 2) : 0; + for (i = 0; i < 256; i++) { - r = gammatable[vid_gamma][palette[3 * i + 0]] + gammatable[vid_gamma][0]; - g = gammatable[vid_gamma][palette[3 * i + 1]] + gammatable[vid_gamma][0]; - b = gammatable[vid_gamma][palette[3 * i + 2]] + gammatable[vid_gamma][0]; + // [PN] Apply intensity and saturation corrections + byte pal[3]; + byte channels[3]; + + CALC_INTENSITY(pal, palette, i); + CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); + + r = gammatable[vid_gamma][channels[0]] + gammatable[vid_gamma][0]; + g = gammatable[vid_gamma][channels[1]] + gammatable[vid_gamma][0]; + b = gammatable[vid_gamma][channels[2]] + gammatable[vid_gamma][0]; pal_color[j++] = 0xff000000 | (r << 16) | (g << 8) | b; } diff --git a/src/heretic/sb_bar.c b/src/heretic/sb_bar.c index 9d58b255..87f1ece2 100644 --- a/src/heretic/sb_bar.c +++ b/src/heretic/sb_bar.c @@ -575,7 +575,7 @@ static void ShadeLine(int x, int y, int height, int shade) #ifndef CRISPY_TRUECOLOR shades = colormaps + 9 * 256 + shade * 2 * 256; #else - shade = 0xFF - (((9 + shade * 2) << 8) / 32); // [crispy] shade to darkest 32nd COLORMAP row + shade = (int)BETWEEN(0, 255, 0xFF - (((9 + shade * 2) << 8) / 32) * vid_contrast); // [crispy] shade to darkest 32nd COLORMAP row #endif dest = I_VideoBuffer + y * SCREENWIDTH + x + (WIDESCREENDELTA * vid_resolution); while (height--) diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index 641366a6..08b1f964 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -430,11 +430,12 @@ static void M_ID_ScreenWipe (int choice); static void M_ID_Banners (int choice); static void M_Draw_ID_Display (void); -static void M_ID_Gamma (int choice); static void M_ID_FOV (int choice); static void M_ID_MenuShading (int choice); static void M_ID_LevelBrightness (int choice); +static void M_ID_Gamma (int choice); static void M_ID_Saturation (int choice); +static void M_ID_Contrast (int choice); static void M_ID_R_Intensity (int choice); static void M_ID_G_Intensity (int choice); static void M_ID_B_Intensity (int choice); @@ -1387,12 +1388,13 @@ static void M_ID_Banners (int choice) // ----------------------------------------------------------------------------- static MenuItem_t ID_Menu_Display[] = { - { ITT_LRFUNC, "GAMMA-CORRECTION", M_ID_Gamma, 0, MENU_NONE }, { ITT_LRFUNC, "FIELD OF VIEW", M_ID_FOV, 0, MENU_NONE }, { ITT_LRFUNC, "MENU BACKGROUND SHADING", M_ID_MenuShading, 0, MENU_NONE }, { ITT_LRFUNC, "EXTRA LEVEL BRIGHTNESS", M_ID_LevelBrightness, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }, + { ITT_LRFUNC, "GAMMA-CORRECTION", M_ID_Gamma, 0, MENU_NONE }, { ITT_LRFUNC, "SATURATION", M_ID_Saturation, 0, MENU_NONE }, + { ITT_LRFUNC, "CONTRAST", M_ID_Contrast, 0, MENU_NONE }, { ITT_LRFUNC, "RED INTENSITY", M_ID_R_Intensity, 0, MENU_NONE }, { ITT_LRFUNC, "GREEN INTENSITY", M_ID_G_Intensity, 0, MENU_NONE }, { ITT_LRFUNC, "BLUE INTENSITY", M_ID_B_Intensity, 0, MENU_NONE }, @@ -1405,7 +1407,7 @@ static MenuItem_t ID_Menu_Display[] = { static Menu_t ID_Def_Display = { ID_MENU_LEFTOFFSET, ID_MENU_TOPOFFSET, M_Draw_ID_Display, - 13, ID_Menu_Display, + 14, ID_Menu_Display, 0, SmallFont, false, false, MENU_ID_MAIN @@ -1417,82 +1419,73 @@ static void M_Draw_ID_Display (void) MN_DrTextACentered("DISPLAY OPTIONS", 10, cr[CR_YELLOW]); - // Gamma-correction num - MN_DrTextA(gammalvls[vid_gamma][1], M_ItemRightAlign(gammalvls[vid_gamma][1]), 20, - M_Item_Glow(0, GLOW_LIGHTGRAY)); - // Field of View sprintf(str, "%d", vid_fov); - MN_DrTextA(str, M_ItemRightAlign(str), 30, - M_Item_Glow(1, vid_fov == 135 || vid_fov == 70 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 20, + M_Item_Glow(0, vid_fov == 135 || vid_fov == 70 ? GLOW_YELLOW : vid_fov == 90 ? GLOW_DARKRED : GLOW_GREEN)); // Background shading sprintf(str, dp_menu_shading ? "%d" : "OFF", dp_menu_shading); - MN_DrTextA(str, M_ItemRightAlign(str), 40, - M_Item_Glow(2, dp_menu_shading == 12 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 30, + M_Item_Glow(1, dp_menu_shading == 12 ? GLOW_YELLOW : dp_menu_shading > 0 ? GLOW_GREEN : GLOW_DARKRED)); // Extra level brightness sprintf(str, dp_level_brightness ? "%d" : "OFF", dp_level_brightness); - MN_DrTextA(str, M_ItemRightAlign(str), 50, - M_Item_Glow(3, dp_level_brightness == 8 ? GLOW_YELLOW : + MN_DrTextA(str, M_ItemRightAlign(str), 40, + M_Item_Glow(2, dp_level_brightness == 8 ? GLOW_YELLOW : dp_level_brightness > 0 ? GLOW_GREEN : GLOW_DARKRED)); - MN_DrTextACentered("COLOR SETTINGS", 60, cr[CR_YELLOW]); + MN_DrTextACentered("COLOR SETTINGS", 50, cr[CR_YELLOW]); + + // Gamma-correction num + sprintf(str, "%s", gammalvls[vid_gamma][1]); + MN_DrTextA(str, M_ItemRightAlign(str), 60, + M_Item_Glow(4, GLOW_LIGHTGRAY)); // Saturation M_snprintf(str, 6, "%d%%", vid_saturation); MN_DrTextA(str, M_ItemRightAlign(str), 70, M_Item_Glow(5, GLOW_LIGHTGRAY)); + // Contrast + M_snprintf(str, 6, "%3f", vid_contrast); + MN_DrTextA(str, M_ItemRightAlign(str), 80, + M_Item_Glow(6, GLOW_YELLOW)); + // RED intensity M_snprintf(str, 6, "%3f", vid_r_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 80, - M_Item_Glow(6, GLOW_RED)); + MN_DrTextA(str, M_ItemRightAlign(str), 90, + M_Item_Glow(7, GLOW_RED)); // GREEN intensity M_snprintf(str, 6, "%3f", vid_g_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 90, - M_Item_Glow(7, GLOW_GREEN)); + MN_DrTextA(str, M_ItemRightAlign(str), 100, + M_Item_Glow(8, GLOW_GREEN)); // BLUE intensity M_snprintf(str, 6, "%3f", vid_b_intensity); - MN_DrTextA(str, M_ItemRightAlign(str), 100, - M_Item_Glow(8, GLOW_BLUE)); + MN_DrTextA(str, M_ItemRightAlign(str), 110, + M_Item_Glow(9, GLOW_BLUE)); - MN_DrTextACentered("MESSAGES SETTINGS", 110, cr[CR_YELLOW]); + MN_DrTextACentered("MESSAGES SETTINGS", 120, cr[CR_YELLOW]); // Messages enabled sprintf(str, msg_show ? "ON" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 120, - M_Item_Glow(10, msg_show ? GLOW_DARKRED : GLOW_GREEN)); + MN_DrTextA(str, M_ItemRightAlign(str), 130, + M_Item_Glow(11, msg_show ? GLOW_DARKRED : GLOW_GREEN)); // Text casts shadows sprintf(str, msg_text_shadows ? "ON" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 130, - M_Item_Glow(11, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); + MN_DrTextA(str, M_ItemRightAlign(str), 140, + M_Item_Glow(12, msg_text_shadows ? GLOW_GREEN : GLOW_DARKRED)); // Local time sprintf(str, msg_local_time == 1 ? "12-HOUR FORMAT" : msg_local_time == 2 ? "24-HOUR FORMAT" : "OFF"); - MN_DrTextA(str, M_ItemRightAlign(str), 140, - M_Item_Glow(12, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); -} - -static void M_ID_Gamma (int choice) -{ - shade_wait = I_GetTime() + TICRATE; - vid_gamma = M_INT_Slider(vid_gamma, 0, MAXGAMMA-1, choice, true); - -#ifndef CRISPY_TRUECOLOR - I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); -#else - I_SetPalette(SB_palette); - R_InitTrueColormaps(LevelUseFullBright ? "COLORMAP" : "FOGMAP"); - R_FillBackScreen(); - SB_ForceRedraw(); -#endif + MN_DrTextA(str, M_ItemRightAlign(str), 150, + M_Item_Glow(13, msg_local_time ? GLOW_GREEN : GLOW_DARKRED)); } static void M_ID_FOV (int choice) @@ -1515,6 +1508,21 @@ static void M_ID_LevelBrightness (int choice) dp_level_brightness = M_INT_Slider(dp_level_brightness, 0, 8, choice, true); } +static void M_ID_Gamma (int choice) +{ + shade_wait = I_GetTime() + TICRATE; + vid_gamma = M_INT_Slider(vid_gamma, 0, MAXGAMMA-1, choice, true); + +#ifndef CRISPY_TRUECOLOR + I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); +#else + I_SetPalette(SB_palette); + R_InitTrueColormaps(LevelUseFullBright ? "COLORMAP" : "FOGMAP"); + R_FillBackScreen(); + SB_ForceRedraw(); +#endif +} + static void M_ID_Saturation (int choice) { shade_wait = I_GetTime() + TICRATE; @@ -1529,6 +1537,20 @@ static void M_ID_Saturation (int choice) #endif } +static void M_ID_Contrast (int choice) +{ + shade_wait = I_GetTime() + TICRATE; + vid_contrast = M_FLOAT_Slider(vid_contrast, 0.000000f, 2.000000f, 0.025000f, choice, true); + +#ifndef CRISPY_TRUECOLOR + I_SetPalette ((byte *)W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE) + sb_palette * 768); +#else + R_InitTrueColormaps(LevelUseFullBright ? "COLORMAP" : "FOGMAP"); + R_FillBackScreen(); + SB_ForceRedraw(); +#endif +} + static void M_ID_R_Intensity (int choice) { shade_wait = I_GetTime() + TICRATE; @@ -3707,6 +3729,7 @@ static void M_ID_ApplyResetHook (void) dp_level_brightness = 0; // Color settings vid_saturation = 100; + vid_contrast = 1.000000; vid_r_intensity = 1.000000; vid_g_intensity = 1.000000; vid_b_intensity = 1.000000; diff --git a/src/hexen/r_data.c b/src/hexen/r_data.c index 8789b8c9..61b53454 100644 --- a/src/hexen/r_data.c +++ b/src/hexen/r_data.c @@ -684,7 +684,12 @@ void R_InitColormaps(void) // [PN] Macros to optimize and standardize color calculations in the R_InitColormaps. // CALC_INTENSITY calculates the RGB components from playpal based on intensity settings. // CALC_SATURATION applies saturation correction using values from CALC_INTENSITY along -// with the a_hi and a_lo coefficients. Also, thanks Alaux! +// with the a_hi and a_lo coefficients. +// CALC_CONTRAST adjusts the contrast of the red, green, and blue channels +// based on the vid_contrast variable. A value of 1.0 preserves the original contrast, +// while values below 1.0 reduce it, and values above 1.0 enhance it. The calculation +// ensures that channel values remain within the valid range [0, 255]. +// Also, thanks Alaux! #define CALC_INTENSITY(pal, playpal, index) \ { pal[0] = playpal[3 * (index) + 0] * vid_r_intensity; \ @@ -696,6 +701,11 @@ void R_InitColormaps(void) channels[1] = (byte)((1 - a_hi) * pal[1] + a_lo * (pal[0] + pal[2])); \ channels[2] = (byte)((1 - a_hi) * pal[2] + a_lo * (pal[0] + pal[1])); } +#define CALC_CONTRAST(channels, contrast) \ + { channels[0] = (int)BETWEEN(0, 255, (int)(128 + (channels[0] - 128) * contrast)); \ + channels[1] = (int)BETWEEN(0, 255, (int)(128 + (channels[1] - 128) * contrast)); \ + channels[2] = (int)BETWEEN(0, 255, (int)(128 + (channels[2] - 128) * contrast)); } + // [crispy] Our own function to generate colormaps for normal and foggy levels. void R_InitTrueColormaps(char *current_colormap) { @@ -746,6 +756,7 @@ void R_InitTrueColormaps(char *current_colormap) CALC_INTENSITY(pal, playpal, k); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] * (1. - scale) + gammatable[vid_gamma][fade_color] * scale; g = gammatable[vid_gamma][channels[1]] * (1. - scale) + gammatable[vid_gamma][fade_color] * scale; @@ -767,6 +778,7 @@ void R_InitTrueColormaps(char *current_colormap) CALC_INTENSITY(pal, playpal, colormap[c * 256 + i]); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]] & ~3; g = gammatable[vid_gamma][channels[1]] & ~3; @@ -792,6 +804,7 @@ void R_InitTrueColormaps(char *current_colormap) CALC_INTENSITY(pal, playpal, i); CALC_SATURATION(channels, pal, a_hi, a_lo); + CALC_CONTRAST(channels, vid_contrast); r = gammatable[vid_gamma][channels[0]]; g = gammatable[vid_gamma][channels[1]]; diff --git a/src/hexen/sb_bar.c b/src/hexen/sb_bar.c index ed80bd93..33c017bd 100644 --- a/src/hexen/sb_bar.c +++ b/src/hexen/sb_bar.c @@ -1611,32 +1611,51 @@ void DrawMainBar(void) V_DrawPatch(77, 164, manaPatch1); V_DrawPatch(110, 164, manaPatch2); V_DrawPatch(94, 164, manaVialPatch1); - for (i = 165; i < 187 - (22 * CPlayer->mana[0]) / MAX_MANA; i++) - { - for (j = 0; j < vid_resolution; j++) - for (k = 0; k < vid_resolution; k++) - { - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((95 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((96 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((97 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - } - } - V_DrawPatch(102, 164, manaVialPatch2); - for (i = 165; i < 187 - (22 * CPlayer->mana[1]) / MAX_MANA; i++) - { - for (j = 0; j < vid_resolution; j++) - for (k = 0; k < vid_resolution; k++) - { - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((103 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((104 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - I_VideoBuffer[SCREENWIDTH * ((i * vid_resolution) + j) - + ((105 + WIDESCREENDELTA) * vid_resolution) + k] = 0; - } + + // [PN] Adjusted "black" color to depend on vid_contrast. + // Instead of hardcoding 0 (absolute black), the adjusted_black value + // dynamically darkens or lightens based on the current contrast setting. + // This ensures that the color remains visually consistent and adaptable + // to user-defined contrast levels, avoiding issues like color distortion + // or overly dark rendering in low-contrast scenarios. + { + int adjusted_black = (int)(128 * (1.0 - vid_contrast)); + if (adjusted_black < 0) adjusted_black = 0; + if (adjusted_black > 255) adjusted_black = 255; + adjusted_black = (adjusted_black << 16) | (adjusted_black << 8) | adjusted_black; + + for (i = 165; i < 187 - (22 * CPlayer->mana[0]) / MAX_MANA; i++) + { + for (j = 0; j < vid_resolution; j++) + { + const int base_index = SCREENWIDTH * ((i * vid_resolution) + j) + + ((95 + WIDESCREENDELTA) * vid_resolution); + + // [PN] Since three consecutive columns are being filled + for (k = 0; k < 3 * vid_resolution; k++) + { + I_VideoBuffer[base_index + k] = adjusted_black; + } + } + } + + V_DrawPatch(102, 164, manaVialPatch2); + + // [PN] This loop handles the second vertical bar, following the same logic as above. + for (i = 165; i < 187 - (22 * CPlayer->mana[1]) / MAX_MANA; i++) + { + for (j = 0; j < vid_resolution; j++) + { + const int base_index = SCREENWIDTH * ((i * vid_resolution) + j) + + ((103 + WIDESCREENDELTA) * vid_resolution); + + // [PN] Since three consecutive columns are being filled + for (k = 0; k < 3 * vid_resolution; k++) + { + I_VideoBuffer[base_index + k] = adjusted_black; + } + } + } } oldweapon = CPlayer->readyweapon; } diff --git a/src/id_vars.c b/src/id_vars.c index 116b2c0c..74b88acd 100644 --- a/src/id_vars.c +++ b/src/id_vars.c @@ -62,6 +62,7 @@ int dp_menu_shading = 0; int dp_level_brightness = 0; // Color settings int vid_saturation = 100; +float vid_contrast = 1.000000; float vid_r_intensity = 1.000000; float vid_g_intensity = 1.000000; float vid_b_intensity = 1.000000; @@ -244,6 +245,7 @@ void ID_BindVariables (GameMission_t mission) M_BindIntVariable("dp_level_brightness", &dp_level_brightness); // Color settings M_BindIntVariable("vid_saturation", &vid_saturation); + M_BindFloatVariable("vid_contrast", &vid_contrast); M_BindFloatVariable("vid_r_intensity", &vid_r_intensity); M_BindFloatVariable("vid_g_intensity", &vid_g_intensity); M_BindFloatVariable("vid_b_intensity", &vid_b_intensity); diff --git a/src/id_vars.h b/src/id_vars.h index f8fb366d..3875f182 100644 --- a/src/id_vars.h +++ b/src/id_vars.h @@ -43,6 +43,7 @@ extern int vid_showfps; extern int vid_gamma; extern int vid_fov; extern int vid_saturation; +extern float vid_contrast; extern float vid_r_intensity; extern float vid_g_intensity; extern float vid_b_intensity; diff --git a/src/m_config.c b/src/m_config.c index 7b164b17..1549032c 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -192,6 +192,7 @@ static default_t doom_defaults_list[] = CONFIG_VARIABLE_INT(vid_gamma), CONFIG_VARIABLE_INT(vid_fov), CONFIG_VARIABLE_INT(vid_saturation), + CONFIG_VARIABLE_FLOAT(vid_contrast), CONFIG_VARIABLE_FLOAT(vid_r_intensity), CONFIG_VARIABLE_FLOAT(vid_g_intensity), CONFIG_VARIABLE_FLOAT(vid_b_intensity),