diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs index 042ccd8acf..fe47804d8f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/LibLynx.cs @@ -31,6 +31,10 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx [DllImport(dllname, CallingConvention = cc)] public static extern 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); + + [DllImport(dllname, CallingConvention = cc)] public static extern int BinStateSize(IntPtr s); [DllImport(dllname, CallingConvention = cc)] @@ -42,6 +46,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx [DllImport(dllname, CallingConvention = cc)] public static extern void TxtStateLoad(IntPtr s, [In]ref TextStateFPtrs ff); + [DllImport(dllname, CallingConvention = cc)] + public static extern IntPtr GetRamPointer(IntPtr s); [Flags] public enum Buttons : ushort diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index b915d14f2a..5b7f98f451 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -12,7 +12,7 @@ using Newtonsoft.Json; namespace BizHawk.Emulation.Cores.Atari.Lynx { [CoreAttributes("Handy", "K. Wilkins", true, false, "mednafen 0-9-34-1", "http://mednafen.sourceforge.net/")] - public class Lynx : IEmulator, IVideoProvider, ISyncSoundProvider + public class Lynx : IEmulator, IVideoProvider, ISyncSoundProvider, IMemoryDomains { IntPtr Core; @@ -112,6 +112,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx BufferWidth = WIDTH; BufferHeight = HEIGHT; } + SetupMemoryDomains(); } catch { @@ -161,10 +162,6 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } } - #region debugging - - #endregion - #region Controller private static readonly ControllerDefinition LynxTroller = new ControllerDefinition @@ -366,5 +363,33 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } #endregion + + #region MemoryDomains + + private void SetupMemoryDomains() + { + var mms = new List(); + mms.Add(MemoryDomain.FromIntPtr("RAM", 65536, MemoryDomain.Endian.Little, LibLynx.GetRamPointer(Core), true)); + + IntPtr p; + int s; + if (LibLynx.GetSaveRamPtr(Core, out s, out p)) + mms.Add(MemoryDomain.FromIntPtr("Save RAM", s, MemoryDomain.Endian.Little, p, true)); + + IntPtr p0, p1; + int s0, s1; + LibLynx.GetReadOnlyCartPtrs(Core, out s0, out p0, out s1, out p1); + if (s0 > 0 && p0 != IntPtr.Zero) + mms.Add(MemoryDomain.FromIntPtr("Cart A", s0, MemoryDomain.Endian.Little, p0, false)); + if (s1 > 0 && p1 != IntPtr.Zero) + mms.Add(MemoryDomain.FromIntPtr("Cart B", s1, MemoryDomain.Endian.Little, p1, false)); + + MemoryDomains = new MemoryDomainList(mms, 0); + } + + + public MemoryDomainList MemoryDomains { get; private set; } + + #endregion } } diff --git a/lynx/cart.cpp b/lynx/cart.cpp index a4840465ef..5afc0596f9 100644 --- a/lynx/cart.cpp +++ b/lynx/cart.cpp @@ -331,6 +331,14 @@ bool CCart::GetSaveRamPtr(int &size, uint8 *&data) } } +void CCart::GetReadOnlyPtrs(int &s0, uint8 *&p0, int &s1, uint8 *&p1) +{ + s0 = mMaskBank0 + 1; + s1 = mMaskBank1 + 1; + p0 = mCartBank0; + p1 = mCartBank1; +} + SYNCFUNC(CCart) { NSS(mWriteEnableBank0); diff --git a/lynx/cart.h b/lynx/cart.h index 278799fea2..fbe9e91b3c 100644 --- a/lynx/cart.h +++ b/lynx/cart.h @@ -108,6 +108,7 @@ public: // when the original cart did not have it bool GetSaveRamPtr(int &size, uint8 *&data); + void GetReadOnlyPtrs(int &s0, uint8 *&p0, int &s1, uint8 *&p1); templatevoid SyncState(NewState *ns); diff --git a/lynx/cinterface.cpp b/lynx/cinterface.cpp index 9a303d7e07..e0421e6b61 100644 --- a/lynx/cinterface.cpp +++ b/lynx/cinterface.cpp @@ -47,6 +47,10 @@ EXPORT int GetSaveRamPtr(CSystem *s, int *size, uint8 **data) return s->GetSaveRamPtr(*size, *data); } +EXPORT void GetReadOnlyCartPtrs(CSystem *s, int *s0, uint8 **p0, int *s1, uint8 **p1) +{ + s->GetReadOnlyCartPtrs(*s0, *p0, *s1, *p1); +} EXPORT int BinStateSize(CSystem *s) { @@ -81,3 +85,8 @@ EXPORT void TxtStateLoad(CSystem *s, FPtrs *ff) s->SyncState(&loader); } +EXPORT void *GetRamPointer(CSystem *s) +{ + return s->GetRamPointer(); +} + diff --git a/lynx/system.h b/lynx/system.h index 3fa74f7b2a..421649f770 100644 --- a/lynx/system.h +++ b/lynx/system.h @@ -143,6 +143,7 @@ public: bool Advance(int buttons, uint32 *vbuff, int16 *sbuff, int &sbuffsize); bool GetSaveRamPtr(int &size, uint8 *&data) { return mCart->GetSaveRamPtr(size, data); } + void GetReadOnlyCartPtrs(int &s0, uint8 *&p0, int &s1, uint8 *&p1) { mCart->GetReadOnlyPtrs(s0, p0, s1, p1); } // // We MUST have separate CPU & RAM peek & poke handlers as all CPU accesses must diff --git a/output/dll/bizlynx.dll b/output/dll/bizlynx.dll index 83c1ac20a8..7903f302ac 100644 Binary files a/output/dll/bizlynx.dll and b/output/dll/bizlynx.dll differ