From cc3ed634bb65455b695b2552ceca270558696695 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 17 Sep 2016 17:20:23 -0400 Subject: [PATCH] attempt to implement UNIF_UNL-SHERO - works except for Sachen title screen chr mapping --- .../BizHawk.Emulation.Cores.csproj | 1 + .../NES/Boards/UNIF/UNIF_UNL-SHERO.cs | 87 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 51caf83399..20b3f2dc7a 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -757,6 +757,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs new file mode 100644 index 0000000000..9ad814d9a6 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs @@ -0,0 +1,87 @@ +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + public class UNIF_UNL_SHERO : MMC3Board_Base + { + [MapperProp] + public bool RegionAsia = false; + + private byte reg; + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "UNIF_UNL-SHERO": + break; + default: + return false; + } + + BaseSetup(); + AutoMapperProps.Apply(this); + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("reg", ref reg); + ser.Sync("RegionAsia", ref RegionAsia); + } + + public override void WriteEXP(int addr, byte value) + { + if (addr == 0x100) + { + reg = value; + } + + base.WriteEXP(addr, value); + } + + public override byte ReadEXP(int addr) + { + if (addr == 0x100) + { + return (byte)(RegionAsia ? 0xFF : 00); + } + + return base.ReadEXP(addr); + } + + + public override byte ReadPPU(int addr) + { + // TODO: why doesn't this work? + if (addr < 0x2000 & ((reg & 0x40) > 0)) + { + return VROM[addr]; + } + + return base.ReadPPU(addr); + } + + protected override int Get_CHRBank_1K(int addr) + { + if (addr < 0x800) + { + return base.Get_CHRBank_1K(addr) | ((reg & 8) << 5); + } + else if (addr < 0x1000) + { + return base.Get_CHRBank_1K(addr) | ((reg & 4) << 6); + } + else if (addr < 0x1800) + { + return base.Get_CHRBank_1K(addr) | ((reg & 1) << 8); + } + else + { + return base.Get_CHRBank_1K(addr) | ((reg & 2) << 7); + } + } + } +}