set_cursor_pos

pull/23/head
E. Almqvist 3 years ago
parent 1aef676066
commit 159ab0e1a2
  1. 3
      src/kernel/kernel.c
  2. 17
      src/kernel/lib/vga.c

@ -6,5 +6,6 @@ void main() {
*vidmem = 'X';
clear_screen();
println("eOS Version 0.0 2021", 0x0f);
set_cursor_pos(0, 5);
println("\t eOS Version 0.0 2021", 0xf0);
}

@ -12,7 +12,8 @@
#define VIDEO_MEM_MAX (char*)0xb8fa0
// Global
static int cursor_row = 0;
static unsigned int cursor_row = 0;
static unsigned int cursor_col = 0;
/*
VGA & Memory Functions
@ -23,8 +24,8 @@ char* get_vga_charpos_pointer(unsigned int col, unsigned int row) {
void putc(char c, unsigned int col, unsigned int row, int colorcode) {
char* mem = get_vga_charpos_pointer(col, row);
*mem = c;
*(mem+1) = colorcode;
*mem = c; // Write the character
*(mem+1) = colorcode; // Write the colorcode
}
@ -32,18 +33,22 @@ void putc(char c, unsigned int col, unsigned int row, int colorcode) {
Graphics Functions
*/
void clear_screen() {
for( char* c = VIDEO_MEM; c <= VIDEO_MEM_MAX; c += 2 ) {
// Make all the characters spaces
for( char* c = VIDEO_MEM; c <= VIDEO_MEM_MAX; c += 2 )
*c = 0x20;
}
}
/*
General Printing Functions
*/
void set_cursor_pos(unsigned int x, unsigned int y) {
cursor_col, cursor_row = x, y;
}
void print(char* str, int colorcode) {
for( char* c = str; *c != '\0'; c++ )
putc(*c, (int)(c - str), cursor_row, colorcode);
putc(*c, (unsigned int)(c - str + cursor_col), cursor_row, colorcode);
}
void println(char* str, int colorcode) {

Loading…
Cancel
Save