Update VRC-1 to run VS system game mirroring modes

This commit is contained in:
alyosha-tas 2016-10-29 18:54:34 -04:00 committed by GitHub
parent 5cc269e347
commit 3bf90c5e42
1 changed files with 54 additions and 1 deletions

View File

@ -1,5 +1,6 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
using System;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
@ -15,6 +16,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
IntBuffer chr_banks_4k = new IntBuffer(2);
int[] chr_regs_4k = new int[2];
//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 Dispose()
{
base.Dispose();
@ -27,6 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
base.SyncState(ser);
ser.Sync("prg_banks_8k", ref prg_banks_8k);
ser.Sync("chr_banks_4k", ref chr_banks_4k);
ser.Sync("VS_CIRAM", ref CIRAM_VS, false);
for (int i = 0; i < 2; i++) ser.Sync("chr_regs_4k_" + i, ref chr_regs_4k[i]);
if (ser.IsReader)
@ -82,7 +88,54 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
addr = (bank_4k << 12) | ofs;
return VROM[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)
{
// The game VS Goonies apparently scans for more CIRAM then actually exists, so we have to mask out nonsensical values
addr &= 0x2FFF;
if (NES._isVS)
{
if (addr < 0x2000)
{
if (VRAM != null)
VRAM[addr] = value;
}
else
{
Console.WriteLine(addr);
addr = addr - 0x2000;
if (addr < 0x800)
{
NES.CIRAM[addr] = value;
}
else
{
CIRAM_VS[addr - 0x800] = value;
}
}
}
else
base.WritePPU(addr, value);
}
void SyncCHR()