diff --git a/BizHawk.Emulation.Common/MemoryDomain.cs b/BizHawk.Emulation.Common/MemoryDomain.cs
index e7018f34d7..08e4c5943f 100644
--- a/BizHawk.Emulation.Common/MemoryDomain.cs
+++ b/BizHawk.Emulation.Common/MemoryDomain.cs
@@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Common
throw new ArgumentNullException("data");
if (size <= 0)
throw new ArgumentOutOfRangeException("size");
- byte *p = (byte*) data;
+ byte* p = (byte*)data;
return new MemoryDomain
(
name,
@@ -64,6 +64,45 @@ namespace BizHawk.Emulation.Common
);
}
+ ///
+ /// create a memorydomain that references an unmanaged memory block with 16 bit swaps
+ ///
+ ///
+ ///
+ ///
+ /// must remain valid as long as the MemoryDomain exists!
+ /// if false, writes will be ignored
+ ///
+ public unsafe static MemoryDomain FromIntPtrSwap16(string name, int size, Endian endian, IntPtr data, bool writable = true)
+ {
+ if (data == IntPtr.Zero)
+ throw new ArgumentNullException("data");
+ if (size <= 0)
+ throw new ArgumentOutOfRangeException("size");
+ byte* p = (byte*)data;
+ return new MemoryDomain
+ (
+ name,
+ size,
+ endian,
+ delegate(int addr)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ return p[addr ^ 1];
+ },
+ delegate(int addr, byte val)
+ {
+ if (writable)
+ {
+ if (addr < 0 || addr >= size)
+ throw new ArgumentOutOfRangeException();
+ p[addr ^ 1] = val;
+ }
+ }
+ );
+ }
+
public override string ToString()
{
return Name;
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs
index 680361e6a2..7f4e6cc4a3 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs
@@ -592,7 +592,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
continue;
string name = Marshal.PtrToStringAnsi(pname);
- mm.Add(MemoryDomain.FromIntPtr(name, size, MemoryDomain.Endian.Unknown, area));
+ mm.Add(MemoryDomain.FromIntPtrSwap16(name, size, MemoryDomain.Endian.Big, area));
}
MemoryDomains = new MemoryDomainList(mm, 0);
}