add getCursor

This commit is contained in:
Eggert Jung
2025-04-18 17:53:34 +02:00
parent 566966cb2d
commit db3e15449f
3 changed files with 18 additions and 10 deletions

View File

@@ -8,7 +8,12 @@ namespace CGA {
void writeCGAReg(int reg, int data){
index_port.outb(reg);
data_port.outb(data);
data_port.outw(data);
}
uint16_t readCGAReg(int reg){
index_port.outb(reg);
return data_port.inb();
}
void setCursor(unsigned abs_x, unsigned abs_y) {
@@ -19,8 +24,11 @@ void setCursor(unsigned abs_x, unsigned abs_y) {
}
void getCursor(unsigned& abs_x, unsigned& abs_y) {
(void)abs_x;
(void)abs_y;
uint16_t pos = readCGAReg(RegisterIndex::CURSOR_LOW);
pos |= (readCGAReg(RegisterIndex::CURSOR_HIGH) << 8);
abs_x = pos / 80;
abs_y = pos % 80;
}
void show(unsigned abs_x, unsigned abs_y, char character, Attribute attrib) {

View File

@@ -67,7 +67,6 @@ enum Color {
* (`-fno-strict-aliasing`). In \StuBS we use this feature extensively due to
* the improved code readability.
*
* \todo(11) Fill in the bitfield
*/
union Attribute {
struct {
@@ -79,8 +78,6 @@ union Attribute {
/*! \brief Attribute constructor (with default values)
*
* \todo(11) Complete constructor
*
* \param foreground Foreground color (Default: \ref LIGHT_GREY)
* \param background Background color (Default: \ref BLACK)
* \param blink Blink if `true` (default: no blinking)
@@ -91,8 +88,6 @@ union Attribute {
/*! \brief Set the keyboard hardware cursor to absolute screen position
*
* \todo(11) Implement the method using \ref IOPort
*
* \param abs_x absolute column of the keyboard hardware cursor
* \param abs_y absolute row of the keyboard hardware cursor
*/