2017-05-12 19:06:34 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-02-22 23:50:11 +00:00
|
|
|
|
using System.Linq;
|
2017-05-12 19:06:34 +00:00
|
|
|
|
|
2014-12-18 18:39:55 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
|
|
|
|
{
|
|
|
|
|
public partial class C64 : IDebuggable
|
|
|
|
|
{
|
2017-05-13 18:04:02 +00:00
|
|
|
|
private IDebuggable _selectedDebuggable;
|
2016-02-22 23:50:11 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
private IEnumerable<IDebuggable> GetAvailableDebuggables()
|
|
|
|
|
{
|
|
|
|
|
yield return _board.Cpu;
|
|
|
|
|
if (_board.DiskDrive != null)
|
|
|
|
|
{
|
|
|
|
|
yield return _board.DiskDrive;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-22 23:50:11 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
private void SetDefaultDebuggable()
|
|
|
|
|
{
|
|
|
|
|
_selectedDebuggable = GetAvailableDebuggables().First();
|
|
|
|
|
}
|
2016-02-22 23:50:11 +00:00
|
|
|
|
|
2017-05-12 19:06:34 +00:00
|
|
|
|
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
2014-12-18 18:39:55 +00:00
|
|
|
|
{
|
2017-04-24 13:35:05 +00:00
|
|
|
|
if (_selectedDebuggable == null)
|
|
|
|
|
{
|
|
|
|
|
SetDefaultDebuggable();
|
|
|
|
|
}
|
2017-05-12 19:06:34 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
return _selectedDebuggable.GetCpuFlagsAndRegisters();
|
2014-12-18 18:39:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 19:06:34 +00:00
|
|
|
|
public void SetCpuRegister(string register, int value)
|
2015-09-28 18:53:19 +00:00
|
|
|
|
{
|
2017-04-24 13:35:05 +00:00
|
|
|
|
if (_selectedDebuggable == null)
|
|
|
|
|
{
|
|
|
|
|
SetDefaultDebuggable();
|
|
|
|
|
}
|
2017-05-12 19:06:34 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
_selectedDebuggable.SetCpuRegister(register, value);
|
2015-09-28 18:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 19:06:34 +00:00
|
|
|
|
public bool CanStep(StepType type)
|
2015-09-28 18:53:19 +00:00
|
|
|
|
{
|
2017-04-24 13:35:05 +00:00
|
|
|
|
if (_selectedDebuggable == null)
|
|
|
|
|
{
|
|
|
|
|
SetDefaultDebuggable();
|
|
|
|
|
}
|
2017-05-12 19:06:34 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
return _selectedDebuggable.CanStep(type);
|
2015-09-28 18:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 19:06:34 +00:00
|
|
|
|
public void Step(StepType type)
|
2015-09-28 18:53:19 +00:00
|
|
|
|
{
|
2017-04-24 13:35:05 +00:00
|
|
|
|
if (_selectedDebuggable == null)
|
|
|
|
|
{
|
|
|
|
|
SetDefaultDebuggable();
|
|
|
|
|
}
|
2017-05-12 19:06:34 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
_selectedDebuggable.Step(type);
|
2015-09-28 18:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-12 16:55:42 +00:00
|
|
|
|
public long TotalExecutedCycles => _selectedDebuggable.TotalExecutedCycles;
|
2017-01-10 01:23:05 +00:00
|
|
|
|
|
2017-04-24 13:35:05 +00:00
|
|
|
|
private readonly IMemoryCallbackSystem _memoryCallbacks;
|
2015-09-28 18:53:19 +00:00
|
|
|
|
|
2017-05-12 19:06:34 +00:00
|
|
|
|
IMemoryCallbackSystem IDebuggable.MemoryCallbacks => _memoryCallbacks;
|
2015-09-28 18:53:19 +00:00
|
|
|
|
}
|
2014-12-18 18:39:55 +00:00
|
|
|
|
}
|