From a0ea09a226b6363bd9dcf5d1580a938c647473b9 Mon Sep 17 00:00:00 2001 From: goyuken Date: Wed, 9 Jan 2013 23:22:40 +0000 Subject: [PATCH] nes: mapper 117: some sort of vrc7 clone. fixes "Crayon Shin-Chan" (not that one, the other one) --- .../Consoles/Nintendo/NES/Boards/VRC7.cs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/VRC7.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/VRC7.cs index 85c09f322a..a4b8a0b133 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/VRC7.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/VRC7.cs @@ -52,6 +52,39 @@ namespace BizHawk.Emulation.Consoles.Nintendo IRQSignal = (irq_pending && irq_enabled); } + + static int RemapM117(int addr) + { + //addr &= 0x7007; // i don't know all of which bits are decoded, but this breaks stuff + switch (addr) + { + //prg + case 0x0000: return 0x0000; + case 0x0001: return 0x0001; + case 0x0002: return 0x1000; + //chr + case 0x2000: return 0x2000; + case 0x2001: return 0x2001; + case 0x2002: return 0x3000; + case 0x2003: return 0x3001; + case 0x2004: return 0x4000; + case 0x2005: return 0x4001; + case 0x2006: return 0x5000; + case 0x2007: return 0x5001; + //irq + // fake addressees to activate different irq handling logic + case 0x4001: return 0x10001; + case 0x4002: return 0x10002; + case 0x4003: return 0x10003; + case 0x6000: return 0x10004; + //mir + case 0x5000: return 0x6000; + + //probably nothing at all + default: return 0xffff; + } + } + public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) @@ -80,6 +113,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo else throw new Exception("Unknown PCB type for VRC7"); break; + case "MAPPER117": + // not sure quite what this is + // different address mapping, and somewhat different irq logic + Cart.vram_size = 0; + Cart.wram_size = 0; + remap = RemapM117; + fm = null; + break; default: return false; } @@ -222,6 +263,24 @@ namespace BizHawk.Emulation.Consoles.Nintendo irq_enabled = irq_autoen; SyncIRQ(); break; + + // special irq logic for M117 + // RemapM117() sends some addresses to these "virtual addresses" for irq handling + case 0x10001: + irq_reload = (byte)(237 - value); // what + break; + case 0x10002: + irq_pending = false; + SyncIRQ(); + break; + case 0x10003: + irq_counter = irq_reload; + break; + case 0x10004: + irq_enabled = value.Bit(0); + irq_pending = false; + SyncIRQ(); + break; } }