BizHawk/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ICodeDataLog.cs

75 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.IO;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{
2017-04-25 15:42:11 +00:00
public partial class Gameboy : ICodeDataLogger
{
2017-04-25 15:42:11 +00:00
public void SetCDL(ICodeDataLog cdl)
{
2017-04-25 15:42:11 +00:00
_cdl = cdl;
LibGambatte.gambatte_setcdcallback(GambatteState, cdl == null ? null : _cdCallback);
}
2017-04-25 15:42:11 +00:00
public void NewCDL(ICodeDataLog cdl)
{
cdl["ROM"] = new byte[MemoryDomains["ROM"].Size];
2017-04-25 15:42:11 +00:00
// cdl["HRAM"] = new byte[_memoryDomains["HRAM"].Size]; //this is probably useless, but it's here if someone needs it
cdl["WRAM"] = new byte[MemoryDomains["WRAM"].Size];
if (MemoryDomains.Has("CartRAM"))
2017-04-25 15:42:11 +00:00
{
cdl["CartRAM"] = new byte[MemoryDomains["CartRAM"].Size];
2017-04-25 15:42:11 +00:00
}
cdl.SubType = "GB";
cdl.SubVer = 0;
}
2017-04-25 15:42:11 +00:00
[FeatureNotImplemented]
void ICodeDataLogger.DisassembleCDL(Stream s, ICodeDataLog cdl)
{
}
private ICodeDataLog _cdl;
private readonly LibGambatte.CDCallback _cdCallback;
2017-04-25 15:42:11 +00:00
private void CDCallbackProc(int addr, LibGambatte.CDLog_AddrType addrtype, LibGambatte.CDLog_Flags flags)
{
2017-04-25 15:42:11 +00:00
if (_cdl == null)
{
return;
}
if (!_cdl.Active)
{
return;
}
string key;
switch (addrtype)
{
2017-04-25 15:42:11 +00:00
case LibGambatte.CDLog_AddrType.ROM:
key = "ROM";
break;
case LibGambatte.CDLog_AddrType.HRAM:
key = "HRAM";
break;
case LibGambatte.CDLog_AddrType.WRAM:
key = "WRAM";
break;
case LibGambatte.CDLog_AddrType.CartRAM:
key = "CartRAM";
break;
default:
throw new InvalidOperationException("Juniper lightbulb proxy");
}
2017-04-25 15:42:11 +00:00
_cdl[key][addr] |= (byte)flags;
}
}
}