[coreboot] [PATCH] libpayload: correct tinycurses color on the VGA console

Ulf Jordan jordan at chalmers.se
Sat Aug 16 15:12:27 CEST 2008


The attached patch makes the VGA output from tinycurses match the curses 
color macros.

Build and run tested under QEMU with coreinfo+coreboot-v3, 
bayou-0.3+coreboot-v3 (now looks very red, just like the color pairs 
specify...), and tint-0.03b+coreboot-v3.

-------------- next part --------------
Fix tinycurses color output on the VGA console.

The CGA compatible 16 color VGA text mode expects Intensity RGB color
specifications, in the order IRGB from most to least significant bit.
Curses COLOR_ macros follows ANSI X3.64/ISO 6429/ECMA-48, specifying
RGB color in the order BGR from most to least significant bit.
Consequently, it is necessary to swap the red and blue bits.

Signed-off-by: Ulf Jordan <jordan at chalmers.se>

Index: libpayload/curses/tinycurses.c
--- libpayload/curses/tinycurses.c	(revision 3511)
+++ libpayload/curses/tinycurses.c	(arbetskopia)
@@ -658,6 +658,8 @@
 	return OK;
+#define SWAP_RED_BLUE(c) \
+	(((c) & 0x4400) >> 2) | ((c) & 0xAA00) | (((c) & 0x1100) << 2)
 int wnoutrefresh(WINDOW *win)
 	// FIXME.
@@ -720,6 +722,8 @@
+			c = SWAP_RED_BLUE(c);
 			if (curses_flags & F_ENABLE_CONSOLE) {
 				ch = win->_line[y].text[x].chars[0];

More information about the coreboot mailing list