diff --git a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs index 44036f85d2..b06eca96e4 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -501,7 +501,7 @@ namespace BizHawk.Emulation.Consoles.GB System.Runtime.InteropServices.Marshal.Copy(data, CachedMemory, 0, length); readneeded = false; } - return CachedMemory[addr]; + return CachedMemory[addr & (CachedMemory.Length - 1)]; } 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); readneeded = false; } - CachedMemory[addr] = val; + CachedMemory[addr & (CachedMemory.Length - 1)] = val; writeneeded = true; } }