- 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.

svn path=/branches/ntvdm/; revision=59673
This commit is contained in:
Hermès Bélusca-Maïto 2013-08-09 00:13:54 +00:00
parent 12b2347206
commit bd75425efd

View file

@ -265,11 +265,15 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
static VOID VgaLeaveGraphicsMode(VOID) static VOID VgaLeaveGraphicsMode(VOID)
{ {
/* Release the console framebuffer mutex if needed */
ReleaseMutex(ConsoleMutex);
/* Switch back to the text buffer */ /* Switch back to the text buffer */
SetConsoleActiveScreenBuffer(TextConsoleBuffer); SetConsoleActiveScreenBuffer(TextConsoleBuffer);
/* Cleanup the video data */ /* Cleanup the video data */
CloseHandle(ConsoleMutex); CloseHandle(ConsoleMutex);
ConsoleMutex = NULL;
CloseHandle(GraphicsConsoleBuffer); CloseHandle(GraphicsConsoleBuffer);
GraphicsConsoleBuffer = NULL; GraphicsConsoleBuffer = NULL;
} }
@ -350,17 +354,22 @@ static VOID VgaUpdateFramebuffer(VOID)
DWORD Address = (VgaCrtcRegisters[VGA_CRTC_START_ADDR_HIGH_REG] << 8) DWORD Address = (VgaCrtcRegisters[VGA_CRTC_START_ADDR_HIGH_REG] << 8)
+ VgaCrtcRegisters[VGA_CRTC_START_ADDR_LOW_REG]; + VgaCrtcRegisters[VGA_CRTC_START_ADDR_LOW_REG];
DWORD ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2; 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 */ /* Check if this is text mode or graphics mode */
if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA) if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
{ {
/* Graphics mode */ /* 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 */ /* Loop through the pixels */
for (j = 0; j < Resolution.X; j++) for (j = 0; j < Resolution.X; j++)
{ {
@ -460,11 +469,25 @@ static VOID VgaUpdateFramebuffer(VOID)
VgaMarkForUpdate(i, j); VgaMarkForUpdate(i, j);
} }
} }
/* Move to the next scanline */
Address += ScanlineSize;
}
/*
* Release the console framebuffer mutex
* so that we allow for repainting.
*/
ReleaseMutex(ConsoleMutex);
} }
else else
{ {
/* Text mode */ /* Text mode */
PCHAR_INFO CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
/* Loop through the scanlines */
for (i = 0; i < Resolution.Y; i++)
{
/* Loop through the characters */ /* Loop through the characters */
for (j = 0; j < Resolution.X; j++) for (j = 0; j < Resolution.X; j++)
{ {
@ -488,11 +511,11 @@ static VOID VgaUpdateFramebuffer(VOID)
VgaMarkForUpdate(i, j); VgaMarkForUpdate(i, j);
} }
} }
}
/* Move to the next scanline */ /* Move to the next scanline */
Address += ScanlineSize; Address += ScanlineSize;
} }
}
} }
static VOID VgaUpdateTextCursor(VOID) static VOID VgaUpdateTextCursor(VOID)