From 65c857abba7d30d130a9646213b9b67143ab3839 Mon Sep 17 00:00:00 2001 From: Frederic Meyer Date: Sun, 24 May 2020 20:45:41 +0200 Subject: [PATCH] [core] memory: Fix unaligned S16 reads from out-of-bounds ROM. --- source/emulator/core/cpu-memory.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/emulator/core/cpu-memory.inl b/source/emulator/core/cpu-memory.inl index 7a0a1a7bb..5b9df7f3a 100644 --- a/source/emulator/core/cpu-memory.inl +++ b/source/emulator/core/cpu-memory.inl @@ -125,7 +125,7 @@ inline auto CPU::ReadByte(std::uint32_t address, Access access) -> std::uint8_t // return gpio->read(address); // } if (address >= memory.rom.size) { - return address / 2; + return (address / 2) >> ((address & 1) * 8); } return Read(memory.rom.data.get(), address); }