mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Merge branch 'patch-fixes' into 'master'
Patch fixes (Resolves #230) Closes #230 See merge request STJr/SRB2Internal!347
This commit is contained in:
commit
3f1d84a6b3
1 changed files with 22 additions and 11 deletions
21
src/r_data.c
21
src/r_data.c
|
@ -262,6 +262,9 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph
|
||||||
// if there's no pixel in here
|
// if there's no pixel in here
|
||||||
if (!background.rgba)
|
if (!background.rgba)
|
||||||
output.s.alpha = foreground.s.alpha;
|
output.s.alpha = foreground.s.alpha;
|
||||||
|
else
|
||||||
|
output.s.alpha = 0xFF;
|
||||||
|
return output.rgba;
|
||||||
}
|
}
|
||||||
#define clamp(c) max(min(c, 0xFF), 0x00);
|
#define clamp(c) max(min(c, 0xFF), 0x00);
|
||||||
else
|
else
|
||||||
|
@ -310,16 +313,24 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph
|
||||||
|
|
||||||
UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha)
|
UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha)
|
||||||
{
|
{
|
||||||
if ((style == AST_TRANSLUCENT) && (alpha <= (10*255/11))) // Alpha style set to translucent? Is the alpha small enough for translucency?
|
// Alpha style set to translucent?
|
||||||
|
if (style == AST_TRANSLUCENT)
|
||||||
|
{
|
||||||
|
// Is the alpha small enough for translucency?
|
||||||
|
if (alpha <= (10*255/11))
|
||||||
{
|
{
|
||||||
UINT8 *mytransmap;
|
UINT8 *mytransmap;
|
||||||
if (alpha < 255/11) // Is the patch way too translucent? Don't render then.
|
// Is the patch way too translucent? Don't blend then.
|
||||||
|
if (alpha < 255/11)
|
||||||
return background;
|
return background;
|
||||||
// The equation's not exact but it works as intended. I'll call it a day for now.
|
// The equation's not exact but it works as intended. I'll call it a day for now.
|
||||||
mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT);
|
mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT);
|
||||||
if (background != 0xFF)
|
if (background != 0xFF)
|
||||||
return *(mytransmap + (background<<8) + foreground);
|
return *(mytransmap + (background<<8) + foreground);
|
||||||
}
|
}
|
||||||
|
else // just copy the pixel
|
||||||
|
return foreground;
|
||||||
|
}
|
||||||
// just copy the pixel
|
// just copy the pixel
|
||||||
else if (style == AST_COPY)
|
else if (style == AST_COPY)
|
||||||
return foreground;
|
return foreground;
|
||||||
|
@ -375,7 +386,7 @@ static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpa
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
for (; dest < cache + position + count; source++, dest++)
|
for (; dest < cache + position + count; source++, dest++)
|
||||||
if (*dest != 0xFF)
|
if (*source != 0xFF)
|
||||||
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
|
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +395,7 @@ static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpa
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_DrawTransColumnInCache
|
// R_DrawBlendFlippedColumnInCache
|
||||||
// Similar to the one above except that the column is inverted.
|
// Similar to the one above except that the column is inverted.
|
||||||
//
|
//
|
||||||
static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight)
|
static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight)
|
||||||
|
@ -419,7 +430,7 @@ static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
for (; dest < cache + position + count; --source, dest++)
|
for (; dest < cache + position + count; --source, dest++)
|
||||||
if (*dest != 0xFF)
|
if (*source != 0xFF)
|
||||||
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
|
*dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue