From d03577ade68037367f1f7eb0cb197be7dfba4d3e Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 23 Apr 2017 11:46:37 -0500 Subject: [PATCH] Intellivision - partially implement IDebuggable - flag/register getting and setting, and TotalExecutedCycles --- .../BizHawk.Emulation.Cores.csproj | 3 + BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs | 4 +- .../Intellivision.IDebuggable.cs | 101 ++++++++++++++++++ .../Consoles/Intellivision/Intellivision.cs | 3 +- 4 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index 9d0ef455f7..d4bf566fe4 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -412,6 +412,9 @@ + + Intellivision.cs + Intellivision.cs diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs index f2c908e9c4..84f78002cd 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs @@ -10,9 +10,9 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 private const ushort RESET = 0x1000; private const ushort INTERRUPT = 0x1004; - private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, Interruptible, Interrupted; + internal bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, Interruptible, Interrupted; //private bool MSync; - private ushort[] Register = new ushort[8]; + internal ushort[] Register = new ushort[8]; private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } } private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs new file mode 100644 index 0000000000..d777272bc5 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IDebuggable.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Intellivision +{ + public partial class Intellivision : IDebuggable + { + public IDictionary GetCpuFlagsAndRegisters() + { + return new Dictionary + { + ["R0"] = _cpu.Register[0], + ["R1"] = _cpu.Register[1], + ["R2"] = _cpu.Register[2], + ["R3"] = _cpu.Register[3], + ["R4"] = _cpu.Register[4], + ["R5"] = _cpu.Register[5], + ["R6"] = _cpu.Register[6], + ["R7"] = _cpu.Register[7], + + ["FlagS"] = _cpu.FlagS ? 1 : 0, + ["FlagC"] = _cpu.FlagC ? 1 : 0, + ["FlagZ"] = _cpu.FlagZ ? 1 : 0, + ["FlagO"] = _cpu.FlagO ? 1 : 0, + ["FlagI"] = _cpu.FlagI ? 1 : 0, + ["FlagD"] = _cpu.FlagD ? 1 : 0, + }; + } + + public void SetCpuRegister(string register, int value) + { + switch (register) + { + default: + throw new InvalidOperationException(); + + case "R0": + _cpu.Register[0] = (ushort)value; + break; + case "R1": + _cpu.Register[1] = (ushort)value; + break; + case "R2": + _cpu.Register[2] = (ushort)value; + break; + case "R3": + _cpu.Register[3] = (ushort)value; + break; + case "R4": + _cpu.Register[4] = (ushort)value; + break; + case "R5": + _cpu.Register[5] = (ushort)value; + break; + case "R6": + _cpu.Register[6] = (ushort)value; + break; + case "R7": + _cpu.Register[7] = (ushort)value; + break; + + case "FlagS": + _cpu.FlagS = value > 0; + break; + case "FlagC": + _cpu.FlagC = value > 0; + break; + case "FlagZ": + _cpu.FlagZ = value > 0; + break; + case "FlagO": + _cpu.FlagO = value > 0; + break; + case "FlagI": + _cpu.FlagI = value > 0; + break; + case "FlagD": + _cpu.FlagD = value > 0; + break; + } + } + + [FeatureNotImplemented] + public IMemoryCallbackSystem MemoryCallbacks { get { throw new NotImplementedException(); } } + + public bool CanStep(StepType type) + { + return false; + } + + [FeatureNotImplemented] + public void Step(StepType type) + { + throw new NotImplementedException(); + } + + public int TotalExecutedCycles => _cpu.TotalExecutedCycles; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index d37bcea8c1..5c2525835e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -12,7 +12,8 @@ namespace BizHawk.Emulation.Cores.Intellivision isReleased: true )] [ServiceNotApplicable(typeof(ISaveRam), typeof(IDriveLight), typeof(IRegionable))] - public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable, ISettable + public sealed partial class Intellivision : IEmulator, IStatable, IInputPollable, + IDebuggable, ISettable { [CoreConstructor("INTV")] public Intellivision(CoreComm comm, GameInfo game, byte[] rom, object Settings, object SyncSettings)