Newer
Older
tree-os / src / kernel / lib / textMode / cursor.c
@Lukas Lukas on 28 Mar 2021 562 bytes Initial commit after relocation
#include <stdint.h>
#include <lib/textMode/cursor.h>
#include <lib/ports.h>
#include <lib/textMode/stdio.h>

void setCursorOffset(uint16_t offset) {
	outb(0x3D4, 0x0F);
	outb(0x3D5, (uint8_t) (offset & 0xFF));
	outb(0x3D4, 0x0E);
	outb(0x3D5, (uint8_t) ((offset >> 8) & 0xFF));
}

void setCursorPosition(uint8_t x, uint8_t y) {
    setCursorOffset(x + y * VIDEO_WIDTH);
}

uint16_t getCursorOffset() {
    uint16_t result = 0;
    outb(0x3D4, 0x0F);
    result |= inb(0x3D5);
    outb(0x3D4, 0x0E);
    result |= ((uint16_t)inb(0x3D5)) << 8;
    return result;
}