Remove unecessary offset and fix line wrapping

This commit is contained in:
Victor Timofei 2022-05-03 21:27:52 +03:00
parent 81c07553e6
commit 192ff10bb1
Signed by: vtimofei
GPG Key ID: B790DCEBE281403A
1 changed files with 7 additions and 4 deletions

View File

@ -39,7 +39,7 @@ void putchar (uint16_t c, int32_t cx, int32_t cy, uint32_t fg, uint32_t bg)
unsigned char *glyph = (unsigned char *)&consolefonts_binary__start + font->headersize +
(c > 0 && c < font->numglyphs ? c : 0) * font->bytesperglyph;
uint32_t offs = (cy * font->height * scanline) + (cx * (font->width + 1) * sizeof (PIXEL));
uint32_t offs = (cy * font->height * scanline) + (cx * (font->width) * sizeof (PIXEL));
uint32_t x, y, line, mask;
for (y = 0; y < font->height; y++) {
@ -63,12 +63,17 @@ void console_push()
void console_puts(uint16_t ch)
{
if (ch == '\n' || console_x > console_max_x) {
if (ch == '\n') {
console_x = 0;
console_y++;
return;
}
if (console_x >= console_max_x) {
console_x = 0;
console_y++;
}
if (console_y > console_max_y)
console_push();
@ -160,6 +165,4 @@ void kernel_main (uint32_t multiboot_struct_addr)
console_init(mbi);
kprintf("Console width is %d\n", mbi->framebuffer_width);
// TODO: Test line wrapping
//console_write("Hello World! 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890");
}