From ae3980cfa284fdbe787602fb9c7583fe6a45f678 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Tue, 13 May 2025 15:35:47 +0200 Subject: [PATCH] check cga pos bounds and debug print --- arch/textwindow.cc | 17 ++++++++++++++--- main.cc | 10 +++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/arch/textwindow.cc b/arch/textwindow.cc index cb0adca..32bbeee 100644 --- a/arch/textwindow.cc +++ b/arch/textwindow.cc @@ -14,12 +14,23 @@ TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row, setPos(0,0); } +extern unsigned int testx, testy; void TextWindow::setPos(unsigned rel_x, unsigned rel_y) { + unsigned abs_x = from_col + rel_x; + unsigned abs_y = from_row + rel_y; + + if(abs_x >= CGA::COLUMNS) + return; + if(abs_y >= CGA::ROWS) + return; + if(use_cursor){ - CGA::setCursor(from_col + rel_x, from_row + rel_y); + testx = abs_x; + testy = abs_y; + CGA::setCursor(abs_x, abs_y); }else{ - pos_x = from_col + rel_x; - pos_y = from_row + rel_y; + pos_x = abs_x; + pos_y = abs_y; } } diff --git a/main.cc b/main.cc index 4452c47..6c9d43b 100644 --- a/main.cc +++ b/main.cc @@ -63,9 +63,13 @@ OutputStream* copyout[Core::MAX]{ &dout[7] }; +unsigned int testx, testy; + // Main function // (the bootstrap processor starts here)} extern "C" int main() { + CGA::setCursor(0, 0); + unsigned int numCPUs = Core::count(); DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl; @@ -102,8 +106,12 @@ extern "C" int main() { PS2Controller::drainBuffer(); - Application{}.action(); + DBG << "Main CPU " << static_cast(LAPIC::getID()) << endl << flush; + + //Application{}.action(); while (true){ + DBG << "pos: " << testx << ", " << testy << endl << flush; + Core::pause(); } return 0;