Add libdarm.so, migrate Darm class to BizInvoker
`Tools` > `Debugger` no longer crashes immediately on Linux with mGBA core
This commit is contained in:
parent
0bdd1b6d64
commit
fb5a5ed78c
Binary file not shown.
|
@ -2,11 +2,12 @@
|
|||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.BizInvoke;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Components.ARM
|
||||
{
|
||||
public static class Darm
|
||||
public abstract class Darm
|
||||
{
|
||||
public const string dllname = "libdarm.dll";
|
||||
public const CallingConvention cc = CallingConvention.Cdecl;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -76,20 +77,20 @@ namespace BizHawk.Emulation.Cores.Components.ARM
|
|||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
public byte[] mnemonic = new byte[12];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6 * 32)]
|
||||
public byte[,] arg = new byte[6, 32];
|
||||
public byte[] arg = new byte[6 * 32];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
||||
public byte[] shift = new byte[12];
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
||||
public byte[] total = new byte[64];
|
||||
}
|
||||
|
||||
[DllImport(dllname, CallingConvention = cc, EntryPoint = "darm_disasm")]
|
||||
public static extern bool Disassemble([Out] Darm_T d, ushort w, ushort w2, uint addr);
|
||||
[BizImport(cc, Compatibility = true, EntryPoint = "darm_disasm")]
|
||||
public abstract bool Disassemble([Out] Darm_T d, ushort w, ushort w2, uint addr);
|
||||
|
||||
[DllImport(dllname, CallingConvention = cc, EntryPoint = "darm_str2")]
|
||||
public static extern bool Str([In] [Out]Darm_T d, [Out]Darm_Str_T s, bool lowercase);
|
||||
[BizImport(cc, Compatibility = true, EntryPoint = "darm_str2")]
|
||||
public abstract bool Str([In] [Out]Darm_T d, [Out]Darm_Str_T s, bool lowercase);
|
||||
|
||||
public static string DisassembleStuff(uint addr, uint opcode)
|
||||
public string DisassembleStuff(uint addr, uint opcode)
|
||||
{
|
||||
var d = new Darm_T();
|
||||
var s = new Darm_Str_T();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using BizHawk.BizInvoke;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Components.ARM;
|
||||
|
||||
|
@ -6,6 +9,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
public class ArmV4Disassembler : VerifiedDisassembler
|
||||
{
|
||||
private readonly Darm _libdarm = BizInvoker.GetInvoker<Darm>(
|
||||
new DynamicLibraryImportResolver(OSTailoredCode.IsUnixHost ? "libdarm.so" : "libdarm.dll", hasLimitedLifetime: false),
|
||||
CallingConventionAdapters.Native
|
||||
);
|
||||
|
||||
public override IEnumerable<string> AvailableCpus => new[]
|
||||
{
|
||||
"ARM v4",
|
||||
|
@ -20,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
{
|
||||
addr &= unchecked((uint)~1);
|
||||
int op = m.PeekByte((int)addr) | m.PeekByte((int)addr + 1) << 8;
|
||||
string ret = Darm.DisassembleStuff(addr | 1, (uint)op);
|
||||
string ret = _libdarm.DisassembleStuff(addr | 1, (uint)op);
|
||||
length = 2;
|
||||
return ret;
|
||||
}
|
||||
|
@ -31,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
| m.PeekByte((int)addr + 1) << 8
|
||||
| m.PeekByte((int)addr + 2) << 16
|
||||
| m.PeekByte((int)addr + 3) << 24;
|
||||
string ret = Darm.DisassembleStuff(addr, (uint)op);
|
||||
string ret = _libdarm.DisassembleStuff(addr, (uint)op);
|
||||
length = 4;
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue