Add: framebuffer color output functions

This commit is contained in:
xamidev
2024-07-15 19:07:22 +02:00
parent 124d88f7b7
commit 43808da332
7 changed files with 51 additions and 10 deletions

36
stdio.c
View File

@@ -102,6 +102,33 @@ void putc(char c)
move_cursor(VGA_X, VGA_Y);
}
void colorputc(char c, unsigned int color)
{
switch(c)
{
case '\n':
VGA_X = 0;
VGA_Y++;
break;
case '\r':
VGA_X = 0;
break;
default:
putchar(VGA_X, VGA_Y, c);
putcolor(VGA_X, VGA_Y, color);
VGA_X++;
break;
}
if (VGA_X >= VGA_WIDTH)
{
VGA_Y++;
VGA_X = 0;
}
if (VGA_Y >= VGA_HEIGHT) scroll(1);
move_cursor(VGA_X, VGA_Y);
}
void puts(const char* str)
{
while (*str)
@@ -111,6 +138,15 @@ void puts(const char* str)
}
}
void colorputs(const char* str, unsigned int color)
{
while (*str)
{
colorputc(*str, color);
str++;
}
}
void printf(const char* fmt, ...)
{
int* argp = (int*) &fmt;