From d64a985d97c2b74a7ae048e65c7e43b6f1580482 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 24 Sep 2011 18:28:07 +0000 Subject: [PATCH] NES - Implement board HVC_UNROM_74HC08 (Mapper 180). Crazy Climber (J) now works. Testing is limited since it uses a crazy climber controller that we don't emulate --- BizHawk.Emulation/BizHawk.Emulation.csproj | 1 + .../Consoles/Nintendo/Docs/compatibility.txt | 2 +- .../Nintendo/NES/Boards/HVC_UNROM_74HC08.cs | 67 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/HVC_UNROM_74HC08.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 702c48972c..ac813c843e 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -94,6 +94,7 @@ Code + Code diff --git a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt index 49e7eeae47..efbad18df9 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt +++ b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt @@ -95,7 +95,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an 159 Bandai {{See 016}} 164 Pirate Junk 165 Pirate Junk -180 Misc (J) Nothing +180 Misc (J) Complete (but we don't implement the crazy climber controller) 182 MMC3Variant Nothing 184 Sunsoft-1 Complete 185 Misc (J) {{See 003}} This one will be an organizational pain as the games need additional data in gamedb diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/HVC_UNROM_74HC08.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/HVC_UNROM_74HC08.cs new file mode 100644 index 0000000000..0391122b8d --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/HVC_UNROM_74HC08.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + class HVC_UNROM_74HC08 : NES.NESBoardBase + { + //Mapper 180 + //Crazy Climber (J) + + 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 "HVC-UNROM+74HC08": + break; + default: + return false; + } + SetMirrorType(Cart.pad_h, Cart.pad_v); + prg_bank_mask_16k = (Cart.prg_size / 16) - 1; + prg_banks_16k[0] = 0; + 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[1] = prg_bank_16k; + } + + public override void WritePRG(int addr, byte value) + { + prg_bank_16k = (byte)(value & 7); + SyncPRG(); + } + + 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]; + } + } +}