kern

view 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 source
1 #include <string.h>
2 #include "vid.h"
4 static uint16_t *vmem = (uint16_t*)0xb8000;
6 void clear_scr(int color)
7 {
8 memset(vmem, 0, WIDTH * HEIGHT * 2);
9 }
11 void set_char(char c, int x, int y, int fg, int bg)
12 {
13 uint16_t attr = (fg & 0xf) | ((bg & 7) << 4);
14 vmem[y * WIDTH + x] = (uint16_t)c | (attr << 8);
15 }
17 void scroll_scr(void)
18 {
19 /* copy the second up to last text line, one line back, then
20 * clear the last line.
21 */
22 memmove(vmem, vmem + WIDTH, WIDTH * (HEIGHT - 1) * 2);
23 memset(vmem + WIDTH * (HEIGHT -1), 0, WIDTH * 2);
24 }