kern
diff src/vid.c @ 1:ebe5e0e44a9d
pretty much finished the code for article 1, might do minor adjustments though
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 02 Dec 2010 08:45:41 +0200 |
parents | 662ff2170531 |
children | 86781ef20689 |
line diff
1.1 --- a/src/vid.c Wed Dec 01 22:02:42 2010 +0200 1.2 +++ b/src/vid.c Thu Dec 02 08:45:41 2010 +0200 1.3 @@ -1,26 +1,24 @@ 1.4 #include <string.h> 1.5 #include "vid.h" 1.6 1.7 -#define WIDTH 80 1.8 -#define HEIGHT 25 1.9 static uint16_t *vmem = (uint16_t*)0xb8000; 1.10 1.11 -void clear_scr(void) 1.12 +void clear_scr(int color) 1.13 { 1.14 memset(vmem, 0, WIDTH * HEIGHT * 2); 1.15 } 1.16 1.17 -void set_cursor(int x, int y) 1.18 +void set_char(char c, int x, int y, int fg, int bg) 1.19 { 1.20 - if(x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) { 1.21 - /* disable cursor */ 1.22 - return; 1.23 - } 1.24 - /* set cursor position */ 1.25 + uint16_t attr = (fg & 0xf) | ((bg & 7) << 4); 1.26 + vmem[y * WIDTH + x] = (uint16_t)c | (attr << 8); 1.27 } 1.28 1.29 -void put_char(char c, int x, int y, int fg, int bg) 1.30 +void scroll_scr(void) 1.31 { 1.32 - uint16_t attr = (fg & 0xf) | ((bg & 7) << 4); 1.33 - vmem[y * 80 + x] = (uint16_t)c | (attr << 8); 1.34 + /* copy the second up to last text line, one line back, then 1.35 + * clear the last line. 1.36 + */ 1.37 + memmove(vmem, vmem + WIDTH, WIDTH * (HEIGHT - 1) * 2); 1.38 + memset(vmem + WIDTH * (HEIGHT -1), 0, WIDTH * 2); 1.39 }