From 99e3454527f971e83c6dcd512e1d415e7cd9ac8a Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Tue, 18 Jul 2017 21:40:29 +0100 Subject: [PATCH] Memory locking is dependent on the GB hardware, not the size of the program, so allow lock ranges to be manually specified. Signed-off-by: Adrian.Conlon --- inc/Memory.h | 4 ++++ src/Memory.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/Memory.h b/inc/Memory.h index 685f474..cbb3f8e 100644 --- a/inc/Memory.h +++ b/inc/Memory.h @@ -98,6 +98,10 @@ namespace EightBit { void loadRom(const std::string& path, uint16_t offset); void loadRam(const std::string& path, uint16_t offset); + void lock(int address, int size) { + std::fill(m_locked.begin() + address, m_locked.begin() + address + size, true); + } + protected: std::array m_bus; std::array m_locked; diff --git a/src/Memory.cpp b/src/Memory.cpp index 060a711..de1af21 100644 --- a/src/Memory.cpp +++ b/src/Memory.cpp @@ -35,7 +35,7 @@ void EightBit::Memory::clear() { void EightBit::Memory::loadRom(const std::string& path, uint16_t offset) { auto size = loadMemory(path, offset); - std::fill(m_locked.begin() + offset, m_locked.begin() + offset + size, true); + lock(offset, size); } void EightBit::Memory::loadRam(const std::string& path, uint16_t offset) {