SMS: improve rendering accuracy of left-column blanking. I have to say I never thought that would be a thing that needed improved rendering. Also fix issue with when Sprite Overflow fires.

This commit is contained in:
beirich 2014-03-18 00:50:08 +00:00
parent cbc4d925be
commit 3b66e61c82
2 changed files with 72 additions and 71 deletions

View File

@ -133,15 +133,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
int SpritesDrawnThisScanline = 0;
for (int i = 0; i < 64; i++)
{
if (SpritesDrawnThisScanline >= 8)
{
collisionHappens = false; // technically the VDP stops processing sprite past this so we would never set the collision bit for sprites past this
if (overflowHappens)
StatusByte |= 0x40; // Set Overflow bit
if (SpriteLimit)
renderHappens = false; // should be able to break/return, but to ensure this has no effect on sync we keep processing and disable rendering
}
int x = VRAM[SpriteBase + 0x80 + (i * 2)];
if (ShiftSpritesLeft8Pixels)
x -= 8;
@ -155,6 +146,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (y + SpriteHeight <= ScanLine || y > ScanLine)
continue;
if (SpritesDrawnThisScanline >= 8)
{
collisionHappens = false; // technically the VDP stops processing sprite past this so we would never set the collision bit for sprites past this
if (overflowHappens)
StatusByte |= 0x40; // Set Overflow bit
if (SpriteLimit)
renderHappens = false; // should be able to break/return, but to ensure this has no effect on sync we keep processing and disable rendering
}
int tileNo = VRAM[SpriteBase + 0x80 + (i * 2) + 1];
if (EnableLargeSprites)
tileNo &= 0xFE;
@ -210,15 +210,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
int SpritesDrawnThisScanline = 0;
for (int i = 0; i < 64; i++)
{
if (SpritesDrawnThisScanline >= 8)
{
collisionHappens = false; // technically the VDP stops processing sprite past this so we would never set the collision bit for sprites past this
if (overflowHappens)
StatusByte |= 0x40; // Set Overflow bit
if (SpriteLimit)
renderHappens = false; // should be able to break/return, but to ensure this has no effect on sync we keep processing and disable rendering
}
int x = VRAM[SpriteBase + 0x80 + (i * 2)];
if (ShiftSpritesLeft8Pixels)
x -= 8;
@ -232,6 +223,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (y + (SpriteHeight * 2) <= ScanLine || y > ScanLine)
continue;
if (SpritesDrawnThisScanline >= 8)
{
collisionHappens = false; // technically the VDP stops processing sprite past this so we would never set the collision bit for sprites past this
if (overflowHappens)
StatusByte |= 0x40; // Set Overflow bit
if (SpriteLimit)
renderHappens = false; // should be able to break/return, but to ensure this has no effect on sync we keep processing and disable rendering
}
int tileNo = VRAM[SpriteBase + 0x80 + (i * 2) + 1];
if (EnableLargeSprites)
tileNo &= 0xFE;
@ -260,23 +260,23 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
}
}
// Performs render buffer blanking. This includes the left-column blanking as well as Game Gear blanking if requested.
// Should be called at the end of the frame.
internal void RenderBlankingRegions()
// Renders left-blanking. Should be done per scanline, not per-frame.
internal void RenderLineBlanking(bool render)
{
int blankingColor = Palette[BackdropColor];
if (!LeftBlanking || ScanLine >= FrameHeight || !render)
return;
if (LeftBlanking)
{
for (int y = 0; y < FrameHeight; y++)
{
int ofs = ScanLine * 256;
for (int x = 0; x < 8; x++)
FrameBuffer[(y * 256) + x] = blankingColor;
}
FrameBuffer[ofs++] = Palette[BackdropColor];
}
if (mode == VdpMode.GameGear)
// Handles GG clipping or highlighting
internal void ProcessGGScreen()
{
if (mode != VdpMode.GameGear)
return;
if (Sms.Settings.ShowClippedRegions == false)
{
int yStart = (FrameHeight - 144) / 2;
@ -333,5 +333,4 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
}
}
}
}
}

View File

@ -364,7 +364,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
Cpu.ExecuteCycles(IPeriod);
if (ScanLine == scanlinesPerFrame - 1)
RenderBlankingRegions();
ProcessGGScreen();
}
}
@ -380,6 +380,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
RenderSpritesCurrentLineDoubleSize(Sms.Settings.DispOBJ & render);
else
RenderSpritesCurrentLine(Sms.Settings.DispOBJ & render);
RenderLineBlanking(render);
}
else if (TmsMode == 2)
{