From bfae7804f2c1eb53e840613911a2bb8d10c9117a Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Mon, 28 Mar 2011 16:43:15 +0000 Subject: [PATCH] NES - implement freeze system on PPU bus --- BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs | 3 +++ BizHawk.Emulation/Consoles/Nintendo/NES/PPU.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index a9bcf14380..af590a2b7b 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -259,6 +259,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo RAM.GetFreeze = addr => sysbus_freeze[addr & 0x07FF]; RAM.SetFreeze = (addr, value) => sysbus_freeze[addr & 0x07FF] = value; + PPUBus.GetFreeze = addr => ppu.ppubus_freeze[addr]; + PPUBus.SetFreeze = (addr, value) => ppu.ppubus_freeze[addr] = value; + //demo a game genie code GetWatch(NESWatch.EDomain.Sysbus, 0xB424).SetGameGenie(-1, 0x10); GetWatch(NESWatch.EDomain.Sysbus, 0xB424).RemoveGameGenie(); diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/PPU.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/PPU.cs index 077cc3db5e..9a48ee98f2 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/PPU.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/PPU.cs @@ -13,7 +13,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo { public partial class PPU { - //when the ppu issues a write it goes through here and into the game board + public MemoryDomain.FreezeData[] ppubus_freeze = new MemoryDomain.FreezeData[16384]; + + //when the ppu issues a write it goes through here and into the game board public void ppubus_write(int addr, byte value) { nes.board.WritePPU(addr, value); @@ -22,7 +24,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo //when the ppu issues a read it goes through here and into the game board public byte ppubus_read(int addr) { - return nes.board.ReadPPU(addr); + //apply freeze + if (ppubus_freeze[addr].IsFrozen) + return ppubus_freeze[addr].value; + else + return nes.board.ReadPPU(addr); } //debug tools peek into the ppu through this