vga.c (713B)
1 #include "oxytoxin.h" 2 3 void vga_cursor_enable(uint8_t s, uint8_t e) { 4 outb(vga_ctrl, 0x0a); 5 outb(vga_data, (inb(vga_data) & 0xc0) | s); 6 7 outb(vga_ctrl, 0x0b); 8 outb(vga_data, (inb(vga_data) & 0xe0) | e); 9 } 10 11 void vga_cursor_disable(void) { 12 outb(vga_ctrl, 0x0a); 13 outb(vga_data, 0x20); 14 } 15 16 void vga_cursor_update(int x, int y) { 17 uint16_t pos; 18 19 pos = y * vga_width + x; 20 outb(vga_ctrl, 0x0f); 21 outb(vga_data, (uint8_t) (pos & 0xff)); 22 23 outb(vga_ctrl, 0x0e); 24 outb(vga_data, (uint8_t) ((pos >> 8) & 0xff)); 25 } 26 27 uint16_t vga_cursor_get_pos(void) { 28 uint16_t pos; 29 30 pos = 0; 31 outb(vga_ctrl, 0x0f); 32 33 pos |= inb(0x3d5); 34 outb(vga_ctrl, 0x0e); 35 36 pos |= ((uint16_t)inb(0x3d5) << 8); 37 return pos; 38 } 39