From 05febc98036e287af4e77593d093f946de3e6513 Mon Sep 17 00:00:00 2001 From: GutPuncher Date: Mon, 26 Aug 2024 02:14:30 -0400 Subject: [PATCH] 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;