diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index 5738b05eef..e07f6c7f45 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -165,6 +165,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA #region IMemoryDomains + unsafe byte PeekWRAM(IntPtr xwram, long addr) { return *(byte*)xwram.ToPointer();} + unsafe void PokeWRAM(IntPtr xwram, long addr, byte value) { *(byte*)xwram.ToPointer() = value; } + private MemoryDomainList CreateMemoryDomains(int romsize) { var s = new LibmGBA.MemoryAreas(); @@ -180,6 +183,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA mm.Add(MemoryDomain.FromIntPtr("OAM", 1024, l, s.oam, false, 4)); mm.Add(MemoryDomain.FromIntPtr("ROM", romsize, l, s.rom, false, 4)); + // special combined ram memory domain + { + var ew = mm[1]; + var iw = mm[0]; + MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, + delegate(long addr) + { + if (addr < 0 || addr >= (256 + 32) * 1024) + throw new IndexOutOfRangeException(); + if (addr >= 256 * 1024) + return PeekWRAM(s.iwram,addr & 32767); + else + return PeekWRAM(s.wram, addr); + }, + delegate(long addr, byte val) + { + if (addr < 0 || addr >= (256 + 32) * 1024) + throw new IndexOutOfRangeException(); + if (addr >= 256 * 1024) + PokeWRAM(s.iwram, addr & 32767, val); + else + PokeWRAM(s.wram, addr, val); + }, 4); + mm.Add(cr); + } + _gpumem = new GBAGPUMemoryAreas { mmio = s.mmio,