diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index c0f88b4310..75ef0e99ad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -71,7 +71,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES A, B1, B2, B3 } - //register 0: public int chr_mode; public int prg_mode; @@ -249,6 +248,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES const int pputimeout = 4; // i don't know if this is right, but anything lower will not boot Bill & Ted bool disablemirror = false; // mapper 171: mmc1 without mirroring control + + //the VS actually does have 2 KB of nametable address space + //let's make the extra space here, instead of in the main NES to avoid confusion + byte[] CIRAM_VS = new byte[0x800]; + + //state public MMC1 mmc1; /// number of cycles since last WritePRG() @@ -294,12 +299,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return VRAM[Gen_CHR_Address(addr) & vram_mask]; else return VROM[Gen_CHR_Address(addr)]; } - else return base.ReadPPU(addr); - } + else + { + if (NES._isVS) + { + addr = addr - 0x2000; + if (addr < 0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr - 0x800]; + } + } + else + return base.ReadPPU(addr); + } + } public override void WritePPU(int addr, byte value) { - if (addr < 0x2000) + + if (NES._isVS) + { + if (addr < 0x2000) + { + if (VRAM != null) + VRAM[Gen_CHR_Address(addr) & vram_mask] = value; + } + else + { + addr = addr - 0x2000; + if (addr < 0x800) + { + NES.CIRAM[addr] = value; + } + else + { + CIRAM_VS[addr - 0x800] = value; + } + } + } + else if (addr < 0x2000) { if (Cart.vram_size != 0) VRAM[Gen_CHR_Address(addr) & vram_mask] = value; @@ -312,6 +354,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.SyncState(ser); mmc1.SyncState(ser); ser.Sync("ppuclock", ref ppuclock); + + if (NES._isVS) + ser.Sync("VS_CIRAM", ref CIRAM_VS, false); } public override bool Configure(NES.EDetectionOrigin origin) @@ -320,6 +365,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { case "MAPPER116_HACKY": break; + case "MAPPER001_VS": + // VS mapper MMC1 + NES._isVS = true; + //update the state of the dip switches + //this is only done at power on + NES.VS_dips[0] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[1] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[2] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[3] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[4] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[5] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[6] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + NES.VS_dips[7] = (byte)(NES.SyncSettings.VSDipswitches.Dip_Switch_1 ? 1 : 0); + break; case "MAPPER001": // there's no way to define PRG oversize for mapper001 due to how the MMC1 regs work // so 512KB must mean SUROM or SXROM. SUROM is more common, so we try that @@ -445,7 +504,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.Dispose(); if(mmc1 != null) mmc1.Dispose(); } - } //class SxROM