mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:25:41 +00:00
[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). svn path=/branches/ntvdm/; revision=59669
This commit is contained in:
parent
58c1653592
commit
b4ed87bb3a
8 changed files with 57 additions and 29 deletions
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 ********************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
/* 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;
|
||||||
|
@ -227,16 +227,15 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution, UINT BitDepth)
|
||||||
/* Fill the bitmap info header */
|
/* Fill the bitmap info header */
|
||||||
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER));
|
ZeroMemory(&BitmapInfo->bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||||
BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
BitmapInfo->bmiHeader.biWidth = Resolution->X;
|
BitmapInfo->bmiHeader.biWidth = Resolution->X;
|
||||||
BitmapInfo->bmiHeader.biHeight = Resolution->Y;
|
BitmapInfo->bmiHeader.biHeight = Resolution->Y;
|
||||||
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;
|
||||||
|
@ -281,7 +280,7 @@ static BOOL VgaEnterTextMode(PCOORD Resolution)
|
||||||
ConsoleFramebuffer = HeapAlloc(GetProcessHeap(),
|
ConsoleFramebuffer = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
Resolution->X * Resolution->Y
|
Resolution->X * Resolution->Y
|
||||||
* sizeof(CHAR_INFO));
|
* sizeof(CHAR_INFO));
|
||||||
if (ConsoleFramebuffer == NULL)
|
if (ConsoleFramebuffer == NULL)
|
||||||
{
|
{
|
||||||
DisplayMessage(L"An unexpected error occurred!\n");
|
DisplayMessage(L"An unexpected error occurred!\n");
|
||||||
|
@ -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;
|
||||||
|
@ -334,9 +333,9 @@ static VOID VgaUpdateMode(VOID)
|
||||||
|
|
||||||
/* Perform a full update */
|
/* Perform a full update */
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,11 +952,11 @@ VOID VgaInitialize(HANDLE TextHandle)
|
||||||
ModeChanged = FALSE;
|
ModeChanged = FALSE;
|
||||||
|
|
||||||
/* Get the data */
|
/* Get the data */
|
||||||
Resolution = VgaGetDisplayResolution();
|
Resolution = VgaGetDisplayResolution();
|
||||||
CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
|
CharBuffer = (PCHAR_INFO)ConsoleFramebuffer;
|
||||||
AddressSize = VgaGetAddressSize();
|
AddressSize = VgaGetAddressSize();
|
||||||
ScreenRect.Left = ScreenRect.Top = 0;
|
ScreenRect.Left = ScreenRect.Top = 0;
|
||||||
ScreenRect.Right = Resolution.X;
|
ScreenRect.Right = Resolution.X;
|
||||||
ScreenRect.Bottom = Resolution.Y;
|
ScreenRect.Bottom = Resolution.Y;
|
||||||
ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
|
ScanlineSize = (DWORD)VgaCrtcRegisters[VGA_CRTC_OFFSET_REG] * 2;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue