Add mode 1 to ColecoVision

This commit is contained in:
alyosha-tas 2018-02-25 15:31:03 -05:00
parent 50fdeb59e1
commit 82d8060fc8
1 changed files with 38 additions and 4 deletions

View File

@ -170,9 +170,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
else if (Mode2Bit) TmsMode = 2;
else if (Mode3Bit) TmsMode = 3;
else TmsMode = 0;
if (TmsMode == 1)
throw new Exception("TMS video mode 1! please tell vecna which game uses this!");
}
private void RenderScanline(int scanLine)
@ -195,7 +192,11 @@ namespace BizHawk.Emulation.Cores.ColecoVision
RenderBackgroundM3(scanLine);
RenderTmsSprites(scanLine);
}
// This may seem silly but if I ever implement mode 1, sprites are not rendered in that.
else if (TmsMode == 1)
{
RenderBackgroundM1(scanLine);
// no sprites (text mode)
}
}
private void RenderBackgroundM0(int scanLine)
@ -233,6 +234,39 @@ namespace BizHawk.Emulation.Cores.ColecoVision
}
}
private void RenderBackgroundM1(int scanLine)
{
if (DisplayOn == false)
{
Array.Clear(FrameBuffer, scanLine * 256, 256);
return;
}
int yc = scanLine / 8;
int yofs = scanLine % 8;
int FrameBufferOffset = scanLine * 256;
int PatternNameOffset = TmsPatternNameTableBase + (yc * 40);
int ScreenBGColor = PaletteTMS9918[Registers[7] & 0x0F];
for (int xc = 0; xc < 40; xc++)
{
int pn = VRAM[PatternNameOffset++];
int pv = VRAM[PatternGeneratorBase + (pn * 8) + yofs];
int colorEntry = Registers[7];
int fgIndex = (colorEntry >> 4) & 0x0F;
int bgIndex = colorEntry & 0x0F;
int fgColor = fgIndex == 0 ? ScreenBGColor : PaletteTMS9918[fgIndex];
int bgColor = bgIndex == 0 ? ScreenBGColor : PaletteTMS9918[bgIndex];
FrameBuffer[FrameBufferOffset++] = ((pv & 0x80) > 0) ? fgColor : bgColor;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x40) > 0) ? fgColor : bgColor;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x20) > 0) ? fgColor : bgColor;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x10) > 0) ? fgColor : bgColor;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x08) > 0) ? fgColor : bgColor;
FrameBuffer[FrameBufferOffset++] = ((pv & 0x04) > 0) ? fgColor : bgColor;
}
}
void RenderBackgroundM2(int scanLine)
{
if (DisplayOn == false)