diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index db6cb5cb44..1223bcc205 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -673,6 +673,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs new file mode 100644 index 0000000000..6894140673 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs @@ -0,0 +1,84 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // Adapted from FCEUX src + public sealed class Mapper123 : MMC3Board_Base + { + private ByteBuffer EXPREGS = new ByteBuffer(8); + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "MAPPER123": // Nestopia suggests this board is mapper 123, I do not have any ROMs with this ines header info to confirm + case "UNIF_UNL-H2288": + break; + default: + return false; + } + + BaseSetup(); + return true; + } + + public override void WriteEXP(int addr, byte value) + { + if (addr >= 0x1000) + { + if ((addr & 0x800) > 0) + { + if ((addr & 1) > 0) + { + EXPREGS[1] = value; + } + else + { + EXPREGS[0] = value; + } + } + } + else + { + base.WriteEXP(addr, value); + } + } + + public override void WritePRG(int addr, byte value) + { + if (addr < 0x2000) + { + switch ((addr + 0x8000) & 0x8001) + { + case 0x8000: break; + case 0x8001: break; + } + } + else + { + base.WritePRG(addr, value); + } + } + + public override byte ReadPRG(int addr) + { + if ((EXPREGS[0] & 0x40) > 0) + { + var bank = (EXPREGS[0] & 5) | ((EXPREGS[0] & 8) >> 2) | ((EXPREGS[0] & 0x20) >> 2); + if ((EXPREGS[0] & 2) > 0) + { + return ROM[((bank >> 1) << 15) + (addr & 0x7FFF)]; + } + else + { + return ROM[(bank << 14) + (addr & 0x3FFF)]; + } + } + else + { + //return (byte)(base.ReadPRG(addr) & 0x3F); + return base.ReadPRG(addr); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs index 3a968dcc5e..11e99cebf5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs @@ -15,6 +15,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case "MAPPER238": // Nestopia suggests this board is mapper 238, I do not have any ROMs with this ines header info to confirm case "UNIF_UNL-603-5052": break; + default: + return false; } BaseSetup();