From 4cf66cdc9522569de4df2e61f9b2515808e989c4 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Wed, 21 Sep 2011 01:28:50 +0000 Subject: [PATCH] Rename to Mapper 89 and add mapper 93 to this file. Bootgod points both ines mappers to Sunsoft2 with no distinction between the two, and all documented games for these two mappers point to another board type instead. But at least we have the mappers implemented. Next step is to get games pointing to these --- .../Consoles/Nintendo/NES/Boards/Sunsoft2.cs | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Sunsoft2.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Sunsoft2.cs index a2f33ffd70..9d0e233d94 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Sunsoft2.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Sunsoft2.cs @@ -4,7 +4,7 @@ using System.Diagnostics; namespace BizHawk.Emulation.Consoles.Nintendo { - class Sunsoft2 : NES.NESBoardBase + class MAPPER89 : NES.NESBoardBase { int chr; int prg_bank_mask_16k; @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo { switch (Cart.board_type) { - case "SUNSOFT-2": + case "MAPPER89": break; default: return false; @@ -77,4 +77,66 @@ namespace BizHawk.Emulation.Consoles.Nintendo return base.ReadPPU(addr); } } + + class MAPPER93 : NES.NESBoardBase + { + int prg_bank_mask_16k; + byte prg_bank_16k; + ByteBuffer prg_banks_16k = new ByteBuffer(2); + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER93": + break; + default: + return false; + } + SetMirrorType(Cart.pad_h, Cart.pad_v); + prg_bank_mask_16k = (Cart.prg_size / 16) - 1; + prg_banks_16k[1] = 0xFF; + return true; + } + + public override void Dispose() + { + prg_banks_16k.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); + ser.Sync("prg_bank_16k", ref prg_bank_16k); + ser.Sync("prg_banks_16k", ref prg_banks_16k); + } + + void SyncPRG() + { + prg_banks_16k[0] = prg_bank_16k; + } + + public override void WritePRG(int addr, byte value) + { + prg_bank_16k = (byte)((value >> 4) & 15); + SyncPRG(); + + if (value.Bit(0)) + SetMirrorType(EMirrorType.Horizontal); + else + SetMirrorType(EMirrorType.Vertical); + } + + public override byte ReadPRG(int addr) + { + int bank_16k = addr >> 14; + int ofs = addr & ((1 << 14) - 1); + bank_16k = prg_banks_16k[bank_16k]; + bank_16k &= prg_bank_mask_16k; + addr = (bank_16k << 14) | ofs; + return ROM[addr]; + } + } }