From da1ab4d6ff5e98a02b20815f2fabc8e82311789f Mon Sep 17 00:00:00 2001 From: Tom-on64 Date: Fri, 19 Apr 2024 14:10:45 +0200 Subject: [PATCH] Added cursor rendering (kinda badly, will delete any characters under it) --- include/screen.h | 2 ++ include/timer.h | 8 +++++++- src/kernel.c | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/screen.h b/include/screen.h index dc9772a..7364169 100644 --- a/include/screen.h +++ b/include/screen.h @@ -48,9 +48,11 @@ void printAt(const char* str, uint32_t x, uint32_t y) { void putc(char c) { if (c == '\n') { + putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor cursor.y++; cursor.x = 0; } else if (c == '\b') { + putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor TODO: make this better cursor.x--; putcAt(' ', cursor.x, cursor.y); } else { diff --git a/include/timer.h b/include/timer.h index 0e51377..633e09b 100644 --- a/include/timer.h +++ b/include/timer.h @@ -6,12 +6,18 @@ #include "irq.h" #include "system.h" +#include "screen.h" + #define INPUT_CLK 1193180 uint32_t timerTicks = 0; void timerHandler() { timerTicks++; + + // TODO: Improve the cursor rendering + if (timerTicks % 500 == 0) putcAt(127, cursor.x, cursor.y); + else if (timerTicks % 250 == 0) putcAt(' ', cursor.x, cursor.y); } void setupTimer() { @@ -30,7 +36,7 @@ void timerPhase(uint32_t hz) { void sleep(uint32_t ticks) { uint32_t eticks = ticks + timerTicks; - while (timerTicks != eticks); // Should avoid overflows unlike '<' + while (timerTicks != eticks); // Should ignore overflows unlike '<' } diff --git a/src/kernel.c b/src/kernel.c index 188e040..a7fcf7e 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -22,7 +22,7 @@ void main() { setupKeyboard(); setupTimer(); - timerPhase(100); // 1 tick per 10ms + timerPhase(1000); // 1 tick per ~1ms // Screen setup diskRead(25, 4, (char*)0x6000); // Read font from disk