diff --git a/Assets/dll/libdarm.so b/Assets/dll/libdarm.so new file mode 100755 index 0000000000..fe0e31d009 Binary files /dev/null and b/Assets/dll/libdarm.so differ diff --git a/src/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs b/src/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs index 2c9b870bd3..9f0ac45a9d 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs @@ -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(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs index ce30c3d638..cedcfe5173 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/ArmV4Disassembler.cs @@ -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( + new DynamicLibraryImportResolver(OSTailoredCode.IsUnixHost ? "libdarm.so" : "libdarm.dll", hasLimitedLifetime: false), + CallingConventionAdapters.Native + ); + public override IEnumerable 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; }