From 6a22d1cd5cf43e017f16e545168f4560726affbe Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 3 Sep 2016 16:24:29 -0400 Subject: [PATCH] Implement unif_BMC-ws board --- .../BizHawk.Emulation.Cores.csproj | 1 + .../NES/Boards/UNIF/UNIF_BMC-190in1.cs | 2 +- .../Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs | 81 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index e10b38108f..a684268e3f 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -731,6 +731,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-190in1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-190in1.cs index 81f22b44bb..c5091bfc3f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-190in1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-190in1.cs @@ -3,7 +3,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - public class UNIF_BMC_190in1 : NES.NESBoardBase + public sealed class UNIF_BMC_190in1 : NES.NESBoardBase { private int _reg; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs new file mode 100644 index 0000000000..2a78d8ce9e --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs @@ -0,0 +1,81 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Based on Nitnendulator src + public sealed class UNIF_BMC_WS : NES.NESBoardBase + { + private byte _reg0; + private byte _reg1; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_BMC-WS": + break; + default: + return false; + } + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("reg0", ref _reg0); + ser.Sync("reg1", ref _reg1); + } + + public override void WriteWRAM(int addr, byte value) + { + if ((_reg0 & 0x20) > 0) + { + return; + } + + switch (addr & 1) + { + case 0: + _reg0 = value; + break; + case 1: + _reg1 = value; + break; + } + + if ((_reg0 & 0x10) > 0) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } + } + + public override byte ReadPRG(int addr) + { + if ((_reg0 & 0x08) > 0) + { + return ROM[((_reg0 & 0x07) * 0x4000) + (addr & 0x3FFF)]; + } + else + { + return ROM[(((_reg0 & 0x6) >> 1) * 0x8000) + (addr & 0x7FFF)]; + } + + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + { + return VROM[((_reg1 & 0x07) * 0x2000) + (addr & 0x1FFF)]; + } + + return base.ReadPPU(addr); + } + } +}