Remove o files
This commit is contained in:
parent
8ff3b32642
commit
682b215c0d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.bin
|
1
Makefile
1
Makefile
@ -17,3 +17,4 @@ $(O_FILES):
|
|||||||
gcc -Iinclude -fno-pie -m32 -ffreestanding -c ${@:.o=.c} -o $@
|
gcc -Iinclude -fno-pie -m32 -ffreestanding -c ${@:.o=.c} -o $@
|
||||||
clean:
|
clean:
|
||||||
find . -name \*.o | xargs --no-run-if-empty rm
|
find . -name \*.o | xargs --no-run-if-empty rm
|
||||||
|
find . -name \*.bin | xargs --no-run-if-empty rm
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "../include/console.h"
|
||||||
|
|
||||||
const int VGA_WIDTH = 80;
|
const int VGA_WIDTH = 80;
|
||||||
const int VGA_HEIGHT = 25;
|
const int VGA_HEIGHT = 25;
|
||||||
@ -7,6 +8,22 @@ char* const VGA_BUFFER = (char*) 0xb8000;
|
|||||||
|
|
||||||
static int terminal_position = 0;
|
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() {
|
void clear_terminal() {
|
||||||
|
|
||||||
for (int i=0; i<(VGA_WIDTH * VGA_HEIGHT); i++) {
|
for (int i=0; i<(VGA_WIDTH * VGA_HEIGHT); i++) {
|
||||||
@ -19,19 +36,30 @@ void clear_terminal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_character(char c) {
|
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') {
|
if (c == '\n') {
|
||||||
terminal_position = (terminal_position + (VGA_BYTES_PER_CHARACTER * VGA_WIDTH)) - (terminal_position % (VGA_BYTES_PER_CHARACTER * VGA_WIDTH));
|
terminal_position = (terminal_position + (VGA_BYTES_PER_CHARACTER * VGA_WIDTH)) - (terminal_position % (VGA_BYTES_PER_CHARACTER * VGA_WIDTH));
|
||||||
} else {
|
} else {
|
||||||
VGA_BUFFER[(terminal_position * VGA_BYTES_PER_CHARACTER)] = c;
|
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++;
|
terminal_position++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_string(char* string) {
|
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++) {
|
for (int i=0; string[i] != '\0'; i++) {
|
||||||
print_character(string[i]);
|
print_character_with_color(string[i], bg, fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,50 @@
|
|||||||
|
|
||||||
void print_line(char* str);
|
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
|
#endif
|
Loading…
Reference in New Issue
Block a user