SMS: fix backdrop colors

This commit is contained in:
alyosha-tas 2021-11-18 08:54:13 -05:00
parent 9448e56f0a
commit c636c01424
2 changed files with 11 additions and 7 deletions
src/BizHawk.Emulation.Cores/Consoles/Sega/SMS

View File

@ -309,28 +309,25 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
OverscanFrameBuffer = new int[OverscanFrameHeight * OverscanFrameWidth];
}
// TODO: overscan color can change, this should be calculated per scanline, not done in bulk at the end
int overscan_color = Palette[BackdropColor];
// Top overscan
for (int y=0; y<overscanTop; y++)
for (int x = 0; x < OverscanFrameWidth; x++)
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = overscan_color;
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = Backdrop_SL[0];
// Bottom overscan
for (int y = overscanTop + 192; y < OverscanFrameHeight; y++)
for (int x = 0; x < OverscanFrameWidth; x++)
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = overscan_color;
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = Backdrop_SL[FrameHeight-1];
// Left overscan
for (int y = overscanTop; y < overscanTop + 192; y++)
for (int x = 0; x < overscanLeft; x++)
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = overscan_color;
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = Backdrop_SL[y - overscanTop];
// Right overscan
for (int y = overscanTop; y < overscanTop + 192; y++)
for (int x = overscanLeft + 256; x < OverscanFrameWidth; x++)
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = overscan_color;
OverscanFrameBuffer[(y * OverscanFrameWidth) + x] = Backdrop_SL[y - overscanTop];
// Active display area
for (int y = 0; y < 192; y++)

View File

@ -47,6 +47,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public int[] FrameBuffer = new int[256 * 192];
public int[] GameGearFrameBuffer = new int[160 * 144];
public int[] OverscanFrameBuffer = null;
public int[] Backdrop_SL = new int[256];
public bool Mode1Bit => (Registers[1] & 16) > 0;
public bool Mode2Bit => (Registers[0] & 2) > 0;
@ -382,6 +383,11 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
internal void RenderCurrentScanline(bool render)
{
if (ScanLine < FrameHeight)
{
Backdrop_SL[ScanLine] = Palette[(byte)(16 + (Registers[7] & 15))];
}
// only mode 4 supports frameskip. deal with it
if (TmsMode == 4)
{
@ -423,6 +429,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
ser.Sync(nameof(CRAM), ref CRAM, false);
ser.Sync(nameof(VRAM), ref VRAM, false);
ser.Sync(nameof(HCounter), ref HCounter);
ser.Sync(nameof(Backdrop_SL), ref Backdrop_SL, false);
ser.EndSection();
if (ser.IsReader)