Clean up `IDebuggable` impl. for GBHawkLink{,3x,4x}
This commit is contained in:
parent
b36f4aa4ef
commit
ed5a708f93
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -8,27 +8,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|||
{
|
||||
public partial class GBHawkLink : IDebuggable
|
||||
{
|
||||
private const string PFX_L = "Left ";
|
||||
|
||||
private const string PFX_R = "Right ";
|
||||
|
||||
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
var left = L.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("Left " + reg.Key, reg.Value));
|
||||
|
||||
var right = R.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("Right " + reg.Key, reg.Value));
|
||||
|
||||
return left.Union(right).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
Dictionary<string, RegisterValue> dict = new();
|
||||
foreach (var ref in L.GetCpuFlagsAndRegisters()) dict[PFX_L + reg.Key] = reg.Value;
|
||||
foreach (var ref in R.GetCpuFlagsAndRegisters()) dict[PFX_R + reg.Key] = reg.Value;
|
||||
return dict;
|
||||
}
|
||||
|
||||
public void SetCpuRegister(string register, int value)
|
||||
{
|
||||
if (register.StartsWithOrdinal("Left "))
|
||||
{
|
||||
L.SetCpuRegister(register.Replace("Left ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("Right "))
|
||||
{
|
||||
R.SetCpuRegister(register.Replace("Right ", ""), value);
|
||||
}
|
||||
if (register.StartsWithOrdinal(PFX_L)) L.SetCpuRegister(register.Substring(PFX_L.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_R)) R.SetCpuRegister(register.Substring(PFX_R.Length), value);
|
||||
}
|
||||
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -8,34 +8,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x
|
|||
{
|
||||
public partial class GBHawkLink3x : IDebuggable
|
||||
{
|
||||
private const string PFX_C = "Center ";
|
||||
|
||||
private const string PFX_L = "Left ";
|
||||
|
||||
private const string PFX_R = "Right ";
|
||||
|
||||
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
var left = L.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("Left " + reg.Key, reg.Value));
|
||||
|
||||
var center = C.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("Center " + reg.Key, reg.Value));
|
||||
|
||||
var right = R.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("Right " + reg.Key, reg.Value));
|
||||
|
||||
return left.Union(center).Union(right).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
Dictionary<string, RegisterValue> dict = new();
|
||||
foreach (var ref in L.GetCpuFlagsAndRegisters()) dict[PFX_L + reg.Key] = reg.Value;
|
||||
foreach (var ref in C.GetCpuFlagsAndRegisters()) dict[PFX_C + reg.Key] = reg.Value;
|
||||
foreach (var ref in R.GetCpuFlagsAndRegisters()) dict[PFX_R + reg.Key] = reg.Value;
|
||||
return dict;
|
||||
}
|
||||
|
||||
public void SetCpuRegister(string register, int value)
|
||||
{
|
||||
if (register.StartsWithOrdinal("Left "))
|
||||
{
|
||||
L.SetCpuRegister(register.Replace("Left ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("Center "))
|
||||
{
|
||||
C.SetCpuRegister(register.Replace("Center ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("Right "))
|
||||
{
|
||||
R.SetCpuRegister(register.Replace("Right ", ""), value);
|
||||
}
|
||||
if (register.StartsWithOrdinal(PFX_C)) C.SetCpuRegister(register.Substring(PFX_C.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_L)) L.SetCpuRegister(register.Substring(PFX_L.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_R)) R.SetCpuRegister(register.Substring(PFX_R.Length), value);
|
||||
}
|
||||
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
|
@ -8,41 +8,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
|
|||
{
|
||||
public partial class GBHawkLink4x : IDebuggable
|
||||
{
|
||||
private const string PFX_A = "A ";
|
||||
|
||||
private const string PFX_B = "B ";
|
||||
|
||||
private const string PFX_C = "C ";
|
||||
|
||||
private const string PFX_D = "D ";
|
||||
|
||||
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
var a = A.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("A " + reg.Key, reg.Value));
|
||||
|
||||
var b = B.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("B " + reg.Key, reg.Value));
|
||||
|
||||
var c = C.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("C " + reg.Key, reg.Value));
|
||||
|
||||
var d = D.GetCpuFlagsAndRegisters()
|
||||
.Select(reg => new KeyValuePair<string, RegisterValue>("D " + reg.Key, reg.Value));
|
||||
|
||||
return a.Union(b).Union(c).Union(d).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
Dictionary<string, RegisterValue> dict = new();
|
||||
foreach (var ref in A.GetCpuFlagsAndRegisters()) dict[PFX_A + reg.Key] = reg.Value;
|
||||
foreach (var ref in B.GetCpuFlagsAndRegisters()) dict[PFX_B + reg.Key] = reg.Value;
|
||||
foreach (var ref in C.GetCpuFlagsAndRegisters()) dict[PFX_C + reg.Key] = reg.Value;
|
||||
foreach (var ref in D.GetCpuFlagsAndRegisters()) dict[PFX_D + reg.Key] = reg.Value;
|
||||
return dict;
|
||||
}
|
||||
|
||||
public void SetCpuRegister(string register, int value)
|
||||
{
|
||||
if (register.StartsWithOrdinal("A "))
|
||||
{
|
||||
A.SetCpuRegister(register.Replace("A ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("B "))
|
||||
{
|
||||
B.SetCpuRegister(register.Replace("B ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("C "))
|
||||
{
|
||||
C.SetCpuRegister(register.Replace("C ", ""), value);
|
||||
}
|
||||
else if (register.StartsWithOrdinal("D "))
|
||||
{
|
||||
D.SetCpuRegister(register.Replace("D ", ""), value);
|
||||
}
|
||||
if (register.StartsWithOrdinal(PFX_A)) A.SetCpuRegister(register.Substring(PFX_A.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_B)) B.SetCpuRegister(register.Substring(PFX_B.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_C)) C.SetCpuRegister(register.Substring(PFX_C.Length), value);
|
||||
else if (register.StartsWithOrdinal(PFX_D)) D.SetCpuRegister(register.Substring(PFX_D.Length), value);
|
||||
}
|
||||
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });
|
||||
|
|
Loading…
Reference in New Issue