From 8231032f899365a4c87405812452b1944a6e2c54 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 24 Dec 2016 19:22:31 -0500 Subject: [PATCH] - fixed a crash - tried to make MAKETRANSDOT algorithm more consistent with original --- src/v_draw.cpp | 19 ++++++++++--------- src/v_video.cpp | 11 +++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 703a059ef7..b529770d6b 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -70,6 +70,7 @@ CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) StatusBar->ScreenSizeChanged(); } } +EXTERN_CVAR(Bool, r_blendmethod) // [RH] Stretch values to make a 320x200 image best fit the screen // without using fractional steppings @@ -1009,17 +1010,17 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level) uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx; uint32_t fg = swrenderer::LightBgra::shade_pal_index_simple(basecolor, swrenderer::LightBgra::calc_light_multiplier(0)); - uint32_t fg_red = (fg >> 16) & 0xff; - uint32_t fg_green = (fg >> 8) & 0xff; - uint32_t fg_blue = fg & 0xff; + uint32_t fg_red = (((fg >> 16) & 0xff) * (63 - level)) >> 6; + uint32_t fg_green = (((fg >> 8) & 0xff) * (63 - level)) >> 6; + uint32_t fg_blue = ((fg & 0xff) * (63 - level)) >> 6; - uint32_t bg_red = (*spot >> 16) & 0xff; - uint32_t bg_green = (*spot >> 8) & 0xff; - uint32_t bg_blue = (*spot) & 0xff; + uint32_t bg_red = (((*spot >> 16) & 0xff) * level) >> 6; + uint32_t bg_green = (((*spot >> 8) & 0xff) * level) >> 6; + uint32_t bg_blue = (((*spot) & 0xff) * level) >> 6; - uint32_t red = (fg_red + bg_red + 1) / 2; - uint32_t green = (fg_green + bg_green + 1) / 2; - uint32_t blue = (fg_blue + bg_blue + 1) / 2; + uint32_t red = fg_red + bg_red; + uint32_t green = fg_green + bg_green; + uint32_t blue = fg_blue + bg_blue; *spot = 0xff000000 | (red << 16) | (green << 8) | blue; } diff --git a/src/v_video.cpp b/src/v_video.cpp index bd322bf52f..146e2eb025 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -424,6 +424,17 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) if (!r_blendmethod) { + { + int amount; + + amount = (int)(damount * 64); + bg2rgb = Col2RGB8[64 - amount]; + + fg = (((color.r * amount) >> 4) << 20) | + ((color.g * amount) >> 4) | + (((color.b * amount) >> 4) << 10); + } + for (y = h; y != 0; y--) { for (x = w; x != 0; x--)