GB - mask peek and poke memory functions, fixes potential exceptions when calling on bogus addresses for that domain

This commit is contained in:
adelikat 2012-12-27 18:48:12 +00:00
parent 2988217d77
commit 06bd1b979a
1 changed files with 2 additions and 2 deletions

View File

@ -501,7 +501,7 @@ namespace BizHawk.Emulation.Consoles.GB
System.Runtime.InteropServices.Marshal.Copy(data, CachedMemory, 0, length); System.Runtime.InteropServices.Marshal.Copy(data, CachedMemory, 0, length);
readneeded = false; readneeded = false;
} }
return CachedMemory[addr]; return CachedMemory[addr & (CachedMemory.Length - 1)];
} }
public void Poke(int addr, byte val) public void Poke(int addr, byte val)
{ {
@ -513,7 +513,7 @@ namespace BizHawk.Emulation.Consoles.GB
System.Runtime.InteropServices.Marshal.Copy(data, CachedMemory, 0, length); System.Runtime.InteropServices.Marshal.Copy(data, CachedMemory, 0, length);
readneeded = false; readneeded = false;
} }
CachedMemory[addr] = val; CachedMemory[addr & (CachedMemory.Length - 1)] = val;
writeneeded = true; writeneeded = true;
} }
} }