From 4723ec8acc1fb08a872e24a563a2282f76fcdfac Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 23 Aug 2015 22:36:15 -0400 Subject: [PATCH] NesHawk - MILLIONS OF MOAR GAMEZ!!! --- .../BizHawk.Emulation.Cores.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Mapper213.cs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index e85ce537b2..336bb0e95b 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -551,6 +551,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs new file mode 100644 index 0000000000..4315b308f1 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs @@ -0,0 +1,60 @@ +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // 9999999-in-1 [p2] + // http://wiki.nesdev.com/w/index.php/INES_Mapper_213 + public class Mapper213 : NES.NESBoardBase + { + private int _reg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER213": + break; + default: + return false; + } + + SetMirrorType(Cart.pad_h, Cart.pad_v); + + _reg = 65535; + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("_reg", ref _reg); + } + + public override void WritePRG(int addr, byte value) + { + addr += 0x8000; + + _reg = addr; + SetMirrorType(addr.Bit(3) ? EMirrorType.Vertical : EMirrorType.Horizontal); + } + + public override byte ReadPRG(int addr) + { + int bank = (_reg >> 1) & 3; + return ROM[(bank * 0x8000) + (addr & 0x7FFF)]; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + { + int bank = (_reg >> 3) & 7; + return VROM[(bank * 0x2000) + (addr & 0x1FFF)]; + } + + return base.ReadPPU(addr); + } + } +}