From 3ce2d8365dd6a91c068a20b0caf4b683634ceba3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 13 Jun 2016 20:01:31 +0200 Subject: [PATCH] Fix HUD colors when hw2d is off --- src/r_draw_rgba.cpp | 9 ++++++--- src/r_drawt_rgba.cpp | 19 +++++++++++++------ src/v_draw.cpp | 13 +++++++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/r_draw_rgba.cpp b/src/r_draw_rgba.cpp index d5c275d0e..7e9f85117 100644 --- a/src/r_draw_rgba.cpp +++ b/src/r_draw_rgba.cpp @@ -325,11 +325,11 @@ public: { int pitch = dc_pitch * thread->num_cores; - BYTE color = dc_color; + uint32_t color = shade_pal_index_simple(dc_color, light); do { - *dest = shade_pal_index_simple(color, light); + *dest = color; dest += pitch; } while (--count); } @@ -629,6 +629,7 @@ class DrawAddColumnRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; fixed_t dc_srcalpha; fixed_t dc_destalpha; + BYTE *dc_colormap; public: DrawAddColumnRGBACommand() @@ -643,6 +644,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_srcalpha = ::dc_srcalpha; dc_destalpha = ::dc_destalpha; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -667,13 +669,14 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(source[frac >> FRACBITS], light, shade_constants); + uint32_t fg = shade_pal_index(colormap[source[frac >> FRACBITS]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; diff --git a/src/r_drawt_rgba.cpp b/src/r_drawt_rgba.cpp index 5f0fc4156..cd124ac63 100644 --- a/src/r_drawt_rgba.cpp +++ b/src/r_drawt_rgba.cpp @@ -512,6 +512,7 @@ class RtAdd1colRGBACommand : public DrawerCommand ShadeConstants dc_shade_constants; fixed_t dc_srcalpha; fixed_t dc_destalpha; + BYTE *dc_colormap; public: RtAdd1colRGBACommand(int hx, int sx, int yl, int yh) @@ -527,6 +528,7 @@ public: dc_shade_constants = ::dc_shade_constants; dc_srcalpha = ::dc_srcalpha; dc_destalpha = ::dc_destalpha; + dc_colormap = ::dc_colormap; } void Execute(DrawerThread *thread) override @@ -548,12 +550,13 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); do { - uint32_t fg = shade_pal_index(*source, light, shade_constants); + uint32_t fg = shade_pal_index(colormap[*source], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -583,6 +586,7 @@ class RtAdd4colsRGBACommand : public DrawerCommand int dc_pitch; fixed_t dc_light; ShadeConstants dc_shade_constants; + BYTE *dc_colormap; public: RtAdd4colsRGBACommand(int sx, int yl, int yh) @@ -595,6 +599,7 @@ public: dc_pitch = ::dc_pitch; dc_light = ::dc_light; dc_shade_constants = ::dc_shade_constants; + dc_colormap = ::dc_colormap; } #ifdef NO_SSE @@ -617,6 +622,7 @@ public: uint32_t light = calc_light_multiplier(dc_light); ShadeConstants shade_constants = dc_shade_constants; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -624,7 +630,7 @@ public: do { for (int i = 0; i < 4; i++) { - uint32_t fg = shade_pal_index(source[i], light, shade_constants); + uint32_t fg = shade_pal_index(colormap[source[i]], light, shade_constants); uint32_t fg_red = (fg >> 16) & 0xff; uint32_t fg_green = (fg >> 8) & 0xff; uint32_t fg_blue = fg & 0xff; @@ -664,6 +670,7 @@ public: uint32_t light = calc_light_multiplier(dc_light); uint32_t *palette = (uint32_t*)GPalette.BaseColors; + BYTE *colormap = dc_colormap; uint32_t fg_alpha = dc_srcalpha >> (FRACBITS - 8); uint32_t bg_alpha = dc_destalpha >> (FRACBITS - 8); @@ -678,10 +685,10 @@ public: __m128i mbg_alpha = _mm_set_epi16(256, bg_alpha, bg_alpha, bg_alpha, 256, bg_alpha, bg_alpha, bg_alpha); do { - uint32_t p0 = source[0]; - uint32_t p1 = source[1]; - uint32_t p2 = source[2]; - uint32_t p3 = source[3]; + uint32_t p0 = colormap[source[0]]; + uint32_t p1 = colormap[source[1]]; + uint32_t p2 = colormap[source[2]]; + uint32_t p3 = colormap[source[3]]; // shade_pal_index: __m128i fg = _mm_set_epi32(palette[p3], palette[p2], palette[p1], palette[p0]); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index c2dbf31c5..d03853c11 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1095,9 +1095,10 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real } if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; for (int i = 0; i <= deltaX; i++) - spot[i] = palColor; + spot[i] = fillColor; } else { @@ -1108,11 +1109,12 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { // vertical line if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int pitch = GetPitch(); do { - *spot = palColor; + *spot = fillColor; spot += pitch; } while (--deltaY != 0); } @@ -1131,11 +1133,12 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real { // diagonal line. if (IsBgra()) { + uint32_t fillColor = GPalette.BaseColors[palColor].d; uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0; int advance = GetPitch() + xDir; do { - *spot = palColor; + *spot = fillColor; spot += advance; } while (--deltaY != 0); } @@ -1299,12 +1302,14 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin if (IsBgra()) { + uint32_t fill_color = GPalette.BaseColors[palcolor]; + uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left; x = right - left; for (y = top; y < bottom; y++) { for (int i = 0; i < x; i++) - dest[i] = palcolor; + dest[i] = fill_color; dest += Pitch; } }