From 4973e3eba1f8c5b9d49bac78186032a4abb0dc7c Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 1 Aug 2021 21:36:45 +1000 Subject: [PATCH] Refactor ITraceable and related types --- .../CallbackBasedTraceBuffer.cs | 21 ++---- .../Base Implementations/TraceBuffer.cs | 15 ++--- src/BizHawk.Emulation.Common/Extensions.cs | 5 ++ .../Interfaces/Services/ITraceable.cs | 32 ++++----- .../CPUs/CP1610/CP1610.Execute.cs | 13 ++-- .../CPUs/HuC6280/HuC6280.cs | 12 ++-- .../CPUs/Intel8048/I8048.cs | 17 ++--- .../CPUs/LR35902/LR35902.cs | 66 ++++--------------- .../CPUs/MC6800/MC6800.cs | 21 +++--- .../CPUs/MC6809/MC6809.cs | 31 ++++----- .../CPUs/MOS 6502X/Execute.cs | 13 +--- .../CPUs/MOS 6502X/MOS6502X.cs | 18 ++--- src/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs | 14 ++-- .../Calculator/TI83.IEmulator.cs | 2 +- .../Calculator/TI83.cs | 2 +- .../AmstradCPC/AmstradCPC.IEmulator.cs | 2 +- .../Computers/AmstradCPC/AmstradCPC.cs | 2 +- .../Computers/AppleII/AppleII.IDebuggable.cs | 2 +- .../Computers/AppleII/AppleII.cs | 16 ++--- .../Computers/Commodore64/C64.IEmulator.cs | 2 +- .../Computers/Commodore64/C64.cs | 2 +- .../Computers/MSX/MSX.IEmulator.cs | 2 +- .../Computers/MSX/MSX.cs | 8 +-- .../SinclairSpectrum/ZXSpectrum.IEmulator.cs | 2 +- .../Computers/SinclairSpectrum/ZXSpectrum.cs | 2 +- .../Consoles/Atari/2600/Atari2600.Core.cs | 2 +- .../Consoles/Atari/2600/Atari2600.cs | 2 +- .../Atari/A7800Hawk/A7800Hawk.IEmulator.cs | 2 +- .../Consoles/Atari/A7800Hawk/A7800Hawk.cs | 2 +- .../Consoles/Coleco/ColecoVision.IEmulator.cs | 2 +- .../Consoles/Coleco/ColecoVision.cs | 5 +- .../Fairchild/ChannelF/ChannelF.IEmulator.cs | 2 +- .../Consoles/Fairchild/ChannelF/ChannelF.cs | 2 +- .../Consoles/Fairchild/ChannelF/F8/F3850.cs | 11 ++-- .../GCE/Vectrex/VectrexHawk.IEmulator.cs | 2 +- .../Consoles/GCE/Vectrex/VectrexHawk.cs | 2 +- .../Intellivision/Intellivision.IEmulator.cs | 2 +- .../Consoles/Intellivision/Intellivision.cs | 2 +- .../Magnavox/Odyssey2/O2Hawk.IEmulator.cs | 2 +- .../Consoles/Magnavox/Odyssey2/O2Hawk.cs | 2 +- .../Nintendo/BSNES/BsnesCore.IEmulator.cs | 2 +- .../Consoles/Nintendo/BSNES/BsnesCore.cs | 14 +--- .../Consoles/Nintendo/GBA/MGBAHawk.cs | 16 ++--- .../Nintendo/GBHawk/GBHawk.IEmulator.cs | 2 +- .../Consoles/Nintendo/GBHawk/GBHawk.cs | 2 +- .../GBHawkLink/GBHawkLink.IEmulator.cs | 2 +- .../Nintendo/GBHawkLink/GBHawkLink.cs | 2 +- .../GBHawkLink3x/GBHawkLink3x.IEmulator.cs | 2 +- .../Nintendo/GBHawkLink3x/GBHawkLink3x.cs | 2 +- .../GBHawkLink4x/GBHawkLink4x.IEmulator.cs | 2 +- .../Nintendo/GBHawkLink4x/GBHawkLink4x.cs | 2 +- .../Nintendo/Gameboy/Gambatte.ITraceable.cs | 20 +++--- .../Consoles/Nintendo/Gameboy/Gambatte.cs | 8 +-- .../Consoles/Nintendo/N64/N64.ITraceable.cs | 11 +--- .../Consoles/Nintendo/N64/N64.cs | 9 +-- .../Consoles/Nintendo/NES/NES.Core.cs | 2 +- .../Consoles/Nintendo/NES/NES.cs | 2 +- .../Nintendo/QuickNES/QuickNES.ITraceable.cs | 12 ++-- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 2 +- .../Nintendo/SNES/LibsnesCore.IEmulator.cs | 2 +- .../Consoles/Nintendo/SNES/LibsnesCore.cs | 29 ++------ .../Nintendo/SubGBHawk/SubGBHawk.IEmulator.cs | 2 +- .../Consoles/Nintendo/SubGBHawk/SubGBHawk.cs | 2 +- .../SubNESHawk/SubNESHawk.IEmulator.cs | 2 +- .../Nintendo/SubNESHawk/SubNESHawk.cs | 3 +- .../Consoles/PC Engine/PCEngine.IEmulator.cs | 2 +- .../Consoles/PC Engine/PCEngine.cs | 8 +-- .../Sega/GGHawkLink/GGHawkLink.IEmulator.cs | 2 +- .../Consoles/Sega/GGHawkLink/GGHawkLink.cs | 2 +- .../Consoles/Sega/SMS/SMS.IEmulator.cs | 2 +- .../Consoles/Sega/SMS/SMS.cs | 2 +- .../Consoles/Sega/gpgx64/GPGX.ITraceable.cs | 16 ++--- .../Consoles/Sony/PSX/Octoshock.ITraceable.cs | 10 +-- .../Consoles/Sony/PSX/Octoshock.cs | 2 +- 74 files changed, 190 insertions(+), 374 deletions(-) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 4b515e2e54..c57fbccb90 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -15,8 +15,10 @@ namespace BizHawk.Emulation.Common /// public abstract class CallbackBasedTraceBuffer : ITraceable { + private const string DEFAULT_HEADER = "Instructions"; + /// does not provide memory callback support or does not implement - protected CallbackBasedTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler) + protected CallbackBasedTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler, string header = DEFAULT_HEADER) { if (!debuggableCore.MemoryCallbacksAvailable()) { @@ -32,7 +34,7 @@ namespace BizHawk.Emulation.Common throw new InvalidOperationException($"{nameof(IDebuggable.GetCpuFlagsAndRegisters)} is required"); } - Header = "Instructions"; + Header = header; DebuggableCore = debuggableCore; MemoryDomains = memoryDomains; Disassembler = disassembler; @@ -48,20 +50,9 @@ namespace BizHawk.Emulation.Common private ITraceSink _sink; - public bool Enabled => Sink != null; - - public void Put(TraceInfo info) - { - Sink.Put(info); - } - public ITraceSink Sink { - private get - { - return _sink; - } - + get => _sink; set { _sink = value; @@ -75,7 +66,7 @@ namespace BizHawk.Emulation.Common } } - public string Header { get; protected set; } + public string Header { get; } private class TracingMemoryCallback : IMemoryCallback { diff --git a/src/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs b/src/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs index 8ecf461696..1b8b7ed131 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/TraceBuffer.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace BizHawk.Emulation.Common +namespace BizHawk.Emulation.Common { /// /// A generic implementation of ITraceable that can be used by any core @@ -8,15 +6,12 @@ namespace BizHawk.Emulation.Common /// public class TraceBuffer : ITraceable { - public string Header { get; set; } = "Instructions"; + private const string DEFAULT_HEADER = "Instructions"; - public ITraceSink Sink { private get; set; } + public string Header { get; } - public bool Enabled => Sink != null; + public ITraceSink? Sink { get; set; } - public void Put(TraceInfo info) - { - Sink.Put(info); - } + public TraceBuffer(string header = DEFAULT_HEADER) => Header = header; } } diff --git a/src/BizHawk.Emulation.Common/Extensions.cs b/src/BizHawk.Emulation.Common/Extensions.cs index b25044c80a..3bf7318180 100644 --- a/src/BizHawk.Emulation.Common/Extensions.cs +++ b/src/BizHawk.Emulation.Common/Extensions.cs @@ -484,5 +484,10 @@ namespace BizHawk.Emulation.Common public static string SystemIDToDisplayName(string sysID) => SystemIDDisplayNames.TryGetValue(sysID, out var dispName) ? dispName : string.Empty; + + public static bool IsEnabled(this ITraceable core) => core.Sink is not null; + + /// TODO no-op instead of NRE when not "enabled"? + public static void Put(this ITraceable core, TraceInfo info) => core.Sink.Put(info); } } diff --git a/src/BizHawk.Emulation.Common/Interfaces/Services/ITraceable.cs b/src/BizHawk.Emulation.Common/Interfaces/Services/ITraceable.cs index e78341464f..112e3047c3 100644 --- a/src/BizHawk.Emulation.Common/Interfaces/Services/ITraceable.cs +++ b/src/BizHawk.Emulation.Common/Interfaces/Services/ITraceable.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace BizHawk.Emulation.Common +namespace BizHawk.Emulation.Common { public interface ITraceSink { @@ -23,25 +21,19 @@ namespace BizHawk.Emulation.Common /// that's right, we can only have one sink. /// a sink can route to two other sinks if it has to, though /// - ITraceSink Sink { set; } - - /// - /// Gets a value indicating whether tracing is enabled - /// This is defined as equivalent to Sink != null - /// It's put here because it's such a common operation to check whether it's enabled, and it's not nice to write Sink != null all over - /// - bool Enabled { get; } - - /// - /// This is defined as equivalent to Sink.Put - /// TBD: could it be defined as equivalent to if(Enabled) Sink.Put()? Probably not, that's just a small amount of wasted work - /// - void Put(TraceInfo info); + ITraceSink? Sink { get; set; } } - public class TraceInfo + public readonly struct TraceInfo { - public string Disassembly { get; set; } - public string RegisterInfo { get; set; } + public readonly string Disassembly; + + public readonly string RegisterInfo; + + public TraceInfo(string disassembly, string registerInfo) + { + Disassembly = disassembly; + RegisterInfo = registerInfo; + } } } diff --git a/src/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs b/src/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs index 51621374cd..f54501250f 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs @@ -19,11 +19,9 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 public int opcode; public TraceInfo CP1610State(bool disassemble = true) - { - return new TraceInfo - { - Disassembly = $"{RegisterPC - 1:X4}: {opcode:X2} {(disassemble ? Disassemble((ushort)(RegisterPC - 1), out _) : "---")} ".PadRight(26), - RegisterInfo = string.Join(" ", + => new( + disassembly: $"{RegisterPC - 1:X4}: {opcode:X2} {(disassemble ? Disassemble((ushort)(RegisterPC - 1), out _) : "---")} ".PadRight(26), + registerInfo: string.Join(" ", new[] { $"Cy:{TotalExecutedCycles}", @@ -34,10 +32,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 FlagO ? "O" : "o", FlagI ? "I" : "i", FlagD ? "D" : "d") - } - .Concat(Register.Select((r, i) => $"R{i}:{4:X4}"))) - }; - } + }.Concat(Register.Select((r, i) => $"R{i}:{4:X4}")))); private void Calc_FlagC(int result) { diff --git a/src/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/src/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index bead4faf0b..f17360fa68 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -381,11 +381,9 @@ namespace BizHawk.Emulation.Cores.Components.H6280 public string TraceHeader => "HuC6280: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP, Cy), flags (NVTBDIZC)"; public TraceInfo State() - { - return new TraceInfo - { - Disassembly = $"{MPR[PC >> 13]:X2}:{PC:X4}: {ReadMemory(PC):X2} {Disassemble(PC, out _)} ".PadRight(30), - RegisterInfo = string.Join(" ", + => new( + disassembly: $"{MPR[PC >> 13]:X2}:{PC:X4}: {ReadMemory(PC):X2} {Disassemble(PC, out _)} ".PadRight(30), + registerInfo: string.Join(" ", $"A:{A:X2}", $"X:{X:X2}", $"Y:{Y:X2}", @@ -400,9 +398,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 FlagD ? "D" : "d", FlagI ? "I" : "i", FlagZ ? "Z" : "z", - FlagC ? "C" : "c")) - }; - } + FlagC ? "C" : "c"))); private static readonly byte[] TableNZ = { diff --git a/src/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs b/src/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs index c0de2f215a..0badf0243b 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs @@ -448,7 +448,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 { IRQPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); IRQ_(0); IRQCallback(); @@ -458,7 +458,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 { TIRQPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====TIRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====TIRQ====", registerInfo: string.Empty)); IRQ_(1); IRQCallback(); @@ -522,11 +522,9 @@ namespace BizHawk.Emulation.Cores.Components.I8048 public string TraceHeader => "I8048: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (CAFBIFT0T1TFR)"; public TraceInfo State(bool disassemble = true) - { - return new TraceInfo - { - Disassembly = $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), - RegisterInfo = string.Format( + => new( + disassembly: $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), + registerInfo: string.Format( "A:{0:X2} R0:{1:X2} R1:{2:X2} R2:{3:X2} R3:{4:X2} R4:{5:X2} R5:{6:X2} R6:{7:X2} R7:{8:X2} PSW:{9:X4} Cy:{10} LY:{11} {12}{13}{14}{15}{16}{17}{18}{19}{20}{21}{22}", Regs[A], Regs[(ushort)(R0 + RB)], @@ -550,10 +548,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 T0 ? "T" : "t", T1 ? "T" : "t", TF ? "T" : "t", - RB > 0 ? "R" : "r" - ) - }; - } + RB > 0 ? "R" : "r")); /// /// Optimization method to set cur_instr diff --git a/src/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs b/src/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs index 9af8155ea7..902936a04d 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -164,11 +164,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { interrupts_enabled = false; - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); // call interrupt processor // lowest bit set is highest priority @@ -333,11 +329,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { interrupts_enabled = false; - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); RegPC--; @@ -347,11 +339,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====un-halted====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====un-halted====", registerInfo: string.Empty)); OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State(useRGBDSSyntax)); @@ -364,11 +352,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { interrupts_enabled = false; - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); halted = false; if (Halt_bug_4) @@ -407,11 +391,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 else if (temp) { // even if interrupt servicing is disabled, any interrupt flag raised still resumes execution - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====un-halted====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====un-halted====", registerInfo: string.Empty)); halted = false; if (is_GBC) @@ -493,21 +473,13 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 interrupts_enabled = false; I_use = false; - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====un-stop====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====un-stop====", registerInfo: string.Empty)); stopped = false; stop_check = false; stop_time = 0; - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); // call interrupt processor // lowest bit set is highest priority @@ -527,11 +499,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 if (stop_time == 0) { - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====un-stop====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====un-stop====", registerInfo: string.Empty)); stopped = false; @@ -555,11 +523,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 if ((buttons_pressed & 0xF) != 0xF) { // TODO: On a gameboy, you can only un-STOP once, needs further testing - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====un-stop====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====un-stop====", registerInfo: string.Empty)); stopped = false; OnExecFetch?.Invoke(RegPC); @@ -753,11 +717,9 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 public string TraceHeader => "LR35902: PC, machine code, mnemonic, operands, registers (A, F, B, C, D, E, H, L, SP), Cy, flags (ZNHCI)"; public TraceInfo State(bool useRGBDSSyntax, bool disassemble = true) - { - return new TraceInfo - { - Disassembly = $"{(disassemble ? Disassemble(RegPC, ReadMemory, useRGBDSSyntax, out _) : "---")} ".PadRight(40), - RegisterInfo = string.Join(" ", + => new( + disassembly: $"{(disassemble ? Disassemble(RegPC, ReadMemory, useRGBDSSyntax, out _) : "---")} ".PadRight(40), + registerInfo: string.Join(" ", $"A:{Regs[A]:X2}", $"F:{Regs[F]:X2}", $"B:{Regs[B]:X2}", @@ -775,9 +737,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 FlagH ? "H" : "h", FlagC ? "C" : "c", FlagI ? "I" : "i", - interrupts_enabled ? "E" : "e")) - }; - } + interrupts_enabled ? "E" : "e"))); private void FetchInstruction(int op) { diff --git a/src/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs b/src/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs index 25140a1f59..407578349f 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs @@ -433,7 +433,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====CWAI NMI====", registerInfo: string.Empty)); } else if (IRQPending && !FlagI) { @@ -446,7 +446,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====CWAI IRQ====", registerInfo: string.Empty)); } else { @@ -465,7 +465,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 { NMIPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====NMI====", registerInfo: string.Empty)); NMI_(); NMICallback(); @@ -476,7 +476,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 { IRQPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); IRQ_(); IRQCallback(); @@ -501,11 +501,9 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, SP, CC), Cy, flags (EHINZVC)"; public TraceInfo State(bool disassemble = true) - { - return new TraceInfo - { - Disassembly = $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), - RegisterInfo = string.Format( + => new( + disassembly: $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), + registerInfo: string.Format( "A:{0:X2} B:{1:X2} X:{2:X4} SP:{3:X4} CC:{4:X2} Cy:{5} {6}{7}{8}{9}{10}{11}", Regs[A], Regs[B], @@ -518,10 +516,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 FlagN ? "N" : "n", FlagZ ? "Z" : "z", FlagV ? "V" : "v", - FlagC ? "C" : "c" - ) - }; - } + FlagC ? "C" : "c")); /// /// Optimization method to set cur_instr diff --git a/src/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs b/src/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs index e7c9b46484..00ee253c9c 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs @@ -473,7 +473,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====CWAI NMI====", registerInfo: string.Empty)); } else if (FIRQPending && !FlagF) { @@ -486,7 +486,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI FIRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====CWAI FIRQ====", registerInfo: string.Empty)); } else if (IRQPending && !FlagI) { @@ -499,7 +499,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====CWAI IRQ====", registerInfo: string.Empty)); } else { @@ -522,7 +522,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====SYNC NMI====", registerInfo: string.Empty)); } else if (FIRQPending) { @@ -537,7 +537,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC FIRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====SYNC FIRQ====", registerInfo: string.Empty)); } else { @@ -563,7 +563,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====SYNC IRQ====", registerInfo: string.Empty)); } else { @@ -593,7 +593,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { NMIPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====NMI====", registerInfo: string.Empty)); NMI_(); NMICallback(); @@ -604,7 +604,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { FIRQPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====FIRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====FIRQ====", registerInfo: string.Empty)); FIRQ_(); FIRQCallback(); @@ -615,7 +615,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { IRQPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); IRQ_(); IRQCallback(); instr_pntr = irq_pntr = 0; @@ -639,11 +639,9 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (EFHINZVC)"; public TraceInfo State(bool disassemble = true) - { - return new TraceInfo - { - Disassembly = $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), - RegisterInfo = string.Format( + => new( + disassembly: $"{(disassemble ? Disassemble(Regs[PC], ReadMemory, out _) : "---")} ".PadRight(50), + registerInfo: string.Format( "A:{0:X2} B:{1:X2} X:{2:X4} Y:{3:X4} US:{4:X4} SP:{5:X4} DP:{6:X2} CC:{7:X2} Cy:{8} {9}{10}{11}{12}{13}{14}{15}{16}", Regs[A], Regs[B], @@ -661,10 +659,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 FlagN ? "N" : "n", FlagZ ? "Z" : "z", FlagV ? "V" : "v", - FlagC ? "C" : "c" - ) - }; - } + FlagC ? "C" : "c")); /// /// Optimization method to set cur_instr diff --git a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs index fdd7483ff6..9896ad40f4 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs @@ -561,12 +561,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 interrupt_pending = false; if (NMI) { - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====NMI====", - RegisterInfo = "" - }); - + TraceCallback?.Invoke(new(disassembly: "====NMI====", registerInfo: string.Empty)); ea = NMIVector; opcode = VOP_NMI; NMI = false; @@ -577,11 +572,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 if (IRQ && !my_iflag) { - TraceCallback?.Invoke(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); ea = IRQVector; opcode = VOP_IRQ; mi = 0; diff --git a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 7f26cc1f35..5f58193b05 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -94,13 +94,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 public TraceInfo State(bool disassemble = true) { - if (!disassemble) - { - return new TraceInfo { - Disassembly = "", - RegisterInfo = "" - }; - } + if (!disassemble) return new(disassembly: string.Empty, registerInfo: string.Empty); string rawbytes = ""; string disasm = Disassemble(PC, out var length); @@ -110,10 +104,9 @@ namespace BizHawk.Emulation.Cores.Components.M6502 rawbytes += $" {_link.PeekMemory((ushort)(PC + i)):X2}"; } - return new TraceInfo - { - Disassembly = $"{PC:X4}: {rawbytes,-9} {disasm} ".PadRight(32), - RegisterInfo = string.Join(" ", + return new( + disassembly: $"{PC:X4}: {rawbytes,-9} {disasm} ".PadRight(32), + registerInfo: string.Join(" ", $"A:{A:X2}", $"X:{X:X2}", $"Y:{Y:X2}", @@ -131,8 +124,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 // !RDY ? "R" : "r" ), $"Cy:{TotalExecutedCycles}", - $"PPU-Cy:{ext_ppu_cycle}") - }; + $"PPU-Cy:{ext_ppu_cycle}")); } public bool AtStart => opcode == VOP_Fetch1 || Microcode[opcode][mi] >= Uop.End; diff --git a/src/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/src/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 8f7cc33938..75181abe6d 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -775,7 +775,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { nonMaskableInterruptPending = false; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====NMI====", registerInfo: string.Empty)); iff2 = iff1; iff1 = false; @@ -796,7 +796,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A iff1 = iff2 = false; EI_pending = 0; - TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); + TraceCallback?.Invoke(new(disassembly: "====IRQ====", registerInfo: string.Empty)); switch (interruptMode) { @@ -867,10 +867,9 @@ namespace BizHawk.Emulation.Cores.Components.Z80A } } - return new TraceInfo - { - Disassembly = $"{RegPC:X4}: {byte_code.PadRight(12)} {disasm.PadRight(26)}", - RegisterInfo = string.Join(" ", + return new( + disassembly: $"{RegPC:X4}: {byte_code.PadRight(12)} {disasm.PadRight(26)}", + registerInfo: string.Join(" ", $"AF:{(Regs[A] << 8) + Regs[F]:X4}", $"BC:{(Regs[B] << 8) + Regs[C]:X4}", $"DE:{(Regs[D] << 8) + Regs[E]:X4}", @@ -888,8 +887,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A Flag5 ? "5" : "-", FlagZ ? "Z" : "z", FlagS ? "S" : "s", - FlagI ? "E" : "e")) - }; + FlagI ? "E" : "e"))); } /// diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs index f87becf7b3..7b101fe099 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Calculators _controller = controller; _lagged = true; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs index 4c5f229092..4641aac1ca 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Calculators HardReset(); SetupMemoryDomains(); - _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; + _tracer = new TraceBuffer(_cpu.TraceHeader); ser.Register(_tracer); ser.Register(_cpu); diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs index 71422a0b69..323bdfb869 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _isLag = true; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs index 8bc7fda372..58549b1474 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC CoreComm = lp.Comm; _gameInfo = lp.Roms.Select(r => r.Game).ToList(); _cpu = new Z80A(); - _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; + _tracer = new TraceBuffer(_cpu.TraceHeader); _files = lp.Roms.Select(r => r.RomData).ToList(); var settings = lp.Settings ?? new AmstradCPCSettings(); diff --git a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs index b143d24417..9566f1b14a 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs @@ -139,7 +139,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII private void StepInto() { - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _machine.Cpu.TraceCallback = TracerWrapper; } diff --git a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index d2c4372f86..ab8f5d8640 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -24,10 +24,8 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII var ser = new BasicServiceProvider(this); ServiceProvider = ser; - _tracer = new TraceBuffer - { - Header = "6502: PC, opcode, register (A, X, Y, P, SP, Cy), flags (NVTBDIZC)" - }; + const string TRACE_HEADER = "6502: PC, opcode, register (A, X, Y, P, SP, Cy), flags (NVTBDIZC)"; + _tracer = new TraceBuffer(TRACE_HEADER); _disk1 = _romSet[0]; @@ -121,17 +119,11 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII private bool _prevPressed; private void TracerWrapper(string[] content) - { - _tracer.Put(new TraceInfo - { - Disassembly = content[0], - RegisterInfo = content[1] - }); - } + => _tracer.Put(new(disassembly: content[0], registerInfo: content[1])); private void FrameAdv(IController controller, bool render, bool renderSound) { - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _machine.Cpu.TraceCallback = TracerWrapper; } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs index 31c60bbb4d..5cb70d7064 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { _board.Controller = controller; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _board.Cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index a5909112af..7e72c1a0a4 100644 --- a/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/src/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -54,7 +54,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ser.Register(_board.Vic); ser.Register(this); - _tracer = new TraceBuffer { Header = _board.Cpu.TraceHeader }; + _tracer = new TraceBuffer(_board.Cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); diff --git a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs index 199fd5d5f6..feca758d61 100644 --- a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs @@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX if (current_controller == MSXControllerKB) { kb_rows_check(controller); } - if (Tracer.Enabled) + if (Tracer.IsEnabled()) { tracecb = MakeTrace; } diff --git a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs index f88662b74c..8cf843bfce 100644 --- a/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs +++ b/src/BizHawk.Emulation.Cores/Computers/MSX/MSX.cs @@ -81,7 +81,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX Console.WriteLine(Header_Length + " " + Disasm_Length + " " + Reg_String_Length); - Tracer = new TraceBuffer { Header = newHeader.ToString() }; + Tracer = new TraceBuffer(newHeader.ToString()); var serviceProvider = ServiceProvider as BasicServiceProvider; serviceProvider.Register(Tracer); @@ -132,11 +132,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX LibMSX.MSX_getdisassembly(MSX_Pntr, new_d, t, Disasm_Length); LibMSX.MSX_getregisterstate(MSX_Pntr, new_r, t, Reg_String_Length); - Tracer.Put(new TraceInfo - { - Disassembly = new_d.ToString().PadRight(36), - RegisterInfo = new_r.ToString() - }); + Tracer.Put(new(disassembly: new_d.ToString().PadRight(36), registerInfo: new_r.ToString())); } private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs index 8d8ca3e203..123c2ba263 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _isLag = true; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index bb650f5c47..487a675b07 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _cpu = new Z80A(); - _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; + _tracer = new TraceBuffer(_cpu.TraceHeader); _files = lp.Roms.Select(r => r.RomData).ToList(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs index 6553a39267..4b4a958b40 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs @@ -317,7 +317,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (cyc_counter == 3) { _m6532.Timer.Tick(); - if (Tracer.Enabled && Cpu.AtStart) + if (Tracer.IsEnabled() && Cpu.AtStart) { Tracer.Put(Cpu.TraceState()); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index edb1f4b7d5..e8c6b10593 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 RebootCore(); SetupMemoryDomains(); - Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; + Tracer = new TraceBuffer(Cpu.TraceHeader); ser.Register(Cpu); ser.Register(Tracer); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs index 4e7608745d..4b811bf834 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs @@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public bool FrameAdvance(IController controller, bool render, bool renderSound) { - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index 4deeb7d370..9b19670c79 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -261,7 +261,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk ser.Register(this); ServiceProvider = ser; - _tracer = new TraceBuffer { Header = cpu.TraceHeader }; + _tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); SetupMemoryDomains(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs index 34a8e09d5c..81e70e8c9d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision } _isLag = true; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 24e8b47401..4e08d4fb7a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -57,15 +57,14 @@ namespace BizHawk.Emulation.Cores.ColecoVision LoadRom(rom, skipBios); SetupMemoryDomains(); - _tracer.Header = _cpu.TraceHeader; ser.Register(_cpu); - ser.Register(_tracer); + ser.Register(_tracer = new TraceBuffer(_cpu.TraceHeader)); } private readonly Z80A _cpu; private readonly TMS9918A _vdp; private readonly byte[] _biosRom; - private readonly TraceBuffer _tracer = new TraceBuffer(); + private readonly TraceBuffer _tracer; private byte[] _romData; private byte[] _ram = new byte[1024]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs index c3a46802bb..692c346811 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs @@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF _controller = controller; _isLag = false; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { CPU.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs index 5e83197960..a70d4673e7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF DummyReadMemory = ReadBus }; - _tracer = new TraceBuffer { Header = CPU.TraceHeader }; + _tracer = new TraceBuffer(CPU.TraceHeader); var bios01 = comm.CoreFileProvider.GetFirmwareOrThrow(new("ChannelF", "ChannelF_sl131253")); var bios02 = comm.CoreFileProvider.GetFirmwareOrThrow(new("ChannelF", "ChannelF_sl131254")); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs index 06a9f9dc3b..1bbf017b6b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs @@ -723,14 +723,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF } } - return new TraceInfo - { - Disassembly = string.Format( + return new( + disassembly: string.Format( "{0:X4}: {1} {2}", pc, byte_code.PadRight(12), disasm.PadRight(26)), - RegisterInfo = string.Format( + registerInfo: string.Format( "Flags:{75}{76}{77}{78}{79} " + "PC1:{0:X4} DC0:{1:X4} A:{2:X2} ISAR:{3:X2} DB:{4:X2} IO:{5:X2} J:{6:X2} H:{7:X4} K:{8:X4} Q:{9:X4} " + "R0:{10:X2} R1:{11:X2} R2:{12:X2} R3:{13:X2} R4:{14:X2} R5:{15:X2} R6:{16:X2} R7:{17:X2} R8:{18:X2} R9:{19:X2} " + @@ -763,9 +762,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF FlagO ? "O" : "o", FlagZ ? "Z" : "z", FlagC ? "C" : "c", - FlagS ? "S" : "s"), - - }; + FlagS ? "S" : "s")); } /// diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs index 37679fc028..2fa297ddb9 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public bool FrameAdvance(IController controller, bool render, bool rendersound) { - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs index 8d7731c666..27cd16e360 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs @@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex _settings = new object(); // TODO: wtf is this _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); - _tracer = new TraceBuffer { Header = cpu.TraceHeader }; + _tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); SetupMemoryDomains(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs index 4c5ddba371..589d9849e0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public bool FrameAdvance(IController controller, bool render, bool renderSound) { - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index f3ff476e0f..6c0f692b75 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Intellivision LoadExecutiveRom(comm.CoreFileProvider.GetFirmwareOrThrow(new("INTV", "EROM"), "Executive ROM is required.")); LoadGraphicsRom(comm.CoreFileProvider.GetFirmwareOrThrow(new("INTV", "GROM"), "Graphics ROM is required.")); - _tracer = new TraceBuffer { Header = _cpu.TraceHeader }; + _tracer = new TraceBuffer(_cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); SetupMemoryDomains(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs index ca257c3b11..9175a52b68 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { //Console.WriteLine("-----------------------FRAME-----------------------"); - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs index 9c790e4f09..f335fc6298 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs @@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk ser.Register(this); ServiceProvider = ser; - _tracer = new TraceBuffer { Header = cpu.TraceHeader }; + _tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); SetupMemoryDomains(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs index 0267eecb2a..bebcba4ab1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.IEmulator.cs @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES }; // TODO: I really don't think stuff like this should be set every single frame (only on change) Api.core.snes_set_layer_enables(ref enables); - Api.core.snes_set_trace_enabled(_tracer.Enabled); + Api.core.snes_set_trace_enabled(_tracer.IsEnabled()); Api.core.snes_set_video_enabled(render); Api.core.snes_set_audio_enabled(renderSound); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs index 3d49712fad..bbb9e136fe 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs @@ -138,10 +138,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES SetMemoryDomains(); - _tracer = new TraceBuffer - { - Header = "65816: PC, mnemonic, operands, registers (A, X, Y, S, D, B, flags (NVMXDIZC), V, H)" - }; + const string TRACE_HEADER = "65816: PC, mnemonic, operands, registers (A, X, Y, S, D, B, flags (NVMXDIZC), V, H)"; + _tracer = new TraceBuffer(TRACE_HEADER); ser.Register(new W65816_DisassemblerService()); ser.Register(_tracer); @@ -381,12 +379,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES } private void snes_trace(string disassembly, string registerInfo) - { - _tracer.Put(new TraceInfo - { - Disassembly = disassembly, - RegisterInfo = registerInfo - }); - } + => _tracer.Put(new(disassembly: disassembly, registerInfo: registerInfo)); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index a959ce9698..958e551612 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -66,10 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA ServiceProvider = ser; PutSettings(_settings); - Tracer = new TraceBuffer - { - Header = "ARM7: PC, machine code, mnemonic, operands, registers" - }; + const string TRACE_HEADER = "ARM7: PC, machine code, mnemonic, operands, registers"; + Tracer = new TraceBuffer(TRACE_HEADER); _tracecb = msg => Tracer.Put(_traceInfo(msg)); ser.Register(Tracer); MemoryCallbacks = new MGBAMemoryCallbackSystem(this); @@ -107,11 +105,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA sb.Append($" { RegisterNames[i] }:{ regs[RegisterNames[i]].Value:X8}"); } - return new TraceInfo - { - Disassembly = $"{pc:X8}: { machineCode } { instruction }".PadRight(50), - RegisterInfo = sb.ToString() - }; + return new( + disassembly: $"{pc:X8}: { machineCode } { instruction }".PadRight(50), + registerInfo: sb.ToString()); } public bool FrameAdvance(IController controller, bool render, bool renderSound = true) @@ -124,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA WireMemoryDomainPointers(); } - LibmGBA.BizSetTraceCallback(Core, Tracer.Enabled ? _tracecb : null); + LibmGBA.BizSetTraceCallback(Core, Tracer.IsEnabled() ? _tracecb : null); IsLagFrame = LibmGBA.BizAdvance( Core, diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index bbe6af7b5a..315ac5361d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk ppu.color_palette[3] = color_palette_Gr[3]; } - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index d8e7d8548b..e362ecb8c6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -187,7 +187,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk _ = PutSettings(settings ?? new GBSettings()); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); - _tracer = new TraceBuffer { Header = cpu.TraceHeader }; + _tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(_tracer); ser.Register(new StateSerializer(SyncState)); ser.Register(_disassembler); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs index 3b3b736e3b..1b6a7c91a8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs @@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink R.ppu.color_palette[3] = color_palette_Gr[3]; } - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { L.cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index f059dfc388..c248243e9f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink ser.Register(this); ser.Register(this); - _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; + _tracer = new TraceBuffer(L.cpu.TraceHeader); ser.Register(_tracer); _lStates = L.ServiceProvider.GetService(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs index bd113eb7b4..9c42ec885b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs @@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x R.ppu.color_palette[3] = color_palette_Gr[3]; } - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { L.cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs index 8abd707e6c..74036426d1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs @@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x ser.Register(this); ser.Register(this); - _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; + _tracer = new TraceBuffer(L.cpu.TraceHeader); ser.Register(_tracer); _lStates = L.ServiceProvider.GetService(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs index e80c8d0867..1c0d467006 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs @@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x D.ppu.color_palette[3] = color_palette_Gr[3]; } - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { A.cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs index 260977e246..cd25ca2324 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs @@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x ser.Register(this); ser.Register(this); - _tracer = new TraceBuffer { Header = A.cpu.TraceHeader }; + _tracer = new TraceBuffer(A.cpu.TraceHeader); ser.Register(_tracer); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ITraceable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ITraceable.cs index 10d78f562a..b0f33766d0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ITraceable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ITraceable.cs @@ -15,16 +15,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy int[] s = new int[14]; System.Runtime.InteropServices.Marshal.Copy(_s, s, 0, 14); - Tracer.Put(new TraceInfo - { - Disassembly = - LR35902.Disassemble( - (ushort) s[1], - addr => (addr == (ushort)s[1]) ? (byte)((s[12] >> 16) & 0xFF) : ((addr == (ushort)s[1] + 1) ? (byte)((s[12] >> 8) & 0xFF) : (byte)(s[12] & 0xFF)), - _settings.RgbdsSyntax, - out _).PadRight(36), - RegisterInfo = - string.Format( + Tracer.Put(new( + disassembly: LR35902.Disassemble( + (ushort) s[1], + addr => (addr == (ushort)s[1]) ? (byte)((s[12] >> 16) & 0xFF) : ((addr == (ushort)s[1] + 1) ? (byte)((s[12] >> 8) & 0xFF) : (byte)(s[12] & 0xFF)), + _settings.RgbdsSyntax, + out _).PadRight(36), + registerInfo: string.Format( "A:{3:x2} F:{8:x2} B:{4:x2} C:{5:x2} D:{6:x2} E:{7:x2} H:{9:x2} L:{10:x2} LY:{13:x2} SP:{2:x2} {11} Cy:{0}", s[0], s[1] & 0xffff, @@ -39,8 +36,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy s[10] & 0xff, s[11] != 0 ? "skip" : "", s[12] & 0xffffff, - s[13] & 0xff) - }); + s[13] & 0xff))); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 63ce881bd5..852baae8d3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -24,10 +24,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy var ser = new BasicServiceProvider(this); ser.Register(_disassembler); ServiceProvider = ser; - Tracer = new TraceBuffer - { - Header = "LR35902: PC, opcode, registers (A, F, B, C, D, E, H, L, LY, SP, CY)" - }; + const string TRACE_HEADER = "LR35902: PC, opcode, registers (A, F, B, C, D, E, H, L, LY, SP, CY)"; + Tracer = new TraceBuffer(TRACE_HEADER); ser.Register(Tracer); InitMemoryCallbacks(); @@ -327,7 +325,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy LibGambatte.gambatte_reset(GambatteState); } - if (Tracer.Enabled) + if (Tracer.IsEnabled()) { _tracecb = MakeTrace; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs index a6c9b64853..1fed847e53 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs @@ -17,11 +17,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 var length = 0; var disasm = Disassemble(MemoryDomains.SystemBus, pc, out length); - var traceInfo = new TraceInfo - { - Disassembly = $"{pc:X}: {disasm.PadRight(32)}" - }; - var sb = new StringBuilder(); for (int i = 1; i < 32; i++) // r0 is always zero @@ -45,16 +40,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 // drop MMU co-processor regs for now - traceInfo.RegisterInfo = sb.ToString().Trim(); - - Tracer.Put(traceInfo); + Tracer.Put(new(disassembly: $"{pc:X}: {disasm.PadRight(32)}", registerInfo: sb.ToString().Trim())); } private const string TraceHeader = "r3400: PC, mnemonic, operands, registers (GPRs, Load/Link Bit, MultHI, MultLO, Implementation/Revision, Control/Status, FGRs)"; private void ConnectTracer() { - Tracer = new TraceBuffer { Header = TraceHeader }; + Tracer = new TraceBuffer(TraceHeader); (ServiceProvider as BasicServiceProvider).Register(Tracer); _tracecb = new mupen64plusApi.TraceCallback(MakeTrace); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 5fed267416..955e04de86 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -214,14 +214,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 IsVIFrame = false; - if (Tracer != null && Tracer.Enabled) - { - api.setTraceCallback(_tracecb); - } - else - { - api.setTraceCallback(null); - } + api.setTraceCallback(Tracer?.IsEnabled() is true ? _tracecb : null); _audioProvider.RenderSound = rendersound; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs index 769503c9d7..511bdeb708 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -287,7 +287,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { _controller = controller; - if (Tracer.Enabled) + if (Tracer.IsEnabled()) cpu.TraceCallback = s => Tracer.Put(s); else cpu.TraceCallback = null; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 1b3e013968..df21bce748 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Register(cpu); - Tracer = new TraceBuffer { Header = cpu.TraceHeader }; + Tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(Tracer); ser.Register(videoProvider); ser.Register(this); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs index 7f79c764df..faa0856873 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs @@ -28,21 +28,19 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES string opcodeStr = MOS6502X.Disassemble(pc, out _, address => _memoryDomains.SystemBus.PeekByte(address)); - Tracer.Put(new TraceInfo - { - Disassembly = $"{pc:X4}: {opcodeStr}".PadRight(26), - RegisterInfo = string.Join(" ", + Tracer.Put(new( + disassembly: $"{pc:X4}: {opcodeStr}".PadRight(26), + registerInfo: string.Join(" ", $"A:{a:X2}", $"X:{x:X2}", $"Y:{y:X2}", $"P:{p:X2}", - $"SP:{sp:X2}") - }); + $"SP:{sp:X2}"))); } private void ConnectTracer() { - Tracer = new TraceBuffer { Header = TraceHeader }; + Tracer = new TraceBuffer(TraceHeader); ((BasicServiceProvider) ServiceProvider).Register(Tracer); _traceCb = MakeTrace; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 4fadb9dd50..f1508b7bd2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -194,7 +194,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES SetPads(controller, out var j1, out var j2); - QN.qn_set_tracecb(Context, Tracer.Enabled ? _traceCb : null); + QN.qn_set_tracecb(Context, Tracer.IsEnabled() ? _traceCb : null); LibQuickNES.ThrowStringError(QN.qn_emulate_frame(Context, j1, j2)); IsLagFrame = QN.qn_get_joypad_read_count(Context) == 0; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs index d20ed70bc8..f303edf0da 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs @@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES IsLagFrame = true; - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { //Api.QUERY_set_trace_callback(1<<(int)LibsnesApi.eTRACE.SMP, _tracecb); //TEST -- it works but theres no way to control it from the frontend now diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index c7bfc34d78..3e59feb8e8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -36,10 +36,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES var ser = new BasicServiceProvider(this); ServiceProvider = ser; - _tracer = new TraceBuffer - { - Header = "65816: PC, mnemonic, operands, registers (A, X, Y, S, D, DB, flags (NVMXDIZC), V, H)" - }; + const string TRACE_HEADER = "65816: PC, mnemonic, operands, registers (A, X, Y, S, D, DB, flags (NVMXDIZC), V, H)"; + _tracer = new TraceBuffer(TRACE_HEADER); ser.Register(new W65816_DisassemblerService()); @@ -352,34 +350,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES if (which == (uint)LibsnesApi.eTRACE.CPU) { var split = msg.Split(new[] { splitStr }, 2, StringSplitOptions.None); - - _tracer.Put(new TraceInfo - { - Disassembly = split[0].PadRight(34), - RegisterInfo = splitStr + split[1] - }); + _tracer.Put(new(disassembly: split[0].PadRight(34), registerInfo: splitStr + split[1])); } else if (which == (uint)LibsnesApi.eTRACE.SMP) { int idx = msg.IndexOf("YA:"); - string dis = msg.Substring(0,idx).TrimEnd(); - string regs = msg.Substring(idx); - _tracer.Put(new TraceInfo - { - Disassembly = dis, - RegisterInfo = regs - }); + _tracer.Put(new(disassembly: msg.Substring(0, idx).TrimEnd(), registerInfo: msg.Substring(idx))); } else if (which == (uint)LibsnesApi.eTRACE.GB) { int idx = msg.IndexOf("AF:"); - string dis = msg.Substring(0,idx).TrimEnd(); - string regs = msg.Substring(idx); - _tracer.Put(new TraceInfo - { - Disassembly = dis, - RegisterInfo = regs - }); + _tracer.Put(new(disassembly: msg.Substring(0, idx).TrimEnd(), registerInfo: msg.Substring(idx))); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.IEmulator.cs index 8625f6f771..3834011c7e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.IEmulator.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk _GBCore.ppu.color_palette[2] = GBHawk.GBHawk.color_palette_Gr[2]; _GBCore.ppu.color_palette[3] = GBHawk.GBHawk.color_palette_Gr[3]; } - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _GBCore.cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs index 8046910768..0c8f9cd808 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubGBHawk/SubGBHawk.cs @@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubGBHawk ser.Register(_GBCore.ServiceProvider.GetService()); ser.Register(_GBCore.ServiceProvider.GetService()); - _tracer = new TraceBuffer { Header = _GBCore.cpu.TraceHeader }; + _tracer = new TraceBuffer(_GBCore.cpu.TraceHeader); ser.Register(_tracer); _GBCore.ControllerDefinition.AddAxis("Input Cycle", 0.RangeTo(70224), 70224); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs index add0e7afd9..197f38e99c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk public bool FrameAdvance(IController controller, bool render, bool renderSound) { //Console.WriteLine("-----------------------FRAME-----------------------"); - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { _nesCore.cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs index 485d2f64a8..9517345448 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -41,7 +41,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk ser.Register(_nesCore.ServiceProvider.GetService()); ser.Register(_nesCore.ServiceProvider.GetService()); - _tracer = new TraceBuffer { Header = "6502: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP), flags (NVTBDIZCR), CPU Cycle, PPU Cycle" }; + const string TRACE_HEADER = "6502: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP), flags (NVTBDIZCR), CPU Cycle, PPU Cycle"; + _tracer = new TraceBuffer(TRACE_HEADER); ser.Register(_tracer); diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs index cce59b28b7..7c1ce7c52f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.PCEngine CheckSpriteLimit(); PSG.BeginFrame(Cpu.TotalExecutedCycles); - Cpu.Debug = Tracer.Enabled; + Cpu.Debug = Tracer.IsEnabled(); if (SuperGrafx) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index cb689b6d40..1a71588e29 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -225,11 +225,7 @@ namespace BizHawk.Emulation.Cores.PCEngine RomLength = RomData.Length; // user request: current value of the SF2MapperLatch on the tracelogger - Cpu.Logger = s => Tracer.Put(new TraceInfo - { - Disassembly = $"{SF2MapperLatch:X1}:{s}", - RegisterInfo = "" - }); + Cpu.Logger = s => Tracer.Put(new(disassembly: $"{SF2MapperLatch:X1}:{s}", registerInfo: string.Empty)); } else { @@ -319,7 +315,7 @@ namespace BizHawk.Emulation.Cores.PCEngine Cpu.ResetPC(); - Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; + Tracer = new TraceBuffer(Cpu.TraceHeader); var ser = new BasicServiceProvider(this); ServiceProvider = ser; ser.Register(Tracer); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs index 30e92db6cb..4684c167e5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink public bool FrameAdvance(IController controller, bool render, bool renderSound) { //Console.WriteLine("-----------------------FRAME-----------------------"); - if (_tracer.Enabled) + if (_tracer.IsEnabled()) { L.Cpu.TraceCallback = s => _tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs index 074bfee09a..08ad31ab3b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs @@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink ser.Register(this); ser.Register(this); - _tracer = new TraceBuffer { Header = L.Cpu.TraceHeader }; + _tracer = new TraceBuffer(L.Cpu.TraceHeader); ser.Register(_tracer); ServiceProvider = ser; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs index 8c328327ef..c16cf8a959 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs @@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem PSG.Set_Panning(Settings.ForceStereoSeparation ? ForceStereoByte : (byte)0xFF); } - if (Tracer.Enabled) + if (Tracer.IsEnabled()) { Cpu.TraceCallback = s => Tracer.Put(s); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index b89d78aa4d..b553dcb91c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -194,7 +194,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem //this manages the linkage between the cpu and mapper callbacks so it needs running before bootup is complete ((ICodeDataLogger)this).SetCDL(null); - Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; + Tracer = new TraceBuffer(Cpu.TraceHeader); ser.Register(Tracer); ser.Register(Cpu); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs index 63acf307a0..50500d7e6a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs @@ -10,11 +10,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public class GPGXTraceBuffer : CallbackBasedTraceBuffer { + private const string TRACE_HEADER = "M68K: PC, machine code, mnemonic, operands, registers (D0-D7, A0-A7, SR, USP), flags (XNZVC)"; + public GPGXTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler) - : base(debuggableCore, memoryDomains, disassembler) - { - Header = "M68K: PC, machine code, mnemonic, operands, registers (D0-D7, A0-A7, SR, USP), flags (XNZVC)"; - } + : base(debuggableCore, memoryDomains, disassembler, TRACE_HEADER) {} protected override void TraceFromCallback(uint addr, uint value, uint flags) { @@ -22,11 +21,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx uint pc = (uint)regs["M68K PC"].Value; var disasm = Disassembler.Disassemble(MemoryDomains.SystemBus, pc & 0xFFFFFF, out _); - var traceInfo = new TraceInfo - { - Disassembly = $"{pc:X6}: {disasm}".PadRight(50) - }; - var sb = new StringBuilder(); foreach (var r in regs) @@ -49,9 +43,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx (sr & 2) > 0 ? "V" : "v", (sr & 1) > 0 ? "C" : "c")); - traceInfo.RegisterInfo = sb.ToString().Trim(); - - Put(traceInfo); + this.Put(new(disassembly: $"{pc:X6}: {disasm}".PadRight(50), registerInfo: sb.ToString().Trim())); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs index d90cd7f9d9..f93a71b5ca 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX { public TraceBuffer Tracer { get; private set; } - public static string TraceHeader = "R3000A: PC, machine code, mnemonic, operands, registers (GPRs, lo, hi, sr, cause, epc)"; + public const string TraceHeader = "R3000A: PC, machine code, mnemonic, operands, registers (GPRs, lo, hi, sr, cause, epc)"; private OctoshockDll.ShockCallback_Trace trace_cb; @@ -25,17 +25,13 @@ namespace BizHawk.Emulation.Cores.Sony.PSX sb.Append($"{r.Key}:{r.Value.Value.ToHexString(r.Value.BitSize / 4)} "); } - Tracer.Put(new TraceInfo - { - Disassembly = $"{PC:X8}: {inst:X8} {dis.PadRight(30)}", - RegisterInfo = sb.ToString().Trim() - }); + Tracer.Put(new(disassembly: $"{PC:X8}: {inst:X8} {dis.PadRight(30)}", registerInfo: sb.ToString().Trim())); } private void ConnectTracer() { trace_cb = new OctoshockDll.ShockCallback_Trace(ShockTraceCallback); - Tracer = new TraceBuffer { Header = TraceHeader }; + Tracer = new TraceBuffer(TraceHeader); ServiceProvider = new BasicServiceProvider(this); (ServiceProvider as BasicServiceProvider).Register(Tracer); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 9377bf5663..099bbb6cb8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -829,7 +829,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX OctoshockDll.shock_SetRenderOptions(psx, ref ropts); //prep tracer - if (Tracer.Enabled) + if (Tracer.IsEnabled()) OctoshockDll.shock_SetTraceCallback(psx, IntPtr.Zero, trace_cb); else OctoshockDll.shock_SetTraceCallback(psx, IntPtr.Zero, null);