From a13b3a537c19617264c118a4223a696efefafe5a Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Sat, 5 Apr 2025 17:00:59 -0700 Subject: [PATCH 1/2] [cmds] Fix vga_drawhline in Paint --- elkscmd/gui/event.c | 10 +++++----- elkscmd/gui/graphics.c | 7 ------- elkscmd/gui/graphics.h | 6 ++---- elkscmd/gui/render.c | 2 +- elkscmd/gui/vga-c86.s | 3 --- elkscmd/gui/vga-ia16.S | 7 ++----- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/elkscmd/gui/event.c b/elkscmd/gui/event.c index c2b9e6256..b42b81ac8 100644 --- a/elkscmd/gui/event.c +++ b/elkscmd/gui/event.c @@ -115,13 +115,13 @@ int event_wait_timeout(struct event *e, int timeout) posy += y; if (posx < 0) posx = 0; if (posy < 0) posy = 0; - if ((drawing || altdrawing)){ - if (posx >= SCREEN_WIDTH) posx = SCREEN_WIDTH - 1; - if (posy >= SCREEN_HEIGHT) posy = SCREEN_HEIGHT - 1; - } else { + //if ((drawing || altdrawing)){ + //if (posx >= SCREEN_WIDTH) posx = SCREEN_WIDTH - 1; + //if (posy >= SCREEN_HEIGHT) posy = SCREEN_HEIGHT - 1; + //} else { if (posx >= SCREENWIDTH) posx = SCREENWIDTH - 1; if (posy >= SCREENHEIGHT) posy = SCREENHEIGHT - 1; - } + //} event->x = posx; event->y = posy; event->xrel = x; diff --git a/elkscmd/gui/graphics.c b/elkscmd/gui/graphics.c index 4b293a66a..1e7278bb1 100644 --- a/elkscmd/gui/graphics.c +++ b/elkscmd/gui/graphics.c @@ -230,13 +230,6 @@ void graphics_close(void) set_mode(TEXT_MODE); } -// Draw a horizontal line from x1,1 to x2,y including final point -void drawhline(int x1, int x2, int y, int c) -{ - while (x1 <= x2) - drawpixel(x1++, y, c); -} - #ifdef __WATCOMC__ void drawpixel(int x, int y, int color) { diff --git a/elkscmd/gui/graphics.h b/elkscmd/gui/graphics.h index 95537a625..9ccb729b6 100644 --- a/elkscmd/gui/graphics.h +++ b/elkscmd/gui/graphics.h @@ -24,11 +24,9 @@ int save_bmp(char *pathname); #define readpixel(x,y) pal_readpixel(x,y) #elif defined(__C86__) || defined(__ia16__) /* use ASM vga_ routines */ #define drawpixel(x,y,c) vga_drawpixel(x,y,c) -// #define drawhline(x1,x2,y,c) vga_drawhline(x1,x2,y,c) +#define drawhline(x1,x2,y,c) vga_drawhline(x1,x2,y,c) #define drawvline(x,y1,y2,c) vga_drawvline(x,y1,y2,c) #define readpixel(x,y) vga_readpixel(x,y) - -void drawhline(int x1, int x2, int y, int c); #else void drawpixel(int x,int y, int color); void drawhline(int x1, int x2, int y, int c); @@ -40,7 +38,7 @@ void fillrect(int x1, int y1, int x2, int y2, int c); /* VGA 16 color, 4bpp routines implemented in ASM in vga-ia16.S and vga-c86.s */ void vga_init(void); void vga_drawpixel(int x, int y, int c); -// void vga_drawhline(int x1, int x2, int y, int c); +void vga_drawhline(int x1, int x2, int y, int c); void vga_drawvline(int x, int y1, int y2, int c); int vga_readpixel(int x, int y); diff --git a/elkscmd/gui/render.c b/elkscmd/gui/render.c index e068256e5..f9bee58ac 100644 --- a/elkscmd/gui/render.c +++ b/elkscmd/gui/render.c @@ -115,7 +115,7 @@ void R_DrawCurrentColor(void) int startingPixelXOffset = SCREEN_WIDTH + 10 + 32 + 1; int startingPixelYOffset = 10 + 128 + 10; - fillrect(startingPixelXOffset, startingPixelYOffset, startingPixelXOffset + 61, \ + fillrect(startingPixelXOffset, startingPixelYOffset, startingPixelXOffset + 61, startingPixelYOffset + 29, currentMainColor); // Draw white frame if the main color matches the panel backgound diff --git a/elkscmd/gui/vga-c86.s b/elkscmd/gui/vga-c86.s index 658acd266..f0e6e67fa 100644 --- a/elkscmd/gui/vga-c86.s +++ b/elkscmd/gui/vga-c86.s @@ -48,7 +48,6 @@ _vga_init: ; static unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; ; //set_op(0); ; set_color(c); -; select_mask(); ; set_mask(mask[x&7]); ; .global _vga_drawpixel @@ -113,7 +112,6 @@ _vga_drawpixel: ; set_color(c); ; //set_op(0); ; char far *dst = SCREENBASE + x1 / 8 + y * BYTESPERLN; -; select_mask(); ; if (x1 / 8 == x2 / 8) { ; set_mask((0xff >> (x1 & 7)) & (0xff << (7 - (x2 & 7)))); ; *dst |= 1; @@ -265,7 +263,6 @@ L44: mov ah, bl ; AH := bit mask for last byte ; C version: ; //set_op(0); ; set_color(c); -; select_mask(); ; set_mask(mask[x&7]); ; char far *dst = SCREENBASE + x / 8 + y1 * BYTESPERLN; ; char far *last = SCREENBASE + x / 8 + y2 * BYTESPERLN; diff --git a/elkscmd/gui/vga-ia16.S b/elkscmd/gui/vga-ia16.S index 350df1846..02179632f 100644 --- a/elkscmd/gui/vga-ia16.S +++ b/elkscmd/gui/vga-ia16.S @@ -49,7 +49,6 @@ vga_init: // static unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; // //set_op(0); // set_color(c); -// select_mask(); // set_mask(mask[x&7]); // .global vga_drawpixel @@ -114,7 +113,6 @@ vga_drawpixel: // set_color(c); // //set_op(0); // char far *dst = SCREENBASE + x1 / 8 + y * BYTESPERLN; -// select_mask(); // if (x1 / 8 == x2 / 8) { // set_mask((0xff >> (x1 & 7)) & (0xff << (7 - (x2 & 7)))); // *dst |= 1; @@ -208,7 +206,7 @@ vga_drawhline: // get Graphics Controller port address into DX mov %dx, %bx // BH := bit mask for first byte // BL := bit mask for last byte - mov $0x3ce, %dx // DX := Graphics Controller port + mov $0x03ce, %dx // DX := Graphics Controller port mov $8, %al // AL := Bit mask Register number // make video buffer addressable through DS:SI @@ -223,7 +221,7 @@ vga_drawhline: or %cx, %cx jnz L42 // jump if more than one byte in the line - and %bl, %bh // BL := bit mask for the line + and %bh, %bl // BL := bit mask for the line jmp L44 L42: mov %bh, %ah // AH := bit mask for first byte @@ -266,7 +264,6 @@ L44: mov %bl, %ah // AH := bit mask for last byte // C version: // //set_op(0); // set_color(c); -// select_mask(); // set_mask(mask[x&7]); // char far *dst = SCREENBASE + x / 8 + y1 * BYTESPERLN; // char far *last = SCREENBASE + x / 8 + y2 * BYTESPERLN; From 6eddf1462d24b7aa9cdd1b7abd5c9db0c7abed9b Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Sat, 5 Apr 2025 17:24:03 -0700 Subject: [PATCH 2/2] Cleanup --- elkscmd/gui/vga-c86.s | 2 +- elkscmd/gui/vga-ia16.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/elkscmd/gui/vga-c86.s b/elkscmd/gui/vga-c86.s index f0e6e67fa..d1f56f6a9 100644 --- a/elkscmd/gui/vga-c86.s +++ b/elkscmd/gui/vga-c86.s @@ -105,7 +105,7 @@ _vga_drawpixel: ret ; -; Draw a horizontal line from x1,1 to x2,y including final point +; Draw a horizontal line from x1,y to x2,y including final point ; void vga_drawhine(int x1, int x2, int y, int color); ; ; C version: diff --git a/elkscmd/gui/vga-ia16.S b/elkscmd/gui/vga-ia16.S index 02179632f..d7eb714bc 100644 --- a/elkscmd/gui/vga-ia16.S +++ b/elkscmd/gui/vga-ia16.S @@ -106,7 +106,7 @@ vga_drawpixel: ret // -// Draw a horizontal line from x1,1 to x2,y including final point +// Draw a horizontal line from x1,y to x2,y including final point // void vga_drawhine(int x1, int x2, int y, int color) // // C version: