NES PPU clean up

This commit is contained in:
alyosha-tas 2017-03-03 20:51:36 -05:00 committed by GitHub
parent ca2fa6c95e
commit 0960ca8a89
3 changed files with 18 additions and 16 deletions

View File

@ -218,6 +218,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.Sync("Is_even_cycle", ref is_even_cycle); ser.Sync("Is_even_cycle", ref is_even_cycle);
ser.Sync("soam_index", ref soam_index); ser.Sync("soam_index", ref soam_index);
ser.Sync("install_2006", ref install_2006); 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("ppu_open_bus", ref ppu_open_bus);
ser.Sync("double_2007_read", ref double_2007_read); ser.Sync("double_2007_read", ref double_2007_read);
@ -287,6 +288,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (install_2006==0) if (install_2006==0)
{ {
ppur.install_latches(); 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;
} }
} }

View File

@ -479,10 +479,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//VRAM address register (write) //VRAM address register (write)
void write_2006(byte value) void write_2006(byte value)
{ {
if (ppur.status.cycle==256)
{
conflict_2006 = true;
}
if (!vtoggle) if (!vtoggle)
{ {
ppur._vt &= 0x07; ppur._vt &= 0x07;
@ -502,14 +499,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// ppur.install_latches(); // ppur.install_latches();
install_2006 = 3; 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; vtoggle ^= true;

View File

@ -39,10 +39,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public int spriteHeight; 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 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 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 // installing vram address is delayed after second write to 2006, set this up here
public int install_2006; public int install_2006;
public bool race_2006;
struct TempOAM struct TempOAM
{ {
@ -134,14 +135,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
break; break;
case 7: case 7:
race_2006 = false;
runppu(1); runppu(1);
//horizontal scroll clocked at cycle 3 and then //horizontal scroll clocked at cycle 3 and then
//vertical scroll at 256 //vertical scroll at 256
if (ppu_was_on) if (ppu_was_on)
{ {
ppur.increment_hsc(); ppur.increment_hsc();
if (ppur.status.cycle == 256 && !conflict_2006) if (ppur.status.cycle == 256 && !race_2006)
ppur.increment_vs(); ppur.increment_vs();
} }
ppu_was_on = false; ppu_was_on = false;
@ -734,7 +736,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
else else
runppu(1); runppu(1);
conflict_2006 = false; race_2006 = false;
} // scanline loop } // scanline loop
ppur.status.sl = 241; ppur.status.sl = 241;