From 8a70759e0a2aec24d69a5db8a16322d7f1858a6e Mon Sep 17 00:00:00 2001 From: lachwright Date: Thu, 12 Dec 2019 01:27:41 +0800 Subject: [PATCH 1/3] Add TC_DASHMODE color shader --- src/hardware/hw_md2.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 9d9171cea..61afee0ab 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -729,6 +729,39 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, cur++; image++; blendimage++; } } + else if (skinnum == TC_DASHMODE) + { + while (size--) + { + if (image->s.alpha == 0 && blendimage->s.alpha == 0) + { + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + cur->rgba = image->rgba; + } + else + { + UINT8 ialpha = 255 - blendimage->s.alpha, balpha = blendimage->s.alpha; + RGBA_t icolor = *image, bcolor; + + if (blendimage->s.alpha) + { + bcolor.s.blue = 0; + bcolor.s.red = 255; + bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3; + } + if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic + { + icolor.s.red = image->s.blue; + icolor.s.blue = image->s.red; + } + cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255; + cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255; + cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255; + cur->s.alpha = image->s.alpha; + } + cur++; image++; blendimage++; + } + } else { while (size--) From ea129f701c86f87daa7355e6f031d0633951cdfa Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 11 Dec 2019 22:45:47 -0300 Subject: [PATCH 2/3] Fix Ploadflat closing the game with "Too many flats in level" error message --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3c45509ee..8a927d65a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -672,7 +672,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // INT32 P_AddLevelFlatRuntime(const char *flatname) { - return Ploadflat(0, flatname); + return Ploadflat(levelflats, flatname); } // help function for $$$.sav checking From 7f092b884b7eb0a89a5b86b2a832a925bab22d80 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Thu, 12 Dec 2019 22:32:19 -0300 Subject: [PATCH 3/3] Initialise the variable, obviously --- src/hardware/hw_md2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 61afee0ab..fea7f50bd 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -743,6 +743,8 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT8 ialpha = 255 - blendimage->s.alpha, balpha = blendimage->s.alpha; RGBA_t icolor = *image, bcolor; + memset(&bcolor, 0x00, sizeof(RGBA_t)); + if (blendimage->s.alpha) { bcolor.s.blue = 0;