From 8e0260b8a09d1cad0f1e6511d8ebfc756096a064 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Wed, 11 Aug 2021 20:27:44 +0200 Subject: [PATCH] Refactor --- src/lib/vga.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/vga.c b/src/lib/vga.c index 33de16a..ae2407a 100644 --- a/src/lib/vga.c +++ b/src/lib/vga.c @@ -4,15 +4,13 @@ // Charpos = 0xb8000 + 2(row*80 + col) #define VIDEO_MEM (char*)0xb8000 -static char* cursor_pos = VIDEO_MEM; static int cursor_y = 0; -void set_cursor_pos(unsigned int row, unsigned int col) { cursor_pos = (char*)(VIDEO_MEM + 2*(row*80 + col)); } +char* get_cursor_pos(unsigned int row, unsigned int col) { return (char*)(VIDEO_MEM + 2*(row*80 + col)); } void print(char* str, unsigned int str_len) { for( unsigned int i = 0; i < str_len; i++ ) { - set_cursor_pos(i, cursor_y); // set cursor pos - *cursor_pos = str[i]; // Write char to video memory + *get_cursor_pos(i, cursor_y) = str[i]; // write to video memory } }