diff --git a/BizHawk.Emulation.Common/MemoryDomain.cs b/BizHawk.Emulation.Common/MemoryDomain.cs
index dd7ef12e33..7c4c3a7849 100644
--- a/BizHawk.Emulation.Common/MemoryDomain.cs
+++ b/BizHawk.Emulation.Common/MemoryDomain.cs
@@ -32,8 +32,9 @@ namespace BizHawk.Emulation.Common
///
///
/// must remain valid as long as the MemoryDomain exists!
+ /// if false, writes will be ignored
///
- public unsafe static MemoryDomain FromIntPtr(string name, int size, Endian endian, IntPtr data)
+ public unsafe static MemoryDomain FromIntPtr(string name, int size, Endian endian, IntPtr data, bool writable = true)
{
if (data == IntPtr.Zero)
throw new ArgumentNullException("data");
@@ -53,15 +54,16 @@ namespace BizHawk.Emulation.Common
},
delegate(int addr, byte val)
{
- if (addr < 0 || addr >= size)
- throw new ArgumentOutOfRangeException();
- p[addr] = val;
+ if (writable)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ p[addr] = val;
+ }
}
);
}
- public MemoryDomain() { }
-
public override string ToString()
{
return Name;
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs
index 04956d9e07..6977b50dcf 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs
@@ -122,6 +122,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public static extern bool SaveRamSave(IntPtr g, byte[] data, int length);
[DllImport(dllname, CallingConvention = cc)]
public static extern bool SaveRamLoad(IntPtr g, byte[] data, int length);
+ [DllImport(dllname, CallingConvention = cc)]
+ public static extern void GetMemoryAreas(IntPtr g, [Out]MemoryAreas mem);
+ [DllImport(dllname, CallingConvention = cc)]
+ public static extern void SystemBusWrite(IntPtr g, int addr, byte val);
+ [DllImport(dllname, CallingConvention = cc)]
+ public static extern byte SystemBusRead(IntPtr g, int addr);
+
+
+ [StructLayout(LayoutKind.Sequential)]
+ public class MemoryAreas
+ {
+ public IntPtr bios;
+ public IntPtr iwram;
+ public IntPtr ewram;
+ public IntPtr palram;
+ public IntPtr vram;
+ public IntPtr oam;
+ public IntPtr rom;
+ public IntPtr mmio;
+ }
}
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
index 2fe873e8ba..fb251ba7f5 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
@@ -73,6 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
savebuff = new byte[LibVBANext.BinStateSize(Core)];
savebuff2 = new byte[savebuff.Length + 13];
+ InitMemoryDomains();
}
catch
{
@@ -253,11 +254,38 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
#region Debugging
- public MemoryDomainList MemoryDomains
+ void InitMemoryDomains()
{
- get { return MemoryDomainList.GetDummyList(); }
+ var mm = new List();
+ var s = new LibVBANext.MemoryAreas();
+ var l = MemoryDomain.Endian.Little;
+ LibVBANext.GetMemoryAreas(Core, s);
+ mm.Add(MemoryDomain.FromIntPtr("IWRAM", 32 * 1024, l, s.iwram));
+ mm.Add(MemoryDomain.FromIntPtr("EWRAM", 256 * 1024, l, s.ewram));
+ mm.Add(MemoryDomain.FromIntPtr("BIOS", 16 * 1024, l, s.bios, false));
+ mm.Add(MemoryDomain.FromIntPtr("PALRAM", 1024, l, s.palram, false));
+ mm.Add(MemoryDomain.FromIntPtr("VRAM", 96 * 1024, l, s.vram));
+ mm.Add(MemoryDomain.FromIntPtr("OAM", 1024, l, s.oam));
+ mm.Add(MemoryDomain.FromIntPtr("ROM", 32 * 1024 * 1024, l, s.rom));
+
+ mm.Add(new MemoryDomain("BUS", 0x10000000, l,
+ delegate(int addr)
+ {
+ if (addr < 0 || addr >= 0x10000000)
+ throw new ArgumentOutOfRangeException();
+ return LibVBANext.SystemBusRead(Core, addr);
+ },
+ delegate(int addr, byte val)
+ {
+ if (addr < 0 || addr >= 0x10000000)
+ throw new ArgumentOutOfRangeException();
+ LibVBANext.SystemBusWrite(Core, addr, val);
+ }));
+ MemoryDomains = new MemoryDomainList(mm, 0);
}
+ public MemoryDomainList MemoryDomains { get; private set; }
+
public Dictionary GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
index d5b2d0e89e..9e7477b07f 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
@@ -319,28 +319,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
if (data != IntPtr.Zero && size > 0 && name != IntPtr.Zero)
{
- byte* p = (byte*)data;
-
- mm.Add(new MemoryDomain
- (
- Marshal.PtrToStringAnsi(name),
- size,
- MemoryDomain.Endian.Unknown,
- delegate(int addr)
- {
- if (addr < 0 || addr >= size)
- throw new ArgumentOutOfRangeException();
- return p[addr];
- },
- delegate(int addr, byte val)
- {
- if (!writable)
- return;
- if (addr < 0 || addr >= size)
- throw new ArgumentOutOfRangeException();
- p[addr] = val;
- }
- ));
+ mm.Add(MemoryDomain.FromIntPtr(Marshal.PtrToStringAnsi(name), size, MemoryDomain.Endian.Little, data, writable));
}
}
// add system bus
diff --git a/output/dll/libvbanext.dll b/output/dll/libvbanext.dll
index 60350c839f..afa0071028 100644
Binary files a/output/dll/libvbanext.dll and b/output/dll/libvbanext.dll differ
diff --git a/vbanext/instance.cpp b/vbanext/instance.cpp
index d89585f572..44626f4ca0 100644
--- a/vbanext/instance.cpp
+++ b/vbanext/instance.cpp
@@ -13321,6 +13321,27 @@ templatebool SyncBatteryRam(NewState *ns)
return lagged;
}
+ void FillMemoryAreas(MemoryAreas &mem)
+ {
+ mem.bios = bios;
+ mem.iwram = internalRAM;
+ mem.ewram = workRAM;
+ mem.palram = graphics.paletteRAM;
+ mem.mmio = ioMem;
+ mem.rom = rom;
+ mem.vram = vram;
+ mem.oam = oam;
+ }
+
+ void BusWrite(u32 addr, u8 val)
+ {
+ CPUWriteByte(addr, val);
+ }
+ u8 BusRead(u32 addr)
+ {
+ return CPUReadByte(addr);
+ }
+
}; // class Gigazoid
// zeroing mem operators: these are very important
@@ -13447,5 +13468,19 @@ EXPORT void TxtStateLoad(Gigazoid *g, FPtrs *ff)
g->SyncState(&loader);
}
+EXPORT void GetMemoryAreas(Gigazoid *g, MemoryAreas *mem)
+{
+ g->FillMemoryAreas(*mem);
+}
+
+EXPORT void SystemBusWrite(Gigazoid *g, u32 addr, u8 val)
+{
+ g->BusWrite(addr, val);
+}
+
+EXPORT u8 SystemBusRead(Gigazoid *g, u32 addr)
+{
+ return g->BusRead(addr);
+}
#include "optable.inc"
diff --git a/vbanext/instance.h b/vbanext/instance.h
index 028302d5e6..68b043823b 100644
--- a/vbanext/instance.h
+++ b/vbanext/instance.h
@@ -20,6 +20,18 @@ struct FrontEndSettings
};
+struct MemoryAreas
+{
+ void *bios;
+ void *iwram;
+ void *ewram;
+ void *palram;
+ void *vram;
+ void *oam;
+ void *rom;
+ void *mmio;
+};
+
#define FLASH_128K_SZ 0x20000
#define EEPROM_IDLE 0