static PBIOS_DATA_AREA Bda;
static BYTE BiosKeyboardMap[256];
-static HANDLE BiosConsoleInput = INVALID_HANDLE_VALUE;
+static HANDLE BiosConsoleInput = INVALID_HANDLE_VALUE;
static HANDLE BiosConsoleOutput = INVALID_HANDLE_VALUE;
static CONSOLE_SCREEN_BUFFER_INFO BiosSavedBufferInfo;
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF,
/* CRTC Registers */
- 0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0E, 0x0F,
+ 0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0F,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3,
0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF,
/* CRTC Registers */
- 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0E, 0x0F,
+ 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0F,
0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
0xFF,
{
INT i, j;
INT Counter = 0;
+ WORD Character;
DWORD VideoAddress = TO_LINEAR(TEXT_VIDEO_SEG, Page * Bda->VideoPageSize);
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{
for (j = Rectangle.Left; j <= Rectangle.Right; j++)
{
- WORD Character;
-
/* Read from video memory */
VgaReadMemory(VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
(LPVOID)&Character,
{
INT i, j;
INT Counter = 0;
+ WORD Character;
DWORD VideoAddress = TO_LINEAR(TEXT_VIDEO_SEG, Page * Bda->VideoPageSize);
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{
for (j = Rectangle.Left; j <= Rectangle.Right; j++)
{
- WORD Character = Buffer[Counter++];
+ Character = Buffer[Counter++];
/* Read from video memory */
VgaWriteMemory(VideoAddress + (i * Bda->ScreenColumns + j) * sizeof(WORD),
/* Update the values in the BDA */
Bda->VideoMode = ModeNumber;
Bda->VideoPage = 0;
- Bda->VideoPageSize = BIOS_PAGE_SIZE;
+ Bda->VideoPageSize = BIOS_PAGE_SIZE;
Bda->VideoPageOffset = 0;
Bda->CharacterHeight = 16;
/* Set the start address in the CRTC */
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_LOC_LOW_REG);
- VgaWritePort(VGA_CRTC_DATA, LOBYTE(Bda->VideoPageOffset));
+ VgaWritePort(VGA_CRTC_DATA , LOBYTE(Bda->VideoPageOffset));
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_LOC_HIGH_REG);
- VgaWritePort(VGA_CRTC_DATA, HIBYTE(Bda->VideoPageOffset));
+ VgaWritePort(VGA_CRTC_DATA , HIBYTE(Bda->VideoPageOffset));
return TRUE;
}
BiosCode[Offset++] = 0xCF; // iret
}
- /* Get the input and output handles to the real console */
- BiosConsoleInput = CreateFile(TEXT("CONIN$"),
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- 0,
- NULL);
-
- BiosConsoleOutput = CreateFile(TEXT("CONOUT$"),
+ /* Get the input handle to the real console, and check for success */
+ BiosConsoleInput = CreateFileW(L"CONIN$",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
+ if (BiosConsoleInput == INVALID_HANDLE_VALUE)
+ {
+ return FALSE;
+ }
- /* Make sure it was successful */
- if ((BiosConsoleInput == INVALID_HANDLE_VALUE)
- || (BiosConsoleOutput == INVALID_HANDLE_VALUE))
+ /* Get the output handle to the real console, and check for success */
+ BiosConsoleOutput = CreateFileW(L"CONOUT$",
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL);
+ if (BiosConsoleOutput == INVALID_HANDLE_VALUE)
{
+ CloseHandle(BiosConsoleInput);
return FALSE;
}
/* Save the console screen buffer information */
if (!GetConsoleScreenBufferInfo(BiosConsoleOutput, &BiosSavedBufferInfo))
{
+ CloseHandle(BiosConsoleOutput);
+ CloseHandle(BiosConsoleInput);
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.X,
+ BiosSavedBufferInfo.dwCursorPosition.Y,
+ 0);
+
/* Set the console input mode */
SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);
/* Initialize the PIC */
PicWriteCommand(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4);
- PicWriteCommand(PIC_SLAVE_CMD, PIC_ICW1 | PIC_ICW1_ICW4);
+ PicWriteCommand(PIC_SLAVE_CMD , PIC_ICW1 | PIC_ICW1_ICW4);
/* Set the interrupt offsets */
PicWriteData(PIC_MASTER_DATA, BIOS_PIC_MASTER_INT);
- PicWriteData(PIC_SLAVE_DATA, BIOS_PIC_SLAVE_INT);
+ PicWriteData(PIC_SLAVE_DATA , BIOS_PIC_SLAVE_INT);
/* Tell the master PIC there is a slave at IRQ 2 */
PicWriteData(PIC_MASTER_DATA, 1 << 2);
- PicWriteData(PIC_SLAVE_DATA, 2);
+ PicWriteData(PIC_SLAVE_DATA , 2);
/* Make sure the PIC is in 8086 mode */
PicWriteData(PIC_MASTER_DATA, PIC_ICW4_8086);
- PicWriteData(PIC_SLAVE_DATA, PIC_ICW4_8086);
+ PicWriteData(PIC_SLAVE_DATA , PIC_ICW4_8086);
/* Clear the masks for both PICs */
PicWriteData(PIC_MASTER_DATA, 0x00);
- PicWriteData(PIC_SLAVE_DATA, 0x00);
+ PicWriteData(PIC_SLAVE_DATA , 0x00);
PitWriteCommand(0x34);
PitWriteData(0, 0x00);
SetConsoleScreenBufferSize(BiosConsoleOutput, BiosSavedBufferInfo.dwSize);
/* Close the console handles */
- if (BiosConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleInput);
if (BiosConsoleOutput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleOutput);
+ if (BiosConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(BiosConsoleInput);
}
WORD BiosPeekCharacter(VOID)
/* Modify the CRTC registers */
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_LOC_LOW_REG);
- VgaWritePort(VGA_CRTC_DATA, LOBYTE(Offset));
+ VgaWritePort(VGA_CRTC_DATA , LOBYTE(Offset));
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_LOC_HIGH_REG);
- VgaWritePort(VGA_CRTC_DATA, HIBYTE(Offset));
+ VgaWritePort(VGA_CRTC_DATA , HIBYTE(Offset));
}
}
BYTE Page,
BYTE FillAttribute)
{
- INT i;
+ DWORD i;
LPWORD WindowData;
DWORD WindowSize = (Rectangle.Bottom - Rectangle.Top + 1)
* (Rectangle.Right - Rectangle.Left + 1);
DWORD Edx = EmulatorGetRegister(EMULATOR_REG_DX);
DWORD Ebx = EmulatorGetRegister(EMULATOR_REG_BX);
- UNREFERENCED_PARAMETER(Ecx);
-
switch (HIBYTE(Eax))
{
/* Set Video Mode */
/* Modify the CRTC registers */
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_START_REG);
- VgaWritePort(VGA_CRTC_DATA, Bda->CursorStartLine);
+ VgaWritePort(VGA_CRTC_DATA , Bda->CursorStartLine);
VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_CURSOR_END_REG);
- VgaWritePort(VGA_CRTC_DATA, Bda->CursorEndLine);
+ VgaWritePort(VGA_CRTC_DATA , Bda->CursorEndLine);
break;
}