start disassembler work
This commit is contained in:
parent
e41b8a4ffe
commit
4c7e3f2a06
|
@ -0,0 +1,9 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Components.vr6502
|
||||
{
|
||||
public partial class vr6502// : IDisassemblable
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -53,8 +53,21 @@ namespace BizHawk.Emulation.Cores.Components.vr6502
|
|||
[DllImport(lib, CallingConvention = cc)]
|
||||
public static extern IntPtr vrEmu6502Int(ref VrEmu6502State state);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return the mnemonic string for a given opcode
|
||||
/// </summary>
|
||||
[DllImport(lib, CallingConvention = cc)]
|
||||
public static extern IntPtr vrEmu6502OpcodeToMnemonicStr(ref VrEmu6502State state, byte opcode);
|
||||
|
||||
/// <summary>
|
||||
/// Return the address mode for a given opcode
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string, RegisterValue> GetCpuFlagsAndRegisters()
|
||||
{
|
||||
return new Dictionary<string, RegisterValue>
|
||||
|
|
Loading…
Reference in New Issue