add getCursor

main
Eggert Jung 6 months ago
parent 566966cb2d
commit db3e15449f

@ -8,7 +8,12 @@ namespace CGA {
void writeCGAReg(int reg, int data){ void writeCGAReg(int reg, int data){
index_port.outb(reg); 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) { 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 getCursor(unsigned& abs_x, unsigned& abs_y) {
(void)abs_x; uint16_t pos = readCGAReg(RegisterIndex::CURSOR_LOW);
(void)abs_y; 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) { void show(unsigned abs_x, unsigned abs_y, char character, Attribute attrib) {

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

@ -10,8 +10,13 @@ extern "C" int main() {
unsigned int numCPUs = Core::count(); unsigned int numCPUs = Core::count();
DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl; DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl;
CGA::setCursor(1, 2); CGA::setCursor(0, 0);
unsigned x,y;
CGA::getCursor(x, y);
CGA::setCursor(x+1, y+1);
/* Start application processors /* Start application processors
* To avoid unexpected behaviour, make sure that interrupts are not * To avoid unexpected behaviour, make sure that interrupts are not
* enabled before the APs are booted. Otherwise it might interfere with the * enabled before the APs are booted. Otherwise it might interfere with the

Loading…
Cancel
Save