Remove o files

This commit is contained in:
River 2025-04-11 17:48:15 -04:00
parent 8ff3b32642
commit 682b215c0d
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
4 changed files with 78 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.bin

View File

@ -17,3 +17,4 @@ $(O_FILES):
gcc -Iinclude -fno-pie -m32 -ffreestanding -c ${@:.o=.c} -o $@
clean:
find . -name \*.o | xargs --no-run-if-empty rm
find . -name \*.bin | xargs --no-run-if-empty rm

View File

@ -1,3 +1,4 @@
#include "../include/console.h"
const int VGA_WIDTH = 80;
const int VGA_HEIGHT = 25;
@ -7,6 +8,22 @@ char* const VGA_BUFFER = (char*) 0xb8000;
static int terminal_position = 0;
static VGA_Color terminal_font_color = LIGHT_GRAY; // Default font color will be light gray
static VGA_Color terminal_background_color = BLACK; // Default background color is black
void set_terminal_font_color(VGA_Color col) {
terminal_font_color = col;
}
void set_terminal_background_color(VGA_Color col) {
terminal_background_color = col;
}
void clear_terminal() {
for (int i=0; i<(VGA_WIDTH * VGA_HEIGHT); i++) {
@ -19,19 +36,30 @@ void clear_terminal() {
}
void print_character(char c) {
print_character_with_color(c, terminal_background_color, terminal_font_color);
}
void print_character_with_color(char c, VGA_Color bg, VGA_Color fg) {
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;
int full_color = (bg << 4) | fg;
VGA_BUFFER[(terminal_position * VGA_BYTES_PER_CHARACTER) + 1] = full_color;
terminal_position++;
}
}
void print_string(char* string) {
print_string_with_color(string, terminal_background_color, terminal_font_color);
}
void print_string_with_color(char* string, VGA_Color bg, VGA_Color fg) {
for (int i=0; string[i] != '\0'; i++) {
print_character(string[i]);
print_character_with_color(string[i], bg, fg);
}
}

View File

@ -16,4 +16,50 @@
void print_line(char* str);
typedef enum {
BLACK=0,
BLUE,
GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHT_GRAY,
DARK_GRAY,
LIGHT_BLUE,
LIGHT_GREEN,
LIGHT_CYAN,
LIGHT_RED,
LIGHT_MAGENTA,
YELLOW,
WHITE
} VGA_Color;
void print_character_with_color(char c, VGA_Color bg_color, VGA_Color font_color);
void print_string_with_color(char* str, VGA_Color bg_color, VGA_Color font_color);
void print_line_with_color(char* str, VGA_Color bg_color, VGA_Color font_color);
void set_terminal_font_color(VGA_Color col);
void set_terminal_background_color(VGA_Color col);
#endif