diff options
Diffstat (limited to 'src/crt.c')
-rw-r--r-- | src/crt.c | 88 |
1 files changed, 85 insertions, 3 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.3 2008/02/04 20:23:55 james + * *** empty log message *** + * * Revision 1.2 2008/02/04 02:05:06 james * *** empty log message *** * @@ -21,15 +24,94 @@ static char rcsid[] = "$Id$"; #include "project.h" void +crt_erase (CRT * c, CRT_Pos s, CRT_Pos e,int ea) +{ + CRT_CA *ps = &c->screen[CRT_ADDR_POS (&s)]; + CRT_CA *pe = &c->screen[CRT_ADDR_POS (&e)]; + + while (ps <= pe) + { + ps->chr = ' '; + if (ea) + ps->attr = CRT_ATTR_NORMAL; + ps++; + } + +} + +void crt_cls (CRT * c) { + CRT_Pos s = { 0, 0 }; + CRT_Pos e = { CRT_COLS - 1, CRT_ROWS - 1 }; int i; - for (i = 0; i < CRT_CELS; ++i) + crt_erase (c, s, e,1); + +#if 0 + for (i = 0; i < CRT_ROWS; ++i) + { + c->screen[CRT_ADDR (i, i)].chr = '@' + i; + c->screen[CRT_ADDR (i, i)].attr = CRT_ATTR_NORMAL; + } +#endif + +} + +void +crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e,int ea) +{ + int l, n; + int p; + + s.x=0; + e.x=CRT_COLS-1; + + l = e.x - s.x; + l++; + l *= sizeof (CRT_CA); + + n = e.y - s.y; + + p = CRT_ADDR_POS (&s); + + while (n--) { - c->screen[i].chr = ' '; - c->screen[i].chr = CRT_ATTR_NORMAL; + memcpy (&c->screen[p], &c->screen[p + CRT_COLS], l); + p += CRT_COLS; } + + s.y = e.y; + crt_erase (c, s, e,ea); + +} + +void +crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e,int ea) +{ + int l, n; + int p; + + s.x=0; + e.x=CRT_COLS-1; + + l = e.x - s.x; + l++; + l *= sizeof (CRT_CA); + + n = e.y - s.y; + + p = CRT_ADDR_POS (&e); + + while (n--) + { + memcpy (&c->screen[p], &c->screen[p + CRT_COLS], l); + p -= CRT_COLS; + } + + e.y = s.y; + crt_erase (c, s, e,ea); + } void |