diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs new file mode 100644 index 0000000000..1672e98708 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs @@ -0,0 +1,40 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +using BizHawk.Emulation.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Nintendo.N64 +{ + public partial class N64 + { + private readonly ITraceable Tracer; + + public class m64pTraceBuffer : CallbackBasedTraceBuffer + { + public m64pTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler) + : base(debuggableCore, memoryDomains, disassembler) + { + Header = "r3400: PC, mnemonic, arguments"; + } + + public override void TraceFromCallback() + { + var regs = DebuggableCore.GetCpuFlagsAndRegisters(); + uint pc = (uint)regs["PC"].Value; + var length = 0; + var disasm = Disassembler.Disassemble(MemoryDomains.SystemBus, pc, out length); + + var traceInfo = new TraceInfo + { + Disassembly = string.Format("{0:X}: {1}", pc, disasm), + RegisterInfo = "" + }; + + Buffer.Add(traceInfo); + } + } + + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index a135eddf56..fa81131360 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -140,6 +140,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 InitMemoryDomains(); RefreshMemoryCallbacks(); + Tracer = new m64pTraceBuffer(this, MemoryDomains, this); + (ServiceProvider as BasicServiceProvider).Register(Tracer); + api.AsyncExecuteEmulator(); // Hack: Saving a state on frame 0 has been shown to not be sync stable. Advance past that frame to avoid the problem.