From 35ec42073f6942d53919a9c6ed545985e61f8605 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 1 Sep 2012 18:34:31 +0000 Subject: [PATCH] NES - implement address poking on the system bus domain. Anything in the EXP, WRAM, PRG regions is done via the built in cheat system due to being handled by the mappers. This may not be the ideal way to do this but it seems to work well, and I don't know of a more logical way to handle this. --- .../Consoles/Nintendo/NES/Core.cs | 19 +++++++++++++++++++ .../Consoles/Nintendo/NES/NES.cs | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs index be8eaa21cf..2a2c18c4b4 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs @@ -238,6 +238,25 @@ namespace BizHawk.Emulation.Consoles.Nintendo public byte DummyReadMemory(ushort addr) { return 0; } + private void ApplySystemBusPoke(int addr, byte value) + { + if (addr < 0x2000) + { + ram[(addr & 0x7FF)] = value; + } + else if (addr < 0x4000) + { + ppu.WriteReg((addr & 0x07), value); + } + else if (addr < 0x4020) + { + WriteReg(addr, value); + } + else + { + ApplyGameGenie(addr, value, null); //Apply a cheat to the remaining regions since they have no direct access, this may not be the best way to handle this situation + } + } public byte ReadMemory(ushort addr) { diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index 510ea790e5..90feffdd16 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -325,7 +325,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo var RAM = new MemoryDomain("RAM", 0x800, Endian.Little, addr => ram[addr & 0x07FF], (addr, value) => ram[addr & 0x07FF] = value); var SystemBus = new MemoryDomain("System Bus", 0x10000, Endian.Little, - addr => ReadMemory((ushort)addr), (addr, value) => WriteMemory((ushort)addr, value)); + addr => ReadMemory((ushort)addr), (addr, value) => ApplySystemBusPoke(addr, value)); //WriteMemory((ushort)addr, value)); var PPUBus = new MemoryDomain("PPU Bus", 0x4000, Endian.Little, addr => ppu.ppubus_peek(addr), (addr, value) => ppu.ppubus_write(addr, value)); var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, Endian.Little,