From 45375fb5d0dbbd7d8b64bfa187054f44c7022c25 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 9 Nov 2019 09:48:59 -0500 Subject: [PATCH] Makes endian aware. --- Machines/AtariST/Video.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Machines/AtariST/Video.cpp b/Machines/AtariST/Video.cpp index da888e9d4..a58138f17 100644 --- a/Machines/AtariST/Video.cpp +++ b/Machines/AtariST/Video.cpp @@ -302,8 +302,13 @@ void Video::shift_out(int length) { output_shifter_ <<= pixels; } } break; - case OutputBpp::Two: + case OutputBpp::Two: { pixel_buffer_.pixels_output += length; +#if TARGET_RT_BIG_ENDIAN + const int upper = 0; +#else + const int upper = 1; +#endif if(pixel_buffer_.pixel_pointer) { while(length--) { *pixel_buffer_.pixel_pointer = palette_[ @@ -313,20 +318,20 @@ void Video::shift_out(int length) { // 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; + shifter_halves_[upper] = (shifter_halves_[upper] << 1) & 0xfffefffe; + shifter_halves_[upper] |= (shifter_halves_[upper^1] & 0x80008000) >> 15; + shifter_halves_[upper^1] = (shifter_halves_[upper^1] << 1) & 0xfffefffe; ++pixel_buffer_.pixel_pointer; } } else { while(length--) { - shifter_halves_[1] = (shifter_halves_[1] << 1) & 0xfffefffe; - shifter_halves_[1] |= (shifter_halves_[0] & 0x80008000) >> 15; - shifter_halves_[0] = (shifter_halves_[0] << 1) & 0xfffefffe; + shifter_halves_[upper] = (shifter_halves_[upper] << 1) & 0xfffefffe; + shifter_halves_[upper] |= (shifter_halves_[upper^1] & 0x80008000) >> 15; + shifter_halves_[upper^1] = (shifter_halves_[upper^1] << 1) & 0xfffefffe; } } - break; + } break; default: case OutputBpp::Four: pixel_buffer_.pixels_output += length >> 1;