Issues with terminal scrolling in graphical mode
Posted: Mon Nov 06, 2023 1:50 pm
Hi, I'm new to OSDev and I setup a minimal kernel with BOOTBOOT and all it does so far is printing. For a few days, I've been trying to figure out how to copy a row of glyphs up by one row, like I managed in VGA mode, but it seems that my code only clears the line above.
(For context) How the glyphs are drawn:
The function that's supposed to replace the destination line with the source line (possibly bad code quality):
I hope this is complete, but if I missed anything, let me know and I will provide any details.
Thank you in advance.
(For context) How the glyphs are drawn:
Code: Select all
void
kdrawc(char c, int x, int y, uint32_t color)
{
uint8_t *glyph = (uint8_t *) &BINARY_FONT_PSF_START
+ font->header_size
+ (c > 0 && c < font->num_glyph ? c : 0)
* font->bytes_per_glyph;
int offset = (y * font->height * bootboot.fb_scanline) +
(x * (font->width + 1) * sizeof(uint32_t));
int bytes_per_line = (font->width + 7) / 8;
for (int y = 0; y < font->height; ++y) {
int line = offset;
int mask = 1 << (font->width - 1);
for (int x = 0; x < font->width; ++x) {
*((PIXEL *) ((uint64_t) &fb + line)) =
((int) *glyph) & mask ? color : 0;
mask >>= 1;
line += sizeof(PIXEL);
}
glyph += bytes_per_line;
offset += bootboot.fb_scanline;
}
}
Code: Select all
void
kmoveline(int dst_line, int src_line)
{
int dst_offset = (dst_line * pfont->height * bootboot.fb_scanline) +
(0 * (pfont->width + 1) * sizeof(uint32_t));
int src_offset = (src_line * pfont->height * bootboot.fb_scanline) +
(0 * (pfont->width + 1) * sizeof(uint32_t));
for (int dst_y = 0; dst_y < pfont->height; ++dst_y) {
int dst_line = dst_offset;
for (int src_y = 0; src_y < pfont->height; ++src_y) {
int src_line = src_offset;
for (int dst_x = 0; dst_x < (pfont->width + 1); ++dst_x) {
for (int src_x = 0; src_x < (pfont->width + 1); ++src_x) {
*((PIXEL *) ((uint64_t) &fb + dst_line)) =
*((PIXEL *) ((uint64_t) &fb + src_line));
src_line += sizeof(PIXEL);
}
dst_line += sizeof(PIXEL);
}
src_offset += bootboot.fb_scanline;
}
dst_offset += bootboot.fb_scanline;
}
}
Thank you in advance.