From: Brett Gordon Date: Thu, 8 Oct 2015 18:19:14 +0000 (-0400) Subject: coco3: separate low-level video methods into separate source file. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=c226705c00b322b856b0765ae9c8ecde20eebd66;p=FUZIX.git coco3: separate low-level video methods into separate source file. --- diff --git a/Kernel/platform-coco3/devtty.c b/Kernel/platform-coco3/devtty.c index 0c66f3af..e4fd2c32 100644 --- a/Kernel/platform-coco3/devtty.c +++ b/Kernel/platform-coco3/devtty.c @@ -129,13 +129,13 @@ static struct mode_s mode[4] = { }; -static struct pty ptytab[] = { +static struct pty ptytab[] VSECTD = { { - (unsigned char *) 0xb400, + (unsigned char *) 0x2000, NULL, 0, {0, 0, 0, 0}, - 0xb400 / 8, + 0x10000 / 8, 0x74, /* 80 column */ 80, 25, @@ -144,11 +144,11 @@ static struct pty ptytab[] = { &fmodes[0] }, { - (unsigned char *) 0xac00, + (unsigned char *) 0x3000, NULL, 0, {0, 0, 0, 0}, - 0xac00 / 8, + 0x11000 / 8, 0x6c, /* 40 column */ 40, 25, @@ -160,7 +160,7 @@ static struct pty ptytab[] = { /* ptr to current active pty table */ -struct pty *curpty = &ptytab[0]; +struct pty *curpty VSECTD = &ptytab[0]; /* current minor for input */ int curminor = 1; @@ -431,72 +431,6 @@ void platform_interrupt(void) -/* These are routines stolen from the stock vt.c's VT_SIMPLE code, and modified - to suite multiple vts -*/ - - -static uint8_t *char_addr(unsigned int y1, unsigned char x1) -{ - return curpty->base + VT_WIDTH * y1 + (uint16_t) x1; -} - -void cursor_off(void) -{ - if (curpty->cpos) - *curpty->cpos = curpty->csave; -} - -void cursor_on(int8_t y, int8_t x) -{ - curpty->csave = *char_addr(y, x); - curpty->cpos = char_addr(y, x); - *curpty->cpos = VT_MAP_CHAR('_'); -} - -void plot_char(int8_t y, int8_t x, uint16_t c) -{ - *char_addr(y, x) = VT_MAP_CHAR(c); -} - -void clear_lines(int8_t y, int8_t ct) -{ - unsigned char *s = char_addr(y, 0); - memset(s, ' ', ct * VT_WIDTH); -} - -void clear_across(int8_t y, int8_t x, int16_t l) -{ - unsigned char *s = char_addr(y, x); - memset(s, ' ', l); -} - -/* FIXME: these should use memmove */ - -void scroll_up(void) -{ - memcpy(curpty->base, curpty->base + VT_WIDTH, - VT_WIDTH * VT_BOTTOM); -} - -void scroll_down(void) -{ - memcpy(curpty->base + VT_WIDTH, curpty->base, - VT_WIDTH * VT_BOTTOM); -} - - -unsigned char vt_map(unsigned char c) -{ - /* The CoCo3's gime has a strange code for underscore */ - if (c == '_') - return 0x7F; - if (c == '`') - return 0x5E; /* up arrow */ - return c; -} - - int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) { if ( minor > 2 ) /* remove once DW get its own ioctl() */ diff --git a/Kernel/platform-coco3/video.c b/Kernel/platform-coco3/video.c new file mode 100644 index 00000000..631da1cf --- /dev/null +++ b/Kernel/platform-coco3/video.c @@ -0,0 +1,99 @@ +#include +#include + + + +/* These are routines stolen from the stock vt.c's VT_SIMPLE code, and modified + to suite multiple vts + + These routines are called by vt.c. They play with Kernel banking, so this + module should be compiled into the .video section. These routines should + only reference/call things that are in .video or .videodata + +*/ + +static void map_for_video() +{ + *( uint8_t *)0xffa9 = 8; + *( uint8_t *)0xffaa = 9; +} + +static void map_for_kernel() +{ + *( uint8_t *)0xffa9 = 1; + *( uint8_t *)0xffaa = 2; +} + +static uint8_t *char_addr(unsigned int y1, unsigned char x1) +{ + return curpty->base + VT_WIDTH * y1 + (uint16_t) x1; +} + +void cursor_off(void) +{ + map_for_video(); + if (curpty->cpos) + *curpty->cpos = curpty->csave; + map_for_kernel(); +} + +void cursor_on(int8_t y, int8_t x) +{ + map_for_video(); + curpty->csave = *char_addr(y, x); + curpty->cpos = char_addr(y, x); + *curpty->cpos = VT_MAP_CHAR('_'); + map_for_kernel(); +} + +void plot_char(int8_t y, int8_t x, uint16_t c) +{ + map_for_video(); + *char_addr(y, x) = VT_MAP_CHAR(c); + 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); + 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); + map_for_kernel(); +} + +/* FIXME: these should use memmove */ + +void scroll_up(void) +{ + map_for_video(); + memcpy(curpty->base, curpty->base + VT_WIDTH, + VT_WIDTH * VT_BOTTOM); + map_for_kernel(); +} + +void scroll_down(void) +{ + map_for_video(); + memcpy(curpty->base + VT_WIDTH, curpty->base, + VT_WIDTH * VT_BOTTOM); + map_for_kernel(); +} + + +unsigned char vt_map(unsigned char c) +{ + /* The CoCo3's gime has a strange code for underscore */ + if (c == '_') + return 0x7F; + if (c == '`') + return 0x5E; /* up arrow */ + return c; +}