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_scroll(int s)
35 crtc_write(CRTC_START_H, s >> 8);
36 crtc_write(CRTC_START_L, s);
41 vga_setcolor(VGA_WHITE, VGA_BLACK);
44 memset((void*)0xb8000, 0, 80 * 25 * 2);
47 void vga_clearline(int row)
53 ptr = (uint16_t*)0xb8000 + row * 80;
54 memset16(ptr, attr, 80);
57 /* write a copy to wrap-around future scrolling */
59 memset16(ptr, attr, 80);
63 void vga_drawchar(int x, int y, int c)
65 uint16_t *ptr, val = (c & 0xff) | attr;
69 ptr = (uint16_t*)0xb8000 + y * 80 + x;
73 /* write a copy to wrap-around future scrolling */
79 static void crtc_write(int reg, unsigned char val)
81 outp(CRTC_ADDR_PORT, reg);
82 outp(CRTC_DATA_PORT, val);