From 06bd1b979ac61182d1133f5b4edfe5cfb6558a3e Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 27 Dec 2012 18:48:12 +0000 Subject: [PATCH] GB - mask peek and poke memory functions, fixes potential exceptions when calling on bogus addresses for that domain --- BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } }