From 17560355945f84843096f24ff18a4cc85a7f2e8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Mar 2018 00:54:03 +0100 Subject: [PATCH] - fixes in DDS decoder. - let FPatchTexture use the inline color getters. --- src/textures/ddstexture.cpp | 13 ++++++++++--- src/textures/patchtexture.cpp | 14 ++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index f1cfe606e..358979132 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -474,7 +474,8 @@ void FDDSTexture::ReadRGB (FileReader &lump, uint8_t *buffer, int pixelmode) uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR; uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR; uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR; - *pixelp = RGBToPalette(pixelmode == PIX_Palette, r >> 24, g >> 24, b >> 24); + uint32_t a = (c & AMask) << AShiftL; a |= a >> AShiftR; + *pixelp = RGBToPalette(pixelmode == PIX_Palette, r >> 24, g >> 24, b >> 24, a >> 24); } else { @@ -658,11 +659,17 @@ void FDDSTexture::DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t { break; } - if (pixelmode != PIX_ARGB) + if (pixelmode == PIX_Palette) { buffer[oy + y + (ox + x) * Height] = ((yalphaslice >> (x*4)) & 15) < 8 ? (bMasked = true, 0) : palcol[(yslice >> (x + x)) & 3]; } + else if (pixelmode == PIX_Alphatex) + { + int alphaval = ((yalphaslice >> (x * 4)) & 15); + int palval = palcol[(yslice >> (x + x)) & 3]; + buffer[oy + y + (ox + x) * Height] = palval * alphaval / 15; + } else { uint8_t * tcp = &buffer[(ox + x)*4 + (oy + y) * Width*4]; @@ -670,7 +677,7 @@ void FDDSTexture::DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t tcp[0] = color[c].r; tcp[1] = color[c].g; tcp[2] = color[c].b; - tcp[3] = color[c].a; + tcp[3] = ((yalphaslice >> (x * 4)) & 15) * 0x11; } } } diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index f6d396444..153d7c6f1 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -119,7 +119,7 @@ static bool CheckIfPatch(FileReader & file, bool &isalpha) { // only check this if the texture passed validation. // Here is a good point because we already have a valid buffer of the lump's data. - isalpha = checkPatchForAlpha(data, file.GetLength()); + isalpha = checkPatchForAlpha(data, (uint32_t)file.GetLength()); } return !gapAtStart; } @@ -183,20 +183,14 @@ uint8_t *FPatchTexture::MakeTexture (FRenderStyle style) maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3); - if (style.Flags & STYLEF_RedIsAlpha) - { - remap = translationtables[TRANSLATION_Standard][isalpha? STD_Gray : STD_Grayscale]->Remap; - } - else if (bNoRemap0) + remap = GetRemap(style, isalpha); + // Special case for skies + if (bNoRemap0 && remap == GPalette.Remap) { memcpy(remaptable, GPalette.Remap, 256); remaptable[0] = 0; remap = remaptable; } - else - { - remap = isalpha? GrayMap : GPalette.Remap; - } if (badflag) {