From a1cdd5dbfda6572c4f87f08855904959a072b416 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 5 Apr 2012 18:55:34 +0000 Subject: [PATCH] nes-fix mapper 242 --- .../Consoles/Nintendo/NES/Boards/Mapper242.cs | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper242.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper242.cs index e529095224..aac792257b 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper242.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper242.cs @@ -4,9 +4,7 @@ using System.Diagnostics; namespace BizHawk.Emulation.Consoles.Nintendo { - //(doesnt work in neshawk; works in fceux) - - /* + /* PCB Class: Unknown iNES Mapper 242 PRG-ROM: 32KB @@ -15,18 +13,18 @@ CHR-ROM: 16KB CHR-RAM: None Battery is not available mirroring - both - * - * Games: - * Wai Xing Zhan Shi (Ch) - */ + * + * Games: + * Wai Xing Zhan Shi (Ch) + */ - class Mapper242 : NES.NESBoardBase - { - int prg, mirror; - - public override bool Configure(NES.EDetectionOrigin origin) - { - //configure + class Mapper242 : NES.NESBoardBase + { + int prg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + //configure switch (Cart.board_type) { case "MAPPER242": @@ -34,32 +32,31 @@ mirroring - both default: return false; } - return true; - } + SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); + return true; + } - public override byte ReadPRG(int addr) - { - return ROM[addr + (prg * 0x8000)]; - } + public override byte ReadPRG(int addr) + { + return ROM[addr + (prg * 0x8000)]; + } - public override void WritePRG(int addr, byte value) - { - mirror = (value & 0x03); + public override void WritePRG(int addr, byte value) + { prg = (addr >> 3) & 15; - switch (mirror) - { - case 0: SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); break; - case 1: SetMirrorType(NES.NESBoardBase.EMirrorType.Horizontal); break; - case 2: SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenA); break; - case 3: SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenB); break; - } - } + //fceux had different logic here for the mirroring, but that didnt match with experiments on dragon quest 8 nor disch's docs + //i changed it at the same time + bool mirror = addr.Bit(1); + if (mirror) + SetMirrorType(NES.NESBoardBase.EMirrorType.Horizontal); + else + SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); + } public override void SyncState(Serializer ser) - { + { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("mirror", ref mirror); - } - } + ser.Sync("prg", ref prg); + } + } }