From 8aa425c9d89b999016ce7f3e10febfec011a77c3 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 6 Nov 2019 23:25:36 -0500 Subject: [PATCH] Fixes medium resolution mode. --- Machines/AtariST/Video.cpp | 16 ++++++++++++---- Machines/AtariST/Video.hpp | 5 ++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Machines/AtariST/Video.cpp b/Machines/AtariST/Video.cpp index dfd930e1c..088f78f21 100644 --- a/Machines/AtariST/Video.cpp +++ b/Machines/AtariST/Video.cpp @@ -264,12 +264,20 @@ void Video::shift_out(int length) { ((output_shifter >> 63) & 1) | ((output_shifter >> 46) & 2) ]; - output_shifter = (output_shifter << 1);// & 0xfeffffff; + // This ensures that the top two words shift one to the left; + // their least significant bits are fed from the most significant bits + // of the bottom two words, respectively. + shifter_halves[1] = (shifter_halves[1] << 1) & 0xfffefffe; + shifter_halves[1] |= (shifter_halves[0] & 0x80008000) >> 15; + shifter_halves[0] = (shifter_halves[0] << 1) & 0xfffefffe; + ++pixel_buffer_.pixel_pointer; } } else { while(length--) { - output_shifter = (output_shifter << 1);// & 0xfeffffff; + shifter_halves[1] = (shifter_halves[1] << 1) & 0xfffefffe; + shifter_halves[1] |= (shifter_halves[0] & 0x80008000) >> 15; + shifter_halves[0] = (shifter_halves[0] << 1) & 0xfffefffe; } } break; @@ -284,13 +292,13 @@ void Video::shift_out(int length) { ((output_shifter >> 29) & 4) | ((output_shifter >> 12) & 8) ]; - output_shifter = (output_shifter << 1);// & 0xfefefefe; + output_shifter = (output_shifter << 1) & 0xfffefffefffefffe; ++pixel_buffer_.pixel_pointer; length -= 2; } } else { while(length) { - output_shifter = (output_shifter << 1);// & 0xfefefefe; + output_shifter = (output_shifter << 1) & 0xfffefffefffefffe; length -= 2; } } diff --git a/Machines/AtariST/Video.hpp b/Machines/AtariST/Video.hpp index 413ade1d7..a2e4756c8 100644 --- a/Machines/AtariST/Video.hpp +++ b/Machines/AtariST/Video.hpp @@ -79,7 +79,10 @@ class Video { int data_latch_position_ = 0; uint16_t data_latch_[4]; - uint64_t output_shifter; + union { + uint64_t output_shifter; + uint32_t shifter_halves[2]; + }; void shift_out(int length); void latch_word();