diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 70a31ea30..6c4bef30c 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -360,10 +360,10 @@ template struct Base { break; } } - ram_[ram_pointer_ & 16383] = read_ahead_buffer_; + ram_[ram_pointer_ & memory_mask(personality)] = read_ahead_buffer_; break; case MemoryAccess::Read: - read_ahead_buffer_ = ram_[ram_pointer_ & 16383]; + read_ahead_buffer_ = ram_[ram_pointer_ & memory_mask(personality)]; break; } ++ram_pointer_; diff --git a/Components/9918/Implementation/PersonalityTraits.hpp b/Components/9918/Implementation/PersonalityTraits.hpp index 6a6afdac0..985a4d02a 100644 --- a/Components/9918/Implementation/PersonalityTraits.hpp +++ b/Components/9918/Implementation/PersonalityTraits.hpp @@ -42,6 +42,10 @@ constexpr size_t memory_size(Personality p) { } } +constexpr uint16_t memory_mask(Personality p) { + return (memory_size(p) >= 65536) ? 0xffff : uint16_t(memory_size(p) - 1); +} + } }