From 48766c2b88af8115cfe67757a39a1c2b0fed4246 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 28 Oct 2016 18:11:34 -0500 Subject: [PATCH] NesHawk - support mapper 170 --- .../BizHawk.Emulation.Cores.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Mapper170.cs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 92a232e83c..2661109f08 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -625,6 +625,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs new file mode 100644 index 0000000000..37f90c2a0f --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs @@ -0,0 +1,60 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class Mapper170 : NES.NESBoardBase + { + private byte reg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER170": + break; + default: + return false; + } + + return true; + } + + public override void SyncState(Serializer ser) + { + ser.Sync("reg", ref reg); + base.SyncState(ser); + } + + public override byte ReadPRG(int addr) + { + if (addr < 0x4000) + { + return base.ReadPRG(addr); + } + + int last16kBank = ROM.Length - 0x4000; + return ROM[last16kBank + (addr & 0x3FFF)]; + } + + public override void WriteWRAM(int addr, byte value) + { + if (addr == 0x502 || addr == 0x1000) + { + reg = (byte)(value << 1 & 0x80); + } + + + base.WriteWRAM(addr, value); + } + + public override byte ReadWRAM(int addr) + { + if (addr == 0x1001 || addr == 0x1777) + { + return (byte)(reg | NES.DB & 0x7F); + } + + return base.ReadWRAM(addr); + } + } +}