diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index e2a50d5e12..91afa802f4 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -242,6 +242,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs new file mode 100644 index 0000000000..72a36b5308 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public sealed class Farid_UNROM_8_in_1 : NES.NESBoardBase + { + // http://forums.nesdev.com/viewtopic.php?f=9&t=11099 + + // state + int c; // clock bit for the second 74'161 + int e; // /load for second 74'161. guaranteed to be 0 on powerup + int prginner; + int prgouter; // guaranteed to be 0 on powerup + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_FARID_UNROM_8-IN-1": + AssertPrg(1024); + AssertChr(0); + break; + default: + return false; + } + + Cart.vram_size = 8; + SetMirrorType(Cart.pad_h, Cart.pad_v); + return true; + } + + public override void WritePRG(int addr, byte value) + { + prginner = value & 7; + int newc = value >> 7; + int newe = value >> 3 & 1; + + if (newc > c && e == 0) // latch e and outer + { + e = newe; + prgouter = value >> 4 & 7; + } + c = newc; + } + + public override byte ReadPRG(int addr) + { + int bnk = addr >= 0x4000 ? 7 : prginner; + bnk |= prgouter << 3; + return ROM[bnk << 14 | addr & 0x3fff]; + } + + public override void SyncState(BizHawk.Common.Serializer ser) + { + base.SyncState(ser); + ser.Sync("c", ref c); + ser.Sync("e", ref e); + ser.Sync("prginner", ref prginner); + ser.Sync("prgouter", ref prgouter); + } + + public override void NESSoftReset() + { + e = 0; + prgouter = 0; + } + } +}