mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 15:13:18 +00:00
[NTVDM]
- Simplify code (flags resetting) - Fix console palette initialization (use version 3) and palette change. svn path=/branches/ntvdm/; revision=59720
This commit is contained in:
parent
53fa8a9cdd
commit
8a6a428ccc
1 changed files with 46 additions and 42 deletions
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
||||||
static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
|
static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
|
||||||
|
|
||||||
static CONST COLORREF VgaDefaultPalette[VGA_MAX_COLORS] =
|
static CONST COLORREF VgaDefaultPalette[VGA_MAX_COLORS] =
|
||||||
|
@ -318,7 +318,7 @@ static VOID VgaWriteDac(BYTE Data)
|
||||||
/* Update the palette entry */
|
/* Update the palette entry */
|
||||||
SetPaletteEntries(PaletteHandle, PaletteIndex, 1, &Entry);
|
SetPaletteEntries(PaletteHandle, PaletteIndex, 1, &Entry);
|
||||||
|
|
||||||
/* Set the palette changed flag */
|
/* Set the palette change flag */
|
||||||
PaletteChanged = TRUE;
|
PaletteChanged = TRUE;
|
||||||
|
|
||||||
/* Update the index */
|
/* Update the index */
|
||||||
|
@ -340,7 +340,7 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
|
||||||
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
|
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
|
||||||
BYTE BitmapInfoBuffer[VGA_BITMAP_INFO_SIZE];
|
BYTE BitmapInfoBuffer[VGA_BITMAP_INFO_SIZE];
|
||||||
LPBITMAPINFO BitmapInfo = (LPBITMAPINFO)BitmapInfoBuffer;
|
LPBITMAPINFO BitmapInfo = (LPBITMAPINFO)BitmapInfoBuffer;
|
||||||
LPWORD PaletteIndex = (LPWORD)(BitmapInfoBuffer + sizeof(BITMAPINFOHEADER));
|
LPWORD PaletteIndex = (LPWORD)(BitmapInfo->bmiColors);
|
||||||
|
|
||||||
/* Fill the bitmap info header */
|
/* Fill the bitmap info header */
|
||||||
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER));
|
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||||
|
@ -350,7 +350,7 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
|
||||||
BitmapInfo->bmiHeader.biBitCount = 8;
|
BitmapInfo->bmiHeader.biBitCount = 8;
|
||||||
BitmapInfo->bmiHeader.biPlanes = 1;
|
BitmapInfo->bmiHeader.biPlanes = 1;
|
||||||
BitmapInfo->bmiHeader.biCompression = BI_RGB;
|
BitmapInfo->bmiHeader.biCompression = BI_RGB;
|
||||||
BitmapInfo->bmiHeader.biSizeImage = Resolution->X * Resolution->Y;
|
BitmapInfo->bmiHeader.biSizeImage = Resolution->X * Resolution->Y /* * 1 == biBitCount / 8 */;
|
||||||
|
|
||||||
/* Fill the palette data */
|
/* Fill the palette data */
|
||||||
for (i = 0; i < (VGA_PALETTE_SIZE / 3); i++) PaletteIndex[i] = (WORD)i;
|
for (i = 0; i < (VGA_PALETTE_SIZE / 3); i++) PaletteIndex[i] = (WORD)i;
|
||||||
|
@ -378,6 +378,14 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
|
||||||
/* Set the active buffer */
|
/* Set the active buffer */
|
||||||
SetConsoleActiveScreenBuffer(GraphicsConsoleBuffer);
|
SetConsoleActiveScreenBuffer(GraphicsConsoleBuffer);
|
||||||
|
|
||||||
|
/* Set the graphics mode palette */
|
||||||
|
SetConsolePalette(GraphicsConsoleBuffer,
|
||||||
|
PaletteHandle,
|
||||||
|
SYSPAL_NOSTATIC256);
|
||||||
|
|
||||||
|
/* Clear the text mode flag */
|
||||||
|
TextMode = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,6 +421,9 @@ static BOOL VgaEnterTextMode(PCOORD Resolution)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the text mode flag */
|
||||||
|
TextMode = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,10 +434,13 @@ static VOID VgaLeaveTextMode(VOID)
|
||||||
ConsoleFramebuffer = NULL;
|
ConsoleFramebuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID VgaUpdateMode(VOID)
|
static VOID VgaChangeMode(VOID)
|
||||||
{
|
{
|
||||||
COORD Resolution = VgaGetDisplayResolution();
|
COORD Resolution = VgaGetDisplayResolution();
|
||||||
|
|
||||||
|
/* Reset the mode change flag */
|
||||||
|
// ModeChanged = FALSE;
|
||||||
|
|
||||||
if (!TextMode)
|
if (!TextMode)
|
||||||
{
|
{
|
||||||
/* Leave the current graphics mode */
|
/* Leave the current graphics mode */
|
||||||
|
@ -443,30 +457,22 @@ static VOID VgaUpdateMode(VOID)
|
||||||
{
|
{
|
||||||
/* Enter new text mode */
|
/* Enter new text mode */
|
||||||
if (!VgaEnterTextMode(&Resolution)) return;
|
if (!VgaEnterTextMode(&Resolution)) return;
|
||||||
|
|
||||||
/* Set the text mode flag */
|
|
||||||
TextMode = TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Enter 8-bit graphics mode */
|
/* Enter 8-bit graphics mode */
|
||||||
if (!VgaEnterGraphicsMode(&Resolution)) return;
|
if (!VgaEnterGraphicsMode(&Resolution)) return;
|
||||||
|
|
||||||
/* Clear the text mode flag */
|
|
||||||
TextMode = FALSE;
|
|
||||||
|
|
||||||
/* Set the palette */
|
|
||||||
SetConsolePalette(GraphicsConsoleBuffer,
|
|
||||||
PaletteHandle,
|
|
||||||
SYSPAL_NOSTATIC256);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform a full update */
|
/* Trigger a full update of the screen */
|
||||||
NeedsUpdate = TRUE;
|
NeedsUpdate = TRUE;
|
||||||
UpdateRectangle.Left = 0;
|
UpdateRectangle.Left = 0;
|
||||||
UpdateRectangle.Top = 0;
|
UpdateRectangle.Top = 0;
|
||||||
UpdateRectangle.Right = Resolution.X;
|
UpdateRectangle.Right = Resolution.X;
|
||||||
UpdateRectangle.Bottom = Resolution.Y;
|
UpdateRectangle.Bottom = Resolution.Y;
|
||||||
|
|
||||||
|
/* Reset the mode change flag */
|
||||||
|
ModeChanged = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID VgaUpdateFramebuffer(VOID)
|
static VOID VgaUpdateFramebuffer(VOID)
|
||||||
|
@ -675,6 +681,9 @@ static VOID VgaUpdateTextCursor(VOID)
|
||||||
/* Update the physical cursor */
|
/* Update the physical cursor */
|
||||||
SetConsoleCursorInfo(TextConsoleBuffer, &CursorInfo);
|
SetConsoleCursorInfo(TextConsoleBuffer, &CursorInfo);
|
||||||
SetConsoleCursorPosition(TextConsoleBuffer, Position);
|
SetConsoleCursorPosition(TextConsoleBuffer, Position);
|
||||||
|
|
||||||
|
/* Reset the cursor move flag */
|
||||||
|
CursorMoved = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
@ -735,32 +744,27 @@ VOID VgaRefreshDisplay(VOID)
|
||||||
|
|
||||||
DPRINT("VgaRefreshDisplay\n");
|
DPRINT("VgaRefreshDisplay\n");
|
||||||
|
|
||||||
if (ModeChanged)
|
/* Change the display mode */
|
||||||
{
|
if (ModeChanged) VgaChangeMode();
|
||||||
/* Change the display mode */
|
|
||||||
VgaUpdateMode();
|
|
||||||
|
|
||||||
/* Reset the mode change flag */
|
/* Change the text cursor location */
|
||||||
ModeChanged = FALSE;
|
if (CursorMoved) VgaUpdateTextCursor();
|
||||||
}
|
|
||||||
|
|
||||||
if (CursorMoved)
|
|
||||||
{
|
|
||||||
/* Change the text cursor location */
|
|
||||||
VgaUpdateTextCursor();
|
|
||||||
|
|
||||||
/* Reset the cursor move flag */
|
|
||||||
CursorMoved = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PaletteChanged)
|
if (PaletteChanged)
|
||||||
{
|
{
|
||||||
if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
|
if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_NOALPHA)
|
||||||
{
|
{
|
||||||
/* Set the graphics mode palette */
|
/* Set the graphics mode palette */
|
||||||
SetConsolePalette(GraphicsConsoleBuffer,
|
//SetConsolePalette(GraphicsConsoleBuffer,
|
||||||
PaletteHandle,
|
// PaletteHandle,
|
||||||
SYSPAL_NOSTATIC256);
|
// SYSPAL_NOSTATIC256);
|
||||||
|
|
||||||
|
/* Trigger a full update of the screen */
|
||||||
|
NeedsUpdate = TRUE;
|
||||||
|
UpdateRectangle.Left = 0;
|
||||||
|
UpdateRectangle.Top = 0;
|
||||||
|
UpdateRectangle.Right = Resolution.X;
|
||||||
|
UpdateRectangle.Bottom = Resolution.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaletteChanged = FALSE;
|
PaletteChanged = FALSE;
|
||||||
|
@ -1122,8 +1126,7 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
|
||||||
|
|
||||||
/* Set the default video mode */
|
/* Set the default video mode */
|
||||||
BiosSetVideoMode(BIOS_DEFAULT_VIDEO_MODE);
|
BiosSetVideoMode(BIOS_DEFAULT_VIDEO_MODE);
|
||||||
VgaUpdateMode();
|
VgaChangeMode();
|
||||||
ModeChanged = FALSE;
|
|
||||||
|
|
||||||
/* Get the data */
|
/* Get the data */
|
||||||
Resolution = VgaGetDisplayResolution();
|
Resolution = VgaGetDisplayResolution();
|
||||||
|
@ -1168,7 +1171,7 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
|
||||||
if (Palette == NULL) return FALSE;
|
if (Palette == NULL) return FALSE;
|
||||||
|
|
||||||
/* Initialize the palette */
|
/* Initialize the palette */
|
||||||
Palette->palVersion = 0x0100;
|
Palette->palVersion = 0x0300;
|
||||||
Palette->palNumEntries = VGA_MAX_COLORS;
|
Palette->palNumEntries = VGA_MAX_COLORS;
|
||||||
|
|
||||||
/* Copy the colors of the default palette to the DAC and console palette */
|
/* Copy the colors of the default palette to the DAC and console palette */
|
||||||
|
@ -1178,6 +1181,7 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
|
||||||
Palette->palPalEntry[i].peRed = GetRValue(VgaDefaultPalette[i]);
|
Palette->palPalEntry[i].peRed = GetRValue(VgaDefaultPalette[i]);
|
||||||
Palette->palPalEntry[i].peGreen = GetGValue(VgaDefaultPalette[i]);
|
Palette->palPalEntry[i].peGreen = GetGValue(VgaDefaultPalette[i]);
|
||||||
Palette->palPalEntry[i].peBlue = GetBValue(VgaDefaultPalette[i]);
|
Palette->palPalEntry[i].peBlue = GetBValue(VgaDefaultPalette[i]);
|
||||||
|
Palette->palPalEntry[i].peFlags = 0;
|
||||||
|
|
||||||
/* Set the DAC registers */
|
/* Set the DAC registers */
|
||||||
VgaDacRegisters[i * 3] = VGA_COLOR_TO_DAC(GetRValue(VgaDefaultPalette[i]));
|
VgaDacRegisters[i * 3] = VGA_COLOR_TO_DAC(GetRValue(VgaDefaultPalette[i]));
|
||||||
|
@ -1191,8 +1195,8 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
|
||||||
/* Free the palette */
|
/* Free the palette */
|
||||||
HeapFree(GetProcessHeap(), 0, Palette);
|
HeapFree(GetProcessHeap(), 0, Palette);
|
||||||
|
|
||||||
/* Return success */
|
/* Return success if the palette was successfully created */
|
||||||
return TRUE;
|
return (PaletteHandle ? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue