mirror of
https://github.com/cowmonk/cowos.git
synced 2025-10-28 06:53:26 +00:00
Branch sync and push, reformated and made the OS look more "official"
This commit is contained in:
parent
13389f9617
commit
59e39d9842
9 changed files with 270 additions and 0 deletions
61
kernel/drivers/video/vga.c
Normal file
61
kernel/drivers/video/vga.c
Normal 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));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue