vga, again
This commit is contained in:
@@ -128,3 +128,21 @@ void vga_clear_scrn(uint32_t color) {
|
|||||||
uint32_t vga_write(vfs_node_t* node, uint32_t offset, uint32_t size, uint8_t* buf) {
|
uint32_t vga_write(vfs_node_t* node, uint32_t offset, uint32_t size, uint8_t* buf) {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_draw_vertical_line(uint32_t x, uint32_t y_start, uint32_t y_end, uint32_t color) {
|
||||||
|
if (framebuffer_address == 0) return;
|
||||||
|
|
||||||
|
uint8_t* fb_bytes = (uint8_t*)framebuffer_address;
|
||||||
|
|
||||||
|
for (uint32_t y = y_start; y < y_end; y++) {
|
||||||
|
if (y >= framebuffer_height) break;
|
||||||
|
|
||||||
|
uint8_t* row = fb_bytes + (y * framebuffer_pitch);
|
||||||
|
|
||||||
|
uint32_t* pixel_row = (uint32_t*)row;
|
||||||
|
|
||||||
|
if (x < framebuffer_width) {
|
||||||
|
pixel_row[x] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,4 +42,6 @@ void vga_clear_scrn(uint32_t color);
|
|||||||
|
|
||||||
uint32_t vga_write(vfs_node_t* node, uint32_t offset, uint32_t size, uint8_t* buf);
|
uint32_t vga_write(vfs_node_t* node, uint32_t offset, uint32_t size, uint8_t* buf);
|
||||||
|
|
||||||
|
void test_draw_vertical_line(uint32_t x, uint32_t y_start, uint32_t y_end, uint32_t color);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -141,7 +141,7 @@ void kmain(multiboot_info* mbi) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
console_putchar('c');
|
test_draw_vertical_line(100, 100, 150, 0xFFFFFFFF);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
kprintf("basic initializations complete\n");
|
kprintf("basic initializations complete\n");
|
||||||
|
|||||||
@@ -14,12 +14,19 @@ static void write_vga_char(char c) {
|
|||||||
uint32_t vga_pitch = vga_get_pitch();
|
uint32_t vga_pitch = vga_get_pitch();
|
||||||
uint8_t* glyph = (uint8_t*)font->glyphs + (c * font->hdr->charsz);
|
uint8_t* glyph = (uint8_t*)font->glyphs + (c * font->hdr->charsz);
|
||||||
|
|
||||||
|
uint32_t pixel_y_start = console_row * font->hdr->charsz;
|
||||||
|
uint32_t pixel_x_start = console_col * 8;
|
||||||
|
|
||||||
for (uint32_t y = 0; y < font->hdr->charsz; y++) {
|
for (uint32_t y = 0; y < font->hdr->charsz; y++) {
|
||||||
uint8_t bits = glyph[y];
|
uint8_t bits = glyph[y];
|
||||||
uint32_t* row = (uint32_t*)((uintptr_t)VGA_FRAMEBUFFER + ((console_row + y) * vga_pitch));
|
uint8_t* row_bytes = (uint8_t*)VGA_FRAMEBUFFER + ((pixel_y_start + y) * vga_pitch);
|
||||||
|
uint32_t* pixel_row = (uint32_t*)row_bytes;
|
||||||
|
|
||||||
for (int x = 0; x < 8; x++) {
|
for (int x = 0; x < 8; x++) {
|
||||||
if (bits & (0b10000000 >> x)) {
|
if (bits & (0b10000000 >> x)) {
|
||||||
row[console_col + x] = console_text_color;
|
pixel_row[pixel_x_start + x] = console_text_color;
|
||||||
|
} else {
|
||||||
|
pixel_row[pixel_x_start + x] = console_backgrnd_color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +49,7 @@ void console_init() {
|
|||||||
console_row = 0;
|
console_row = 0;
|
||||||
console_col = 0;
|
console_col = 0;
|
||||||
set_console_fg(0xFFFFFFFF);
|
set_console_fg(0xFFFFFFFF);
|
||||||
vga_clear_scrn(0x00000000);
|
vga_clear_scrn(0x000000FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_putchar(char c) {
|
void console_putchar(char c) {
|
||||||
|
|||||||
Reference in New Issue
Block a user