From 92f18928fbe1ce8402b3634d1d94fd4865548448 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 16 Sep 2016 11:28:56 -0400 Subject: [PATCH] Implement Mapper238/UNIF_UNL-603-5052 --- .../BizHawk.Emulation.Cores.csproj | 1 + .../NES/Boards/MMC3_family/Mapper238.cs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index fa25dec28c..db6cb5cb44 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -684,6 +684,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs new file mode 100644 index 0000000000..3a968dcc5e --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs @@ -0,0 +1,60 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Adapted from FCEUX src + public sealed class Mapper238 : MMC3Board_Base + { + private readonly int[] lut = { 0x00, 0x02, 0x02, 0x03 }; + private byte reg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER238": // Nestopia suggests this board is mapper 238, I do not have any ROMs with this ines header info to confirm + case "UNIF_UNL-603-5052": + break; + } + + BaseSetup(); + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("reg", ref reg); + } + + public override byte ReadEXP(int addr) + { + if (addr < 0x20) + { + return base.ReadEXP(addr); + } + + return reg; + } + + public override byte ReadWRAM(int addr) + { + return reg; + } + + public override void WriteEXP(int addr, byte value) + { + if (addr < 0x20) + { + base.WriteEXP(addr, value); + } + + reg = (byte)lut[value & 3]; + } + + public override void WriteWRAM(int addr, byte value) + { + reg = (byte)lut[value & 3]; + } + } +}