From 33225700ad347138d95930b570afe723b3539bcb Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 17 Sep 2016 12:02:46 -0400 Subject: [PATCH] Failed attempt at supporting Mapper 121 --- Assets/gamedb/gamedb.txt | 1 + .../BizHawk.Emulation.Cores.csproj | 1 + .../NES/Boards/MMC3_family/Mapper121.cs | 102 ++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs diff --git a/Assets/gamedb/gamedb.txt b/Assets/gamedb/gamedb.txt index ed37787e1f..27234dd974 100644 --- a/Assets/gamedb/gamedb.txt +++ b/Assets/gamedb/gamedb.txt @@ -168,6 +168,7 @@ sha1:C282206800426557E7DD66ABF70FEAB6FE9DA1B2 San Guo Zhi (Ch) NES board=MAPPE sha1:E6F080CCF09C62C038D35E3BD503C4E57E716571 B San Guo Zhi (Ch) NES board=MAPPER252;VRAM=2;BATT=true;PAD_H=1 sha1:E2BFF2002F2DD0AA184D5791D008A1350C477AE0 B San Guo Zhi (Ch) NES board=MAPPER252;VRAM=2;BATT=true;PAD_H=1 sha1:B37E6002EF84C172DB413DF4B41451192ADBDC36 Shen Hua Jian Yun III (Ch) NES board=MAPPER253;VRAM=2;BATT=true;PAD_H=1 +sha1:CE1B236ED0EAC133A3DE5411AEF57228220885EF G Super Sonic 5 (1997) (Unl) NES board=MAPPER121 ;;;;;;;;;;;;;;;;;;;----------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;----------------------------------------------------------------------- diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index bc04da0bdf..edd233b3ba 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -674,6 +674,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs new file mode 100644 index 0000000000..5b5ebfa2c0 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs @@ -0,0 +1,102 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Adapted from Nestopia src + public sealed class Mapper121 : MMC3Board_Base + { + private ByteBuffer exRegs = new ByteBuffer(3); + + private readonly byte[] lut = { 0x83, 0x83, 0x42, 0x00 }; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER121": + break; + default: + return false; + } + + BaseSetup(); + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("exRegs", ref exRegs); + } + + public override byte ReadEXP(int addr) + { + if (addr >= 0x1000) + { + return exRegs[2]; + } + else + { + return base.ReadEXP(addr); + } + } + + protected override int Get_PRGBank_8K(int addr) + { + if (addr == 0x4000 && exRegs[0] > 0) + { + return exRegs[0] & prg_mask; + } + + else if (addr == 0x6000 && exRegs[1] > 0) + { + return exRegs[1] & prg_mask; + } + + else + { + return base.Get_PRGBank_8K(addr); + } + } + + public override void WriteEXP(int addr, byte value) + { + if (addr >= 0x1000) // 0x5000-0x5FFF + { + exRegs[2] = lut[value & 0x3]; + } + } + + public override void WritePRG(int addr, byte value) + { + if (addr < 0x2000) + { + if ((addr & 3) == 3) + { + switch (value) + { + case 0x28: exRegs[0] = 0x0C; break; + case 0x26: exRegs[1] = 0x08; break; + case 0xAB: exRegs[1] = 0x07; break; + case 0xEC: exRegs[1] = 0x0D; break; + case 0xEF: exRegs[1] = 0x0D; break; + case 0xFF: exRegs[1] = 0x09; break; + + case 0x20: exRegs[1] = 0x13; break; + case 0x29: exRegs[1] = 0x1B; break; + + default: exRegs[0] = 0x0; exRegs[1] = 0x0; break; + } + } + //else + //{ + // base.WritePRG(addr, value); + //} + } + //else + //{ + // base.WritePRG(addr, value); + //} + } + } +}