Author: aandrejevic
Date: Wed Aug 7 19:56:28 2013
New Revision: 59669
URL:
http://svn.reactos.org/svn/reactos?rev=59669&view=rev
Log:
[NTVDM]
Fix coding style.
Fix initial cursor position bug.
Fix memory limit constant for VGA memory modes 0 and 1 (64 KB not 32 KB).
Modified:
branches/ntvdm/subsystems/ntvdm/bios.c
branches/ntvdm/subsystems/ntvdm/bios.h
branches/ntvdm/subsystems/ntvdm/dos.c
branches/ntvdm/subsystems/ntvdm/dos.h
branches/ntvdm/subsystems/ntvdm/emulator.c
branches/ntvdm/subsystems/ntvdm/ntvdm.c
branches/ntvdm/subsystems/ntvdm/ntvdm.h
branches/ntvdm/subsystems/ntvdm/vga.c
Modified: branches/ntvdm/subsystems/ntvdm/bios.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -404,11 +404,13 @@
return FALSE;
}
- /* Store the cursor position */
- Bda->CursorPosition[0] = MAKEWORD(BiosSavedBufferInfo.dwCursorPosition.X,
- BiosSavedBufferInfo.dwCursorPosition.Y);
-
+ /* Initialize VGA */
VgaInitialize(BiosConsoleOutput);
+
+ /* Update the cursor position */
+ BiosSetCursorPosition(BiosSavedBufferInfo.dwCursorPosition.Y,
+ BiosSavedBufferInfo.dwCursorPosition.Y,
+ 0);
/* Set the console input mode */
SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);
Modified: branches/ntvdm/subsystems/ntvdm/bios.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -105,6 +105,7 @@
BOOLEAN BiosSetVideoMode(BYTE ModeNumber);
WORD BiosPeekCharacter(VOID);
WORD BiosGetCharacter(VOID);
+VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page);
VOID BiosVideoService(LPWORD Stack);
VOID BiosEquipmentService(LPWORD Stack);
VOID BiosKeyboardService(LPWORD Stack);
Modified: branches/ntvdm/subsystems/ntvdm/dos.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.c?re…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/dos.c [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -205,7 +205,7 @@
for (i = 0; i <= 2; i++)
{
/* Set the index in the SFT */
- DestinationTable[i] = i;
+ DestinationTable[i] = (BYTE)i;
/* Increase the reference count */
DosSftRefCount[i]++;
@@ -864,7 +864,7 @@
PspBlock->FarCall[2] = 0xCB; // retf
/* Set the command line */
- PspBlock->CommandLineSize = strlen(CommandLine);
+ PspBlock->CommandLineSize = (BYTE)min(strlen(CommandLine), DOS_CMDLINE_LENGTH);
RtlCopyMemory(PspBlock->CommandLine, CommandLine, PspBlock->CommandLineSize);
PspBlock->CommandLine[PspBlock->CommandLineSize] = '\r';
}
@@ -1936,6 +1936,8 @@
VOID DosBreakInterrupt(LPWORD Stack)
{
+ UNREFERENCED_PARAMETER(Stack);
+
VdmRunning = FALSE;
}
Modified: branches/ntvdm/subsystems/ntvdm/dos.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/dos.h?re…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/dos.h [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -33,6 +33,7 @@
#define UMB_END_SEGMENT 0xDFFF
#define DOS_ALLOC_HIGH 0x40
#define DOS_ALLOC_HIGH_LOW 0x80
+#define DOS_CMDLINE_LENGTH 127
enum DOS_ALLOC_STRATEGY
{
@@ -89,7 +90,7 @@
BYTE Reserved3[9];
DOS_FCB Fcb;
BYTE CommandLineSize;
- CHAR CommandLine[127];
+ CHAR CommandLine[DOS_CMDLINE_LENGTH];
} DOS_PSP, *PDOS_PSP;
typedef struct _DOS_INPUT_BUFFER
Modified: branches/ntvdm/subsystems/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -35,6 +35,8 @@
static VOID EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{
+ UNREFERENCED_PARAMETER(Context);
+
/* If the A20 line is disabled, mask bit 20 */
if (!A20Line) Address &= ~(1 << 20);
@@ -58,6 +60,8 @@
static VOID EmulatorWriteMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{
+ UNREFERENCED_PARAMETER(Context);
+
/* If the A20 line is disabled, mask bit 20 */
if (!A20Line) Address &= ~(1 << 20);
@@ -84,6 +88,9 @@
static VOID EmulatorReadIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{
+ UNREFERENCED_PARAMETER(Context);
+ UNREFERENCED_PARAMETER(Size);
+
switch (Address)
{
case PIC_MASTER_CMD:
@@ -151,6 +158,9 @@
{
BYTE Byte = *Buffer;
+ UNREFERENCED_PARAMETER(Context);
+ UNREFERENCED_PARAMETER(Size);
+
switch (Address)
{
case PIT_COMMAND_PORT:
@@ -333,16 +343,25 @@
static VOID EmulatorSoftwareInt(PVOID Context, BYTE Number)
{
+ UNREFERENCED_PARAMETER(Context);
+ UNREFERENCED_PARAMETER(Number);
+
/* Do nothing */
}
static VOID EmulatorHardwareInt(PVOID Context, BYTE Number)
{
+ UNREFERENCED_PARAMETER(Context);
+ UNREFERENCED_PARAMETER(Number);
+
/* Do nothing */
}
static VOID EmulatorHardwareIntAck(PVOID Context, BYTE Number)
{
+ UNREFERENCED_PARAMETER(Context);
+ UNREFERENCED_PARAMETER(Number);
+
/* Do nothing */
}
Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.c?…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/ntvdm.c [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -90,6 +90,9 @@
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
#ifndef TESTING
+ UNREFERENCED_PARAMETER(argc);
+ UNREFERENCED_PARAMETER(argv);
+
/* The DOS command line must be ASCII */
WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL);
#else
@@ -185,7 +188,7 @@
if ((CurrentTickCount - LastCyclePrintout) >= 1000)
{
- DPRINT1("NTVDM: %d Instructions Per Second\n", Cycles);
+ DPRINT1("NTVDM: %lu Instructions Per Second\n", Cycles);
LastCyclePrintout = CurrentTickCount;
Cycles = 0;
}
Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.h?…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/ntvdm.h [iso-8859-1] Wed Aug 7 19:56:28 2013
@@ -16,6 +16,7 @@
#include <conio.h>
#include <stdarg.h>
#include <debug.h>
+#include <limits.h>
/* DEFINES ********************************************************************/
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] Wed Aug 7 19:56:28 2013
@@ -15,8 +15,8 @@
/* PRIVATE VARIABLES **********************************************************/
-static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
-static CONST DWORD MemoryLimit[] = { 0xA7FFF, 0xA7FFF, 0xB7FFF, 0xBFFFF };
+static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
+static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
static BYTE VgaMemory[VGA_NUM_BANKS * VGA_BANK_SIZE];
static BYTE VgaMiscRegister;
@@ -124,8 +124,8 @@
/* Check if this is the first time the rectangle is updated */
if (!NeedsUpdate)
{
- UpdateRectangle.Left = UpdateRectangle.Top = (SHORT)0x7FFF;
- UpdateRectangle.Right = UpdateRectangle.Bottom = (SHORT)0x8000;
+ UpdateRectangle.Left = UpdateRectangle.Top = SHRT_MAX;
+ UpdateRectangle.Right = UpdateRectangle.Bottom = SHRT_MIN;
}
/* Expand the rectangle to include the point */
@@ -216,7 +216,7 @@
VgaAcRegisters[VgaAcIndex] = Data;
}
-static BOOL VgaEnterGraphicsMode(PCOORD Resolution, UINT BitDepth)
+static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
{
DWORD i;
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
@@ -227,16 +227,15 @@
/* Fill the bitmap info header */
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER));
BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- BitmapInfo->bmiHeader.biWidth = Resolution->X;
+ BitmapInfo->bmiHeader.biWidth = Resolution->X;
BitmapInfo->bmiHeader.biHeight = Resolution->Y;
BitmapInfo->bmiHeader.biBitCount = 8;
- BitmapInfo->bmiHeader.biPlanes = 1;
+ BitmapInfo->bmiHeader.biPlanes = 1;
BitmapInfo->bmiHeader.biCompression = BI_RGB;
- BitmapInfo->bmiHeader.biSizeImage = Resolution->X * Resolution->Y
- * (BitDepth / 8);
+ BitmapInfo->bmiHeader.biSizeImage = Resolution->X * Resolution->Y;
/* Fill the palette data */
- for (i = 0; i < BitDepth; i++) PaletteIndex[i] = (WORD)i;
+ for (i = 0; i < (VGA_PALETTE_SIZE / 3); i++) PaletteIndex[i] = (WORD)i;
/* Fill the console graphics buffer info */
GraphicsBufferInfo.dwBitMapInfoLength = VGA_BITMAP_INFO_SIZE;
@@ -281,7 +280,7 @@
ConsoleFramebuffer = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
Resolution->X * Resolution->Y
- * sizeof(CHAR_INFO));
+ * sizeof(CHAR_INFO));
if (ConsoleFramebuffer == NULL)
{
DisplayMessage(L"An unexpected error occurred!\n");
@@ -305,7 +304,7 @@
if (!TextMode)
{
- /* Switching from graphics mode to text mode */
+ /* Leave the current graphics mode */
VgaLeaveGraphicsMode();
}
else
@@ -326,7 +325,7 @@
else
{
/* Enter 8-bit graphics mode */
- if (!VgaEnterGraphicsMode(&Resolution, 8)) return;
+ if (!VgaEnterGraphicsMode(&Resolution)) return;
/* Clear the text mode flag */
TextMode = FALSE;
@@ -334,9 +333,9 @@
/* Perform a full update */
NeedsUpdate = TRUE;
- UpdateRectangle.Left = 0;
- UpdateRectangle.Top = 0;
- UpdateRectangle.Right = Resolution.X;
+ UpdateRectangle.Left = 0;
+ UpdateRectangle.Top = 0;
+ UpdateRectangle.Right = Resolution.X;
UpdateRectangle.Bottom = Resolution.Y;
}
@@ -441,7 +440,7 @@
{
BYTE PlaneData = VgaMemory[k * VGA_BANK_SIZE
+ (Address + (j / 8)) *
AddressSize];
-
+
/* If the bit on that plane is set, set it */
if (PlaneData & (1 << (7 - (j % 8)))) PixelData |=
1 << k;
}
@@ -953,11 +952,11 @@
ModeChanged = FALSE;
/* Get the data */
- Resolution = VgaGetDisplayResolution();
- CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
+ Resolution = VgaGetDisplayResolution();
+ CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
AddressSize = VgaGetAddressSize();
- ScreenRect.Left = ScreenRect.Top = 0;
- ScreenRect.Right = Resolution.X;
+ ScreenRect.Left = ScreenRect.Top = 0;
+ ScreenRect.Right = Resolution.X;
ScreenRect.Bottom = Resolution.Y;
ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;