kern
annotate src/vid.c @ 0:662ff2170531
starting the kernel
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 01 Dec 2010 22:02:42 +0200 |
parents | |
children | ebe5e0e44a9d |
rev | line source |
---|---|
nuclear@0 | 1 #include <string.h> |
nuclear@0 | 2 #include "vid.h" |
nuclear@0 | 3 |
nuclear@0 | 4 #define WIDTH 80 |
nuclear@0 | 5 #define HEIGHT 25 |
nuclear@0 | 6 static uint16_t *vmem = (uint16_t*)0xb8000; |
nuclear@0 | 7 |
nuclear@0 | 8 void clear_scr(void) |
nuclear@0 | 9 { |
nuclear@0 | 10 memset(vmem, 0, WIDTH * HEIGHT * 2); |
nuclear@0 | 11 } |
nuclear@0 | 12 |
nuclear@0 | 13 void set_cursor(int x, int y) |
nuclear@0 | 14 { |
nuclear@0 | 15 if(x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) { |
nuclear@0 | 16 /* disable cursor */ |
nuclear@0 | 17 return; |
nuclear@0 | 18 } |
nuclear@0 | 19 /* set cursor position */ |
nuclear@0 | 20 } |
nuclear@0 | 21 |
nuclear@0 | 22 void put_char(char c, int x, int y, int fg, int bg) |
nuclear@0 | 23 { |
nuclear@0 | 24 uint16_t attr = (fg & 0xf) | ((bg & 7) << 4); |
nuclear@0 | 25 vmem[y * 80 + x] = (uint16_t)c | (attr << 8); |
nuclear@0 | 26 } |