From 41e7e302d5e4300059fdfc642c6e71b1761878e9 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 14 Aug 2024 22:16:39 +0200 Subject: [PATCH 1/9] 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; From 4e77bf1c0aee1bf39c17e52686a60ad6e6a4fcc3 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 26 Aug 2024 02:01:43 -0400 Subject: [PATCH 2/9] Add flush command option to sync.sh , to attempt to flush qemu-nbd state and attempt basic repair of filesystem --- build/sync.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/sync.sh b/build/sync.sh index 2491f1a6..cad1cbb9 100755 --- a/build/sync.sh +++ b/build/sync.sh @@ -74,6 +74,12 @@ else sudo modprobe nbd [ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT case $1 in + flush) + mount_vdisk + sudo blockdev --flushbufs /dev/nbd0 + sudo dosfsck -w -r -l -v -t /dev/nbd0 + umount_vdisk + ;; diff) mount_vdisk diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*" From 16eec2be89f51270e1a567d61bcbda5873f1411a Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 26 Aug 2024 02:04:18 -0400 Subject: [PATCH 3/9] Increment sys_os_version_sub --- src/Kernel/KGlobals.ZC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kernel/KGlobals.ZC b/src/Kernel/KGlobals.ZC index f6b65671..028a5196 100755 --- a/src/Kernel/KGlobals.ZC +++ b/src/Kernel/KGlobals.ZC @@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed CDate local_time_offset; F64 *pow10_I64, sys_os_version = 2.03; -U64 sys_os_version_sub = 118; +U64 sys_os_version_sub = 119; U8 *sys_os_version_str; U8 *sys_os_version_full; U8 *sys_os_version_nice; From 9f363f265d1d859aa6d777c79cffc82195166abe Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 26 Aug 2024 02:07:47 -0400 Subject: [PATCH 4/9] Lower DOC_SCROLL_SPEED from 8 to 6 --- src/Kernel/KernelA.HH | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kernel/KernelA.HH b/src/Kernel/KernelA.HH index 94aa3200..d9d731b2 100755 --- a/src/Kernel/KernelA.HH +++ b/src/Kernel/KernelA.HH @@ -1272,7 +1272,7 @@ public class CDocBin #assert !($$ & 7) }; -#define DOC_SCROLL_SPEED 8 +#define DOC_SCROLL_SPEED 6 #define DOCSS_NORMAL 0 #define DOCSS_SINGLE_QUOTE 1 From 05febc98036e287af4e77593d093f946de3e6513 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 26 Aug 2024 02:14:30 -0400 Subject: [PATCH 5/9] Hacking graphics code in pursuit of fixing #28 --- src/Demo/Graphics/32BitColor.ZC | 2 +- src/Demo/Graphics/32BitPaint.ZC | 10 +++---- src/System/Gr/GrDC.ZC | 3 ++- src/System/Gr/GrGlobals.ZC | 2 +- src/System/Gr/GrScreen.ZC | 47 +++++++++++++++++++++++++++------ 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/Demo/Graphics/32BitColor.ZC b/src/Demo/Graphics/32BitColor.ZC index 7487cb2c..4c16fbcc 100755 --- a/src/Demo/Graphics/32BitColor.ZC +++ b/src/Demo/Graphics/32BitColor.ZC @@ -4,7 +4,7 @@ I0 DrawPixel(I64 x, I64 y, CBGR24 color) { - text.fb_alias[x + y * GR_WIDTH] = color; + text.fb_alias[x + y * sys_framebuffer_width] = color; } I0 Color32Demo() diff --git a/src/Demo/Graphics/32BitPaint.ZC b/src/Demo/Graphics/32BitPaint.ZC index eaa2b86d..68b92d08 100755 --- a/src/Demo/Graphics/32BitPaint.ZC +++ b/src/Demo/Graphics/32BitPaint.ZC @@ -32,12 +32,12 @@ U0 PaintGlobalsInit() I0 DrawImagePixel(I64 x, I64 y, CBGR24 color) { - paint.fb[x + y * GR_WIDTH] = color; + paint.fb[x + y * sys_framebuffer_width] = color; } I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color) { - text.fb_alias[x + y * GR_WIDTH] = color; + text.fb_alias[x + y * sys_framebuffer_width] = color; } I0 DrawScreenChar(I64 x, I64 y, I64 char) @@ -136,7 +136,7 @@ U0 PaintLoadImage() U32 PaintImagePeek(I64 x, I64 y) { - return paint.fb[x + y * GR_WIDTH]; + return paint.fb[x + y * sys_framebuffer_width]; } I0 Paint32() @@ -176,7 +176,7 @@ I0 Paint32() // draw the image where the brush was last covering it for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++) for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++) - DrawScreenPixel(i, j, paint.fb[i + j * GR_WIDTH]); + DrawScreenPixel(i, j, paint.fb[i + j * sys_framebuffer_width]); // draw the brush on the screen DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick); @@ -193,7 +193,7 @@ I0 Paint32() // draw the image where the color strings where covering it for (i = 0; i < 3 * FONT_HEIGHT; i++) for (j = 0; j < 12 * FONT_WIDTH; j++) - DrawScreenPixel(j, i, paint.fb[j + i * GR_WIDTH]); + DrawScreenPixel(j, i, paint.fb[j + i * sys_framebuffer_width]); // draw the color strings on screen DrawScreenStr(0, 0 * FONT_HEIGHT, str_r); diff --git a/src/System/Gr/GrDC.ZC b/src/System/Gr/GrDC.ZC index aa65bc61..e2f9b177 100755 --- a/src/System/Gr/GrDC.ZC +++ b/src/System/Gr/GrDC.ZC @@ -214,7 +214,8 @@ public CDC *DCNew(I64 width, I64 height, CTask *task=NULL, Bool null_bitmap=FALS res->win_task = task; res->mem_task = task; res->width = width; - res->width_internal = (width + 7) & ~7; +// res->width_internal = (width + 7) & ~7; + res->width_internal = width & ~7; res->height = height; if (null_bitmap) res->flags |= DCF_DONT_DRAW; diff --git a/src/System/Gr/GrGlobals.ZC b/src/System/Gr/GrGlobals.ZC index ed308a54..819b8481 100755 --- a/src/System/Gr/GrGlobals.ZC +++ b/src/System/Gr/GrGlobals.ZC @@ -47,7 +47,7 @@ public CBGR24 gr_palette[COLORS_NUM]; //See $LK,"SysGrInit",A="MN:SysGrInit"$() //Allows consts to be used instead of variables. HashPublic("GR_WIDTH", HTT_DEFINE_STR);; -DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width); +DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width & ~7); HashPublic("GR_HEIGHT", HTT_DEFINE_STR);; DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height); diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index 1c8e64e6..32a50f9c 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -157,13 +157,15 @@ U0 GrZoomInScreen() src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal; dst = gr.zoomed_dc->body; - for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) +// for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) + for (i = 0; i < gr.dc2->height / gr.screen_zoom; i++) { k = gr.screen_zoom; while (k--) { src2 = src; - for (l = 0; l < GR_WIDTH / gr.screen_zoom; l++) +// for (l = 0; l < GR_WIDTH / gr.screen_zoom; l++) + for (l = 0; l < gr.dc2->width_internal / gr.screen_zoom; l++) { for (j = 0; j < gr.screen_zoom - 1; j++) *dst++ = *src2; @@ -171,7 +173,8 @@ U0 GrZoomInScreen() *dst++ = *src2++; } } - src += GR_WIDTH; +// src += GR_WIDTH; + src += gr.dc2->width_internal; } } @@ -367,34 +370,62 @@ U0 GrCalcScreenUpdates() else screen = gr.zoomed_dc->body; +/* for (i = 0; i < diffs_size; i++) { if (screen[i] != last_screen[i]) dst[i] = src[i]; } - MemCopy(gr.screen_cache, screen, diffs_size * 2); +*/ +// MemCopy(gr.screen_cache, screen, diffs_size * 2); } U0 GrUpdateScreen32() { - U64 size, *dst; +// U64 size, *dst; + U64 size; + U32 *dst; U8 *src; + U64 x; + U64 y; + U64 w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + U64 wi; + U64 yi; if (gr.screen_zoom == 1) { src = gr.dc2->body; size = src + gr.dc2->height * gr.dc2->width_internal; + wi = gr.dc2->width_internal; + yi = gr.dc2->height; } else { GrZoomInScreen; src = gr.zoomed_dc->body; size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal; + wi = gr.zoomed_dc->width_internal; + yi = gr.zoomed_dc->height; +// SysLog("%d\n", wi); +// SysLog("%d\n\n", yi); } - dst = text.raw_screen; - while (src < size) //draw 2 pixels at a time - *dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32; +// dst = text.raw_screen; +// while (src < size) // need to do 1 pixel at a time... //draw 2 pixels at a time +// *dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32; + for (y = 0; y < yi; y++) + { + for (x = 0; x < wi; x++) + { +// dst = text.raw_screen[x + (y * sys_framebuffer_width)]; + dst = text.fb_alias + x + (y * w); +// dst = text.raw_screen + x + (y * w); +// *dst = gr_palette[*src++ & 0xFF]; +// *dst = gr_palette[src[x + (y * sys_framebuffer_width)] & 0xFF]; + *dst = gr_palette[src[x + (y * wi)] & 0xFF]; +// *dst = 0xFFFF0000; + } + } GrCalcScreenUpdates; From f8c984502614dc5e41d5ebf0f886edfba2c05d00 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Thu, 29 Aug 2024 00:49:38 -0400 Subject: [PATCH 6/9] Cleaning up leftover scraps from graphics code hacking, reimplementing GrCalcScreenUpdates --- src/System/Gr/GrScreen.ZC | 46 +++++++++++++++------------------------ 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index 32a50f9c..2d2f9600 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -362,35 +362,36 @@ U0 DCBlotColor8(CDC *dc, CDC *img) U0 GrCalcScreenUpdates() { - U16 *screen, *last_screen = gr.screen_cache; - U64 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT / 2; + U8 *screen, *last_screen = gr.screen_cache; + U32 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT; + U64 x, y, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); if (gr.screen_zoom == 1) screen = gr.dc2->body; else screen = gr.zoomed_dc->body; -/* - for (i = 0; i < diffs_size; i++) + for (y = 0; y < GR_HEIGHT; y++) { - if (screen[i] != last_screen[i]) - dst[i] = src[i]; + for (x = 0; x < GR_WIDTH; x++) + { + i = x + y * GR_WIDTH; + if (screen[i] != last_screen[i]) + { + dst = text.fb_alias + x + y * w; + src = text.raw_screen + x + y * w; + *dst = *src; + } + } } -*/ -// MemCopy(gr.screen_cache, screen, diffs_size * 2); + MemCopy(gr.screen_cache, screen, diffs_size * 2); } U0 GrUpdateScreen32() { -// U64 size, *dst; - U64 size; + U64 size, x, y, wi, yi, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); U32 *dst; U8 *src; - U64 x; - U64 y; - U64 w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); - U64 wi; - U64 yi; if (gr.screen_zoom == 1) { @@ -406,24 +407,13 @@ U0 GrUpdateScreen32() size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal; wi = gr.zoomed_dc->width_internal; yi = gr.zoomed_dc->height; -// SysLog("%d\n", wi); -// SysLog("%d\n\n", yi); } -// dst = text.raw_screen; -// while (src < size) // need to do 1 pixel at a time... //draw 2 pixels at a time -// *dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32; - for (y = 0; y < yi; y++) { for (x = 0; x < wi; x++) { -// dst = text.raw_screen[x + (y * sys_framebuffer_width)]; - dst = text.fb_alias + x + (y * w); -// dst = text.raw_screen + x + (y * w); -// *dst = gr_palette[*src++ & 0xFF]; -// *dst = gr_palette[src[x + (y * sys_framebuffer_width)] & 0xFF]; - *dst = gr_palette[src[x + (y * wi)] & 0xFF]; -// *dst = 0xFFFF0000; + dst = text.raw_screen + x + y * w; + *dst = gr_palette[src[x + y * wi] & 0xFF]; } } From b08c10e3437d10ad58644ea587859484ab1bd066 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Thu, 29 Aug 2024 01:00:35 -0400 Subject: [PATCH 7/9] Fixing GrCalcScreenUpdates incorrect size passed to MemCopy --- src/System/Gr/GrScreen.ZC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index 2d2f9600..83410c58 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -384,7 +384,7 @@ U0 GrCalcScreenUpdates() } } } - MemCopy(gr.screen_cache, screen, diffs_size * 2); + MemCopy(gr.screen_cache, screen, diffs_size); } U0 GrUpdateScreen32() From 38c41e551ac664dd111a978c62ca98e64c3179ef Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Thu, 29 Aug 2024 01:48:17 -0400 Subject: [PATCH 8/9] Fix zoom handling and update screen calculations - Corrected loop bounds in 'GrZoomInScreen' to use 'GR_HEIGHT' and 'GR_WIDTH' constants instead of dynamic values from 'gr.dc2'. - Updated 'src' offset calculations to use 'GR_WIDTH' instead of 'gr.dc2->width_internal'. - Simplified 'GrUpdateScreen32' to use fixed 'GR_HEIGHT' and 'GR_WIDTH' values for screen updates, removing unnecessary calculations and size adjustments based on 'gr.dc2' and 'gr.zoomed_dc'. --- src/System/Gr/GrScreen.ZC | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index 83410c58..42446782 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -157,15 +157,13 @@ U0 GrZoomInScreen() src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal; dst = gr.zoomed_dc->body; -// for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) - for (i = 0; i < gr.dc2->height / gr.screen_zoom; i++) + for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) { k = gr.screen_zoom; while (k--) { src2 = src; -// for (l = 0; l < GR_WIDTH / gr.screen_zoom; l++) - for (l = 0; l < gr.dc2->width_internal / gr.screen_zoom; l++) + for (l = 0; l < GR_WIDTH / gr.screen_zoom; l++) { for (j = 0; j < gr.screen_zoom - 1; j++) *dst++ = *src2; @@ -173,8 +171,7 @@ U0 GrZoomInScreen() *dst++ = *src2++; } } -// src += GR_WIDTH; - src += gr.dc2->width_internal; + src += GR_WIDTH; } } @@ -389,31 +386,23 @@ U0 GrCalcScreenUpdates() U0 GrUpdateScreen32() { - U64 size, x, y, wi, yi, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + U64 x, y, wi, yi, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); U32 *dst; U8 *src; if (gr.screen_zoom == 1) - { src = gr.dc2->body; - size = src + gr.dc2->height * gr.dc2->width_internal; - wi = gr.dc2->width_internal; - yi = gr.dc2->height; - } else { GrZoomInScreen; src = gr.zoomed_dc->body; - size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal; - wi = gr.zoomed_dc->width_internal; - yi = gr.zoomed_dc->height; } - for (y = 0; y < yi; y++) + for (y = 0; y < GR_HEIGHT; y++) { - for (x = 0; x < wi; x++) + for (x = 0; x < GR_WIDTH; x++) { dst = text.raw_screen + x + y * w; - *dst = gr_palette[src[x + y * wi] & 0xFF]; + *dst = gr_palette[src[x + y * GR_WIDTH] & 0xFF]; } } From 2ffd423f7b53dabfa59d8b62dbd7136e544e8af2 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 2 Dec 2024 01:02:34 -0500 Subject: [PATCH 9/9] Refactor framebuffer handling and remove redundant variables. (not tested on baremetal) - Removed the 'fb_width_from_pitch' variable and replaced its usage with 'sys_framebuffer_pidth' to standardize the handling of framebuffer width-from-pitch across the codebase. - Updated references to 'fb_width_from_pitch' in display and screen update functions to use 'sys_framebuffer_pidth', ensuring consistent calculations. - Replaced 'sys_framebuffer_pitch / (sys_framebuffer_bpp / 8)' with 'sys_framebuffer_pidth' to avoid redundant calculations and improve code readability. - Fixed framebuffer calculations in 'GrCalcScreenUpdates', 'GrUpdateScreen32', and related functions to use the correct framebuffer width-from-pitch value. - Corrected and simplified screen update logic in 'GrZoomInScreen' and 'GrUpdateScreen'. --- src/Kernel/Display.ZC | 14 ++++++-------- src/Kernel/KMain.ZC | 3 ++- src/Kernel/KernelB.HH | 2 +- src/System/Gr/GrGlobals.ZC | 2 ++ src/System/Gr/GrScreen.ZC | 33 +++++++++++++++++---------------- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Kernel/Display.ZC b/src/Kernel/Display.ZC index a8b43d50..97ae3793 100755 --- a/src/Kernel/Display.ZC +++ b/src/Kernel/Display.ZC @@ -8,9 +8,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). */ I64 i, row, col, x, y; U32 *framebuffer; - U64 ch_bitmap, fb_width_from_pitch; - - fb_width_from_pitch = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + U64 ch_bitmap; if (!(text.raw_flags & RAWF_SHOW_DOLLAR)) { @@ -62,17 +60,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). {//Scroll screen down MemCopy(text.fb_alias, - text.fb_alias + fb_width_from_pitch * FONT_HEIGHT, - (text.screen_size - fb_width_from_pitch * FONT_HEIGHT) * sizeof(U32)); + text.fb_alias + sys_framebuffer_pidth * FONT_HEIGHT, + (text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT) * sizeof(U32)); - MemSetU32(text.fb_alias + text.screen_size - fb_width_from_pitch * FONT_HEIGHT, BLACK32, fb_width_from_pitch * FONT_HEIGHT); + MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT, BLACK32, sys_framebuffer_pidth * 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 + fb_width_from_pitch * y + x; + framebuffer = text.fb_alias + sys_framebuffer_pidth * y + x; PUSHFD CLI @@ -83,7 +81,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$(). else *framebuffer++ = BLACK32; if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1) - framebuffer += fb_width_from_pitch - FONT_WIDTH; + framebuffer += sys_framebuffer_pidth - FONT_WIDTH; ch_bitmap >>= 1; } POPFD diff --git a/src/Kernel/KMain.ZC b/src/Kernel/KMain.ZC index 8f363e19..8b1df95d 100755 --- a/src/Kernel/KMain.ZC +++ b/src/Kernel/KMain.ZC @@ -91,7 +91,8 @@ U0 SysGrInit() text.cols = sys_framebuffer_width / FONT_WIDTH; text.rows = sys_framebuffer_height / FONT_HEIGHT; - text.screen_size = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8) * sys_framebuffer_height; + sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + text.screen_size = sys_framebuffer_pidth * 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; diff --git a/src/Kernel/KernelB.HH b/src/Kernel/KernelB.HH index 9890ad90..7ccb0348 100755 --- a/src/Kernel/KernelB.HH +++ b/src/Kernel/KernelB.HH @@ -249,7 +249,7 @@ public _extern SYS_FRAMEBUFFER_WIDTH U64 sys_framebuffer_width; public _extern SYS_FRAMEBUFFER_HEIGHT U64 sys_framebuffer_height; public _extern SYS_FRAMEBUFFER_PITCH U64 sys_framebuffer_pitch; public _extern SYS_FRAMEBUFFER_BPP U8 sys_framebuffer_bpp; - +public U64 sys_framebuffer_pidth; _extern SYS_FRAMEBUFFER_LIST CVideoInfo sys_framebuffer_list[VBE_MODES_NUM]; #help_index "Processor/SMBIOS" diff --git a/src/System/Gr/GrGlobals.ZC b/src/System/Gr/GrGlobals.ZC index 819b8481..0bf9e0d7 100755 --- a/src/System/Gr/GrGlobals.ZC +++ b/src/System/Gr/GrGlobals.ZC @@ -56,3 +56,5 @@ DefinePrint("TEXT_ROWS", "%d", text.rows);; HashPublic("TEXT_ROWS", HTT_DEFINE_STR);; DefinePrint("TEXT_COLS", "%d", text.cols);; HashPublic("TEXT_COLS", HTT_DEFINE_STR);; + +sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); \ No newline at end of file diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index 42446782..84335c33 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -142,8 +142,8 @@ public U0 GrScaleZoom(F64 scale) mouse.offset.x = mouse.pos.x - (mouse.pos.x - mouse.offset.x) * s; mouse.offset.y = mouse.pos.y - (mouse.pos.y - mouse.offset.y) * s; mouse.offset.z = mouse.pos.z - (mouse.pos.z - mouse.offset.z) * s; - gr.sx = mouse.pos.x - gr.zoomed_dc->width >> 1 / gr.screen_zoom; - gr.sy = mouse.pos.y - gr.zoomed_dc->height >> 1 / gr.screen_zoom; + gr.sx = mouse.pos.x - GR_WIDTH >> 1 / gr.screen_zoom; + gr.sy = mouse.pos.y - GR_HEIGHT >> 1 / gr.screen_zoom; GrFixZoomScale; } @@ -154,7 +154,7 @@ U0 GrZoomInScreen() GrFixZoomScale; - src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal; + src = gr.dc2->body + gr.sx + gr.sy * GR_WIDTH; dst = gr.zoomed_dc->body; for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) @@ -359,34 +359,35 @@ U0 DCBlotColor8(CDC *dc, CDC *img) U0 GrCalcScreenUpdates() { - U8 *screen, *last_screen = gr.screen_cache; - U32 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT; - U64 x, y, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + U8 *screen, reg RCX *last_screen = gr.screen_cache; + U32 *src = text.raw_screen, *dst = text.fb_alias; + U64 i, j, x, y, yi; if (gr.screen_zoom == 1) screen = gr.dc2->body; else screen = gr.zoomed_dc->body; - for (y = 0; y < GR_HEIGHT; y++) + for (y = yi = 0; y < GR_HEIGHT; yi = ++y * GR_WIDTH) { for (x = 0; x < GR_WIDTH; x++) { - i = x + y * GR_WIDTH; + i = x + yi; + j = x + y * sys_framebuffer_pidth; if (screen[i] != last_screen[i]) { - dst = text.fb_alias + x + y * w; - src = text.raw_screen + x + y * w; + dst = text.fb_alias + j; + src = text.raw_screen + j; *dst = *src; } } } - MemCopy(gr.screen_cache, screen, diffs_size); + MemCopy(gr.screen_cache, screen, GR_WIDTH * GR_HEIGHT); } U0 GrUpdateScreen32() { - U64 x, y, wi, yi, w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8); + U64 x, y, j, i; U32 *dst; U8 *src; @@ -397,12 +398,12 @@ U0 GrUpdateScreen32() GrZoomInScreen; src = gr.zoomed_dc->body; } - for (y = 0; y < GR_HEIGHT; y++) + for (y = j = i = 0; y < GR_HEIGHT; j = ++y * sys_framebuffer_pidth, i = y * GR_WIDTH) { for (x = 0; x < GR_WIDTH; x++) { - dst = text.raw_screen + x + y * w; - *dst = gr_palette[src[x + y * GR_WIDTH] & 0xFF]; + dst = text.raw_screen + x + j; + *dst = gr_palette[src[x + i] & 0xFF]; } } @@ -430,6 +431,6 @@ U0 GrUpdateScreen() (*gr.fp_final_screen_update)(dc); DCDel(dc); - DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, gr.dc2->height * gr.dc2->width_internal >> 3); + DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, GR_HEIGHT * GR_WIDTH >> 3); GrUpdateScreen32; }