mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ BYTE BiosGetVideoMode(VOID);
|
|||
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);
|
||||
|
|
|
@ -205,7 +205,7 @@ static VOID DosCopyHandleTable(LPBYTE DestinationTable)
|
|||
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 @@ VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WOR
|
|||
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 DosInt21h(LPWORD Stack)
|
|||
|
||||
VOID DosBreakInterrupt(LPWORD Stack)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Stack);
|
||||
|
||||
VdmRunning = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ typedef struct _DOS_PSP
|
|||
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
|
||||
|
|
|
@ -35,6 +35,8 @@ static BOOLEAN A20Line = FALSE;
|
|||
|
||||
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 EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT S
|
|||
|
||||
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 EmulatorWriteMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT
|
|||
|
||||
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 @@ static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size
|
|||
{
|
||||
BYTE Byte = *Buffer;
|
||||
|
||||
UNREFERENCED_PARAMETER(Context);
|
||||
UNREFERENCED_PARAMETER(Size);
|
||||
|
||||
switch (Address)
|
||||
{
|
||||
case PIT_COMMAND_PORT:
|
||||
|
@ -333,16 +343,25 @@ static VOID EmulatorBop(WORD Code)
|
|||
|
||||
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 */
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,9 @@ INT wmain(INT argc, WCHAR *argv[])
|
|||
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 @@ INT wmain(INT argc, WCHAR *argv[])
|
|||
|
||||
if ((CurrentTickCount - LastCyclePrintout) >= 1000)
|
||||
{
|
||||
DPRINT1("NTVDM: %d Instructions Per Second\n", Cycles);
|
||||
DPRINT1("NTVDM: %lu Instructions Per Second\n", Cycles);
|
||||
LastCyclePrintout = CurrentTickCount;
|
||||
Cycles = 0;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <conio.h>
|
||||
#include <stdarg.h>
|
||||
#include <debug.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* DEFINES ********************************************************************/
|
||||
|
||||
|
|
|
@ -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 @@ static inline VOID VgaMarkForUpdate(SHORT Row, SHORT Column)
|
|||
/* 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 @@ static VOID VgaWriteAc(BYTE Data)
|
|||
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 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution, UINT BitDepth)
|
|||
/* 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 @@ static BOOL VgaEnterTextMode(PCOORD Resolution)
|
|||
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 @@ static VOID VgaUpdateMode(VOID)
|
|||
|
||||
if (!TextMode)
|
||||
{
|
||||
/* Switching from graphics mode to text mode */
|
||||
/* Leave the current graphics mode */
|
||||
VgaLeaveGraphicsMode();
|
||||
}
|
||||
else
|
||||
|
@ -326,7 +325,7 @@ static VOID VgaUpdateMode(VOID)
|
|||
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 @@ static VOID VgaUpdateMode(VOID)
|
|||
|
||||
/* 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 @@ static VOID VgaUpdateFramebuffer(VOID)
|
|||
{
|
||||
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 @@ VOID VgaInitialize(HANDLE TextHandle)
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue