From ffed0d2205dcd2b275ed52aff3362571d76ce5e7 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sun, 28 May 2017 10:32:21 -0400 Subject: [PATCH] snes9x: memory domains --- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index df1ed5369a..d223befbd6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -70,6 +70,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X _syncSettings = syncSettings; InitControllers(); PutSettings(settings); + InitMemoryDomains(); } catch { @@ -616,5 +617,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X } #endregion + + #region Memory Domains + + private unsafe void InitMemoryDomains() + { + var native = new LibSnes9x.memory_area(); + var domains = new List(); + + var names = new[] { "CARTRAM", "CARTRAM B", "RTC", "WRAM", "VRAM" }; + int index = 0; + foreach (var s in names) + { + _core.biz_get_memory_area(index++, native); + if (native.ptr != IntPtr.Zero && native.size > 0) + { + domains.Add(new MemoryDomainIntPtr(s, MemoryDomain.Endian.Little, + native.ptr, native.size, true, 2)); + } + } + (ServiceProvider as BasicServiceProvider).Register(new MemoryDomainList(domains) + { + MainMemory = domains.Single(d => d.Name == "WRAM") + }); + } + + #endregion } }