diff --git a/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs b/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs
index 8182008bce..8572c9ec3e 100644
--- a/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs
+++ b/src/BizHawk.Emulation.Common/Base Implementations/LinkedDebuggable.cs
@@ -11,36 +11,37 @@ namespace BizHawk.Emulation.Common
///
public class LinkedDebuggable : IDebuggable
{
- private readonly IEmulator[] _linkedCores;
+ private readonly IDebuggable[] _linkedCores;
+
private readonly int _numCores;
- public LinkedDebuggable(IEmulator[] linkedCores, int numCores, MemoryCallbackSystem memoryCallbacks)
+ public LinkedDebuggable(IEnumerable linkedCores, int numCores, MemoryCallbackSystem memoryCallbacks)
{
- _linkedCores = linkedCores;
- _numCores = numCores;
+ _linkedCores = linkedCores.Take(numCores).Select(static core => core.AsDebuggable()).ToArray();
+ _numCores = numCores; // why though?
MemoryCallbacks = memoryCallbacks;
}
public IDictionary GetCpuFlagsAndRegisters()
{
- var ret = new List>();
-
+ Dictionary dict = new();
for (int i = 0; i < _numCores; i++)
{
- ret.AddRange(_linkedCores[i].AsDebuggable().GetCpuFlagsAndRegisters()
- .Select(reg => new KeyValuePair($"P{i + 1} " + reg.Key, reg.Value)).ToList());
+ var pfx = $"P{i + 1} ";
+ foreach (var reg in _linkedCores[i].GetCpuFlagsAndRegisters()) dict[pfx + reg.Key] = reg.Value;
}
-
- return ret.ToDictionary(pair => pair.Key, pair => pair.Value);
+ return dict;
}
public void SetCpuRegister(string register, int value)
{
for (int i = 0; i < _numCores; i++)
{
- if (register.StartsWithOrdinal($"P{i + 1} "))
+ var pfx = $"P{i + 1} ";
+ if (register.StartsWithOrdinal(pfx))
{
- _linkedCores[i].AsDebuggable().SetCpuRegister(register.Replace($"P{i + 1} ", ""), value);
+ _linkedCores[i].SetCpuRegister(register.Substring(pfx.Length), value);
+ return;
}
}
}