minimally fix nes CDL which was broken 3 years ago

This commit is contained in:
zeromus 2020-08-28 19:02:21 -04:00
parent 56082ddf44
commit f89840234d
3 changed files with 28 additions and 15 deletions

View File

@ -50,6 +50,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
void SyncState(Serializer ser);
bool IrqSignal { get; }
NES.CDLog_MapResults MapMemory(ushort addr, bool write);
//mixes the board's custom audio into the supplied sample buffer
void ApplyCustomAudio(short[] samples);

View File

@ -38,6 +38,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//this is set to true when SyncState is called, so that we know the base class SyncState was used
public bool SyncStateFlag;
public virtual NES.CDLog_MapResults MapMemory(ushort addr, bool write)
{
NES.CDLog_MapResults ret = new NES.CDLog_MapResults();
ret.Type = NES.CDLog_AddrType.None;
if (addr < 0x2000)
{
ret.Type = NES.CDLog_AddrType.MainRAM;
ret.Address = addr & 0x7FF;
}
return ret;
}
public virtual void SyncState(Serializer ser)
{
ser.Sync(nameof(_vram), ref _vram, true);

View File

@ -40,16 +40,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
private enum CDLog_AddrType
public enum CDLog_AddrType
{
None,
ROM,
MainRAM,
ROM,
MainRAM,
SaveRAM,
}
[Flags]
private enum CDLog_Flags
public enum CDLog_Flags
{
ExecFirst = 0x01,
ExecOperand = 0x02,
@ -57,28 +57,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
#pragma warning disable CS0649
private struct CDLog_MapResults
public struct CDLog_MapResults
{
public CDLog_AddrType Type;
public int Address;
}
private delegate CDLog_MapResults MapMemoryDelegate(ushort addr, bool write);
private MapMemoryDelegate MapMemory;
private delegate CDLog_MapResults MpMemoryDelegate(ushort addr, bool write);
#pragma warning restore CS0649
private ICodeDataLog CDL;
private void RunCDL(ushort address, CDLog_Flags flags)
{
if (MapMemory != null)
CDLog_MapResults results = Board.MapMemory(address, false);
switch (results.Type)
{
CDLog_MapResults results = MapMemory(address, false);
switch (results.Type)
{
case CDLog_AddrType.None: break;
case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break;
case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break;
}
case CDLog_AddrType.None: break;
case CDLog_AddrType.MainRAM: CDL["RAM"][results.Address] |= (byte)flags; break;
case CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break;
}
}