diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs index c86bd515c1..3568bfce3e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs @@ -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)