kern

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