1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-07 08:26:28 +00:00

Move nullptr check to bottom of pipeline.

This commit is contained in:
Thomas Harte
2025-01-02 21:02:11 -05:00
parent d0703f95af
commit 906e8aa2b2

View File

@@ -381,7 +381,7 @@ public:
++character_position_;
}
if(state == OutputState::Pixels && pixels_) {
if(state == OutputState::Pixels) {
switch(x_scroll_) {
case 0: draw<0>(); break;
case 1: draw<1>(); break;
@@ -861,7 +861,7 @@ private:
void draw_segment() {
if constexpr (length == 0) return;
const auto target = pixels_;
pixels_ += length;
if(target) pixels_ += length;
switch(mode) {
case VideoMode::Text: {
@@ -933,6 +933,7 @@ private:
template <int length>
void draw_1bpp_segment(uint16_t *const target, const uint16_t *colours) {
if(target) {
const auto pixels = output_.pixels();
if constexpr (length >= 1) target[0] = (pixels & 0x80) ? colours[1] : colours[0];
if constexpr (length >= 2) target[1] = (pixels & 0x40) ? colours[1] : colours[0];
@@ -942,6 +943,7 @@ 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);
}
@@ -949,6 +951,7 @@ private:
template <int length, bool is_leftovers>
void draw_2bpp_segment(uint16_t *const target, const uint16_t *colours) {
constexpr int leftover = is_leftovers && (length & 1);
if(target) {
const auto pixels = output_.pixels();
// Intention: skip first output if leftover is 1, but still do the correct
// length of output.
@@ -960,6 +963,7 @@ 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);