From fa18b06dbfc9416b014c7eaf6951b70253c8774a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Apr 2021 21:13:36 -0400 Subject: [PATCH] Correct get_floating_value to be consistent in out-of-bounds behaviour. --- Machines/Sinclair/ZXSpectrum/Video.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Machines/Sinclair/ZXSpectrum/Video.hpp b/Machines/Sinclair/ZXSpectrum/Video.hpp index 7ac67758c..eafbb90d7 100644 --- a/Machines/Sinclair/ZXSpectrum/Video.hpp +++ b/Machines/Sinclair/ZXSpectrum/Video.hpp @@ -401,20 +401,24 @@ template class Video { */ uint8_t get_floating_value() const { constexpr auto timings = get_timings(); + const uint8_t out_of_bounds = (timing == VideoTiming::Plus3) ? last_contended_access_ : 0xff; + const int line = time_into_frame_ / timings.cycles_per_line; - if(line >= 192) return 0xff; + if(line >= 192) { + return out_of_bounds; + } const int time_into_line = time_into_frame_ % timings.cycles_per_line; if(time_into_line >= 256 || (time_into_line&8)) { - return last_contended_access_; + return out_of_bounds; } // The +2a and +3 always return the low bit as set. + const uint8_t value = last_fetches_[(time_into_line >> 1) & 3]; if constexpr (timing == VideoTiming::Plus3) { - return last_fetches_[(time_into_line >> 1) & 3] | 1; + return value | 1; } - - return last_fetches_[(time_into_line >> 1) & 3]; + return value; } /*!