diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 9f0bf18b64..bfb2f7c8cc 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -108,6 +108,7 @@ + diff --git a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt index 80e3547e3e..426145e00a 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt +++ b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt @@ -65,7 +65,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an 075 VRC1 Nothing 076 Misc (J) Nothing 077 Misc (J) Nothing -078 Misc Nothing +078 Misc Complete 079 NINA-06 Complete 080 Misc (J) Nothing 082 Misc (J) Nothing diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper078.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper078.cs new file mode 100644 index 0000000000..b20fcf6641 --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper078.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + class Mapper078 : NES.NESBoardBase + { + bool holydiver; + int chr; + int prg_bank_mask_16k; + byte prg_bank_16k; + ByteBuffer prg_banks_16k = new ByteBuffer(2); + + public override bool Configure(NES.EDetectionOrigin origin) + { + switch (Cart.board_type) + { + case "IREM-HOLYDIVER": + holydiver = true; + break; + case "JALECO-JF-16": + holydiver = false; + break; + default: + return false; + } + + SetMirrorType(Cart.pad_h, Cart.pad_v); + prg_bank_mask_16k = (Cart.prg_size / 16) - 1; + prg_banks_16k[1] = 0xFF; + return true; + } + + public override void Dispose() + { + prg_banks_16k.Dispose(); + base.Dispose(); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("chr", ref chr); + ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); + ser.Sync("prg_bank_16k", ref prg_bank_16k); + ser.Sync("prg_banks_16k", ref prg_banks_16k); + } + + void SyncPRG() + { + prg_banks_16k[0] = prg_bank_16k; + } + + public override void WritePRG(int addr, byte value) + { + prg_bank_16k = (byte)(value & 7); + SyncPRG(); + + if (value.Bit(3)) + { + if (holydiver) + SetMirrorType(EMirrorType.Horizontal); + else + SetMirrorType(EMirrorType.OneScreenA); + } + else + { + if (holydiver) + SetMirrorType(EMirrorType.Vertical); + else + SetMirrorType(EMirrorType.OneScreenB); + } + + chr = (value >> 4); + } + + public override byte ReadPRG(int addr) + { + int bank_16k = addr >> 14; + int ofs = addr & ((1 << 14) - 1); + bank_16k = prg_banks_16k[bank_16k]; + bank_16k &= prg_bank_mask_16k; + addr = (bank_16k << 14) | ofs; + return ROM[addr]; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) + return VROM[(addr & 0x1FFF) + (chr * 0x2000)]; + else + return base.ReadPPU(addr); + } + } +}