From 39faa961a570d2656cb8cc3fb0c92b8ef7f9c5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 1 Oct 2014 00:40:36 +0000 Subject: [PATCH] [NTVDM] The highest bit of the mode number is used to determine whether or not we need to clear the screen. Fix the existing code that was disabled in revision 61907 because it was completely wrong. Now we correctly support this feature. Also check the mode number limit and fail if it is unsupported. svn path=/trunk/; revision=64431 --- reactos/subsystems/ntvdm/bios/vidbios.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/reactos/subsystems/ntvdm/bios/vidbios.c b/reactos/subsystems/ntvdm/bios/vidbios.c index b7ccc17e21b..2b894d6c739 100644 --- a/reactos/subsystems/ntvdm/bios/vidbios.c +++ b/reactos/subsystems/ntvdm/bios/vidbios.c @@ -1003,11 +1003,23 @@ BYTE VidBiosGetVideoMode(VOID) static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber) { BYTE Page; - COORD Resolution; - PVGA_REGISTERS VgaMode = VideoModes[ModeNumber]; + BOOLEAN DoNotClear = !!(ModeNumber & 0x80); + PVGA_REGISTERS VgaMode; - DPRINT1("Switching to mode %Xh; VgaMode = 0x%p\n", ModeNumber, VgaMode); + /* Retrieve the real mode number and check its validity */ + ModeNumber &= 0x7F; + // if (ModeNumber >= sizeof(VideoModes)/sizeof(VideoModes[0])) + if (ModeNumber > BIOS_MAX_VIDEO_MODE) + { + DPRINT1("VidBiosSetVideoMode -- Mode %02Xh invalid\n", ModeNumber); + return FALSE; + } + + VgaMode = VideoModes[ModeNumber]; + + DPRINT1("Switching to mode %02Xh %s clearing the screen; VgaMode = 0x%p\n", + ModeNumber, (DoNotClear ? "without" : "and"), VgaMode); if (!VgaSetRegisters(VgaMode)) return FALSE; @@ -1019,8 +1031,7 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber) * See Ralf Brown: http://www.ctyme.com/intr/rb-0069.htm * for more information. */ - // if ((ModeNumber & 0x08) == 0) VgaClearMemory(); - VgaClearMemory(); + if (!DoNotClear) VgaClearMemory(); // Bda->CrtModeControl; // Bda->CrtColorPaletteMask;