From 4d96122884bf5e7953fc906e4497f2d7135ec02a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 Jan 2023 12:38:19 -0500 Subject: [PATCH] Eliminate hard-coded assumption of 16kb. Clearly I'll have to do something else to support 128k+, probably move the ram pointer? --- Components/9918/Implementation/9918Base.hpp | 4 ++-- Components/9918/Implementation/PersonalityTraits.hpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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); +} + } }