From 2cb64fafb86231d6e33dfa16e1acf7efbe8dd3de Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 22 Aug 2015 09:53:39 -0400 Subject: [PATCH] Mapper 216 - supported enough for Magic Jewelry 2 to work --- .../BizHawk.Emulation.Cores.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Bonza.cs | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 18e981bfbb..f2fe0b8ea3 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -478,6 +478,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs new file mode 100644 index 0000000000..671c58224b --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs @@ -0,0 +1,64 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Bonza (R) + // Magic Jewelry 2 (Unl) + public class Bonza : NES.NESBoardBase + { + private int _chrReg; + private int _prgReg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER216": + break; + default: + return false; + } + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("chrReg", ref _chrReg); + ser.Sync("prgReg", ref _prgReg); + } + + public override void WritePRG(int addr, byte value) + { + _prgReg = addr & 1; + _chrReg = (addr >> 1) & 7; + } + + public override byte ReadEXP(int addr) + { + if (addr == 0x1000) + { + return 0; + } + + return base.ReadEXP(addr); + } + + public override byte ReadPRG(int addr) + { + return ROM[(_prgReg * 0x8000) + (addr & 0x7FFF)]; + } + + public override byte ReadPPU(int addr) + { + // Magic Jewelry has no VROM and does not write chr regs + if (addr < 0x2000 && VROM != null) + { + return VROM[(_chrReg * 2000) + (addr & 0x1FFF)]; + } + + return base.ReadPPU(addr); + } + } +}