diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs index f5ccba49e6..952364d6db 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs @@ -37,5 +37,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK public abstract void HardReset(); [BizImport(CC)] public abstract void SetInputCallback(InputCallback callback); + [BizImport(CC)] + public abstract void GetMemoryArea(int which, ref IntPtr ptr, ref int size, ref bool writable); } } diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs index f7b1b44242..5f750ad572 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/NeoGeoPort.cs @@ -44,6 +44,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK _exe.Seal(); _inputCallback = InputCallbacks.Call; + InitMemoryDomains(); } public unsafe void FrameAdvance(IController controller, bool render, bool rendersound = true) @@ -257,5 +258,32 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK public SyncSoundMode SyncMode => SyncSoundMode.Sync; #endregion + + #region Memory Domains + + private unsafe void InitMemoryDomains() + { + var domains = new List(); + + var domainNames = new[] { "RAM", "ROM", "ORIGINAL ROM" }; + + foreach (var a in domainNames.Select((s, i) => new { s, i })) + { + IntPtr ptr = IntPtr.Zero; + int size = 0; + bool writable = false; + + _neopop.GetMemoryArea(a.i, ref ptr, ref size, ref writable); + + if (ptr != IntPtr.Zero && size > 0) + { + domains.Add(new MemoryDomainIntPtrMonitor(a.s, MemoryDomain.Endian.Little, + ptr, size, writable, 4, _exe)); + } + } + (ServiceProvider as BasicServiceProvider).Register(new MemoryDomainList(domains)); + } + + #endregion } } diff --git a/waterbox/ngp/neopop.cpp b/waterbox/ngp/neopop.cpp index fd4528e7ea..9bb4aa3735 100644 --- a/waterbox/ngp/neopop.cpp +++ b/waterbox/ngp/neopop.cpp @@ -161,92 +161,9 @@ static MDFN_COLD bool Load(const uint8* romdata, int32 romlength) MDFNNGPC_SetSoundRate(44100); return true; } - -/*static void DoSimpleCommand(int cmd) -{ - switch (cmd) - { - case MDFN_MSC_POWER: - case MDFN_MSC_RESET: - reset(); - break; - } -}*/ - -/*static const IDIISG IDII = - { - {"up", "UP ↑", 0, IDIT_BUTTON, "down"}, - {"down", "DOWN ↓", 1, IDIT_BUTTON, "up"}, - {"left", "LEFT ←", 2, IDIT_BUTTON, "right"}, - {"right", "RIGHT →", 3, IDIT_BUTTON, "left"}, - {"a", "A", 5, IDIT_BUTTON_CAN_RAPID, NULL}, - {"b", "B", 6, IDIT_BUTTON_CAN_RAPID, NULL}, - {"option", "OPTION", 4, IDIT_BUTTON, NULL}, -};*/ - -/*static const FileExtensionSpecStruct KnownExtensions[] = - { - {".ngp", gettext_noop("Neo Geo Pocket ROM Image")}, - {".ngc", gettext_noop("Neo Geo Pocket Color ROM Image")}, - {NULL, NULL}}; -}*/ } using namespace MDFN_IEN_NGP; - - -/*MDFNGI EmulatedNGP = - { - "ngp", - "Neo Geo Pocket (Color)", - KnownExtensions, - MODPRIO_INTERNAL_HIGH, - NULL, - PortInfo, - Load, - TestMagic, - NULL, - NULL, - CloseGame, - - SetLayerEnableMask, - "Background Scroll\0Foreground Scroll\0Sprites\0", - - NULL, - NULL, - - NULL, - 0, - - CheatInfo_Empty, - - false, - StateAction, - Emulate, - NULL, - SetInput, - NULL, - DoSimpleCommand, - NULL, - NGPSettings, - MDFN_MASTERCLOCK_FIXED(6144000), - 0, - - false, // Multires possible? - - 160, // lcm_width - 152, // lcm_height - NULL, // Dummy - - 160, // Nominal width - 152, // Nominal height - - 160, // Framebuffer width - 152, // Framebuffer height - - 2, // Number of output sound channels -};*/ - int main(void) { return 0; @@ -277,3 +194,31 @@ EXPORT void SetInputCallback(void (*callback)()) { inputcallback = callback; } + +EXPORT void GetMemoryArea(int which, void **ptr, int *size, int *writable) +{ + switch (which) + { + case 0: + *ptr = CPUExRAM; + *size = 16384; + *writable = 1; + break; + case 1: + *ptr = ngpc_rom.data; + *size = ngpc_rom.length; + *writable = 0; + break; + case 2: + *ptr = ngpc_rom.orig_data; + *size = ngpc_rom.length; + *writable = 0; + break; + default: + *ptr = nullptr; + *size = 0; + *writable = 0; + break; + } +} +