mirror of https://github.com/snes9xgit/snes9x.git
win32: clear extra line when doubling for blargg so that mixing does not
access random bytes (fixes #332)
This commit is contained in:
parent
094cb425b8
commit
6c4954c5be
|
@ -2930,22 +2930,25 @@ void RenderBlarggNTSC( SSurface Src, SSurface Dst, RECT *rect)
|
||||||
|
|
||||||
//Blargg's filter produces half-height output, so we have to double the height again (unless we have double height hi-res)
|
//Blargg's filter produces half-height output, so we have to double the height again (unless we have double height hi-res)
|
||||||
if(Src.Height <= SNES_HEIGHT_EXTENDED)
|
if(Src.Height <= SNES_HEIGHT_EXTENDED)
|
||||||
for (int y = rect->bottom / 2; --y >= 0; )
|
{
|
||||||
|
int last_blargg_line = rect->bottom / 2;
|
||||||
|
memset(Dst.Surface + last_blargg_line * Dst.Pitch, 0, Dst.Pitch);
|
||||||
|
for(int y = last_blargg_line; --y >= 0; )
|
||||||
{
|
{
|
||||||
unsigned char const* in = Dst.Surface + y * Dst.Pitch;
|
unsigned char const* in = Dst.Surface + y * Dst.Pitch;
|
||||||
unsigned char* out = Dst.Surface + y * 2 * Dst.Pitch;
|
unsigned char* out = Dst.Surface + y * 2 * Dst.Pitch;
|
||||||
for (int n = rect->right; n; --n )
|
for(int n = rect->right; n; --n)
|
||||||
{
|
{
|
||||||
unsigned prev = *(unsigned short*) in;
|
unsigned prev = *(unsigned short*)in;
|
||||||
unsigned next = *(unsigned short*) (in + Dst.Pitch);
|
unsigned next = *(unsigned short*)(in + Dst.Pitch);
|
||||||
/* mix 16-bit rgb without losing low bits */
|
/* mix 16-bit rgb without losing low bits */
|
||||||
unsigned mixed = prev + next + ((prev ^ next) & 0x0821);
|
unsigned mixed = prev + next + ((prev ^ next) & 0x0821);
|
||||||
/* darken by 12% */
|
/* darken by 12% */
|
||||||
*(unsigned short*) out = prev;
|
*(unsigned short*)out = prev;
|
||||||
*(unsigned short*) (out + Dst.Pitch) = (mixed >> 1) - (mixed >> 4 & 0x18E3);
|
*(unsigned short*)(out + Dst.Pitch) = (mixed >> 1) - (mixed >> 4 & 0x18E3);
|
||||||
in += 2;
|
in += 2;
|
||||||
out += 2;
|
out += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue