Implement Dithering for video software

This commit is contained in:
Scott Mansell 2016-02-15 14:27:54 +13:00
parent 3ff56aa192
commit 51dc779b7c
1 changed files with 15 additions and 0 deletions

View File

@ -391,6 +391,20 @@ namespace EfbInterface
}
}
static void Dither(u16 x, u16 y, u8 *color)
{
// No blending for RGB8 mode
if (!bpmem.blendmode.dither || bpmem.zcontrol.pixel_format != PEControl::PixelFormat::RGBA6_Z24)
return;
// Flipper uses a standard 2x2 Bayer Matrix for 6 bit dithering
static const u8 dither[2][2] = {{0, 2}, {3, 1}};
// Only the color channels are dithered?
for (int i = BLU_C; i <= RED_C; i++)
color[i] = ((color[i] - (color[i] >> 6)) + dither[y & 1][x & 1]) & 0xfc;
}
void BlendTev(u16 x, u16 y, u8 *color)
{
u32 dstClr;
@ -421,6 +435,7 @@ namespace EfbInterface
if (bpmem.blendmode.colorupdate)
{
Dither(x, y, dstClrPtr);
if (bpmem.blendmode.alphaupdate)
SetPixelAlphaColor(offset, dstClrPtr);
else