From e513eb7cf7f6cca00a4afce352380cc3fea499ef Mon Sep 17 00:00:00 2001 From: goyuken Date: Mon, 3 Dec 2012 19:05:24 +0000 Subject: [PATCH] nes: implement NROM-368. doesn't implement any of the other variants like CNROM-368. supports both 48k and 64k modes --- BizHawk.Emulation/BizHawk.Emulation.csproj | 1 + .../Consoles/Nintendo/NES/Boards/NROM.cs | 4 ++ .../Consoles/Nintendo/NES/Boards/NROM368.cs | 60 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM368.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 567a5e8a92..4bdd8077e1 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -357,6 +357,7 @@ Code + diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM.cs index f80edb8bde..a11826d2d0 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM.cs @@ -19,6 +19,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo switch (Cart.board_type) { case "MAPPER000": + if (Cart.prg_size <= 32) + break; + else + return false; // NROM-368 case "MAPPER219": //adelikat: a version of 3D-Block tries to use this ROM, but plays fine as NROM and 219 is undocumented by Disch break; diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM368.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM368.cs new file mode 100644 index 0000000000..796bdc5479 --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/NROM368.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + public class NROM368 : NES.NESBoardBase + { + // not even one actual prototype of this pile of shit exists, and + // there are already two incompatible implementations. pathetic. + bool small; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_NROM-368": // ?? + break; + case "MAPPER000": + if (Cart.prg_size == 48 || Cart.prg_size == 64) + break; + else + return false; + default: + return false; + } + AssertPrg(48, 64); + small = Cart.prg_size == 48; + SetMirrorType(Cart.pad_h, Cart.pad_v); + return true; + } + + public override byte ReadPRG(int addr) + { + if (small) + return ROM[addr + 0x4000]; + else + return ROM[addr]; + } + + public override byte ReadWRAM(int addr) + { + if (small) + return ROM[addr + 0x2000]; + else + return ROM[addr + 0xa000]; + } + + public override byte ReadEXP(int addr) + { + if (addr < 0x800) + return NES.DB; + if (small) + return ROM[addr]; + else + return ROM[addr + 0x8000]; + } + } +}