Jeffrey Hutzelman
2011-Feb-18 13:42 UTC
[syslinux] [PATCH] core: Honor DISPLAY text background color when in VGA mode
When in VGA graphics mode, BIOS int 10h ah=09h doesn't seem to treat high-order attribute bits as a background color; instead, it apparently always uses black. This means that a background color requested via <SI> in a DISPLAY file is not honored in VGA mode. However, the BIOS supports an "XOR" mode, in which the pixels to be written are XORed with pixels already on the screen (background pixels are left untouched). So, we can get the desired effect by first writing a solid block in the desired background color, followed by XORing in the character to be displayed, using a color which is the XOR of the foreground and background colors. This depends on the existence of an all-pixels-set character at font position 0xDB. Signed-off-by: Jeffrey Hutzelman <jhutz at cmu.edu> --- core/conio.inc | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/core/conio.inc b/core/conio.inc index b450502..0784e65 100644 --- a/core/conio.inc +++ b/core/conio.inc @@ -100,9 +100,25 @@ msg_normal: call write_serial_displaymask ; Write to serial port jz msg_ignore mov bl,[TextAttribute] mov bh,[BIOS_page] + cmp cl,02h + jnz .text + push ax + mov al,0xdb ; solid block + shr bl,4 ; background color mov ah,09h ; Write character/attribute mov cx,1 ; One character only int 10h ; Write to screen + pop ax + mov bl,[TextAttribute] + and bl,0fh ; foreground color + mov bh,[TextAttribute] + shr bh,4 ; background color + xor bl,bh + or bl,80h ; XOR mode + mov bh,[BIOS_page] +.text: mov ah,09h ; Write character/attribute + mov cx,1 ; One character only + int 10h ; Write to screen mov al,[CursorCol] inc ax cmp al,[VidCols] -- 1.7.1
H. Peter Anvin
2011-Feb-18 18:36 UTC
[syslinux] [PATCH] core: Honor DISPLAY text background color when in VGA mode
On 02/18/2011 05:42 AM, Jeffrey Hutzelman wrote:> When in VGA graphics mode, BIOS int 10h ah=09h doesn't seem to > treat high-order attribute bits as a background color; instead, > it apparently always uses black. This means that a background > color requested via <SI> in a DISPLAY file is not honored in > VGA mode. > > However, the BIOS supports an "XOR" mode, in which the pixels > to be written are XORed with pixels already on the screen > (background pixels are left untouched). So, we can get the > desired effect by first writing a solid block in the desired > background color, followed by XORing in the character to be > displayed, using a color which is the XOR of the foreground > and background colors. > > This depends on the existence of an all-pixels-set character > at font position 0xDB. > > Signed-off-by: Jeffrey Hutzelman <jhutz at cmu.edu>Since we already write the graphics screen directly, perhaps we should just generate the text ourselves rather than relying on the BIOS. We have to do that for VESA modes anyway. There are a lot of BIOS bugs in this area and relying on yet another bit of the BIOS (the XOR mode you mention) seems like the wrong thing to do... -hpa