From 47a3e1dd2bab076e12916b96907e08597ff78166 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Mon, 17 Oct 2016 19:25:38 -0400 Subject: [PATCH] Use modified mapper for Chaos World (CH) NOTE: this is a work in progress. The game runs but save ram is broken and the game will not boot if saveram is present. The same problem exists in punes and it is unknown how to resolve this. The game also uses 1 screen mirroring which other 195 mapper games do not, so this might be a different mapper altogether --- .../NES/Boards/MMC3_family/Mapper195_CW.cs | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs new file mode 100644 index 0000000000..60d113fe43 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs @@ -0,0 +1,73 @@ +using System; +// This is a modified 195 board specifically for Chaos World (CH) +// It is a Work in Progress +// Save Ram is broken and the game will not load with save ram written through this mapper +// This is also true on punes +// The game also requires 1 screen mirroring modes that other 195 games dont +// Although the game runs correctly with 195 CHR mapping, other aspects do not work +// More research is needed + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class Mapper195_CW : MMC3Board_Base + { + private int vram_bank_mask_1k; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER195_CW": + break; + default: + return false; + } + + vram_bank_mask_1k = Cart.vram_size / 1 - 1; + + BaseSetup(); + + mmc3.MirrorMask = 3; + return true; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + { + int bank_1k = Get_CHRBank_1K(addr); + + if (bank_1k<=3) + { + return VRAM[(bank_1k << 10) + (addr & 0x3FF)]; + } + else + { + addr = MapCHR(addr); + return VROM[addr + extra_vrom]; + } + } + else + return base.ReadPPU(addr); + } + + public override void WritePPU(int addr, byte value) + { + if (addr < 0x2000) + { + int bank_1k = Get_CHRBank_1K(addr); + + if (bank_1k <= vram_bank_mask_1k) + { + VRAM[(bank_1k << 10) + (addr & 0x3FF)] = value; + } + else + { + // nothing to write to VROM + } + } + else + base.WritePPU(addr, value); + } + } +}