From 80e15531f24fb00eb6e3a3825ceac28f0125ef02 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 23 Aug 2022 13:40:46 +0200 Subject: [PATCH] Emulator: Add bitmask for additional safety in read/write functions --- src/cpu.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index fe8795c..07f83bc 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -392,27 +392,27 @@ void CPU::jp16() uint32_t CPU::pcRead() { - uint32_t data = Emu::the().readMemory(m_pc); + uint32_t data = Emu::the().readMemory(m_pc) & 0x00ff; m_pc = (m_pc + 1) & 0xffff; return data; } void CPU::write(uint32_t address, uint32_t value) { - Emu::the().writeMemory(address, value); + Emu::the().writeMemory(address, value & 0x00ff); } uint32_t CPU::read(uint32_t address) { - return Emu::the().readMemory(address); + return Emu::the().readMemory(address) & 0x00ff; } void CPU::ffWrite(uint32_t address, uint32_t value) { - Emu::the().writeMemory(address | (0xff << 8), value); + Emu::the().writeMemory(address | (0xff << 8), value & 0x00ff); } uint32_t CPU::ffRead(uint32_t address) { - return Emu::the().readMemory(address | (0xff << 8)); + return Emu::the().readMemory(address | (0xff << 8)) & 0x00ff; }