From e8d514701f7b3f90da66e59131c1b803207cc840 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Mon, 8 Jul 2024 06:49:24 -0700 Subject: [PATCH] XGA: Rectangle command needs to obey -/+ X and Y direction bits. If someone wants to draw a bitmap bottom up, then do it --- src/hardware/vga_xga.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/hardware/vga_xga.cpp b/src/hardware/vga_xga.cpp index 6a484d39e76..6a0468c7e80 100644 --- a/src/hardware/vga_xga.cpp +++ b/src/hardware/vga_xga.cpp @@ -83,7 +83,7 @@ struct XGAStatus { bool newline; bool wait; uint16_t cmd; - uint16_t curx, cury; + uint16_t curx, cury, curdx, curdy; uint16_t x1, y1, x2, y2, sizex, sizey; uint32_t data; /* transient data passed by multiple calls */ Bitu datasize; @@ -802,7 +802,7 @@ bool XGA_CheckX(void) { if((xga.waitcmd.curx<2048) && xga.waitcmd.curx > (xga.waitcmd.x2)) { xga.waitcmd.curx = xga.waitcmd.x1; - xga.waitcmd.cury++; + xga.waitcmd.cury += xga.waitcmd.curdy; xga.waitcmd.cury&=0x0fff; newline = true; xga.waitcmd.newline = true; @@ -814,7 +814,7 @@ bool XGA_CheckX(void) { uint16_t realxend=4096-xga.waitcmd.x2; if(realx==realxend) { xga.waitcmd.curx = xga.waitcmd.x1; - xga.waitcmd.cury++; + xga.waitcmd.cury += xga.waitcmd.curdy; xga.waitcmd.cury&=0x0fff; newline = true; xga.waitcmd.newline = true; @@ -824,7 +824,7 @@ bool XGA_CheckX(void) { } else { // else overlapping if(realx==xga.waitcmd.x2) { xga.waitcmd.curx = xga.waitcmd.x1; - xga.waitcmd.cury++; + xga.waitcmd.cury += xga.waitcmd.curdy; xga.waitcmd.cury&=0x0fff; newline = true; xga.waitcmd.newline = true; @@ -834,7 +834,7 @@ bool XGA_CheckX(void) { } } } else { - xga.waitcmd.newline = false; + xga.waitcmd.newline = false; } return newline; } @@ -847,7 +847,7 @@ void XGA_DrawWaitSub(Bitu mixmode, Bitu srcval) { //LOG_MSG("XGA: DrawPattern: Mixmode: %x srcval: %x", mixmode, srcval); XGA_DrawPoint(xga.waitcmd.curx, xga.waitcmd.cury, destval); - xga.waitcmd.curx++; + xga.waitcmd.curx += xga.waitcmd.curdx; xga.waitcmd.curx&=0x0fff; XGA_CheckX(); } @@ -1236,7 +1236,7 @@ void XGA_DrawCmd(Bitu val, Bitu len) { #if XGA_SHOW_COMMAND_TRACE == 1 LOG_MSG("XGA: Drawing Bresenham line"); #endif - XGA_DrawLineBresenham(val); + XGA_DrawLineBresenham(val); } else { #if XGA_SHOW_COMMAND_TRACE == 1 LOG_MSG("XGA: Drawing vector line"); @@ -1262,6 +1262,13 @@ void XGA_DrawCmd(Bitu val, Bitu len) { xga.waitcmd.wait = true; xga.waitcmd.curx = xga.curx; xga.waitcmd.cury = xga.cury; + + /* Windows will always use 101b (+X +Y) to draw left to right, top to bottom. + * Apparently there is an MS-DOS CAD program out there that wants to draw + * (+X -Y) left to right, bottom to top. */ + xga.waitcmd.curdx = ((val>>5)&1) ? 1 : uint16_t(~0u)/*equiv -1*/; + xga.waitcmd.curdy = ((val>>7)&1) ? 1 : uint16_t(~0u)/*equiv -1*/; + xga.waitcmd.x1 = xga.curx; xga.waitcmd.y1 = xga.cury; xga.waitcmd.x2 = (uint16_t)((xga.curx + xga.MAPcount)&0x0fff);