From 0960ca8a89cd2ec0637f47a4ad4dec171e640e4a Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Fri, 3 Mar 2017 20:51:36 -0500 Subject: [PATCH] NES PPU clean up --- .../Consoles/Nintendo/NES/PPU.cs | 11 +++++++++++ .../Consoles/Nintendo/NES/PPU.regs.cs | 13 +------------ .../Consoles/Nintendo/NES/PPU.run.cs | 10 ++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs index f195e2f542..716ec6c9b4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs @@ -218,6 +218,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync("Is_even_cycle", ref is_even_cycle); ser.Sync("soam_index", ref soam_index); ser.Sync("install_2006", ref install_2006); + ser.Sync("race_2006", ref race_2006); ser.Sync("ppu_open_bus", ref ppu_open_bus); ser.Sync("double_2007_read", ref double_2007_read); @@ -287,6 +288,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (install_2006==0) { ppur.install_latches(); + + //nes.LogLine("addr wrote vt = {0}, ht = {1}", ppur._vt, ppur._ht); + //normally the address isnt observed by the board till it gets clocked by a read or write. + //but maybe thats just because a ppu read/write shoves it on the address bus + //apparently this shoves it on the address bus, too, or else blargg's mmc3 tests dont pass + //ONLY if the ppu is not rendering + if (ppur.status.sl == 241 || (!reg_2001.show_obj && !reg_2001.show_bg)) + nes.Board.AddressPPU(ppur.get_2007access()); + + race_2006 = true; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs index 1b37a8c124..e2f56e032c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs @@ -479,10 +479,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //VRAM address register (write) void write_2006(byte value) { - if (ppur.status.cycle==256) - { - conflict_2006 = true; - } + if (!vtoggle) { ppur._vt &= 0x07; @@ -502,14 +499,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // ppur.install_latches(); install_2006 = 3; - - //nes.LogLine("addr wrote vt = {0}, ht = {1}", ppur._vt, ppur._ht); - //normally the address isnt observed by the board till it gets clocked by a read or write. - //but maybe thats just because a ppu read/write shoves it on the address bus - //apparently this shoves it on the address bus, too, or else blargg's mmc3 tests dont pass - //ONLY if the ppu is not rendering - if (ppur.status.sl == 241 || (!reg_2001.show_obj && !reg_2001.show_bg)) - nes.Board.AddressPPU(ppur.get_2007access()); } vtoggle ^= true; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index dc80d08892..55c4fe47a4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -39,10 +39,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public int spriteHeight; public byte[] soam = new byte[512]; // in a real nes, this would only be 32, but we wish to allow more then 8 sprites per scanline public bool reg_2001_color_disable_latch; // the value used here is taken - public bool conflict_2006, ppu_was_on; + public bool ppu_was_on; // installing vram address is delayed after second write to 2006, set this up here public int install_2006; + public bool race_2006; struct TempOAM { @@ -134,14 +135,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 7: - + race_2006 = false; runppu(1); + //horizontal scroll clocked at cycle 3 and then //vertical scroll at 256 if (ppu_was_on) { ppur.increment_hsc(); - if (ppur.status.cycle == 256 && !conflict_2006) + if (ppur.status.cycle == 256 && !race_2006) ppur.increment_vs(); } ppu_was_on = false; @@ -734,7 +736,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else runppu(1); - conflict_2006 = false; + race_2006 = false; } // scanline loop ppur.status.sl = 241;