Author: hbelusca
Date: Fri Aug 9 00:13:54 2013
New Revision: 59673
URL:
http://svn.reactos.org/svn/reactos?rev=59673&view=rev
Log:
[NTVDM]
- Fix usage of the console framebuffer mutex (used only with graphics screen buffers).
- Do not check for text/graphics mode when updating each scan line, in
VgaUpdateFramebuffer.
Modified:
branches/ntvdm/subsystems/ntvdm/vga.c
Modified: branches/ntvdm/subsystems/ntvdm/vga.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/vga.c?re…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/vga.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/vga.c [iso-8859-1] Fri Aug 9 00:13:54 2013
@@ -265,11 +265,15 @@
static VOID VgaLeaveGraphicsMode(VOID)
{
+ /* Release the console framebuffer mutex if needed */
+ ReleaseMutex(ConsoleMutex);
+
/* Switch back to the text buffer */
SetConsoleActiveScreenBuffer(TextConsoleBuffer);
/* Cleanup the video data */
CloseHandle(ConsoleMutex);
+ ConsoleMutex = NULL;
CloseHandle(GraphicsConsoleBuffer);
GraphicsConsoleBuffer = NULL;
}
@@ -350,17 +354,22 @@
DWORD Address = (VgaCrtcRegisters[VGA_CRTC_START_ADDR_HIGH_REG] << 8)
+ VgaCrtcRegisters[VGA_CRTC_START_ADDR_LOW_REG];
DWORD ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
- PCHAR_INFO CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
- PBYTE GraphicsBuffer = (PBYTE)ConsoleFramebuffer;
-
- /* Loop through the scanlines */
- for (i = 0; i < Resolution.Y; i++)
- {
- /* Check if this is text mode or graphics mode */
- if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
- {
- /* Graphics mode */
-
+
+ /* Check if this is text mode or graphics mode */
+ if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
+ {
+ /* Graphics mode */
+ PBYTE GraphicsBuffer = (PBYTE)ConsoleFramebuffer;
+
+ /*
+ * Synchronize access to the graphics framebuffer
+ * with the console framebuffer mutex.
+ */
+ WaitForSingleObject(ConsoleMutex, INFINITE);
+
+ /* Loop through the scanlines */
+ for (i = 0; i < Resolution.Y; i++)
+ {
/* Loop through the pixels */
for (j = 0; j < Resolution.X; j++)
{
@@ -460,11 +469,25 @@
VgaMarkForUpdate(i, j);
}
}
- }
- else
- {
- /* Text mode */
-
+
+ /* Move to the next scanline */
+ Address += ScanlineSize;
+ }
+
+ /*
+ * Release the console framebuffer mutex
+ * so that we allow for repainting.
+ */
+ ReleaseMutex(ConsoleMutex);
+ }
+ else
+ {
+ /* Text mode */
+ PCHAR_INFO CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
+
+ /* Loop through the scanlines */
+ for (i = 0; i < Resolution.Y; i++)
+ {
/* Loop through the characters */
for (j = 0; j < Resolution.X; j++)
{
@@ -488,10 +511,10 @@
VgaMarkForUpdate(i, j);
}
}
- }
-
- /* Move to the next scanline */
- Address += ScanlineSize;
+
+ /* Move to the next scanline */
+ Address += ScanlineSize;
+ }
}
}