From 41e7e302d5e4300059fdfc642c6e71b1761878e9 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 14 Aug 2024 22:16:39 +0200 Subject: [PATCH] Use framebuffer pitch instead of width where necessary --- src/Kernel/Display.ZC | 14 ++++++++------ src/Kernel/KMain.ZC | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Kernel/Display.ZC b/src/Kernel/Display.ZC index ef89e85f..a8b43d50 100755 --- a/src/Kernel/Display.ZC +++ b/src/Kernel/Display.ZC @@ -8,7 +8,9 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). */ I64 i, row, col, x, y; U32 *framebuffer; - U64 ch_bitmap; + U64 ch_bitmap, fb_width_from_pitch; + + fb_width_from_pitch = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); if (!(text.raw_flags & RAWF_SHOW_DOLLAR)) { @@ -60,17 +62,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). {//Scroll screen down MemCopy(text.fb_alias, - text.fb_alias + sys_framebuffer_width * FONT_HEIGHT, - (text.screen_size - sys_framebuffer_width * FONT_HEIGHT) * sizeof(U32)); + text.fb_alias + fb_width_from_pitch * FONT_HEIGHT, + (text.screen_size - fb_width_from_pitch * FONT_HEIGHT) * sizeof(U32)); - MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_width * FONT_HEIGHT, BLACK32, sys_framebuffer_width * FONT_HEIGHT); + MemSetU32(text.fb_alias + text.screen_size - fb_width_from_pitch * FONT_HEIGHT, BLACK32, fb_width_from_pitch * FONT_HEIGHT); text.raw_col -= text.cols ; row = text.rows - 1; } x = col * FONT_WIDTH; y = row * FONT_HEIGHT; ch_bitmap = text.font[ch & 0xFF]; - framebuffer = text.fb_alias + sys_framebuffer_width * y + x; + framebuffer = text.fb_alias + fb_width_from_pitch * y + x; PUSHFD CLI @@ -81,7 +83,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). else *framebuffer++ = BLACK32; if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1) - framebuffer += sys_framebuffer_width - FONT_WIDTH; + framebuffer += fb_width_from_pitch - FONT_WIDTH; ch_bitmap >>= 1; } POPFD diff --git a/src/Kernel/KMain.ZC b/src/Kernel/KMain.ZC index 069734b7..8f363e19 100755 --- a/src/Kernel/KMain.ZC +++ b/src/Kernel/KMain.ZC @@ -91,7 +91,7 @@ U0 SysGrInit() text.cols = sys_framebuffer_width / FONT_WIDTH; text.rows = sys_framebuffer_height / FONT_HEIGHT; - text.screen_size = sys_framebuffer_width * sys_framebuffer_height; + text.screen_size = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8) * sys_framebuffer_height; text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now. text.raw_screen = CAlloc(text.buffer_size); text.fb_alias = sys_framebuffer_addr;