From 4972eb07e376f4e473ef54e7c5929cd6a9fcb1ac Mon Sep 17 00:00:00 2001 From: Brett Gordon Date: Thu, 29 Oct 2015 14:12:46 -0400 Subject: [PATCH] coco3: low level video driver now does color attributes. --- Kernel/platform-coco3/video.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Kernel/platform-coco3/video.c b/Kernel/platform-coco3/video.c index 427722a3..1072ec08 100644 --- a/Kernel/platform-coco3/video.c +++ b/Kernel/platform-coco3/video.c @@ -30,7 +30,7 @@ static void map_for_kernel() static uint8_t *char_addr(unsigned int y1, unsigned char x1) { - return curpty->base + VT_WIDTH * y1 + (uint16_t) x1; + return curpty->base + VT_WIDTH * y1 * 2 + (uint16_t)(x1*2); } void cursor_off(void) @@ -52,24 +52,31 @@ void cursor_on(int8_t y, int8_t x) void plot_char(int8_t y, int8_t x, uint16_t c) { + char *p=char_addr(y,x); map_for_video(); - *char_addr(y, x) = VT_MAP_CHAR(c); + *p++ = VT_MAP_CHAR(c); + *p = curpty->attr; map_for_kernel(); } void clear_lines(int8_t y, int8_t ct) { map_for_video(); - unsigned char *s = char_addr(y, 0); - memset(s, ' ', ct * VT_WIDTH); + uint16_t *s = (uint16_t *)char_addr(y, 0); + ct *= VT_WIDTH; + uint16_t w = ' ' * 0x100 + curpty->attr; + for( ; ct ; ct-- ) + *s++=w; map_for_kernel(); } void clear_across(int8_t y, int8_t x, int16_t l) { map_for_video(); - unsigned char *s = char_addr(y, x); - memset(s, ' ', l); + uint16_t *s = (uint16_t *)char_addr(y, x); + uint16_t w=' ' * 0x100 + curpty->attr; + for( ; l ; l-- ) + *s++=w; map_for_kernel(); } @@ -78,16 +85,16 @@ void clear_across(int8_t y, int8_t x, int16_t l) void scroll_up(void) { map_for_video(); - memcpy(curpty->base, curpty->base + VT_WIDTH, - VT_WIDTH * VT_BOTTOM); + memcpy(curpty->base, curpty->base + VT_WIDTH*2, + VT_WIDTH*2 * VT_BOTTOM); map_for_kernel(); } void scroll_down(void) { map_for_video(); - memcpy(curpty->base + VT_WIDTH, curpty->base, - VT_WIDTH * VT_BOTTOM); + memcpy(curpty->base + VT_WIDTH*2, curpty->base, + VT_WIDTH*2 * VT_BOTTOM); map_for_kernel(); } -- 2.34.1