From 1e454a46fe775fa575b15e8addd11da2c115130b Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 21 Aug 2015 23:23:33 -0400 Subject: [PATCH] NesHawk - implement mapper 214 --- .../BizHawk.Emulation.Cores.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Mapper214.cs | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper214.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 60d90e4ba5..18e981bfbb 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -548,6 +548,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper214.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper214.cs new file mode 100644 index 0000000000..04552df6a8 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper214.cs @@ -0,0 +1,53 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Super Gun 20-in-1 + // http://wiki.nesdev.com/w/index.php/INES_Mapper_214 + public class Mapper214 : NES.NESBoardBase + { + private int _chrReg, _prgReg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER214": + break; + default: + return false; + } + + SetMirrorType(EMirrorType.Vertical); + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("chrReg", ref _chrReg); + } + + public override void WritePRG(int addr, byte value) + { + _chrReg = addr & 3; + _prgReg = (addr >> 2) & 3; + } + + public override byte ReadPRG(int addr) + { + return ROM[(_prgReg * 0x4000) + (addr & 0x3FFF)]; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + { + return VROM[(_chrReg * 0x2000) + (addr & 0x1FFF)]; + } + + return base.ReadPPU(addr); + } + } +}