From 96e7d851222ae2e6669a82123c04c00af6169ff4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 20 Jul 2012 03:52:14 +0000 Subject: [PATCH] NES - add mapper 61, chr mapping is off somehow --- BizHawk.Emulation/BizHawk.Emulation.csproj | 1 + .../Consoles/Nintendo/NES/Boards/Mapper61.cs | 96 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper61.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 514c7c5c64..f7e4ce4a79 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -174,6 +174,7 @@ + diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper61.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper61.cs new file mode 100644 index 0000000000..c2f8af738e --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper61.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + class Mapper61 : NES.NESBoardBase + { + /* + * Here are Disch's original notes: + ======================== + = Mapper 061 = + ======================== + + Example Game: + -------------------------- + 20-in-1 + + + Registers: + --------------------------- + + $8000-FFFF: A~[.... .... M.LO HHHH] + H = High 4 bits of PRG Reg + L = Low bit of PRG Reg + O = PRG Mode + M = Mirroring (0=Vert, 1=Horz) + + + PRG Setup: + --------------------------- + + PRG Reg is 5 bits -- combination of 'H' and 'L' bits. + + $8000 $A000 $C000 $E000 + +-------------------------------+ + PRG Mode 0: | <$8000> | + +-------------------------------+ + PRG Mode 1: | $8000 | $8000 | + +---------------+---------------+ + */ + + public int prg_page; + public bool prg_mode; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER061": + break; + default: + return false; + } + SetMirrorType(EMirrorType.Vertical); + prg_page = 0; + prg_mode = false; + return true; + } + + public override void SyncState(Serializer ser) + { + ser.Sync("prg_page", ref prg_page); + ser.Sync("prg_mode", ref prg_mode); + base.SyncState(ser); + } + + public override void WritePRG(int addr, byte value) + { + if (addr.Bit(7)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } + + prg_mode = addr.Bit(4); + prg_page = ((addr & 0x0F) << 1) | ((addr & 0x20) >> 4); + } + + public override byte ReadPRG(int addr) + { + if (prg_mode == false) + { + return ROM[((prg_page >> 1) * 0x8000) + addr]; + } + else + { + return ROM[(prg_page * 0x4000) + (addr & 0x03FFF)]; + } + } + } +}