From f82195bc494eec48ebb05620e55ca6640ab4bc02 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 14 Oct 2016 12:10:11 +0200 Subject: [PATCH] Switch to true color for translated sprites --- .../fixedfunction/drawcolumncodegen.cpp | 23 +++++++++++-------- .../fixedfunction/drawcolumncodegen.h | 3 ++- src/r_draw.cpp | 5 +++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 721c85dd85..df35fd53c8 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -187,14 +187,14 @@ SSAVec4i DrawColumnCodegen::ProcessPixel(SSAInt sample_index, SSAVec4i bgcolor, case DrawColumnVariant::DrawRevSubClamp: return blend_revsub(Shade(Sample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawTranslated: - return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); + return blend_copy(Shade(TranslateSample(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(Shade(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: @@ -233,14 +233,14 @@ SSAVec4i DrawColumnCodegen::ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolo case DrawColumnVariant::DrawRevSubClamp: return blend_revsub(ShadePal(ColormapSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawTranslated: - return blend_copy(ShadePal(TranslateSample(sample_index), isSimpleShade)); + return blend_copy(ShadePal(TranslateSamplePal(sample_index), isSimpleShade)); case DrawColumnVariant::DrawTlatedAdd: case DrawColumnVariant::DrawAddClampTranslated: - return blend_add(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_add(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawSubClampTranslated: - return blend_sub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_sub(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::DrawRevSubClampTranslated: - return blend_revsub(ShadePal(TranslateSample(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); + return blend_revsub(ShadePal(TranslateSamplePal(sample_index), isSimpleShade), bgcolor, srcalpha, destalpha); case DrawColumnVariant::Fill: return blend_copy(color); case DrawColumnVariant::FillAdd: @@ -267,7 +267,12 @@ SSAInt DrawColumnCodegen::ColormapSample(SSAInt sample_index) return colormap[source[sample_index].load(true).zext_int()].load(true).zext_int(); } -SSAInt DrawColumnCodegen::TranslateSample(SSAInt sample_index) +SSAVec4i DrawColumnCodegen::TranslateSample(SSAInt sample_index) +{ + return translation[source[sample_index].load(true).zext_int() * 4].load_vec4ub(true); +} + +SSAInt DrawColumnCodegen::TranslateSamplePal(SSAInt sample_index) { return translation[source[sample_index].load(true).zext_int()].load(true).zext_int(); } diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.h b/src/r_compiler/fixedfunction/drawcolumncodegen.h index ffba50a15a..5f2ad737de 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.h +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.h @@ -42,7 +42,8 @@ private: SSAVec4i ProcessPixelPal(SSAInt sample_index, SSAVec4i bgcolor, DrawColumnVariant variant, bool isSimpleShade); SSAVec4i Sample(SSAInt frac); SSAInt ColormapSample(SSAInt frac); - SSAInt TranslateSample(SSAInt frac); + SSAVec4i TranslateSample(SSAInt frac); + SSAInt TranslateSamplePal(SSAInt frac); SSAVec4i Shade(SSAVec4i fgcolor, bool isSimpleShade); SSAVec4i ShadePal(SSAInt palIndex, bool isSimpleShade); bool IsPaletteInput(DrawColumnVariant variant); diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 11c7020b4b..03515c8a11 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2695,7 +2695,10 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, FRemapTable *table = TranslationToTable(translation); if (table != NULL && !table->Inactive) { - dc_translation = table->Remap; + if (r_swtruecolor) + dc_translation = (BYTE*)table->Palette; + else + dc_translation = table->Remap; } } basecolormapsave = basecolormap;