From e1fa9c0a4a18695ade96963cefd8cf7b46212dc4 Mon Sep 17 00:00:00 2001 From: goyuken Date: Sat, 13 Oct 2012 17:20:22 +0000 Subject: [PATCH] add mapper038: "Crime Busters (Unl).nes" boots but the game requires zapper... --- BizHawk.Emulation/BizHawk.Emulation.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Mapper038.cs | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper038.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 29d90e51e9..a9346c0cc4 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -152,6 +152,7 @@ + diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper038.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper038.cs new file mode 100644 index 0000000000..e4390de870 --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper038.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + // Crime Busters (Brazil) (Unl) + public class Mapper038 : NES.NESBoardBase + { + //configuraton + int prg_mask, chr_mask; + //state + int prg, chr; + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER038": + case "UNL-PCI556": + break; + default: + return false; + } + AssertPrg(128); + AssertChr(32); + AssertVram(0); + AssertWram(0); + prg_mask = Cart.prg_size / 32 - 1; + chr_mask = Cart.chr_size / 8 - 1; + SetMirrorType(Cart.pad_h, Cart.pad_v); + return true; + } + + public override byte ReadPRG(int addr) + { + return ROM[addr + (prg << 15)]; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + { + return VROM[addr + (chr << 13)]; + } + else return base.ReadPPU(addr); + } + + void writereg(byte value) + { + prg = value & 3 & prg_mask; + chr = (value >> 2) & 3 & chr_mask; + } + + // the standard way to access this register is at 7000:7fff, but due to + // hardware design, f000:ffff also works + public override void WritePRG(int addr, byte value) + { + //if ((addr & 0x7000) == 0x7000) + // writereg(value); + } + + public override void WriteWRAM(int addr, byte value) + { + if ((addr & 0x1000) == 0x1000) + writereg(value); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("chr", ref chr); + ser.Sync("prg", ref prg); + } + } +}