- Towards a complete fix of VGA console attach/detach: a lot of progress is made but few little things need to be checked/adjusted.
- Fix text scroll (at least in text modes) by doing guest-to-guest moves, using the EmulatorCopyMemory function introduced in r68826.
- Fix the computation of the screen rows/columns values stored in the BDA, in graphics modes (in addition to the change of r68090), by dividing the graphics resolution by the character heights & widths. Correct values are indeed needed by some programs, eg. QBasic (I also add a CharacterWidth; normally it should be computable using the CRTC registers, and is always == 8 or 9, but still...).

svn path=/trunk/; revision=68827
This commit is contained in:
Hermès Bélusca-Maïto 2015-08-26 01:26:33 +00:00
parent 91a6866265
commit be6a6195b6
3 changed files with 104 additions and 80 deletions

View file

@ -1937,32 +1937,33 @@ typedef struct _VGA_MODE
{ {
PVGA_REGISTERS VgaRegisters; PVGA_REGISTERS VgaRegisters;
WORD PageSize; WORD PageSize;
WORD CharacterWidth;
WORD CharacterHeight; WORD CharacterHeight;
// PCOLORREF Palette; // PCOLORREF Palette;
} VGA_MODE, *PVGA_MODE; } VGA_MODE, *PVGA_MODE;
static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE + 1] = static CONST VGA_MODE VideoModes[BIOS_MAX_VIDEO_MODE + 1] =
{ {
{&VideoMode_40x25_text, 0x0800, 16}, /* Mode 00h - 16 color (mono) */ {&VideoMode_40x25_text, 0x0800, 9, 16}, /* Mode 00h - 16 color (mono) */
{&VideoMode_40x25_text, 0x0800, 16}, /* Mode 01h - 16 color */ {&VideoMode_40x25_text, 0x0800, 9, 16}, /* Mode 01h - 16 color */
{&VideoMode_80x25_text, 0x1000, 16}, /* Mode 02h - 16 color (mono) */ {&VideoMode_80x25_text, 0x1000, 9, 16}, /* Mode 02h - 16 color (mono) */
{&VideoMode_80x25_text, 0x1000, 16}, /* Mode 03h - 16 color */ {&VideoMode_80x25_text, 0x1000, 9, 16}, /* Mode 03h - 16 color */
{&VideoMode_320x200_4color, 0x4000, 8}, /* Mode 04h - CGA 4 color */ {&VideoMode_320x200_4color, 0x4000, 8, 8}, /* Mode 04h - CGA 4 color */
{&VideoMode_320x200_4color, 0x4000, 8}, /* Mode 05h - CGA same (m) (uses 3rd CGA palette) */ {&VideoMode_320x200_4color, 0x4000, 8, 8}, /* Mode 05h - CGA same (m) (uses 3rd CGA palette) */
{&VideoMode_640x200_2color, 0x4000, 8}, /* Mode 06h - CGA 640*200 2 color */ {&VideoMode_640x200_2color, 0x4000, 8, 8}, /* Mode 06h - CGA 640*200 2 color */
{NULL, 0x1000, 0}, /* Mode 07h - MDA monochrome text 80*25 */ {NULL, 0x1000, 1, 1}, /* Mode 07h - MDA monochrome text 80*25 */
{NULL, 0x0000, 0}, /* Mode 08h - PCjr */ {NULL, 0x0000, 1, 1}, /* Mode 08h - PCjr */
{NULL, 0x0000, 0}, /* Mode 09h - PCjr */ {NULL, 0x0000, 1, 1}, /* Mode 09h - PCjr */
{NULL, 0x0000, 0}, /* Mode 0Ah - PCjr */ {NULL, 0x0000, 1, 1}, /* Mode 0Ah - PCjr */
{NULL, 0x0000, 0}, /* Mode 0Bh - Reserved */ {NULL, 0x0000, 1, 1}, /* Mode 0Bh - Reserved */
{NULL, 0x0000, 0}, /* Mode 0Ch - Reserved */ {NULL, 0x0000, 1, 1}, /* Mode 0Ch - Reserved */
{&VideoMode_320x200_16color, 0x2000, 8}, /* Mode 0Dh - EGA 320*200 16 color */ {&VideoMode_320x200_16color, 0x2000, 8, 8}, /* Mode 0Dh - EGA 320*200 16 color */
{&VideoMode_640x200_16color, 0x4000, 8}, /* Mode 0Eh - EGA 640*200 16 color */ {&VideoMode_640x200_16color, 0x4000, 8, 8}, /* Mode 0Eh - EGA 640*200 16 color */
{NULL, 0x8000, 0}, /* Mode 0Fh - EGA 640*350 mono */ {NULL, 0x8000, 1, 1}, /* Mode 0Fh - EGA 640*350 mono */
{&VideoMode_640x350_16color, 0x8000, 14}, /* Mode 10h - EGA 640*350 HiRes 16 color */ {&VideoMode_640x350_16color, 0x8000, 8, 14}, /* Mode 10h - EGA 640*350 HiRes 16 color */
{&VideoMode_640x480_2color, 0xA000, 16}, /* Mode 11h - VGA 640*480 mono */ {&VideoMode_640x480_2color, 0xA000, 8, 16}, /* Mode 11h - VGA 640*480 mono */
{&VideoMode_640x480_16color, 0xA000, 16}, /* Mode 12h - VGA */ {&VideoMode_640x480_16color, 0xA000, 8, 16}, /* Mode 12h - VGA */
{&VideoMode_320x200_256color, 0x2000, 8}, /* Mode 13h - VGA */ {&VideoMode_320x200_256color, 0x2000, 8, 8}, /* Mode 13h - VGA */
}; };
#define IS_TEXT_MODE(ModeNumber) \ #define IS_TEXT_MODE(ModeNumber) \
@ -2021,10 +2022,10 @@ static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction,
/* Move text lines up */ /* Move text lines up */
for (i = Rectangle.Top + Amount; i <= Rectangle.Bottom; i++) for (i = Rectangle.Top + Amount; i <= Rectangle.Bottom; i++)
{ {
EmulatorWriteMemory(&EmulatorContext, EmulatorCopyMemory(&EmulatorContext,
VideoAddress + ((i - Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD), VideoAddress + ((i - Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
REAL_TO_PHYS(VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD)), VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
(Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD)); (Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD));
} }
/* Fill the bottom of the rectangle */ /* Fill the bottom of the rectangle */
@ -2049,10 +2050,10 @@ static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction,
/* Move text lines down */ /* Move text lines down */
for (i = Rectangle.Bottom - Amount; i >= Rectangle.Top; i--) for (i = Rectangle.Bottom - Amount; i >= Rectangle.Top; i--)
{ {
EmulatorWriteMemory(&EmulatorContext, EmulatorCopyMemory(&EmulatorContext,
VideoAddress + ((i + Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD), VideoAddress + ((i + Amount) * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
REAL_TO_PHYS(VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD)), VideoAddress + ( i * Bda->ScreenColumns + Rectangle.Left) * sizeof(WORD),
(Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD)); (Rectangle.Right - Rectangle.Left + 1) * sizeof(WORD));
} }
/* Fill the top of the rectangle */ /* Fill the top of the rectangle */
@ -2076,10 +2077,10 @@ static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction,
/* Move text lines left */ /* Move text lines left */
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++) for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{ {
EmulatorWriteMemory(&EmulatorContext, EmulatorCopyMemory(&EmulatorContext,
VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD), VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD),
REAL_TO_PHYS(VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD)), VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD),
(Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD)); (Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD));
} }
/* Fill the right of the rectangle */ /* Fill the right of the rectangle */
@ -2099,19 +2100,21 @@ static BOOLEAN VidBiosScrollWindow(SCROLL_DIRECTION Direction,
case SCROLL_RIGHT: case SCROLL_RIGHT:
{ {
INT Right;
/* Move text lines right */ /* Move text lines right */
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++) for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{ {
EmulatorWriteMemory(&EmulatorContext, EmulatorCopyMemory(&EmulatorContext,
VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD), VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left + Amount) * sizeof(WORD),
REAL_TO_PHYS(VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD)), VideoAddress + (i * Bda->ScreenColumns + Rectangle.Left ) * sizeof(WORD),
(Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD)); (Rectangle.Right - Rectangle.Left - Amount + 1) * sizeof(WORD));
} }
/* Fill the left of the rectangle */ /* Fill the left of the rectangle */
Right = Rectangle.Left + Amount - 1;
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++) for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{ {
INT Right = Rectangle.Left + Amount - 1;
for (j = Rectangle.Left; j <= Right; j++) for (j = Rectangle.Left; j <= Right; j++)
{ {
EmulatorWriteMemory(&EmulatorContext, EmulatorWriteMemory(&EmulatorContext,
@ -2372,11 +2375,11 @@ static VOID VidBiosSetCursorShape(WORD CursorStartEnd)
IOWriteB(VGA_CRTC_DATA , LOBYTE(CursorStartEnd)); IOWriteB(VGA_CRTC_DATA , LOBYTE(CursorStartEnd));
} }
VOID VidBiosSyncCursorPosition(VOID) static VOID VidBiosSyncCursorPosition(VOID)
{ {
BYTE Row, Column; BYTE Row, Column;
BYTE Low, High; BYTE Low, High;
SHORT ScreenColumns = VgaGetDisplayResolution().X; SHORT ScreenColumns = Bda->ScreenColumns;
WORD Offset; WORD Offset;
/* Get the cursor position */ /* Get the cursor position */
@ -2493,12 +2496,16 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
/* Update the screen size */ /* Update the screen size */
Resolution = VgaGetDisplayResolution(); Resolution = VgaGetDisplayResolution();
// This could be simplified if the VGA helper always returned the resolution
// in number of pixels, instead of in number of cells for text-modes only...
if (!IS_TEXT_MODE(ModeNumber))
{
Resolution.X /= VideoModes[ModeNumber].CharacterWidth ;
Resolution.Y /= VideoModes[ModeNumber].CharacterHeight;
}
Bda->ScreenColumns = Resolution.X; Bda->ScreenColumns = Resolution.X;
Bda->ScreenRows = Resolution.Y - 1; Bda->ScreenRows = Resolution.Y - 1;
/* Adjust the number of columns for graphics modes */
if (!IS_TEXT_MODE(ModeNumber)) Bda->ScreenColumns >>= 3;
/* Update the current font */ /* Update the current font */
Bda->CharacterHeight = VideoModes[ModeNumber].CharacterHeight; Bda->CharacterHeight = VideoModes[ModeNumber].CharacterHeight;
switch (Bda->CharacterHeight) switch (Bda->CharacterHeight)
@ -2592,7 +2599,7 @@ static BOOLEAN VidBiosSetVideoPage(BYTE PageNumber)
* but we update the cursor position on the VGA side). * but we update the cursor position on the VGA side).
*/ */
VidBiosGetCursorPosition(&Row, &Column, PageNumber); VidBiosGetCursorPosition(&Row, &Column, PageNumber);
VidBiosSetCursorPosition(Row, Column, PageNumber); VidBiosSetCursorPosition( Row, Column, PageNumber);
return TRUE; return TRUE;
} }
@ -2814,11 +2821,11 @@ static VOID VidBiosDrawGlyph(WORD CharData, BOOLEAN UseAttr, BYTE Page, BYTE Row
WORD i, j; WORD i, j;
PUCHAR Font = (PUCHAR)FAR_POINTER(((PULONG)BaseAddress)[0x43]); PUCHAR Font = (PUCHAR)FAR_POINTER(((PULONG)BaseAddress)[0x43]);
PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight]; PUCHAR Glyph = &Font[LOBYTE(CharData) * Bda->CharacterHeight];
BYTE PixelBuffer[8]; BYTE PixelBuffer[8]; // 8 == CharacterWidth
for (i = 0; i < Bda->CharacterHeight; i++) for (i = 0; i < Bda->CharacterHeight; i++)
{ {
for (j = 0; j < 8; j++) for (j = 0; j < ARRAYSIZE(PixelBuffer); j++)
{ {
PixelBuffer[j] = (Glyph[i] & (1 << (7 - j))) ? HIBYTE(CharData) : 0; PixelBuffer[j] = (Glyph[i] & (1 << (7 - j))) ? HIBYTE(CharData) : 0;
} }
@ -2826,7 +2833,7 @@ static VOID VidBiosDrawGlyph(WORD CharData, BOOLEAN UseAttr, BYTE Page, BYTE Row
EmulatorWriteMemory(&EmulatorContext, EmulatorWriteMemory(&EmulatorContext,
TO_LINEAR(GRAPHICS_VIDEO_SEG, TO_LINEAR(GRAPHICS_VIDEO_SEG,
((Row * Bda->CharacterHeight + i) ((Row * Bda->CharacterHeight + i)
* Bda->ScreenColumns + Column) << 3), * Bda->ScreenColumns + Column) * 8),
(LPVOID)PixelBuffer, (LPVOID)PixelBuffer,
sizeof(PixelBuffer)); sizeof(PixelBuffer));
} }

View file

@ -104,8 +104,6 @@ typedef struct _VGA_DYNAMIC_FUNC_TABLE
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID VidBiosSyncCursorPosition(VOID);
VOID WINAPI VidBiosVideoService(LPWORD Stack); VOID WINAPI VidBiosVideoService(LPWORD Stack);
VOID VidBiosDetachFromConsole(VOID); VOID VidBiosDetachFromConsole(VOID);

View file

@ -455,7 +455,6 @@ static VOID VgaUpdateCursorPosition(VOID)
VgaCrtcRegisters[VGA_CRTC_CURSOR_LOC_LOW_REG] = LOBYTE(Offset); VgaCrtcRegisters[VGA_CRTC_CURSOR_LOC_LOW_REG] = LOBYTE(Offset);
VgaCrtcRegisters[VGA_CRTC_CURSOR_LOC_HIGH_REG] = HIBYTE(Offset); VgaCrtcRegisters[VGA_CRTC_CURSOR_LOC_HIGH_REG] = HIBYTE(Offset);
// VidBiosSyncCursorPosition();
VgaUpdateTextCursor(); VgaUpdateTextCursor();
} }
@ -519,13 +518,14 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
ASSERT(CharBuff); ASSERT(CharBuff);
#endif #endif
/* /* Retrieve the latest console information */
* Resize the console GetConsoleScreenBufferInfo(TextConsoleBuffer, &ConsoleInfo);
*/
/* Resize the console */
ConRect.Left = 0; ConRect.Left = 0;
ConRect.Top = ConsoleInfo.srWindow.Top;
ConRect.Right = ConRect.Left + Resolution->X - 1; ConRect.Right = ConRect.Left + Resolution->X - 1;
ConRect.Bottom = ConRect.Top + Resolution->Y - 1; ConRect.Bottom = max(ConsoleInfo.dwCursorPosition.Y, Resolution->Y - 1);
ConRect.Top = ConRect.Bottom - Resolution->Y + 1;
/* /*
* Use this trick to effectively resize the console buffer and window, * Use this trick to effectively resize the console buffer and window,
* because: * because:
@ -534,9 +534,13 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
* - SetConsoleWindowInfo fails if the new console window size is larger * - SetConsoleWindowInfo fails if the new console window size is larger
* than the current console screen buffer size. * than the current console screen buffer size.
*/ */
SetConsoleScreenBufferSize(TextConsoleBuffer, *Resolution); Success = SetConsoleScreenBufferSize(TextConsoleBuffer, *Resolution);
SetConsoleWindowInfo(TextConsoleBuffer, TRUE, &ConRect); DPRINT1("(attach) SetConsoleScreenBufferSize(1) %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
SetConsoleScreenBufferSize(TextConsoleBuffer, *Resolution); Success = SetConsoleWindowInfo(TextConsoleBuffer, TRUE, &ConRect);
DPRINT1("(attach) SetConsoleWindowInfo %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
Success = SetConsoleScreenBufferSize(TextConsoleBuffer, *Resolution);
DPRINT1("(attach) SetConsoleScreenBufferSize(2) %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
/* Update the saved console information */ /* Update the saved console information */
GetConsoleScreenBufferInfo(TextConsoleBuffer, &ConsoleInfo); GetConsoleScreenBufferInfo(TextConsoleBuffer, &ConsoleInfo);
@ -544,14 +548,11 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
* Copy console data into VGA memory * Copy console data into VGA memory
*/ */
/* Get the data */ /* Read the data from the console into the framebuffer... */
AddressSize = VgaGetAddressSize();
ConRect.Left = ConRect.Top = 0; ConRect.Left = ConRect.Top = 0;
ConRect.Right = TextResolution.X; ConRect.Right = TextResolution.X;
ConRect.Bottom = TextResolution.Y; ConRect.Bottom = TextResolution.Y;
ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
/* Read the data from the console into the framebuffer... */
ReadConsoleOutputA(TextConsoleBuffer, ReadConsoleOutputA(TextConsoleBuffer,
CharBuff, CharBuff,
TextResolution, TextResolution,
@ -559,6 +560,8 @@ static BOOL VgaAttachToConsoleInternal(PCOORD Resolution)
&ConRect); &ConRect);
/* ... and copy the framebuffer into the VGA memory */ /* ... and copy the framebuffer into the VGA memory */
AddressSize = VgaGetAddressSize();
ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
/* Loop through the scanlines */ /* Loop through the scanlines */
for (i = 0; i < TextResolution.Y; i++) for (i = 0; i < TextResolution.Y; i++)
@ -1058,6 +1061,7 @@ static VOID VgaLeaveGraphicsMode(VOID)
static BOOL VgaEnterTextMode(PCOORD Resolution) static BOOL VgaEnterTextMode(PCOORD Resolution)
{ {
/* Switch to the text buffer */ /* Switch to the text buffer */
// FIXME: Wouldn't it be preferrable to switch to it AFTER we reset everything??
VgaSetActiveScreenBuffer(TextConsoleBuffer); VgaSetActiveScreenBuffer(TextConsoleBuffer);
/* Adjust the text framebuffer if we changed the resolution */ /* Adjust the text framebuffer if we changed the resolution */
@ -1067,8 +1071,8 @@ static BOOL VgaEnterTextMode(PCOORD Resolution)
VgaDetachFromConsoleInternal(); VgaDetachFromConsoleInternal();
/* /*
* VgaAttachToConsoleInternal sets TextResolution to the * VgaAttachToConsoleInternal sets TextResolution
* new resolution and updates ConsoleInfo. * to the new resolution and updates ConsoleInfo.
*/ */
if (!VgaAttachToConsoleInternal(Resolution)) if (!VgaAttachToConsoleInternal(Resolution))
{ {
@ -1127,6 +1131,9 @@ static VOID VgaChangeMode(VOID)
goto Quit; goto Quit;
} }
// FIXME: Wouldn't it be preferrable to switch to the new console SB
// *ONLY* if we succeeded in setting the new mode??
/* Leave the current video mode */ /* Leave the current video mode */
if (ScreenMode == GRAPHICS_MODE) if (ScreenMode == GRAPHICS_MODE)
VgaLeaveGraphicsMode(); VgaLeaveGraphicsMode();
@ -1495,7 +1502,7 @@ static VOID VgaUpdateTextCursor(VOID)
{ {
/* Hidden cursor */ /* Hidden cursor */
CursorInfo.bVisible = FALSE; CursorInfo.bVisible = FALSE;
CursorInfo.dwSize = 1; // The size needs to be non-null in order SetConsoleCursorInfo to succeed. CursorInfo.dwSize = 1; // The size needs to be non-zero for SetConsoleCursorInfo to succeed.
} }
/* Add the cursor skew to the location */ /* Add the cursor skew to the location */
@ -2315,8 +2322,8 @@ BOOL VgaAttachToConsole(VOID)
// VgaDetachFromConsoleInternal(); // VgaDetachFromConsoleInternal();
/* /*
* VgaAttachToConsoleInternal sets TextResolution to the * VgaAttachToConsoleInternal sets TextResolution
* new resolution and updates ConsoleInfo. * to the new resolution and updates ConsoleInfo.
*/ */
if (!VgaAttachToConsoleInternal(&TextResolution)) if (!VgaAttachToConsoleInternal(&TextResolution))
{ {
@ -2347,6 +2354,8 @@ BOOL VgaAttachToConsole(VOID)
VOID VgaDetachFromConsole(VOID) VOID VgaDetachFromConsole(VOID)
{ {
BOOL Success;
SMALL_RECT ConRect; SMALL_RECT ConRect;
VgaDetachFromConsoleInternal(); VgaDetachFromConsoleInternal();
@ -2361,23 +2370,33 @@ VOID VgaDetachFromConsole(VOID)
OldConsoleFramebuffer = ConsoleFramebuffer; OldConsoleFramebuffer = ConsoleFramebuffer;
ConsoleFramebuffer = NULL; ConsoleFramebuffer = NULL;
/* Restore the old text-mode screen buffer */
VgaSetActiveScreenBuffer(TextConsoleBuffer);
/* Restore the original console size */ /* Restore the original console size */
ConRect.Left = 0; ConRect.Left = ConRect.Top = 0;
ConRect.Top = 0;
ConRect.Right = ConRect.Left + OrgConsoleBufferInfo.srWindow.Right - OrgConsoleBufferInfo.srWindow.Left; ConRect.Right = ConRect.Left + OrgConsoleBufferInfo.srWindow.Right - OrgConsoleBufferInfo.srWindow.Left;
ConRect.Bottom = ConRect.Top + OrgConsoleBufferInfo.srWindow.Bottom - OrgConsoleBufferInfo.srWindow.Top ; ConRect.Bottom = ConRect.Top + OrgConsoleBufferInfo.srWindow.Bottom - OrgConsoleBufferInfo.srWindow.Top ;
/* /* See the following trick explanation in VgaAttachToConsoleInternal */
* See the following trick explanation in VgaAttachToConsoleInternal. Success = SetConsoleScreenBufferSize(TextConsoleBuffer, OrgConsoleBufferInfo.dwSize);
*/ DPRINT1("(detach) SetConsoleScreenBufferSize(1) %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
SetConsoleScreenBufferSize(TextConsoleBuffer, OrgConsoleBufferInfo.dwSize); Success = SetConsoleWindowInfo(TextConsoleBuffer, TRUE, &ConRect);
SetConsoleWindowInfo(TextConsoleBuffer, TRUE, &ConRect); DPRINT1("(detach) SetConsoleWindowInfo %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
SetConsoleScreenBufferSize(TextConsoleBuffer, OrgConsoleBufferInfo.dwSize); Success = SetConsoleScreenBufferSize(TextConsoleBuffer, OrgConsoleBufferInfo.dwSize);
DPRINT1("(detach) SetConsoleScreenBufferSize(2) %s with error %d\n", Success ? "succeeded" : "failed", GetLastError());
/* Restore the original cursor shape */ /* Restore the original cursor shape */
SetConsoleCursorInfo(TextConsoleBuffer, &OrgConsoleCursorInfo); SetConsoleCursorInfo(TextConsoleBuffer, &OrgConsoleCursorInfo);
// FIXME: Should we copy back the screen data to the screen buffer??
// WriteConsoleOutputA(...);
// FIXME: Should we change cursor POSITION??
// VgaUpdateTextCursor();
///* Update the physical cursor */
//SetConsoleCursorInfo(TextConsoleBuffer, &CursorInfo);
//SetConsoleCursorPosition(TextConsoleBuffer, Position /*OrgConsoleBufferInfo.dwCursorPosition*/);
/* Restore the old text-mode screen buffer */
VgaSetActiveScreenBuffer(TextConsoleBuffer);
} }
BOOLEAN VgaInitialize(HANDLE TextHandle) BOOLEAN VgaInitialize(HANDLE TextHandle)
@ -2395,10 +2414,10 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
ConsoleInfo = OrgConsoleBufferInfo; ConsoleInfo = OrgConsoleBufferInfo;
/* Clear the SEQ, GC, CRTC and AC registers */ /* Clear the SEQ, GC, CRTC and AC registers */
RtlZeroMemory(VgaSeqRegisters, sizeof(VgaSeqRegisters)); RtlZeroMemory(VgaSeqRegisters , sizeof(VgaSeqRegisters ));
RtlZeroMemory(VgaGcRegisters, sizeof(VgaGcRegisters)); RtlZeroMemory(VgaGcRegisters , sizeof(VgaGcRegisters ));
RtlZeroMemory(VgaCrtcRegisters, sizeof(VgaCrtcRegisters)); RtlZeroMemory(VgaCrtcRegisters, sizeof(VgaCrtcRegisters));
RtlZeroMemory(VgaAcRegisters, sizeof(VgaAcRegisters)); RtlZeroMemory(VgaAcRegisters , sizeof(VgaAcRegisters ));
/* Initialize the VGA palette and fail if it isn't successfully created */ /* Initialize the VGA palette and fail if it isn't successfully created */
if (!VgaInitializePalette()) return FALSE; if (!VgaInitializePalette()) return FALSE;