From f86e00f925cdd36f213b58743e82bb23cf301f8b Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Tue, 20 Mar 2018 21:17:57 -0400 Subject: [PATCH] PCE: only latch Y-scroll once per scanline after an offset. The latching behaviour is correct, but I'm unsure of what the offset value should be. fixes #771 --- BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs | 9 +++++++-- BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs | 1 + BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs index 0cdd634880..4122f23bc8 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs @@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Cores.PCEngine } } - cpu.Execute(HBlankCycles); + cpu.Execute(24); if (InActiveDisplay) { @@ -92,11 +92,16 @@ namespace BizHawk.Emulation.Cores.PCEngine BackgroundY = Registers[BYR]; latch_bgy = false; } - BackgroundY++; BackgroundY &= 0x01FF; + } + } + cpu.Execute(HBlankCycles - 24); + + if (InActiveDisplay) + { if (render) RenderScanLine(); } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs index eb4050f814..e8fda4374b 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs @@ -323,6 +323,7 @@ namespace BizHawk.Emulation.Cores.PCEngine ser.Sync("ScanLine", ref ScanLine); ser.Sync("BackgroundY", ref BackgroundY); + ser.Sync("latch_bgy", ref latch_bgy); ser.Sync("RCRCounter", ref RCRCounter); ser.Sync("ActiveLine", ref ActiveLine); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs index 8ba32258b5..8c68463029 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs @@ -175,7 +175,7 @@ namespace BizHawk.Emulation.Cores.PCEngine } } - CPU.Execute(VDC1.HBlankCycles); + CPU.Execute(24); if (InActiveDisplay) { @@ -203,10 +203,16 @@ namespace BizHawk.Emulation.Cores.PCEngine VDC2.BackgroundY++; VDC2.BackgroundY &= 0x01FF; } + } + CPU.Execute(VDC1.HBlankCycles - 24); + + if (InActiveDisplay) + { if (render) RenderScanLine(); } + if (ScanLine == VBlankLine && VDC1.VBlankInterruptEnabled) VDC1.StatusByte |= VDC.StatusVerticalBlanking;