diff --git a/BizHawk.Emulation/Consoles/PC Engine/Compat.txt b/BizHawk.Emulation/Consoles/PC Engine/Compat.txt index 8bbfb46d6c..9681043f30 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/Compat.txt +++ b/BizHawk.Emulation/Consoles/PC Engine/Compat.txt @@ -17,7 +17,6 @@ Coryoon - Recent VDC updates broke scrolling. Generally timing sensiti Cross Wiber - Minor; Raster on wrong line Davis Cup Tennis - Some timing issue, splash screen is too slow Dungeon Explorer - Freeze in 'intro' -Fighting Run - Requires 4-color mode emulation of MWR register Legend of Hero Ton- Slight gfx- check top of screen Lode Runner - Freezes in new game Madoo Granzort - Graphics issues because SGX VPC renderer is not using new frame timing diff --git a/BizHawk.Emulation/Consoles/PC Engine/VDC.Render.cs b/BizHawk.Emulation/Consoles/PC Engine/VDC.Render.cs index 3ee1f6ec89..ede55e87a8 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/VDC.Render.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/VDC.Render.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx public void ExecFrame(bool render) { - for (ScanLine = 0; ScanLine < 263;) + for (ScanLine = 0; ScanLine < 263; ) { latchedDisplayStartLine = DisplayStartLine; ActiveLine = ScanLine - latchedDisplayStartLine; @@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx if ((Registers[DCR] & 1) > 0) { - Log.Note("VDC","FIRING SATB DMA COMPLETION IRQ"); + Log.Note("VDC", "FIRING SATB DMA COMPLETION IRQ"); StatusByte |= StatusVramSatDmaComplete; cpu.IRQ1Assert = true; } @@ -167,6 +167,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx return; Array.Clear(InterSpritePriorityBuffer, 0, FrameWidth); + bool Sprite4ColorMode = Sprite4ColorModeEnabled; for (int i = 0; i < 64; i++) { @@ -185,6 +186,15 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx bool hflip = (flags & 0x0800) != 0; bool vflip = (flags & 0x8000) != 0; + int colorMask = 0xFF; + if (Sprite4ColorMode) + { + if ((SpriteAttributeTable[(i * 4) + 2] & 1) == 0) + colorMask = 0x03; + else + colorMask = 0x0C; + } + if (width == 32) patternNo &= 0x1FE; @@ -259,7 +269,9 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx { for (int xs = x >= 0 ? x : 0; xs < x + 16 && xs >= 0 && xs < FrameWidth; xs++) { - byte pixel = SpriteBuffer[(patternNo * 256) + (yofs * 16) + (xs - x)]; + byte pixel = (byte)(SpriteBuffer[(patternNo * 256) + (yofs * 16) + (xs - x)] & colorMask); + if (colorMask == 0x0C) + pixel >>= 2; if (pixel != 0 && InterSpritePriorityBuffer[xs] == 0) { InterSpritePriorityBuffer[xs] = 1; @@ -274,7 +286,9 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx x += 16; for (int xs = x >= 0 ? x : 0; xs < x + 16 && xs >= 0 && xs < FrameWidth; xs++) { - byte pixel = SpriteBuffer[(patternNo * 256) + (yofs * 16) + (xs - x)]; + byte pixel = (byte)(SpriteBuffer[(patternNo * 256) + (yofs * 16) + (xs - x)] & colorMask); + if (colorMask == 0x0C) + pixel >>= 2; if (pixel != 0 && InterSpritePriorityBuffer[xs] == 0) { InterSpritePriorityBuffer[xs] = 1; @@ -293,7 +307,9 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx patternNo++; for (int xs = x >= 0 ? x : 0; xs < x + 16 && xs >= 0 && xs < FrameWidth; xs++) { - byte pixel = SpriteBuffer[(patternNo * 256) + (yofs * 16) + 15 - (xs - x)]; + byte pixel = (byte)(SpriteBuffer[(patternNo * 256) + (yofs * 16) + 15 - (xs - x)] & colorMask); + if (colorMask == 0x0C) + pixel >>= 2; if (pixel != 0 && InterSpritePriorityBuffer[xs] == 0) { InterSpritePriorityBuffer[xs] = 1; @@ -307,7 +323,9 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx x += 16; for (int xs = x >= 0 ? x : 0; xs < x + 16 && xs >= 0 && xs < FrameWidth; xs++) { - byte pixel = SpriteBuffer[(patternNo * 256) + (yofs * 16) + 15 - (xs - x)]; + byte pixel = (byte)(SpriteBuffer[(patternNo * 256) + (yofs * 16) + 15 - (xs - x)] & colorMask); + if (colorMask == 0x0C) + pixel >>= 2; if (pixel != 0 && InterSpritePriorityBuffer[xs] == 0) { InterSpritePriorityBuffer[xs] = 1; diff --git a/BizHawk.Emulation/Consoles/PC Engine/VDC.cs b/BizHawk.Emulation/Consoles/PC Engine/VDC.cs index 33a1114301..e66c0a6b89 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/VDC.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/VDC.cs @@ -41,6 +41,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx public bool RasterCompareInterruptEnabled { get { return (Registers[CR] & 0x04) != 0; } } public bool SpriteOverflowInterruptEnabled { get { return (Registers[CR] & 0x02) != 0; } } public bool SpriteCollisionInterruptEnabled { get { return (Registers[CR] & 0x01) != 0; } } + public bool Sprite4ColorModeEnabled { get { return (Registers[MWR] & 0x0C) != 0; } } public int BatWidth { get { switch((Registers[MWR] >> 4) & 3) { case 0: return 32; case 1: return 64; default: return 128; } } } public int BatHeight { get { return ((Registers[MWR] & 0x40) == 0) ? 32 : 64; } }