diff --git a/src/r_draw_pal.cpp b/src/r_draw_pal.cpp index 33c482934..9d15460af 100644 --- a/src/r_draw_pal.cpp +++ b/src/r_draw_pal.cpp @@ -1183,14 +1183,17 @@ namespace swrenderer dest = thread->dest_for_thread(_dest_y, pitch, dest); pitch *= thread->num_cores; + const PalEntry* pal = GPalette.BaseColors; + int _srcalpha = 32768, _destalpha = 32768; do { - const PalEntry* pal = GPalette.BaseColors; - // *** [SP] this is incomplete, not sure what to do here. - /*int r = clamp((int)pal[_srccolor].r, 0, 255) >> 2; - int g = clamp((int)pal[_srccolor].g, 0, 255) >> 2; - int b = clamp((int)pal[_srccolor].b, 0, 255) >> 2; - *dest = RGB256k.RGB[r][g][b];*/ + int src_r = ((_srccolor << 3) & 0x78) * _srcalpha; + int src_g = ((_srccolor >> 17) & 0x78) * _srcalpha; + int src_b = ((_srccolor >> 7) & 0x78) * _srcalpha; + int r = clamp((src_r + pal[*dest].r * _destalpha)>>18, 0, 255); + int g = clamp((src_g + pal[*dest].g * _destalpha)>>18, 0, 255); + int b = clamp((src_b + pal[*dest].b * _destalpha)>>18, 0, 255); + *dest = RGB256k.RGB[r][g][b]; dest += pitch; } while (--count); diff --git a/src/v_video.cpp b/src/v_video.cpp index 6e333f840..62a587281 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -144,9 +144,7 @@ DWORD Col2RGB8[65][256]; DWORD *Col2RGB8_LessPrecision[65]; DWORD Col2RGB8_Inverse[65][256]; ColorTable32k RGB32k; -#ifndef NO_RGB666 ColorTable256k RGB256k; -#endif } @@ -666,14 +664,12 @@ static void BuildTransTable (const PalEntry *palette) for (g = 0; g < 32; g++) for (b = 0; b < 32; b++) //RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2)); - RGB32k.RGB[r][g][b] = 2; -#ifndef NO_RGB666 + RGB32k.RGB[r][g][b] = 4; // create the RGB666 lookup table for (r = 0; r < 64; r++) for (g = 0; g < 64; g++) for (b = 0; b < 64; b++) RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4)); -#endif int x, y; diff --git a/src/v_video.h b/src/v_video.h index 2079ff64b..57d15869c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -463,14 +463,12 @@ union ColorTable32k extern "C" ColorTable32k RGB32k; // [SP] RGB666 support -#ifndef NO_RGB666 union ColorTable256k { BYTE RGB[64][64][64]; BYTE All[64 *64 *64]; }; extern "C" ColorTable256k RGB256k; -#endif // Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a // special R10B10G10 format for efficient blending computation.