From 68979e8afd471f16c5a39888fbeaa23c2240651e Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 3 Apr 2022 21:41:22 +0200 Subject: write full bytes instead of pixels --- dostsr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dostsr.c b/dostsr.c index 0d24248..f281d8a 100644 --- a/dostsr.c +++ b/dostsr.c @@ -226,6 +226,7 @@ static void show_graphic_cursor(void) uint16_t cursor_xor_mask = get_graphic_cursor_xor_mask_line(offset.y + y) << offset.x; uint8_t pixel_mask = msb_pixel_mask; + uint8_t pixel = *line; unsigned x; // First, backup this scanline to prev before any changes @@ -240,23 +241,19 @@ static void show_graphic_cursor(void) } for (x = 0; x < size.x; x++) { - uint8_t pixel = *line; - if (!(cursor_and_mask & MSB_MASK)) { pixel &= ~pixel_mask; } if (cursor_xor_mask & MSB_MASK) { pixel ^= pixel_mask; } - if (!(cursor_and_mask & MSB_MASK) || (cursor_xor_mask & MSB_MASK)) { - *line = pixel; - } // Advance to the next pixel pixel_mask >>= info->bits_per_pixel; if (!pixel_mask) { // Time to advance to the next byte - line++; + *line = pixel; // Save current byte first + pixel = *(++line); pixel_mask = msb_pixel_mask; } @@ -264,6 +261,11 @@ static void show_graphic_cursor(void) cursor_and_mask <<= 1; cursor_xor_mask <<= 1; } + + if (pixel_mask != msb_pixel_mask) { + // We ended up in the middle of a byte, save it + *line = pixel; + } } } -- cgit v1.2.3