From 99224fd6d013ef2b8b95f7c1e2205b5351954c0b Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 4 Dec 2018 21:49:13 +0100 Subject: [PATCH] Load_HGR() better HGR mode based on "Le Chat Mauve" real display --- src/miscfileformats.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 58613bb0..da5d79ab 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -6784,18 +6784,35 @@ void Load_HGR(T_IO_Context * context) } else { - if (x & 1) + /// HGR emulation following the behaviour of a "Le Chat Mauve" + /// RVB adapter for the Apple //c. + /// Within the bit stream, the color of the middle pixel is :
+ /// + /// 111 \
+ /// 110 }- white
+ /// 011 /
+ /// 010 \ _ color
+ /// 101 /
+ /// 000 \
+ /// 001 }- black
+ /// 100 /
+ ///
+ /// Color depends on the selected palette for the current byte + /// and the position of the pixel (odd or even). + if ((color & 3) == 3) // 11 => white { - if ((color & 6) == 6) // 2 bits to 1 => force White - { - Set_pixel(context, x - 2, y, 3 + previous_palette); - Set_pixel(context, x - 1, y, 3 + palette); - } - else - Set_pixel(context, x - 1, y, (color & 3) + palette); - Set_pixel(context, x, y, (color & 3) + palette); - previous_palette = palette; + Set_pixel(context, x - 1, y, 3 + previous_palette); + Set_pixel(context, x, y, 3 + palette); } + else if ((color & 1) == 0) // 0 => black + Set_pixel(context, x, y, palette); + else // 01 => color + { + if ((color & 7) == 5) // 101 + Set_pixel(context, x - 1, y, 2 - (x & 1) + previous_palette); + Set_pixel(context, x, y, 2 - (x & 1) + palette); + } + previous_palette = palette; } b >>= 1; x++;