From d3c8d201fbcf04425fd191a6ed69959288191192 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 30 Oct 2016 08:58:12 -0500 Subject: [PATCH] NesHawk - add masking to mapper 212 --- .../Consoles/Nintendo/NES/Boards/Mapper212.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs index 1560412862..93d286a2be 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs @@ -10,6 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public class Mapper212 : NES.NESBoardBase { private int _reg; + private int prg_bank_mask_32k, prg_bank_mask_16k, chr_bank_mask_8k; public override bool Configure(NES.EDetectionOrigin origin) { @@ -23,6 +24,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SetMirrorType(Cart.pad_h, Cart.pad_v); + chr_bank_mask_8k = Cart.chr_size / 8 - 1; + prg_bank_mask_16k = Cart.prg_size / 16 - 1; + prg_bank_mask_32k = Cart.prg_size / 32 - 1; + _reg = 65535; return true; @@ -50,11 +55,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if ((_reg & 0x4000) > 0) { int bank = (_reg >> 1) & 3; + bank &= prg_bank_mask_32k; ret = ROM[(bank * 0x8000) + (addr & 0x7FFF)]; } else { int bank = _reg & 7; + bank &= prg_bank_mask_16k; ret = ROM[(bank * 0x4000) + (addr & 0x3FFF)]; } @@ -71,6 +78,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { int bank = _reg & 7; + bank &= chr_bank_mask_8k; return VROM[(bank * 0x2000) + (addr & 0x1FFF)]; }