5 #define CRTC_ADDR_PORT 0x3d4
6 #define CRTC_DATA_PORT 0x3d5
9 #define CRTC_START_H 0x0c
10 #define CRTC_START_L 0x0d
11 #define CRTC_CURPOS_H 0x0e
12 #define CRTC_CURPOS_L 0x0f
14 static void crtc_write(int reg, unsigned char val);
16 static uint16_t attr = 0x0700;
19 void vga_setcolor(int fg, int bg)
21 attr = ((bg & 7) << 12) | ((fg & 0xf) << 8);
24 void vga_setcursor(int x, int y)
26 int loc = (y + yoffs) * 80 + x;
27 crtc_write(CRTC_CURPOS_H, loc >> 8);
28 crtc_write(CRTC_CURPOS_L, loc);
31 void vga_setstart(int start)
34 crtc_write(CRTC_START_H, start >> 8);
35 crtc_write(CRTC_START_L, start);
40 vga_setcolor(VGA_WHITE, VGA_BLACK);
43 memset((void*)0xb8000, 0, 80 * 25 * 2);
46 void vga_drawchar(int x, int y, int c)
48 uint16_t *ptr = (uint16_t*)0xb8000 + (y + yoffs) * 80 + x;
49 *ptr = (c & 0xff) | attr;
52 static void crtc_write(int reg, unsigned char val)
54 outp(CRTC_ADDR_PORT, reg);
55 outp(CRTC_DATA_PORT, val);