WIP: Framebuffer partial support, cursor & scoll TODO

This commit is contained in:
xamidev
2024-08-20 13:38:44 +02:00
parent 52a92a5358
commit f8eb658c33
7 changed files with 37 additions and 26 deletions

View File

@@ -32,7 +32,7 @@ void draw_char(unsigned short int c, int cx, int cy, uint32_t fg, uint32_t bg)
int offs = int offs =
(cy * font->height * scanline) + (cy * font->height * scanline) +
(cx * (font->width + 1) * sizeof(PIXEL)); (cx * (font->width) * sizeof(PIXEL));
unsigned int x, y; unsigned int x, y;
int line, mask; int line, mask;

View File

@@ -28,12 +28,10 @@ typedef struct {
char* ascii_title = char* ascii_title =
"\n" "\n"
" oooooooooo o888 oooo ooooooo oooooooo8\n" "*******************************\n"
" 888 888 888 ooooooo oo oooooo 888 ooooo o888 888o 888 \n" "| Blank OS version 0.3.68-dev |\n"
" 888oooo88 888 ooooo888 888 888 888o888 888 888 888oooooo \n" "*******************************\n"
" 888 888 888 888 888 888 888 8888 88o 888o o888 888\n" "\n";
" o888ooo888 o888o 88ooo88 8o o888o o888o o888o o888o 88ooo88 o88oooo888\n\n"
" --------------------------------- v0.3.55 --------------------------------\n\n";
unsigned int g_multiboot_info_address; unsigned int g_multiboot_info_address;
@@ -44,6 +42,7 @@ int scanline;
uint32_t VGA_WIDTH; uint32_t VGA_WIDTH;
uint32_t VGA_HEIGHT; uint32_t VGA_HEIGHT;
void kmain(multiboot2_info *mb_info) void kmain(multiboot2_info *mb_info)
{ {
@@ -105,8 +104,20 @@ serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
log("Drew to framebuffer.\r\n", 3); log("Drew to framebuffer.\r\n", 3);
} }
/*
puts("This should work by now! Enter Graphics Mode."); puts("This should work by now! Enter Graphics Mode.");
printf("\nMy name is %s, and I'm %d. 0x%x", "Alan", 34, 0xdeadbeef); printf("\nMy name is %s, and I'm %d. 0x%x", "Alan", 34, 0xdeadbeef);
for (int i=0; i<512; i++)
{
printf("%d ", i);
}
*/
//colorputs("Wow, such colorful output!", green, blue);
colorputs(ascii_title, green, black);
while (1); while (1);

View File

@@ -73,7 +73,7 @@ void shell_install()
{ {
char input_buffer[BUFFER_SIZE]; char input_buffer[BUFFER_SIZE];
char* argv[MAX_ARGS]; char* argv[MAX_ARGS];
colorputs("blankos> ", 9); //colorputs("blankos> ", 9);
get_input(input_buffer, BUFFER_SIZE); get_input(input_buffer, BUFFER_SIZE);
puts("\n"); puts("\n");

View File

@@ -10,15 +10,6 @@ extern uint32_t VGA_WIDTH;
extern uint32_t VGA_HEIGHT; extern uint32_t VGA_HEIGHT;
unsigned int VGA_X = 0, VGA_Y = 0; unsigned int VGA_X = 0, VGA_Y = 0;
enum Colors
{
// AARRGGBB?
white = 0xFFFFFFFF,
black = 0x00000000,
red = 0x00FF0000,
green = 0x0000FF00,
blue = 0x000000FF,
};
void move_cursor(int x, int y) void move_cursor(int x, int y)
{ {
@@ -115,7 +106,7 @@ void putc(char c)
move_cursor(VGA_X, VGA_Y); move_cursor(VGA_X, VGA_Y);
} }
void colorputc(char c, unsigned int color) void colorputc(char c, uint32_t fg, uint32_t bg)
{ {
switch(c) switch(c)
{ {
@@ -130,8 +121,7 @@ void colorputc(char c, unsigned int color)
VGA_X += 4; VGA_X += 4;
break; break;
default: default:
putchar(c, VGA_X, VGA_Y, white, black); putchar(c, VGA_X, VGA_Y, fg, bg);
//putcolor(VGA_X, VGA_Y, color);
VGA_X++; VGA_X++;
break; break;
} }
@@ -154,11 +144,11 @@ void puts(const char* str)
} }
} }
void colorputs(const char* str, unsigned int color) void colorputs(const char* str, uint32_t fg, uint32_t bg)
{ {
while (*str) while (*str)
{ {
colorputc(*str, color); colorputc(*str, fg, bg);
str++; str++;
} }
} }

View File

@@ -14,14 +14,14 @@
void move_cursor(int x, int y); void move_cursor(int x, int y);
void putchar(unsigned short int c, int x, int y, uint32_t fg, uint32_t bg); void putchar(unsigned short int c, int x, int y, uint32_t fg, uint32_t bg);
void puts(const char* str); void puts(const char* str);
void colorputs(const char* str, unsigned int color);
void clear(void); void clear(void);
void colorputs(const char* str, uint32_t fg, uint32_t bg);
void putcolor(int x, int y, unsigned int color); void putcolor(int x, int y, unsigned int color);
char getchar(int x, int y); char getchar(int x, int y);
unsigned int getcolor(int x, int y); unsigned int getcolor(int x, int y);
void scroll(int lines); void scroll(int lines);
void putc(char c); void putc(char c);
void colorputc(char c, unsigned int color); void colorputc(char c, uint32_t fg, uint32_t bg);
#define PRINTF_STATE_START 0 #define PRINTF_STATE_START 0
#define PRINTF_STATE_LENGTH 1 #define PRINTF_STATE_LENGTH 1
@@ -43,4 +43,14 @@ void get_input(char *buffer, int size);
void dtostrf(double val, char *buffer, int precision); void dtostrf(double val, char *buffer, int precision);
enum Colors
{
// AARRGGBB?
white = 0xFFFFFFFF,
black = 0x00000000,
red = 0x00FF0000,
green = 0x0000FF00,
blue = 0x000000FF,
};
#endif #endif

View File

@@ -15,7 +15,7 @@ void print_grid(const unsigned char grid[X][Y])
//(grid[i][j] == LIVE) ? putc(42) : putc(32); //(grid[i][j] == LIVE) ? putc(42) : putc(32);
if (grid[i][j] == LIVE) { if (grid[i][j] == LIVE) {
serial_printf(3, "alive"); serial_printf(3, "alive");
colorputc(32, 120); //colorputc(32, 120);
} else { } else {
putc(32); putc(32);
} }

View File

@@ -18,7 +18,7 @@ void program_rainbow()
for (int i=0; i<COLORS; i++) for (int i=0; i<COLORS; i++)
{ {
colorputs(input_buffer, i); //colorputs(input_buffer, i);
puts("\n"); puts("\n");
} }
} }