gpgx: account for the fact that rom and ram are emulated with 16 bit swaps
This commit is contained in:
parent
28bd6229c8
commit
93eb656eba
|
@ -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
|
|||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// create a memorydomain that references an unmanaged memory block with 16 bit swaps
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="endian"></param>
|
||||
/// <param name="data">must remain valid as long as the MemoryDomain exists!</param>
|
||||
/// <param name="writable">if false, writes will be ignored</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue