const int VGA_WIDTH = 80; const int VGA_HEIGHT = 25; const int VGA_BYTES_PER_CHARACTER = 2; char* const VGA_BUFFER = (char*) 0xb8000; static int terminal_position = 0; void clear_terminal() { for (int i=0; i<(VGA_WIDTH * VGA_HEIGHT); i++) { // Text byte gets nulled VGA_BUFFER[i*2] = '\0'; // Style byte gets 0x07 for white text on a black background? VGA_BUFFER[i*2 + 1] = 0x07; } } void print_character(char c) { if (c == '\n') { terminal_position = (terminal_position + (VGA_BYTES_PER_CHARACTER * VGA_WIDTH)) - (terminal_position % (VGA_BYTES_PER_CHARACTER * VGA_WIDTH)); } else { VGA_BUFFER[(terminal_position * VGA_BYTES_PER_CHARACTER)] = c; VGA_BUFFER[(terminal_position * VGA_BYTES_PER_CHARACTER) + 1] = 0x07; terminal_position++; } } void print_string(char* string) { for (int i=0; string[i] != '\0'; i++) { print_character(string[i]); } } void print_line(char* string) { print_string(string); print_character('\n'); }