From 40c2c5f5ef7014ce61cd5a8a699a3f8f629f22c3 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Wed, 9 Nov 2016 20:18:37 -0500 Subject: [PATCH] Add in VS platoon --- .../Consoles/Nintendo/NES/Boards/Sunsoft3.cs | 76 +++++++++++++++++-- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs index 87c94d79cb..58feac37a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs @@ -19,6 +19,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bool irq_asserted; int clock_counter; + //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]; + + public override void SyncState(Serializer ser) { base.SyncState(ser); @@ -29,20 +34,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync("irq_enable", ref irq_enable); ser.Sync("irq_asserted", ref irq_asserted); ser.Sync("clock_counter", ref clock_counter); - SyncIRQ(); - } - public override void Dispose() - { - prg_banks_16k.Dispose(); - chr_banks_2k.Dispose(); - base.Dispose(); + if (NES.IsVS) + { + ser.Sync("VS_CIRAM", ref CIRAM_VS, false); + } + + SyncIRQ(); } public override bool Configure(NES.EDetectionOrigin origin) { switch (Cart.board_type) { + case "MAPPER067VS": + 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 "MAPPER067": break; case "SUNSOFT-3": @@ -146,7 +163,50 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = ApplyMemoryMap(11, chr_banks_2k, addr); return base.ReadPPUChr(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 (NES._isVS) + { + if (addr < 0x2000) + { + addr = ApplyMemoryMap(11, chr_banks_2k, addr); + if (VRAM != null) + VRAM[addr] = value; + } + else + { + addr = addr - 0x2000; + if (addr < 0x800) + { + NES.CIRAM[addr] = value; + } + else + { + CIRAM_VS[addr - 0x800] = value; + } + } + } + else + base.WritePPU(addr, value); } /*