2015-01-16 18:37:42 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|
|
|
|
{
|
|
|
|
|
public partial class Gameboy : IDebuggable
|
|
|
|
|
{
|
|
|
|
|
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
|
|
|
|
{
|
|
|
|
|
int[] data = new int[10];
|
|
|
|
|
LibGambatte.gambatte_getregs(GambatteState, data);
|
|
|
|
|
|
|
|
|
|
return new Dictionary<string, RegisterValue>
|
|
|
|
|
{
|
2017-04-25 13:28:06 +00:00
|
|
|
|
["PC"] = (ushort)(data[(int)LibGambatte.RegIndicies.PC] & 0xffff),
|
|
|
|
|
["SP"] = (ushort)(data[(int)LibGambatte.RegIndicies.SP] & 0xffff),
|
|
|
|
|
["A"] = (byte)(data[(int)LibGambatte.RegIndicies.A] & 0xff),
|
|
|
|
|
["B"] = (byte)(data[(int)LibGambatte.RegIndicies.B] & 0xff),
|
|
|
|
|
["C"] = (byte)(data[(int)LibGambatte.RegIndicies.C] & 0xff),
|
|
|
|
|
["D"] = (byte)(data[(int)LibGambatte.RegIndicies.D] & 0xff),
|
|
|
|
|
["E"] = (byte)(data[(int)LibGambatte.RegIndicies.E] & 0xff),
|
|
|
|
|
["F"] = (byte)(data[(int)LibGambatte.RegIndicies.F] & 0xff),
|
|
|
|
|
["H"] = (byte)(data[(int)LibGambatte.RegIndicies.H] & 0xff),
|
|
|
|
|
["L"] = (byte)(data[(int)LibGambatte.RegIndicies.L] & 0xff)
|
2015-01-16 18:37:42 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[FeatureNotImplemented]
|
|
|
|
|
public void SetCpuRegister(string register, int value)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanStep(StepType type)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[FeatureNotImplemented]
|
2017-04-25 15:42:11 +00:00
|
|
|
|
public void Step(StepType type)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2015-01-16 18:37:42 +00:00
|
|
|
|
|
2017-01-10 01:23:05 +00:00
|
|
|
|
[FeatureNotImplemented]
|
|
|
|
|
public int TotalExecutedCycles
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 15:42:11 +00:00
|
|
|
|
public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks;
|
2015-01-16 18:37:42 +00:00
|
|
|
|
|
2017-04-25 15:42:11 +00:00
|
|
|
|
private LibGambatte.MemoryCallback _readcb;
|
|
|
|
|
private LibGambatte.MemoryCallback _writecb;
|
|
|
|
|
private LibGambatte.MemoryCallback _execcb;
|
2015-01-16 18:37:42 +00:00
|
|
|
|
|
|
|
|
|
private MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// for use in dual core
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal void ConnectMemoryCallbackSystem(MemoryCallbackSystem mcs)
|
|
|
|
|
{
|
|
|
|
|
_memorycallbacks = mcs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitMemoryCallbacks()
|
|
|
|
|
{
|
2017-04-25 15:42:11 +00:00
|
|
|
|
_readcb = addr => MemoryCallbacks.CallReads(addr);
|
|
|
|
|
_writecb = addr => MemoryCallbacks.CallWrites(addr);
|
|
|
|
|
_execcb = addr => MemoryCallbacks.CallExecutes(addr);
|
2015-01-16 18:37:42 +00:00
|
|
|
|
_memorycallbacks.ActiveChanged += RefreshMemoryCallbacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshMemoryCallbacks()
|
|
|
|
|
{
|
|
|
|
|
var mcs = MemoryCallbacks;
|
|
|
|
|
|
2017-04-25 15:42:11 +00:00
|
|
|
|
LibGambatte.gambatte_setreadcallback(GambatteState, mcs.HasReads ? _readcb : null);
|
|
|
|
|
LibGambatte.gambatte_setwritecallback(GambatteState, mcs.HasWrites ? _writecb : null);
|
|
|
|
|
LibGambatte.gambatte_setexeccallback(GambatteState, mcs.HasExecutes ? _execcb : null);
|
2015-01-16 18:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|