diff --git a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Disassembler.cs b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Disassembler.cs
new file mode 100644
index 0000000000..f40cb1c2b0
--- /dev/null
+++ b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Disassembler.cs
@@ -0,0 +1,9 @@
+using BizHawk.Emulation.Common;
+
+namespace BizHawk.Emulation.Cores.Components.vr6502
+{
+ public partial class vr6502// : IDisassemblable
+ {
+
+ }
+}
diff --git a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Interop.cs b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Interop.cs
index 1e6cbd3716..f6bda84d38 100644
--- a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Interop.cs
+++ b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.Interop.cs
@@ -53,8 +53,21 @@ namespace BizHawk.Emulation.Cores.Components.vr6502
[DllImport(lib, CallingConvention = cc)]
public static extern IntPtr vrEmu6502Int(ref VrEmu6502State state);
-
+ ///
+ /// Return the mnemonic string for a given opcode
+ ///
[DllImport(lib, CallingConvention = cc)]
public static extern IntPtr vrEmu6502OpcodeToMnemonicStr(ref VrEmu6502State state, byte opcode);
+
+ ///
+ /// Return the address mode for a given opcode
+ ///
+ [DllImport(lib, CallingConvention = cc)]
+ public static extern IntPtr vrEmu6502GetOpcodeAddrMode(ref VrEmu6502State state, byte opcode);
+
+ [DllImport(lib, CallingConvention = cc)]
+ public static extern ushort vrEmu6502DisassembleInstruction(
+ ref VrEmu6502State state, ushort addr, int bufferSize, IntPtr buffer,
+ IntPtr refAddr, IntPtr labelMap);
}
}
diff --git a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs
index 67f238c8cd..e2096d771f 100644
--- a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs
+++ b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs
@@ -3,7 +3,6 @@ using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-using static BizHawk.Emulation.Cores.Components.vr6502.vr6502;
namespace BizHawk.Emulation.Cores.Components.vr6502
{
@@ -114,6 +113,32 @@ namespace BizHawk.Emulation.Cores.Components.vr6502
return Marshal.PtrToStringAnsi(strPtr);
}
+ public string DisassembleInstruction()
+ {
+ ushort address = _6502s.currentOpcodeAddr;
+ int bufferSize = 256;
+
+ IntPtr buffer = Marshal.AllocHGlobal(bufferSize);
+ IntPtr refAddr = Marshal.AllocHGlobal(sizeof(ushort));
+ IntPtr labelMap = IntPtr.Zero;
+
+ try
+ {
+ ushort nextAddr = VrEmu6502Interop.vrEmu6502DisassembleInstruction(
+ ref _6502s, address, bufferSize, buffer, refAddr, labelMap);
+
+ string disassembly = Marshal.PtrToStringAnsi(buffer);
+ ushort referenceAddress = (ushort) Marshal.ReadInt16(refAddr);
+
+ return $"Disassembly: {disassembly}, Next Address: {nextAddr}, Reference Address: {referenceAddress}";
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(buffer);
+ Marshal.FreeHGlobal(refAddr);
+ }
+ }
+
public IDictionary GetCpuFlagsAndRegisters()
{
return new Dictionary