Hacking graphics code in pursuit of fixing #28

This commit is contained in:
GutPuncher 2024-08-26 02:14:30 -04:00
parent 9f363f265d
commit 05febc9803
No known key found for this signature in database
GPG key ID: 38CE0A7B6841D1C7
5 changed files with 48 additions and 16 deletions

View file

@ -4,7 +4,7 @@
I0 DrawPixel(I64 x, I64 y, CBGR24 color) 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() I0 Color32Demo()

View file

@ -32,12 +32,12 @@ U0 PaintGlobalsInit()
I0 DrawImagePixel(I64 x, I64 y, CBGR24 color) 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) 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) I0 DrawScreenChar(I64 x, I64 y, I64 char)
@ -136,7 +136,7 @@ U0 PaintLoadImage()
U32 PaintImagePeek(I64 x, I64 y) U32 PaintImagePeek(I64 x, I64 y)
{ {
return paint.fb[x + y * GR_WIDTH]; return paint.fb[x + y * sys_framebuffer_width];
} }
I0 Paint32() I0 Paint32()
@ -176,7 +176,7 @@ I0 Paint32()
// draw the image where the brush was last covering it // draw the image where the brush was last covering it
for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++) 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++) 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 // draw the brush on the screen
DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick); 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 // draw the image where the color strings where covering it
for (i = 0; i < 3 * FONT_HEIGHT; i++) for (i = 0; i < 3 * FONT_HEIGHT; i++)
for (j = 0; j < 12 * FONT_WIDTH; j++) 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 // draw the color strings on screen
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r); DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);

View file

@ -214,7 +214,8 @@ public CDC *DCNew(I64 width, I64 height, CTask *task=NULL, Bool null_bitmap=FALS
res->win_task = task; res->win_task = task;
res->mem_task = task; res->mem_task = task;
res->width = width; res->width = width;
res->width_internal = (width + 7) & ~7; // res->width_internal = (width + 7) & ~7;
res->width_internal = width & ~7;
res->height = height; res->height = height;
if (null_bitmap) if (null_bitmap)
res->flags |= DCF_DONT_DRAW; res->flags |= DCF_DONT_DRAW;

View file

@ -47,7 +47,7 @@ public CBGR24 gr_palette[COLORS_NUM];
//See $LK,"SysGrInit",A="MN:SysGrInit"$() //See $LK,"SysGrInit",A="MN:SysGrInit"$()
//Allows consts to be used instead of variables. //Allows consts to be used instead of variables.
HashPublic("GR_WIDTH", HTT_DEFINE_STR);; 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);; HashPublic("GR_HEIGHT", HTT_DEFINE_STR);;
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height); DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);

View file

@ -157,13 +157,15 @@ U0 GrZoomInScreen()
src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal; src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal;
dst = gr.zoomed_dc->body; 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; k = gr.screen_zoom;
while (k--) while (k--)
{ {
src2 = src; 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++) for (j = 0; j < gr.screen_zoom - 1; j++)
*dst++ = *src2; *dst++ = *src2;
@ -171,7 +173,8 @@ U0 GrZoomInScreen()
*dst++ = *src2++; *dst++ = *src2++;
} }
} }
src += GR_WIDTH; // src += GR_WIDTH;
src += gr.dc2->width_internal;
} }
} }
@ -367,34 +370,62 @@ U0 GrCalcScreenUpdates()
else else
screen = gr.zoomed_dc->body; screen = gr.zoomed_dc->body;
/*
for (i = 0; i < diffs_size; i++) for (i = 0; i < diffs_size; i++)
{ {
if (screen[i] != last_screen[i]) if (screen[i] != last_screen[i])
dst[i] = src[i]; dst[i] = src[i];
} }
MemCopy(gr.screen_cache, screen, diffs_size * 2); */
// MemCopy(gr.screen_cache, screen, diffs_size * 2);
} }
U0 GrUpdateScreen32() U0 GrUpdateScreen32()
{ {
U64 size, *dst; // U64 size, *dst;
U64 size;
U32 *dst;
U8 *src; U8 *src;
U64 x;
U64 y;
U64 w = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);
U64 wi;
U64 yi;
if (gr.screen_zoom == 1) if (gr.screen_zoom == 1)
{ {
src = gr.dc2->body; src = gr.dc2->body;
size = src + gr.dc2->height * gr.dc2->width_internal; size = src + gr.dc2->height * gr.dc2->width_internal;
wi = gr.dc2->width_internal;
yi = gr.dc2->height;
} }
else else
{ {
GrZoomInScreen; GrZoomInScreen;
src = gr.zoomed_dc->body; src = gr.zoomed_dc->body;
size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal; 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; // dst = text.raw_screen;
while (src < size) //draw 2 pixels at a time // 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; // *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; GrCalcScreenUpdates;