diff --git a/subsystems/ntvdm/bios.c b/subsystems/ntvdm/bios.c index 51784a0a575..eb61cc0cc40 100644 --- a/subsystems/ntvdm/bios.c +++ b/subsystems/ntvdm/bios.c @@ -17,6 +17,8 @@ #include "ps2.h" #include "timer.h" +#include "registers.h" + /* PRIVATE VARIABLES **********************************************************/ PBIOS_DATA_AREA Bda; @@ -982,15 +984,20 @@ VOID BiosKeyboardService(LPWORD Stack) switch (HIBYTE(Eax)) { + /* Wait for keystroke and read */ case 0x00: + /* Wait for extended keystroke and read */ + case 0x10: // FIXME: Temporarily do the same as INT 16h, 00h { /* Read the character (and wait if necessary) */ EmulatorSetRegister(EMULATOR_REG_AX, BiosGetCharacter()); - break; } + /* Get keystroke status */ case 0x01: + /* Get extended keystroke status */ + case 0x11: // FIXME: Temporarily do the same as INT 16h, 01h { WORD Data = BiosPeekCharacter(); @@ -1008,7 +1015,45 @@ VOID BiosKeyboardService(LPWORD Stack) break; } - + + /* Get shift status */ + case 0x02: + { + /* Return the lower byte of the keyboard shift status word */ + setAL(LOBYTE(Bda->KeybdShiftFlags)); + break; + } + + /* Reserved */ + case 0x04: + { + DPRINT1("BIOS Function INT 16h, AH = 0x04 is RESERVED\n"); + break; + } + + /* Push keystroke */ + case 0x05: + { + /* Return 0 if success, 1 if failure */ + setAL(BiosKbdBufferPush(getCX()) == FALSE); + break; + } + + /* Get extended shift status */ + case 0x12: + { + /* + * Be careful! The returned word is similar to Bda->KeybdShiftFlags + * but the high byte is organized differently: + * the bytes 2 and 3 of the high byte are not the same... + */ + WORD KeybdShiftFlags = (Bda->KeybdShiftFlags & 0xF3FF); + + /* Return the extended keyboard shift status word */ + setAX(KeybdShiftFlags); + break; + } + default: { DPRINT1("BIOS Function INT 16h, AH = 0x%02X NOT IMPLEMENTED\n", @@ -1115,6 +1160,7 @@ VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack) BiosKeyboardMap[VirtualKey] |= (1 << 7); /* Find out which character this is */ + Character = 0; if (ToAscii(VirtualKey, ScanCode, BiosKeyboardMap, &Character, 0) == 0) { /* Not ASCII */ diff --git a/subsystems/ntvdm/bios.h b/subsystems/ntvdm/bios.h index 0b6320fef49..01c7d3d5e38 100644 --- a/subsystems/ntvdm/bios.h +++ b/subsystems/ntvdm/bios.h @@ -21,11 +21,13 @@ #define BIOS_PIC_MASTER_INT 0x08 #define BIOS_PIC_SLAVE_INT 0x70 #define BIOS_SEGMENT 0xF000 + #define BIOS_VIDEO_INTERRUPT 0x10 #define BIOS_EQUIPMENT_INTERRUPT 0x11 #define BIOS_KBD_INTERRUPT 0x16 #define BIOS_TIME_INTERRUPT 0x1A #define BIOS_SYS_TIMER_INTERRUPT 0x1C + #define CONSOLE_FONT_HEIGHT 8 #define BIOS_KBD_BUFFER_SIZE 16 #define BIOS_EQUIPMENT_LIST 0x2C // HACK: Disable FPU for now @@ -51,12 +53,12 @@ typedef struct { WORD SerialPorts[4]; WORD ParallelPorts[3]; - WORD EbdaSegment; + WORD EbdaSegment; // Sometimes, ParallelPort WORD EquipmentList; - BYTE Reserved0; + BYTE Reserved0; // Errors in PCjr infrared keyboard link WORD MemorySize; - WORD Reserved1; - WORD KeyboardFlags; + WORD Reserved1; // Scratch pad for manufacturing error tests + WORD KeybdShiftFlags; BYTE AlternateKeypad; WORD KeybdBufferHead; WORD KeybdBufferTail; diff --git a/subsystems/ntvdm/ntvdm.h b/subsystems/ntvdm/ntvdm.h index f34354824b8..4f4f0323669 100644 --- a/subsystems/ntvdm/ntvdm.h +++ b/subsystems/ntvdm/ntvdm.h @@ -11,12 +11,13 @@ /* INCLUDES *******************************************************************/ -#include #include -#include #include +#include + +#include + #include -#include /* DEFINES ********************************************************************/ diff --git a/subsystems/ntvdm/ps2.c b/subsystems/ntvdm/ps2.c index ed8e82acde2..034d81129f7 100644 --- a/subsystems/ntvdm/ps2.c +++ b/subsystems/ntvdm/ps2.c @@ -300,6 +300,8 @@ DWORD WINAPI InputThreadProc(LPVOID Parameter) KeyboardQueuePush(ScanCode); } + /* TODO: Update the keyboard shift status flags */ + /* Keyboard IRQ */ PicInterruptRequest(1);