Microkernel thing OS experiment (Zig ⚡)

console: fix rendering when pitch != width * bpp

There were some insanely cursed and hard to debug issues on a ThinkPad I
had with a small cropped framebuffer on Libreboot + SeaBIOS.

pci.express 275adef5 765e551a

verified
Changed files
+15 -3
components
ukernel
deps
console
src
+15 -3
components/ukernel/deps/console/src/root.zig
··· 84 84 const canvas_pitch = self.fb.width * self.fb.bypp; 85 85 const byte_fb: [*]u8 = @ptrCast(self.fb.address); 86 86 87 - const src_buf = self.canvas[canvas_pitch * glyph_height * start_line ..][0 .. canvas_pitch * glyph_height * num_lines]; 88 - const dst_buf = byte_fb[self.fb.pitch * glyph_height * start_line ..][0 .. self.fb.pitch * glyph_height * num_lines]; 89 - @memcpy(dst_buf, src_buf); 87 + if (canvas_pitch == self.fb.pitch) { 88 + const src_buf = self.canvas[canvas_pitch * glyph_height * start_line ..][0 .. canvas_pitch * glyph_height * num_lines]; 89 + const dst_buf = byte_fb[self.fb.pitch * glyph_height * start_line ..][0 .. self.fb.pitch * glyph_height * num_lines]; 90 + @memcpy(dst_buf, src_buf); 91 + } else { 92 + // Unfortunately we have to copy line by line 93 + var i: usize = 0; 94 + const canvas_start = canvas_pitch * start_line * glyph_height; 95 + const fb_start = self.fb.pitch * start_line * glyph_height; 96 + while (i < num_lines * glyph_height) : (i += 1) { 97 + const src_line = self.canvas[canvas_start + i * canvas_pitch ..][0..canvas_pitch]; 98 + const dst_line = byte_fb[fb_start + i * self.fb.pitch ..][0..canvas_pitch]; 99 + @memcpy(dst_line, src_line); 100 + } 101 + } 90 102 } 91 103 92 104 /// Write a character to the console, return true if scrolled