diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 0e80f0116e..a214b19552 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -169,6 +169,7 @@ + diff --git a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt index 704754f27d..fdc886337e 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt +++ b/BizHawk.Emulation/Consoles/Nintendo/Docs/compatibility.txt @@ -63,7 +63,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an 073 VRC3 Good 074 Pirate (CN) Junk 075 VRC1 Complete -076 Misc (J) Nothing +076 Misc (J) Complete (namcot108 variant) 077 Misc (J) Complete 078 Misc Complete 079 NINA-06 Complete diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs index 2924f0d01c..216bc58b40 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs @@ -14,8 +14,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo //state int reg_addr; bool chr_mode, prg_mode; - ByteBuffer chr_regs_1k = new ByteBuffer(8); - ByteBuffer prg_regs_8k = new ByteBuffer(4); ByteBuffer regs = new ByteBuffer(8); public byte mirror; @@ -31,6 +29,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo int separator_counter; int irq_countdown; + //volatile state + ByteBuffer chr_regs_1k = new ByteBuffer(8); + ByteBuffer prg_regs_8k = new ByteBuffer(4); //configuration public enum EMMC3Type @@ -51,9 +52,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo public void Dispose() { + regs.Dispose(); chr_regs_1k.Dispose(); prg_regs_8k.Dispose(); - regs.Dispose(); } public NES.NESBoardBase.EMirrorType MirrorType { get { return mirror == 0 ? NES.NESBoardBase.EMirrorType.Vertical : NES.NESBoardBase.EMirrorType.Horizontal; } } diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs index 049075217e..a065c52e8d 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs @@ -5,7 +5,7 @@ using System.Diagnostics; namespace BizHawk.Emulation.Consoles.Nintendo { //aka mapper 118 - //wires the mapper outputs to control the nametables. check out the companion board Mapper095 + //wires the mapper outputs to control the nametables public class TLSROM : MMC3Board_Base { public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs new file mode 100644 index 0000000000..8c8808362a --- /dev/null +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs @@ -0,0 +1,47 @@ +using System; +using System.IO; +using System.Diagnostics; + +namespace BizHawk.Emulation.Consoles.Nintendo +{ + //aka NAMCOT-3446 + public class Mapper076 : Namcot108Board_Base + { + public override bool Configure(NES.EDetectionOrigin origin) + { + //analyze board type + switch (Cart.board_type) + { + case "NAMCOT-3446": //Megami Tensei: Digital Devil Story + case "MAPPER076": + break; + default: + return false; + } + + BaseSetup(); + SetMirrorType(EMirrorType.Vertical); + + return true; + } + + int RewireCHR(int addr) + { + int mapper_addr = addr >> 1; + int bank_1k = mapper.Get_CHRBank_1K(mapper_addr + 0x1000); + int ofs = addr & ((1 << 11) - 1); + return (bank_1k << 11) + ofs; + } + + public override byte ReadPPU(int addr) + { + if (addr < 0x2000) return VROM[RewireCHR(addr)]; + else return base.ReadPPU(addr); + } + public override void WritePPU(int addr, byte value) + { + if (addr < 0x2000) { } + else base.WritePPU(addr, value); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs index eafca2a922..ca9341b1de 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs @@ -14,6 +14,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo { //state int reg_addr; + ByteBuffer regs = new ByteBuffer(8); + + //volatile state ByteBuffer chr_regs_1k = new ByteBuffer(8); ByteBuffer prg_regs_8k = new ByteBuffer(4); @@ -22,23 +25,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo { this.board = board; - prg_regs_8k[0] = 0; - prg_regs_8k[1] = 1; - prg_regs_8k[2] = 0xFE; //constant - prg_regs_8k[3] = 0xFF; //constant - - chr_regs_1k[0] = 0; - chr_regs_1k[1] = 1; - chr_regs_1k[2] = 2; - chr_regs_1k[3] = 3; - chr_regs_1k[4] = 4; - chr_regs_1k[5] = 5; - chr_regs_1k[6] = 6; - chr_regs_1k[7] = 7; + Sync(); } public void Dispose() { + regs.Dispose(); chr_regs_1k.Dispose(); prg_regs_8k.Dispose(); } @@ -46,8 +38,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo public virtual void SyncState(Serializer ser) { ser.Sync("reg_addr", ref reg_addr); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("prg_regs_8k", ref prg_regs_8k); + ser.Sync("regs", ref regs); + Sync(); } public virtual void WritePRG(int addr, byte value) @@ -58,29 +50,34 @@ namespace BizHawk.Emulation.Consoles.Nintendo reg_addr = (value & 7); break; case 0x0001: //$8001 - switch (reg_addr) - { - //bottom bits of these chr regs are ignored - case 0: - chr_regs_1k[0] = (byte)(value & ~1); - chr_regs_1k[1] = (byte)(value | 1); - break; - case 1: - chr_regs_1k[2] = (byte)(value & ~1); - chr_regs_1k[3] = (byte)(value | 1); - break; - - case 2: chr_regs_1k[4] = value; break; - case 3: chr_regs_1k[5] = value; break; - case 4: chr_regs_1k[6] = value; break; - case 5: chr_regs_1k[7] = value; break; - case 6: prg_regs_8k[0] = value; break; - case 7: prg_regs_8k[1] = value; break; - } + regs[reg_addr] = value; + Sync(); break; } } + void Sync() + { + prg_regs_8k[0] = regs[6]; + prg_regs_8k[1] = regs[7]; + prg_regs_8k[2] = 0xFE; + prg_regs_8k[3] = 0xFF; + + byte r0_0 = (byte)(regs[0] & ~1); + byte r0_1 = (byte)(regs[0] | 1); + byte r1_0 = (byte)(regs[1] & ~1); + byte r1_1 = (byte)(regs[1] | 1); + + chr_regs_1k[0] = r0_0; + chr_regs_1k[1] = r0_1; + chr_regs_1k[2] = r1_0; + chr_regs_1k[3] = r1_1; + chr_regs_1k[4] = regs[2]; + chr_regs_1k[5] = regs[3]; + chr_regs_1k[6] = regs[4]; + chr_regs_1k[7] = regs[5]; + } + public int Get_PRGBank_8K(int addr) { int bank_8k = addr >> 13;