From ed9de010c0cdeabf28b234bd6dfeda2a4a21215c Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 6 Mar 2012 09:42:11 +0000 Subject: [PATCH] nes-add some crappy mmc3 multicart mappers --- BizHawk.Emulation/BizHawk.Emulation.csproj | 2 + .../Consoles/Nintendo/Docs/compatibility.txt | 6 +- .../NES/Boards/MMC3_family/MMC3_family.cs | 1 + .../NES/Boards/MMC3_family/Mapper044.cs | 64 +++++++++++++++++++ .../NES/Boards/MMC3_family/Mapper049.cs | 64 +++++++++++++++++++ .../Consoles/Nintendo/NES/Core.cs | 2 +- .../Consoles/Nintendo/NES/iNES.cs | 2 + 7 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs create mode 100644 BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index ee2dbe7c5f..91ccb77ab7 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -116,6 +116,8 @@ + + diff --git a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt index 267032ea16..492561e089 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt +++ b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt @@ -38,12 +38,12 @@ Open bus and bus conflict emulation is not considered complete or thorough in an 032 Irem_G101 Complete 033 Taito Complete 034 Misc Complete -044 Multicart Junk +044 Multicart Complete 045 Multicart Junk 046 Multicart Junk 047 MMC3Multi Decent 048 MMC3Variant Decent -049 Multicart Junk +049 Multicart Complete 050 Pirate Junk 052 Multicart Junk 057 Multicart Junk @@ -67,7 +67,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an 077 Misc (J) Complete 078 Misc Complete 079 NINA-06 Complete -080 Misc (J) Nothing +080 Misc (J) Good 082 Misc (J) Nothing 085 VRC7 Decent (no OPL sound) 086 Misc (J) Decent (no sound) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3_family.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3_family.cs index 67a703ad3c..53f2a3ed4f 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3_family.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3_family.cs @@ -173,6 +173,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo //wram enable/protect wram_write_protect = value.Bit(6); wram_enable = value.Bit(7); + Console.WriteLine("wram_write_protect={0},wram_enable={1}", wram_write_protect, wram_enable); break; case 0x4000: //$C000 - IRQ Reload value irq_reload = value; diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs new file mode 100644 index 0000000000..96a3dccc16 --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs @@ -0,0 +1,64 @@ +using System; +using System.IO; +using System.Diagnostics; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + //http://wiki.nesdev.com/w/index.php/INES_Mapper_044 + public class Mapper044 : MMC3Board_Base + { + public override bool Configure(NES.EDetectionOrigin origin) + { + //analyze board type + switch (Cart.board_type) + { + case "MAPPER044": + break; + default: + return false; + } + + BaseSetup(); + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("block_select", ref block_select); + } + + int block_select; + + public override void WritePRG(int addr, byte value) + { + base.WritePRG(addr, value); + + switch (addr & 0x6001) + { + case 0x2001: //$A001 + block_select = value & 0x7; + break; + } + } + + static readonly int[] PRG_AND = new int[] {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0f }; + static readonly int[] PRG_OR = new int[] { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x60 }; + static readonly int[] CHR_AND = new int[] { 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7f }; + static readonly int[] CHR_OR = new int[] { 0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x300 }; + + protected override int Get_PRGBank_8K(int addr) + { + int bank_8k = mapper.Get_PRGBank_8K(addr); + return (bank_8k & PRG_AND[block_select]) | PRG_OR[block_select]; + } + + protected override int Get_CHRBank_1K(int addr) + { + int bank_1k = base.Get_CHRBank_1K(addr); + return (bank_1k & CHR_AND[block_select]) | CHR_OR[block_select]; + } + + } +} \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs new file mode 100644 index 0000000000..af6affc73d --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs @@ -0,0 +1,64 @@ +using System; +using System.IO; +using System.Diagnostics; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + //http://wiki.nesdev.com/w/index.php/INES_Mapper_044 + public class Mapper049 : MMC3Board_Base + { + public override bool Configure(NES.EDetectionOrigin origin) + { + //analyze board type + switch (Cart.board_type) + { + case "MAPPER049": + break; + default: + return false; + } + + BaseSetup(); + block = prg = 0; + mode = false; + + return true; + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("block", ref block); + ser.Sync("prg", ref prg); + ser.Sync("mode", ref mode); + } + + int block, prg; + bool mode; + + public override void WriteWRAM(int addr, byte value) + { + if (!mmc3.wram_enable || mmc3.wram_write_protect) return; + mode = value.Bit(0); + prg = (value >> 4) & 3; + block = (value >> 6) & 3; + Console.WriteLine("val={3}, addr={4}, prg={0},mode={1},block={2}", prg, mode, block, value, addr); + base.WriteWRAM(addr, value); + } + + + protected override int Get_PRGBank_8K(int addr) + { + if (mode) + return (mapper.Get_PRGBank_8K(addr)&0xF) + block * (128 / 8); + int block_offset = addr >> 13; + return prg * 4 + block_offset; + } + + protected override int Get_CHRBank_1K(int addr) + { + return (base.Get_CHRBank_1K(addr)&0x7F) + block * 128; + } + + } +} \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs index f8324628ae..15f578f8b2 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo public partial class NES : IEmulator { //hardware/state - protected MOS6502 cpu; + public MOS6502 cpu; int cpu_accumulate; //cpu timekeeper public PPU ppu; public APU apu; diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/iNES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/iNES.cs index 139a0de687..c98b824870 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/iNES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/iNES.cs @@ -95,6 +95,8 @@ static string ClassifyTable = @" 7 256 0 8 8 NES-AOROM; battletoads 11 -1 -1 -1 -1 Discrete_74x377-FLEX; Bible Adventures (U) ? 13 32 0 8 16 NES-CPROM; videomation +44 -1 -1 -1 -1 MAPPER044 +49 -1 -1 -1 -1 MAPPER049 65 -1 -1 -1 -1 IREM-H3001-FLEX; //Ai Sensei No Oshiete - Watashi No Hoshi (J).nes 66 64 16 8 0 NES-MHROM; super mario bros / duck hunt 66 128 32 8 0 NES-GNROM; gumshoe