diff --git a/Assets/dll/libbizlynx.dll.so b/Assets/dll/libbizlynx.dll.so old mode 100644 new mode 100755 index f3ea769383..e12b22ba65 Binary files a/Assets/dll/libbizlynx.dll.so and b/Assets/dll/libbizlynx.dll.so differ diff --git a/lynx/cinterface.cpp b/lynx/cinterface.cpp index 3d902f7279..cc3e8a63a9 100644 --- a/lynx/cinterface.cpp +++ b/lynx/cinterface.cpp @@ -17,8 +17,8 @@ void operator delete(void *p) #ifdef _WIN32 #define EXPORT extern "C" __declspec(dllexport) -#elif __linux__ -#define EXPORT extern "C" +#else +#define EXPORT extern "C" __attribute__((visibility("default"))) #endif EXPORT CSystem *Create(const uint8 *game, uint32 gamesize, const uint8 *bios, uint32 biossize, int pagesize0, int pagesize1, int lowpass) diff --git a/lynx/make/Makefile b/lynx/make/Makefile index 01a0985364..a121f03690 100644 --- a/lynx/make/Makefile +++ b/lynx/make/Makefile @@ -11,7 +11,7 @@ else $(error Unknown arch) endif -CXXFLAGS = -Wall -Wno-parentheses -I.. -O3 -std=gnu++11 -fomit-frame-pointer -fno-exceptions -flto -fPIC +CXXFLAGS = -Wall -Wno-parentheses -I.. -O3 -std=gnu++11 -fomit-frame-pointer -fno-exceptions -flto -fPIC -fvisibility=internal TARGET = bizlynx.dll LDFLAGS_32 = -static -static-libgcc -static-libstdc++ diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs index c04add69b1..6d401d205c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs @@ -1,50 +1,50 @@ using System; using System.Runtime.InteropServices; +using BizHawk.BizInvoke; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Atari.Lynx { - public static class LibLynx + public abstract class LibLynx { - private const string dllname = "bizlynx.dll"; private const CallingConvention cc = CallingConvention.Cdecl; - [DllImport(dllname, CallingConvention = cc)] - public static extern IntPtr Create(byte[] game, int gamesize, byte[] bios, int biossize, int pagesize0, int pagesize1, bool lowpass); + [BizImport(cc)] + public abstract IntPtr Create(byte[] game, int gamesize, byte[] bios, int biossize, int pagesize0, int pagesize1, bool lowpass); - [DllImport(dllname, CallingConvention = cc)] - public static extern void Destroy(IntPtr s); + [BizImport(cc)] + public abstract void Destroy(IntPtr s); - [DllImport(dllname, CallingConvention = cc)] - public static extern void Reset(IntPtr s); + [BizImport(cc)] + public abstract void Reset(IntPtr s); - [DllImport(dllname, CallingConvention = cc)] - public static extern bool Advance(IntPtr s, Buttons buttons, int[] vbuff, short[] sbuff, ref int sbuffsize); + [BizImport(cc)] + public abstract bool Advance(IntPtr s, Buttons buttons, int[] vbuff, short[] sbuff, ref int sbuffsize); - [DllImport(dllname, CallingConvention = cc)] - public static extern void SetRotation(IntPtr s, int value); + [BizImport(cc)] + public abstract void SetRotation(IntPtr s, int value); - [DllImport(dllname, CallingConvention = cc)] - public static extern bool GetSaveRamPtr(IntPtr s, out int size, out IntPtr data); + [BizImport(cc)] + public abstract bool GetSaveRamPtr(IntPtr s, out int size, out IntPtr data); - [DllImport(dllname, CallingConvention = cc)] - public static extern void GetReadOnlyCartPtrs(IntPtr s, out int s0, out IntPtr p0, out int s1, out IntPtr p1); + [BizImport(cc)] + public abstract void GetReadOnlyCartPtrs(IntPtr s, out int s0, out IntPtr p0, out int s1, out IntPtr p1); - [DllImport(dllname, CallingConvention = cc)] - public static extern int BinStateSize(IntPtr s); - [DllImport(dllname, CallingConvention = cc)] - public static extern bool BinStateSave(IntPtr s, byte[] data, int length); - [DllImport(dllname, CallingConvention = cc)] - public static extern bool BinStateLoad(IntPtr s, byte[] data, int length); - [DllImport(dllname, CallingConvention = cc)] - public static extern void TxtStateSave(IntPtr s, [In]ref TextStateFPtrs ff); - [DllImport(dllname, CallingConvention = cc)] - public static extern void TxtStateLoad(IntPtr s, [In]ref TextStateFPtrs ff); + [BizImport(cc)] + public abstract int BinStateSize(IntPtr s); + [BizImport(cc)] + public abstract bool BinStateSave(IntPtr s, byte[] data, int length); + [BizImport(cc)] + public abstract bool BinStateLoad(IntPtr s, byte[] data, int length); + [BizImport(cc)] + public abstract void TxtStateSave(IntPtr s, [In]ref TextStateFPtrs ff); + [BizImport(cc)] + public abstract void TxtStateLoad(IntPtr s, [In]ref TextStateFPtrs ff); - [DllImport(dllname, CallingConvention = cc)] - public static extern IntPtr GetRamPointer(IntPtr s); + [BizImport(cc)] + public abstract IntPtr GetRamPointer(IntPtr s); [Flags] public enum Buttons : ushort diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index e31e1ea662..efc725ef3d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -2,6 +2,8 @@ using System.Text; using System.IO; +using BizHawk.BizInvoke; +using BizHawk.Common; using BizHawk.Common.StringExtensions; using BizHawk.Emulation.Common; @@ -11,6 +13,15 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx [ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable), typeof(ISettable<,>) })] public partial class Lynx : IEmulator, IVideoProvider, ISoundProvider, ISaveRam, IStatable, IInputPollable { + private static readonly LibLynx LibLynx; + + static Lynx() + { + var resolver = new DynamicLibraryImportResolver( + OSTailoredCode.IsUnixHost ? "libbizlynx.dll.so" : "bizlynx.dll", hasLimitedLifetime: false); + LibLynx = BizInvoker.GetInvoker(resolver, CallingConventionAdapters.Native); + } + [CoreConstructor(VSystemID.Raw.Lynx)] public Lynx(byte[] file, GameInfo game, CoreComm comm) {