diff --git a/subsystems/ntvdm/vga.c b/subsystems/ntvdm/vga.c index 1851e593372..e527d39c255 100644 --- a/subsystems/ntvdm/vga.c +++ b/subsystems/ntvdm/vga.c @@ -92,6 +92,7 @@ static HANDLE TextConsoleBuffer = NULL; static HANDLE GraphicsConsoleBuffer = NULL; static HANDLE ConsoleMutex = NULL; static HPALETTE PaletteHandle = NULL; +static BOOLEAN DoubleVision = FALSE; static BYTE VgaLatchRegisters[VGA_NUM_BANKS] = {0, 0, 0, 0}; static BYTE VgaMiscRegister; @@ -440,6 +441,13 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution) LPBITMAPINFO BitmapInfo = (LPBITMAPINFO)BitmapInfoBuffer; LPWORD PaletteIndex = (LPWORD)(BitmapInfo->bmiColors); + if ((Resolution->X < VGA_MINIMUM_WIDTH) && (Resolution->Y < VGA_MINIMUM_HEIGHT)) + { + DoubleVision = TRUE; + Resolution->X *= 2; + Resolution->Y *= 2; + } + /* Fill the bitmap info header */ ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER)); BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -500,6 +508,7 @@ static VOID VgaLeaveGraphicsMode(VOID) ConsoleMutex = NULL; CloseHandle(GraphicsConsoleBuffer); GraphicsConsoleBuffer = NULL; + DoubleVision = FALSE; } static BOOL VgaEnterTextMode(PCOORD Resolution) @@ -738,14 +747,32 @@ static VOID VgaUpdateFramebuffer(VOID) PixelData = VgaAcRegisters[PixelData]; } - /* Now check if the resulting pixel data has changed */ - if (GraphicsBuffer[i * Resolution.X + j] != PixelData) + if (DoubleVision) { - /* Yes, write the new value */ - GraphicsBuffer[i * Resolution.X + j] = PixelData; + /* Now check if the resulting pixel data has changed */ + if (GraphicsBuffer[(i * Resolution.X * 4) + (j * 2)] != PixelData) + { + /* Yes, write the new value */ + GraphicsBuffer[(i * Resolution.X * 4) + (j * 2)] = PixelData; + GraphicsBuffer[(i * Resolution.X * 4) + (j * 2 + 1)] = PixelData; + GraphicsBuffer[((i * 2 + 1) * Resolution.X * 2) + (j * 2)] = PixelData; + GraphicsBuffer[((i * 2 + 1) * Resolution.X * 2) + (j * 2 + 1)] = PixelData; - /* Mark the specified pixel as changed */ - VgaMarkForUpdate(i, j); + /* Mark the specified pixel as changed */ + VgaMarkForUpdate(i, j); + } + } + else + { + /* Now check if the resulting pixel data has changed */ + if (GraphicsBuffer[i * Resolution.X + j] != PixelData) + { + /* Yes, write the new value */ + GraphicsBuffer[i * Resolution.X + j] = PixelData; + + /* Mark the specified pixel as changed */ + VgaMarkForUpdate(i, j); + } } } @@ -954,6 +981,15 @@ VOID VgaRefreshDisplay(VOID) &UpdateRectangle); } + if (DoubleVision) + { + /* Scale the update rectangle */ + UpdateRectangle.Left *= 2; + UpdateRectangle.Top *= 2; + UpdateRectangle.Right = UpdateRectangle.Right * 2 + 1; + UpdateRectangle.Bottom = UpdateRectangle.Bottom * 2 + 1; + } + /* Redraw the screen */ InvalidateConsoleDIBits(ConsoleBufferHandle, &UpdateRectangle); diff --git a/subsystems/ntvdm/vga.h b/subsystems/ntvdm/vga.h index 75627c98db5..4686a04439e 100644 --- a/subsystems/ntvdm/vga.h +++ b/subsystems/ntvdm/vga.h @@ -38,6 +38,8 @@ #define VGA_MAX_COLORS 256 #define VGA_PALETTE_SIZE (VGA_MAX_COLORS * 3) #define VGA_BITMAP_INFO_SIZE (sizeof(BITMAPINFOHEADER) + 2 * (VGA_PALETTE_SIZE / 3)) +#define VGA_MINIMUM_WIDTH 400 +#define VGA_MINIMUM_HEIGHT 300 #define VGA_DAC_TO_COLOR(x) (((x) << 2) | ((x) >> 6)) #define VGA_COLOR_TO_DAC(x) ((x) >> 2)