diff options
| author | H. Peter Anvin <hpa@zytor.com> | 2006-09-21 16:44:31 -0700 |
|---|---|---|
| committer | H. Peter Anvin <hpa@zytor.com> | 2006-09-21 16:44:31 -0700 |
| commit | 6ba87f949b0e232f54c8a1552f9a0ed6ff4e9ae1 (patch) | |
| tree | 442c8eb2f38cf6c25c8f29f648098d46b43c216e /com32/lib/sys | |
| parent | c5483c388bed52d4c0299d98e3678a2c3c24e985 (diff) | |
| download | syslinux-6ba87f949b0e232f54c8a1552f9a0ed6ff4e9ae1.tar.gz | |
Use the color table for the shadow, and make it user controllable
Diffstat (limited to 'com32/lib/sys')
| -rw-r--r-- | com32/lib/sys/colortable.c | 2 | ||||
| -rw-r--r-- | com32/lib/sys/vesa/drawtxt.c | 39 | ||||
| -rw-r--r-- | com32/lib/sys/vesa/fill.h | 66 | ||||
| -rw-r--r-- | com32/lib/sys/vesa/initvesa.c | 12 | ||||
| -rw-r--r-- | com32/lib/sys/vesa/video.h | 17 | ||||
| -rw-r--r-- | com32/lib/sys/vesacon_write.c | 9 |
6 files changed, 96 insertions, 49 deletions
diff --git a/com32/lib/sys/colortable.c b/com32/lib/sys/colortable.c index aa1ed6ed..5f7e8022 100644 --- a/com32/lib/sys/colortable.c +++ b/com32/lib/sys/colortable.c @@ -1,7 +1,7 @@ #include <colortbl.h> static struct color_table default_color_table[] = { - {"default", "0", 0xffffffff, 0x00000000 } + {"default", "0", 0xffffffff, 0x00000000, SHADOW_NORMAL } }; struct color_table *console_color_table = &default_color_table; diff --git a/com32/lib/sys/vesa/drawtxt.c b/com32/lib/sys/vesa/drawtxt.c index f35e1b71..c30e19f1 100644 --- a/com32/lib/sys/vesa/drawtxt.c +++ b/com32/lib/sys/vesa/drawtxt.c @@ -85,6 +85,7 @@ static void vesacon_update_characters(int row, int col, int nrows, int ncols) unsigned long pixel_offset, bytes_per_row; uint8_t row_buffer[VIDEO_X_SIZE*4], *rowbufptr; uint8_t *fbrowptr; + uint8_t sha; bgrowptr = &__vesacon_background[row*height+VIDEO_BORDER][col*width+VIDEO_BORDER]; @@ -125,8 +126,9 @@ static void vesacon_update_characters(int row, int col, int nrows, int ncols) chsbits = __vesacon_graphics_font[csptr->ch][pixsrow]; if (__unlikely(csptr == cursor_pointer)) chsbits |= cursor_pattern[pixsrow]; - chsbits &= (csptr->sha & 0x02) ? 0xff : 0x00; - chsbits ^= (csptr->sha & 0x01) ? 0xff : 0x00; + sha = console_color_table[csptr->attr].shadow; + chsbits &= (sha & 0x02) ? 0xff : 0x00; + chsbits ^= (sha & 0x01) ? 0xff : 0x00; chsbits <<= (width-2); csptr++; @@ -145,9 +147,10 @@ static void vesacon_update_characters(int row, int col, int nrows, int ncols) chbits = __vesacon_graphics_font[cptr->ch][pixrow]; if (__unlikely(cptr == cursor_pointer)) chbits |= cursor_pattern[pixrow]; + sha = console_color_table[cptr->attr].shadow; chxbits = chbits; - chxbits &= (cptr->sha & 0x02) ? 0xff : 0x00; - chxbits ^= (cptr->sha & 0x01) ? 0xff : 0x00; + chxbits &= (sha & 0x02) ? 0xff : 0x00; + chxbits ^= (sha & 0x01) ? 0xff : 0x00; fgcolor = console_color_table[cptr->attr].argb_fg; bgcolor = console_color_table[cptr->attr].argb_bg; cptr++; @@ -156,8 +159,9 @@ static void vesacon_update_characters(int row, int col, int nrows, int ncols) chsbits = __vesacon_graphics_font[csptr->ch][pixsrow]; if (__unlikely(csptr == cursor_pointer)) chsbits |= cursor_pattern[pixsrow]; - chsbits &= (csptr->sha & 0x02) ? 0xff : 0x00; - chsbits ^= (csptr->sha & 0x01) ? 0xff : 0x00; + sha = console_color_table[csptr->attr].shadow; + chsbits &= (sha & 0x02) ? 0xff : 0x00; + chsbits ^= (sha & 0x01) ? 0xff : 0x00; csptr++; break; default: @@ -234,21 +238,8 @@ static inline void vesacon_touch(int row, int col, int rows, int cols) upd_x1 = x1; } -/* Fill a number of characters... */ -static inline struct vesa_char *vesacon_fill(struct vesa_char *ptr, - struct vesa_char fill, - unsigned int count) -{ - asm volatile("cld; rep; stosl" - : "+D" (ptr), "+c" (count) - : "a" (fill) - : "memory"); - - return ptr; -} - /* Erase a region of the screen */ -void __vesacon_erase(int x0, int y0, int x1, int y1, uint8_t attr, int rev) +void __vesacon_erase(int x0, int y0, int x1, int y1, uint8_t attr) { int y; struct vesa_char *ptr = &__vesacon_text_display @@ -256,7 +247,6 @@ void __vesacon_erase(int x0, int y0, int x1, int y1, uint8_t attr, int rev) struct vesa_char fill = { .ch = ' ', .attr = attr, - .sha = rev }; int ncols = x1-x0+1; @@ -269,7 +259,7 @@ void __vesacon_erase(int x0, int y0, int x1, int y1, uint8_t attr, int rev) } /* Scroll the screen up */ -void __vesacon_scroll_up(int nrows, uint8_t attr, int rev) +void __vesacon_scroll_up(int nrows, uint8_t attr) { struct vesa_char *fromptr = &__vesacon_text_display [(nrows+1)*(TEXT_PIXEL_COLS/FONT_WIDTH+2)]; @@ -279,28 +269,25 @@ void __vesacon_scroll_up(int nrows, uint8_t attr, int rev) struct vesa_char fill = { .ch = ' ', .attr = attr, - .sha = rev, }; toptr = copy_dword(toptr, fromptr, dword_count); dword_count = nrows*(TEXT_PIXEL_COLS/FONT_WIDTH+2); - /* Danger, Will Robinson: this is wrong if rev != SHADOW_NORMAL */ vesacon_fill(toptr, fill, dword_count); vesacon_touch(0, 0, __vesacon_text_rows, TEXT_PIXEL_COLS/FONT_WIDTH); } /* Draw one character text at a specific area of the screen */ -void __vesacon_write_char(int x, int y, uint8_t ch, uint8_t attr, int rev) +void __vesacon_write_char(int x, int y, uint8_t ch, uint8_t attr) { struct vesa_char *ptr = &__vesacon_text_display [(y+1)*(TEXT_PIXEL_COLS/FONT_WIDTH+2)+(x+1)]; ptr->ch = ch; ptr->attr = attr; - ptr->sha = rev; vesacon_touch(y, x, 1, 1); } diff --git a/com32/lib/sys/vesa/fill.h b/com32/lib/sys/vesa/fill.h new file mode 100644 index 00000000..379852eb --- /dev/null +++ b/com32/lib/sys/vesa/fill.h @@ -0,0 +1,66 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2006 H. Peter Anvin - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +#ifndef LIB_SYS_VESA_FILL_H +#define LIB_SYS_VESA_FILL_H + +#include "video.h" + +/* Fill a number of characters. */ +static inline struct vesa_char *vesacon_fill(struct vesa_char *ptr, + struct vesa_char fill, + unsigned int count) +{ + switch (sizeof(struct vesa_char)) { + case 1: + asm volatile("cld; rep; stosb" + : "+D" (ptr), "+c" (count) + : "a" (fill) + : "memory"); + break; + case 2: + asm volatile("cld; rep; stosw" + : "+D" (ptr), "+c" (count) + : "a" (fill) + : "memory"); + break; + case 4: + asm volatile("cld; rep; stosl" + : "+D" (ptr), "+c" (count) + : "a" (fill) + : "memory"); + break; + default: + while (count--) + *ptr++ = fill; + break; + } + + return ptr; +} + +#endif /* LIB_SYS_VESA_FILL_H */ diff --git a/com32/lib/sys/vesa/initvesa.c b/com32/lib/sys/vesa/initvesa.c index 7394c9d1..35084449 100644 --- a/com32/lib/sys/vesa/initvesa.c +++ b/com32/lib/sys/vesa/initvesa.c @@ -41,6 +41,7 @@ #include <sys/fpu.h> #include "vesa.h" #include "video.h" +#include "fill.h" struct vesa_info __vesa_info; @@ -239,6 +240,10 @@ static int init_text_display(void) { size_t nchars; struct vesa_char *ptr; + struct vesa_char def_char = { + .ch = ' ', + .attr = 0, + }; nchars = (TEXT_PIXEL_ROWS/__vesacon_font_height+2)* (TEXT_PIXEL_COLS/FONT_WIDTH+2); @@ -248,11 +253,8 @@ static int init_text_display(void) if (!ptr) return -1; - /* I really which C had a memset() for larger-than-bytes objects... */ - asm volatile("cld; rep; stosl" - : "+D" (ptr), "+c" (nchars) - : "a" (' '+(0 << 8)+(SHADOW_NORMAL << 16)) - : "memory"); + + vesacon_fill(ptr, def_char, nchars); return 0; } diff --git a/com32/lib/sys/vesa/video.h b/com32/lib/sys/vesa/video.h index 5070f9ef..f8901509 100644 --- a/com32/lib/sys/vesa/video.h +++ b/com32/lib/sys/vesa/video.h @@ -28,6 +28,8 @@ #ifndef LIB_SYS_VESA_VIDEO_H #define LIB_SYS_VESA_VIDEO_H +#include <colortbl.h> + #define FONT_MAX_CHARS 256 #define FONT_MAX_HEIGHT 32 #define FONT_WIDTH 8 @@ -39,16 +41,9 @@ #define TEXT_PIXEL_ROWS (VIDEO_Y_SIZE-2*VIDEO_BORDER) #define TEXT_PIXEL_COLS (VIDEO_X_SIZE-2*VIDEO_BORDER) -#define SHADOW_NONE 0 -#define SHADOW_ALL 1 -#define SHADOW_NORMAL 2 -#define SHADOW_REVERSE 3 - struct vesa_char { uint8_t ch; /* Character */ - uint8_t attr; /* PC-style graphics attribute */ - uint8_t sha; /* Shadow attributes */ - uint8_t pad; /* Currently unused */ + uint8_t attr; /* Color table index */ }; /* Pixel formats in order of decreasing preference; PXF_NONE should be last */ @@ -76,9 +71,9 @@ int __vesacon_init_background(void); int vesacon_load_background(const char *); int __vesacon_init(void); void __vesacon_init_cursor(int); -void __vesacon_erase(int, int, int, int, uint8_t, int); -void __vesacon_scroll_up(int, uint8_t, int); -void __vesacon_write_char(int, int, uint8_t, uint8_t, int); +void __vesacon_erase(int, int, int, int, uint8_t); +void __vesacon_scroll_up(int, uint8_t); +void __vesacon_write_char(int, int, uint8_t, uint8_t); void __vesacon_redraw_text(void); void __vesacon_doit(void); void __vesacon_set_cursor(int, int, int); diff --git a/com32/lib/sys/vesacon_write.c b/com32/lib/sys/vesacon_write.c index 7f1570be..87f70666 100644 --- a/com32/lib/sys/vesacon_write.c +++ b/com32/lib/sys/vesacon_write.c @@ -117,16 +117,14 @@ int __vesacon_close(struct file_info *fp) static void vesacon_erase(const struct term_state *st, int x0, int y0, int x1, int y1) { - __vesacon_erase(x0, y0, x1, y1, st->attr, - st->reverse ? SHADOW_ALL : SHADOW_NORMAL); + __vesacon_erase(x0, y0, x1, y1, st->cindex); } /* Draw text on the screen */ static void vesacon_write_char(int x, int y, uint8_t ch, const struct term_state *st) { - __vesacon_write_char(x, y, ch, st->cindex, - st->reverse ? SHADOW_ALL : SHADOW_NORMAL); + __vesacon_write_char(x, y, ch, st->cindex); } /* Show or hide the cursor */ @@ -137,8 +135,7 @@ static void vesacon_showcursor(const struct term_state *st) static void vesacon_scroll_up(const struct term_state *st) { - __vesacon_scroll_up(1, st->cindex, - st->reverse ? SHADOW_ALL : SHADOW_NORMAL); + __vesacon_scroll_up(1, st->cindex); } ssize_t __vesacon_write(struct file_info *fp, const void *buf, size_t count) |
