Branch sync and push, reformated and made the OS look more "official"

This commit is contained in:
cowmonk 2025-04-17 21:32:48 -07:00
parent 13389f9617
commit 59e39d9842
9 changed files with 270 additions and 0 deletions

View file

@ -0,0 +1,61 @@
#include "../../include/video/vga.h"
#include <string.h>
size_t term_row;
size_t term_col;
uint8_t term_color;
uint16_t* term_buf = (uint16_t*)VGA_MEMORY;
void
term_init(void)
{
term_row = 0;
term_col = 0;
term_color = vga_entry_color(VGA_COLOR_WHITE, VGA_COLOR_BLACK);
for (size_t y = 0; y < VGA_HEIGHT; y++) {
for (size_t x = 0; x < VGA_WIDTH; x++) {
const size_t index = y * VGA_WIDTH + x;
term_buf[index] = vga_entry(' ', term_color);
}
}
}
void
term_setcolor(uint8_t color)
{
term_color = color;
}
void
term_putentryat(char c, uint8_t color, size_t x, size_t y)
{
const size_t index = y * VGA_HEIGHT + x;
term_buf[index] = vga_entry(c, color);
}
void
term_putchar(char c)
{
term_putentryat(c, term_color, term_row);
if (++term_col == VGA_WIDTH) {
term_col = 0;
if (++term_row == VGA_HEIGHT) {
term_row = 0;
}
}
}
void
term_write(const char* data, size_t size)
{
for (size_t i = 0; i < size; i++) {
term_putchar(data[i];
}
}
void
term_writestr(const char* data)
{
term_write(data, strlen(data));
}