From 985c555518c175066680da3c5b5dd651ec49d1ff Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 2 Jan 2025 15:56:39 -0500 Subject: [PATCH] Support multicolour text. --- Machines/Commodore/Plus4/Video.hpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Machines/Commodore/Plus4/Video.hpp b/Machines/Commodore/Plus4/Video.hpp index a56f19c1e..215ccf64c 100644 --- a/Machines/Commodore/Plus4/Video.hpp +++ b/Machines/Commodore/Plus4/Video.hpp @@ -893,7 +893,6 @@ private: } }(); draw_1bpp_segment(target, colours.data()); - output_.advance_pixels(length); } if constexpr (mode == VideoMode::BitmapMulticolour) { @@ -906,12 +905,24 @@ private: background_[1], }; draw_2bpp_segment(target, colours); + } - constexpr int leftover = is_leftovers && (length & 1); - if(is_leftovers) { - output_.advance_pixels(length + leftover); + if constexpr (mode == VideoMode::MulticolourText) { + const auto attributes = output_.attributes<0>(); + if(attributes & 0x08) { + const uint16_t colours[] = { + background_[0], + background_[1], + background_[2], + colour(attributes & ~0x08) + }; + draw_2bpp_segment(target, colours); } else { - output_.advance_pixels(length & ~1); + const uint16_t colours[] = { + background_[0], + colour(attributes & ~0x08) + }; + draw_1bpp_segment(target, colours); } } @@ -932,6 +943,8 @@ private: if constexpr (length >= 6) target[5] = (pixels & 0x04) ? colours[1] : colours[0]; if constexpr (length >= 7) target[6] = (pixels & 0x02) ? colours[1] : colours[0]; if constexpr (length >= 8) target[7] = (pixels & 0x01) ? colours[1] : colours[0]; + + output_.advance_pixels(length); } template @@ -948,6 +961,12 @@ private: if constexpr (length + leftover >= 6) target[5] = colours[(pixels >> 2) & 3]; if constexpr (length + leftover >= 7) target[6] = colours[(pixels >> 0) & 3]; if constexpr (length + leftover >= 8) target[7] = colours[(pixels >> 0) & 3]; + + if(is_leftovers) { + output_.advance_pixels(length + leftover); + } else { + output_.advance_pixels(length & ~1); + } } };