2014-11-23 17:14:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|
|
|
|
{
|
|
|
|
|
public partial class Atari2600 : IDebuggable
|
|
|
|
|
{
|
2014-12-20 13:16:15 +00:00
|
|
|
|
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
2014-11-23 17:14:40 +00:00
|
|
|
|
{
|
2014-12-20 13:16:15 +00:00
|
|
|
|
return new Dictionary<string, RegisterValue>
|
2014-11-23 17:14:40 +00:00
|
|
|
|
{
|
2017-04-25 13:28:06 +00:00
|
|
|
|
["A"] = Cpu.A,
|
|
|
|
|
["X"] = Cpu.X,
|
|
|
|
|
["Y"] = Cpu.Y,
|
|
|
|
|
["S"] = Cpu.S,
|
|
|
|
|
["PC"] = Cpu.PC,
|
2014-11-23 17:14:40 +00:00
|
|
|
|
|
2017-04-25 13:28:06 +00:00
|
|
|
|
["Flag C"] = Cpu.FlagC,
|
|
|
|
|
["Flag Z"] = Cpu.FlagZ,
|
|
|
|
|
["Flag I"] = Cpu.FlagI,
|
|
|
|
|
["Flag D"] = Cpu.FlagD,
|
2014-11-23 17:14:40 +00:00
|
|
|
|
|
2017-04-25 13:28:06 +00:00
|
|
|
|
["Flag B"] = Cpu.FlagB,
|
|
|
|
|
["Flag V"] = Cpu.FlagV,
|
|
|
|
|
["Flag N"] = Cpu.FlagN,
|
|
|
|
|
["Flag T"] = Cpu.FlagT
|
2014-11-23 17:14:40 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCpuRegister(string register, int value)
|
|
|
|
|
{
|
|
|
|
|
switch (register)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
|
case "A":
|
|
|
|
|
Cpu.A = (byte)value;
|
|
|
|
|
break;
|
|
|
|
|
case "X":
|
|
|
|
|
Cpu.X = (byte)value;
|
|
|
|
|
break;
|
|
|
|
|
case "Y":
|
|
|
|
|
Cpu.Y = (byte)value;
|
|
|
|
|
break;
|
|
|
|
|
case "S":
|
|
|
|
|
Cpu.S = (byte)value;
|
|
|
|
|
break;
|
|
|
|
|
case "PC":
|
|
|
|
|
Cpu.PC = (ushort)value;
|
|
|
|
|
break;
|
|
|
|
|
case "Flag I":
|
|
|
|
|
Cpu.FlagI = value > 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-05 00:05:40 +00:00
|
|
|
|
|
2017-08-02 03:05:17 +00:00
|
|
|
|
public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });
|
2014-12-14 18:58:16 +00:00
|
|
|
|
|
2014-12-20 13:29:57 +00:00
|
|
|
|
public bool CanStep(StepType type)
|
|
|
|
|
{
|
2017-09-20 14:27:27 +00:00
|
|
|
|
return false;
|
2014-12-20 13:29:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-14 18:58:16 +00:00
|
|
|
|
[FeatureNotImplemented]
|
2014-12-18 18:48:37 +00:00
|
|
|
|
public void Step(StepType type)
|
|
|
|
|
{
|
2017-09-20 14:27:27 +00:00
|
|
|
|
throw new NotImplementedException();
|
2014-12-18 18:48:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-24 17:08:09 +00:00
|
|
|
|
|
2017-09-20 14:27:27 +00:00
|
|
|
|
public int TotalExecutedCycles => Cpu.TotalExecutedCycles;
|
2014-12-24 17:08:09 +00:00
|
|
|
|
|
|
|
|
|
private int JSRCount = 0;
|
|
|
|
|
|
|
|
|
|
private const byte JSR = 0x20;
|
|
|
|
|
private const byte RTS = 0x60;
|
|
|
|
|
|
2017-04-10 16:24:53 +00:00
|
|
|
|
// the opsize table is used to quickly grab the instruction sizes (in bytes)
|
|
|
|
|
private readonly byte[] opsize =
|
2014-12-18 18:48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4,0,0,0,5,5,0,0,6,0,0,0,7,7,0
|
|
|
|
|
};
|
2014-12-24 15:24:25 +00:00
|
|
|
|
|
|
|
|
|
#region Currently Unused Debug hooks
|
|
|
|
|
|
|
|
|
|
private int CurrentScanLine
|
|
|
|
|
{
|
|
|
|
|
get { return _tia.LineCount; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsVsync
|
|
|
|
|
{
|
|
|
|
|
get { return _tia.IsVSync; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsVBlank
|
|
|
|
|
{
|
|
|
|
|
get { return _tia.IsVBlank; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-11-23 17:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|