Fix coding style.
Fix initial cursor position bug.
Fix memory limit constant for VGA memory modes 0 and 1 (64 KB not 32 KB).


svn path=/branches/ntvdm/; revision=59669
This commit is contained in:
Aleksandar Andrejevic 2013-08-07 19:56:28 +00:00
parent 58c1653592
commit b4ed87bb3a
8 changed files with 57 additions and 29 deletions

View file

@ -404,12 +404,14 @@ BOOLEAN BiosInitialize(VOID)
return FALSE; return FALSE;
} }
/* Store the cursor position */ /* Initialize VGA */
Bda->CursorPosition[0] = MAKEWORD(BiosSavedBufferInfo.dwCursorPosition.X,
BiosSavedBufferInfo.dwCursorPosition.Y);
VgaInitialize(BiosConsoleOutput); VgaInitialize(BiosConsoleOutput);
/* Update the cursor position */
BiosSetCursorPosition(BiosSavedBufferInfo.dwCursorPosition.Y,
BiosSavedBufferInfo.dwCursorPosition.Y,
0);
/* Set the console input mode */ /* Set the console input mode */
SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT); SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);

View file

@ -105,6 +105,7 @@ BYTE BiosGetVideoMode(VOID);
BOOLEAN BiosSetVideoMode(BYTE ModeNumber); BOOLEAN BiosSetVideoMode(BYTE ModeNumber);
WORD BiosPeekCharacter(VOID); WORD BiosPeekCharacter(VOID);
WORD BiosGetCharacter(VOID); WORD BiosGetCharacter(VOID);
VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page);
VOID BiosVideoService(LPWORD Stack); VOID BiosVideoService(LPWORD Stack);
VOID BiosEquipmentService(LPWORD Stack); VOID BiosEquipmentService(LPWORD Stack);
VOID BiosKeyboardService(LPWORD Stack); VOID BiosKeyboardService(LPWORD Stack);

View file

@ -205,7 +205,7 @@ static VOID DosCopyHandleTable(LPBYTE DestinationTable)
for (i = 0; i <= 2; i++) for (i = 0; i <= 2; i++)
{ {
/* Set the index in the SFT */ /* Set the index in the SFT */
DestinationTable[i] = i; DestinationTable[i] = (BYTE)i;
/* Increase the reference count */ /* Increase the reference count */
DosSftRefCount[i]++; DosSftRefCount[i]++;
@ -864,7 +864,7 @@ VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WOR
PspBlock->FarCall[2] = 0xCB; // retf PspBlock->FarCall[2] = 0xCB; // retf
/* Set the command line */ /* Set the command line */
PspBlock->CommandLineSize = strlen(CommandLine); PspBlock->CommandLineSize = (BYTE)min(strlen(CommandLine), DOS_CMDLINE_LENGTH);
RtlCopyMemory(PspBlock->CommandLine, CommandLine, PspBlock->CommandLineSize); RtlCopyMemory(PspBlock->CommandLine, CommandLine, PspBlock->CommandLineSize);
PspBlock->CommandLine[PspBlock->CommandLineSize] = '\r'; PspBlock->CommandLine[PspBlock->CommandLineSize] = '\r';
} }
@ -1936,6 +1936,8 @@ VOID DosInt21h(LPWORD Stack)
VOID DosBreakInterrupt(LPWORD Stack) VOID DosBreakInterrupt(LPWORD Stack)
{ {
UNREFERENCED_PARAMETER(Stack);
VdmRunning = FALSE; VdmRunning = FALSE;
} }

View file

@ -33,6 +33,7 @@
#define UMB_END_SEGMENT 0xDFFF #define UMB_END_SEGMENT 0xDFFF
#define DOS_ALLOC_HIGH 0x40 #define DOS_ALLOC_HIGH 0x40
#define DOS_ALLOC_HIGH_LOW 0x80 #define DOS_ALLOC_HIGH_LOW 0x80
#define DOS_CMDLINE_LENGTH 127
enum DOS_ALLOC_STRATEGY enum DOS_ALLOC_STRATEGY
{ {
@ -89,7 +90,7 @@ typedef struct _DOS_PSP
BYTE Reserved3[9]; BYTE Reserved3[9];
DOS_FCB Fcb; DOS_FCB Fcb;
BYTE CommandLineSize; BYTE CommandLineSize;
CHAR CommandLine[127]; CHAR CommandLine[DOS_CMDLINE_LENGTH];
} DOS_PSP, *PDOS_PSP; } DOS_PSP, *PDOS_PSP;
typedef struct _DOS_INPUT_BUFFER typedef struct _DOS_INPUT_BUFFER

View file

@ -35,6 +35,8 @@ static BOOLEAN A20Line = FALSE;
static VOID EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size) static VOID EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{ {
UNREFERENCED_PARAMETER(Context);
/* If the A20 line is disabled, mask bit 20 */ /* If the A20 line is disabled, mask bit 20 */
if (!A20Line) Address &= ~(1 << 20); if (!A20Line) Address &= ~(1 << 20);
@ -58,6 +60,8 @@ static VOID EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT S
static VOID EmulatorWriteMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size) static VOID EmulatorWriteMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{ {
UNREFERENCED_PARAMETER(Context);
/* If the A20 line is disabled, mask bit 20 */ /* If the A20 line is disabled, mask bit 20 */
if (!A20Line) Address &= ~(1 << 20); if (!A20Line) Address &= ~(1 << 20);
@ -84,6 +88,9 @@ static VOID EmulatorWriteMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT
static VOID EmulatorReadIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size) static VOID EmulatorReadIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{ {
UNREFERENCED_PARAMETER(Context);
UNREFERENCED_PARAMETER(Size);
switch (Address) switch (Address)
{ {
case PIC_MASTER_CMD: case PIC_MASTER_CMD:
@ -151,6 +158,9 @@ static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size
{ {
BYTE Byte = *Buffer; BYTE Byte = *Buffer;
UNREFERENCED_PARAMETER(Context);
UNREFERENCED_PARAMETER(Size);
switch (Address) switch (Address)
{ {
case PIT_COMMAND_PORT: case PIT_COMMAND_PORT:
@ -333,16 +343,25 @@ static VOID EmulatorBop(WORD Code)
static VOID EmulatorSoftwareInt(PVOID Context, BYTE Number) static VOID EmulatorSoftwareInt(PVOID Context, BYTE Number)
{ {
UNREFERENCED_PARAMETER(Context);
UNREFERENCED_PARAMETER(Number);
/* Do nothing */ /* Do nothing */
} }
static VOID EmulatorHardwareInt(PVOID Context, BYTE Number) static VOID EmulatorHardwareInt(PVOID Context, BYTE Number)
{ {
UNREFERENCED_PARAMETER(Context);
UNREFERENCED_PARAMETER(Number);
/* Do nothing */ /* Do nothing */
} }
static VOID EmulatorHardwareIntAck(PVOID Context, BYTE Number) static VOID EmulatorHardwareIntAck(PVOID Context, BYTE Number)
{ {
UNREFERENCED_PARAMETER(Context);
UNREFERENCED_PARAMETER(Number);
/* Do nothing */ /* Do nothing */
} }

View file

@ -90,6 +90,9 @@ INT wmain(INT argc, WCHAR *argv[])
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
#ifndef TESTING #ifndef TESTING
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
/* The DOS command line must be ASCII */ /* The DOS command line must be ASCII */
WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL);
#else #else
@ -185,7 +188,7 @@ INT wmain(INT argc, WCHAR *argv[])
if ((CurrentTickCount - LastCyclePrintout) >= 1000) if ((CurrentTickCount - LastCyclePrintout) >= 1000)
{ {
DPRINT1("NTVDM: %d Instructions Per Second\n", Cycles); DPRINT1("NTVDM: %lu Instructions Per Second\n", Cycles);
LastCyclePrintout = CurrentTickCount; LastCyclePrintout = CurrentTickCount;
Cycles = 0; Cycles = 0;
} }

View file

@ -16,6 +16,7 @@
#include <conio.h> #include <conio.h>
#include <stdarg.h> #include <stdarg.h>
#include <debug.h> #include <debug.h>
#include <limits.h>
/* DEFINES ********************************************************************/ /* DEFINES ********************************************************************/

View file

@ -16,7 +16,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[] = { 0xA7FFF, 0xA7FFF, 0xB7FFF, 0xBFFFF }; static CONST DWORD MemoryLimit[] = { 0xAFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
static BYTE VgaMemory[VGA_NUM_BANKS * VGA_BANK_SIZE]; static BYTE VgaMemory[VGA_NUM_BANKS * VGA_BANK_SIZE];
static BYTE VgaMiscRegister; static BYTE VgaMiscRegister;
@ -124,8 +124,8 @@ static inline VOID VgaMarkForUpdate(SHORT Row, SHORT Column)
/* Check if this is the first time the rectangle is updated */ /* Check if this is the first time the rectangle is updated */
if (!NeedsUpdate) if (!NeedsUpdate)
{ {
UpdateRectangle.Left = UpdateRectangle.Top = (SHORT)0x7FFF; UpdateRectangle.Left = UpdateRectangle.Top = SHRT_MAX;
UpdateRectangle.Right = UpdateRectangle.Bottom = (SHORT)0x8000; UpdateRectangle.Right = UpdateRectangle.Bottom = SHRT_MIN;
} }
/* Expand the rectangle to include the point */ /* Expand the rectangle to include the point */
@ -216,7 +216,7 @@ static VOID VgaWriteAc(BYTE Data)
VgaAcRegisters[VgaAcIndex] = Data; VgaAcRegisters[VgaAcIndex] = Data;
} }
static BOOL VgaEnterGraphicsMode(PCOORD Resolution, UINT BitDepth) static BOOL VgaEnterGraphicsMode(PCOORD Resolution)
{ {
DWORD i; DWORD i;
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo; CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
@ -232,11 +232,10 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution, UINT BitDepth)
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;
* (BitDepth / 8);
/* Fill the palette data */ /* 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 */ /* Fill the console graphics buffer info */
GraphicsBufferInfo.dwBitMapInfoLength = VGA_BITMAP_INFO_SIZE; GraphicsBufferInfo.dwBitMapInfoLength = VGA_BITMAP_INFO_SIZE;
@ -305,7 +304,7 @@ static VOID VgaUpdateMode(VOID)
if (!TextMode) if (!TextMode)
{ {
/* Switching from graphics mode to text mode */ /* Leave the current graphics mode */
VgaLeaveGraphicsMode(); VgaLeaveGraphicsMode();
} }
else else
@ -326,7 +325,7 @@ static VOID VgaUpdateMode(VOID)
else else
{ {
/* Enter 8-bit graphics mode */ /* Enter 8-bit graphics mode */
if (!VgaEnterGraphicsMode(&Resolution, 8)) return; if (!VgaEnterGraphicsMode(&Resolution)) return;
/* Clear the text mode flag */ /* Clear the text mode flag */
TextMode = FALSE; TextMode = FALSE;