From a979721415a6eac1521765ca564460a853865880 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 4 Nov 2016 13:20:29 -0500 Subject: [PATCH] NesHawk - Attempt UNIF_UNL-LH10, something is messed up though, nametable is off --- .../BizHawk.Emulation.Cores.csproj | 1 + .../Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 70810ba034..ee0a4d18ce 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -782,6 +782,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs new file mode 100644 index 0000000000..6532427d7f --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs @@ -0,0 +1,91 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class UNIF_UNL_LH10 : NES.NESBoardBase + { + private ByteBuffer reg = new ByteBuffer(8); + private int cmd; + + private int prg_bank_mask_8; + + public override bool Configure(NES.EDetectionOrigin origin) + { + //configure + switch (Cart.board_type) + { + case "UNIF_UNL-LH10": + NES._isVS = true; + break; + default: + return false; + } + + prg_bank_mask_8 = Cart.prg_size / 8 - 1; + + //SetMirrorType(Cart.pad_h, Cart.pad_v); + SetMirrorType(EMirrorType.Vertical); + return true; + } + + public override void Dispose() + { + reg.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + ser.Sync("reg", ref reg); + ser.Sync("cmd", ref cmd); + base.SyncState(ser); + } + + public override void WritePRG(int addr, byte value) + { + addr += 0x8000; + if (addr < 0xC000 || addr >= 0xE000) + { + switch (addr & 0xE001) + { + case 0x8000: cmd = value & 7; break; + case 0x8001: reg[cmd] = value; break; + } + } + } + + public override byte ReadWRAM(int addr) + { + return ROM[ROM.Length - 0x4000 + addr]; + } + + public override byte ReadPRG(int addr) + { + int bank = 0; + if (addr < 0x2000) + { + bank = reg[6]; + } + else if (addr < 0x4000) + { + bank = reg[7]; + } + else if (addr < 0x6000) + { + bank = 4; + } + else + { + bank = 0xFF; + } + + bank &= prg_bank_mask_8; + return ROM[(bank << 13) + (addr & 0x1FFF)]; + } + + public override byte ReadPPU(int addr) + { + return base.ReadPPU(addr); + } + } +}