From a54985b27919313e97a2b49fe4b5f87824886d92 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 24 Jun 2010 17:50:00 +0200 Subject: [PATCH] conspy: document attribute byte format Signed-off-by: Denys Vlasenko --- miscutils/conspy.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 0a5fdccad..b443c9133 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -62,7 +62,7 @@ struct globals { int kbd_fd; unsigned width; unsigned height; - char last_attr; + uint8_t last_attr; int ioerror_count; int key_count; int escape_count; @@ -112,17 +112,43 @@ static void screen_read_close(void) static void screen_char(char *data) { - if (!BW && G.last_attr != ATTR(data)) { - // BLGCRMOW + uint8_t attr = ATTR(data); + + if (!BW && G.last_attr != attr) { +// Attribute layout for VGA compatible text videobuffer: +// blinking text +// |red bkgd +// ||green bkgd +// |||blue bkgd +// vvvv +// 00000000 <- lsb bit on the right +// bold text / text 8th bit +// red text +// green text +// blue text +// TODO: apparently framebuffer-based console uses different layout +// (bug? attempt to get 8th text bit in better position?) +// red bkgd +// |green bkgd +// ||blue bkgd +// vvv +// 00000000 <- lsb bit on the right +// bold text +// red text +// green text +// blue text +// text 8th bit + // converting RGB color bit triad to BGR: static const char color[8] = "04261537"; + G.last_attr = attr; printf("\033[%c;4%c;3%cm", - (ATTR(data) & 8) ? '1' // bold - : '0', // defaults - color[(ATTR(data) >> 4) & 7], color[ATTR(data) & 7]); - G.last_attr = ATTR(data); + (attr & 8) ? '1' : '0', // bold text / reset all + color[(attr >> 4) & 7], // bkgd color + color[attr & 7] // text color + ); } - bb_putchar(CHAR(data)); + putchar(CHAR(data)); } #define clrscr() printf("\033[1;1H" "\033[0J") -- 2.25.1