Added cuard clauses back

This commit is contained in:
Lee Fogg 2020-04-26 12:15:53 +01:00
parent faa13478f9
commit 8fa13b6730
1 changed files with 7 additions and 3 deletions

View File

@ -55,17 +55,21 @@ namespace Emux.GameBoy.Cartridge
public byte ReadByte(int address)
{
return IsActive ? _externalMemory[address] : (byte)0;
if (_externalMemory != null && IsActive)
return _externalMemory[address];
return 0;
}
public void ReadBytes(int address, byte[] buffer, int offset, int length)
{
Array.Copy(_externalMemory, address, buffer, 0, length);
if (_externalMemory != null)
Array.Copy(_externalMemory, address, buffer, 0, length);
}
public void WriteByte(int address, byte value)
{
if (IsActive)
if (_externalMemory != null && IsActive)
_externalMemory[address] = value;
}