Added cursor rendering (kinda badly, will delete any characters under it)

This commit is contained in:
2024-04-19 14:10:45 +02:00
parent 889f283fcd
commit da1ab4d6ff
3 changed files with 10 additions and 2 deletions
+2
View File
@@ -48,9 +48,11 @@ void printAt(const char* str, uint32_t x, uint32_t y) {
void putc(char c) { void putc(char c) {
if (c == '\n') { if (c == '\n') {
putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor
cursor.y++; cursor.y++;
cursor.x = 0; cursor.x = 0;
} else if (c == '\b') { } else if (c == '\b') {
putcAt(' ', cursor.x, cursor.y); // Make sure we don't leave an extra cursor TODO: make this better
cursor.x--; cursor.x--;
putcAt(' ', cursor.x, cursor.y); putcAt(' ', cursor.x, cursor.y);
} else { } else {
+7 -1
View File
@@ -6,12 +6,18 @@
#include "irq.h" #include "irq.h"
#include "system.h" #include "system.h"
#include "screen.h"
#define INPUT_CLK 1193180 #define INPUT_CLK 1193180
uint32_t timerTicks = 0; uint32_t timerTicks = 0;
void timerHandler() { void timerHandler() {
timerTicks++; 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() { void setupTimer() {
@@ -30,7 +36,7 @@ void timerPhase(uint32_t hz) {
void sleep(uint32_t ticks) { void sleep(uint32_t ticks) {
uint32_t eticks = ticks + timerTicks; uint32_t eticks = ticks + timerTicks;
while (timerTicks != eticks); // Should avoid overflows unlike '<' while (timerTicks != eticks); // Should ignore overflows unlike '<'
} }
+1 -1
View File
@@ -22,7 +22,7 @@ void main() {
setupKeyboard(); setupKeyboard();
setupTimer(); setupTimer();
timerPhase(100); // 1 tick per 10ms timerPhase(1000); // 1 tick per ~1ms
// Screen setup // Screen setup
diskRead(25, 4, (char*)0x6000); // Read font from disk diskRead(25, 4, (char*)0x6000); // Read font from disk