From 933761c5c732fece8ddbe838935f41a914870993 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 25 Oct 2016 17:18:58 -0500 Subject: [PATCH] NESHawk - Mapper 204 - mask registers --- .../Consoles/Nintendo/NES/Boards/Mapper204.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper204.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper204.cs index 44c348d0b8..0998cac269 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper204.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper204.cs @@ -9,6 +9,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { private int _reg1, _reg2; + private int prg_mask_16k, chr_mask_8k; + public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) @@ -19,6 +21,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return false; } + prg_mask_16k = Cart.prg_size / 16 - 1; + chr_mask_8k = Cart.chr_size / 8 - 1; + return true; } @@ -42,17 +47,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x4000) { - return ROM[(_reg2 * 0x4000) + (addr & 0x3FFF)]; + return ROM[((_reg2 & prg_mask_16k) * 0x4000) + (addr & 0x3FFF)]; } - return ROM[(_reg1 * 0x4000) + (addr & 0x3FFF)]; + return ROM[((_reg1 & prg_mask_16k) * 0x4000) + (addr & 0x3FFF)]; } public override byte ReadPPU(int addr) { if (addr < 0x2000) { - return VROM[(_reg2 * 0x2000) + (addr & 0x1FFF)]; + return VROM[((_reg2 & chr_mask_8k) * 0x2000) + (addr & 0x1FFF)]; } return base.ReadPPU(addr);