1998-10-17 13:55:07 +02:00
|
|
|
|
/*
|
|
|
|
|
* DOS interrupt 16h handler
|
2002-03-10 00:29:33 +01:00
|
|
|
|
*
|
|
|
|
|
* Copyright 1998 Joseph Pranevich
|
|
|
|
|
* Copyright 1999 Ove K<EFBFBD>ven
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-10-17 13:55:07 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
1998-10-17 13:55:07 +02:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "module.h"
|
2000-07-25 14:24:53 +02:00
|
|
|
|
#include "dosexe.h"
|
1999-02-24 14:05:13 +01:00
|
|
|
|
#include "wincon.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
|
#include "wine/debug.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
|
#include "windef.h"
|
|
|
|
|
#include "wingdi.h"
|
1999-03-25 17:41:35 +01:00
|
|
|
|
#include "winuser.h"
|
1999-05-22 13:27:40 +02:00
|
|
|
|
#include "miscemu.h"
|
1998-10-17 13:55:07 +02:00
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(int);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
|
1998-10-17 13:55:07 +02:00
|
|
|
|
/**********************************************************************
|
2001-12-04 20:54:44 +01:00
|
|
|
|
* DOSVM_Int16Handler
|
1998-10-17 13:55:07 +02:00
|
|
|
|
*
|
|
|
|
|
* Handler for int 16h (keyboard)
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
2002-06-01 01:06:46 +02:00
|
|
|
|
*
|
1998-10-17 13:55:07 +02:00
|
|
|
|
* KEYB.COM (DOS >3.2) adds functions to this interrupt, they are
|
|
|
|
|
* not currently listed here.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-12-04 20:54:44 +01:00
|
|
|
|
void WINAPI DOSVM_Int16Handler( CONTEXT86 *context )
|
1998-10-17 13:55:07 +02:00
|
|
|
|
{
|
|
|
|
|
switch AH_reg(context) {
|
|
|
|
|
|
|
|
|
|
case 0x00: /* Get Keystroke */
|
1998-12-03 17:29:56 +01:00
|
|
|
|
/* Returns: AH = Scan code
|
2001-12-04 20:54:44 +01:00
|
|
|
|
AL = ASCII character */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Get Keystroke\n");
|
2001-12-04 20:54:44 +01:00
|
|
|
|
DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), FALSE);
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x01: /* Check for Keystroke */
|
1998-12-03 17:29:56 +01:00
|
|
|
|
/* Returns: ZF set if no keystroke */
|
|
|
|
|
/* AH = Scan code */
|
|
|
|
|
/* AL = ASCII character */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Check for Keystroke\n");
|
2001-12-04 20:54:44 +01:00
|
|
|
|
if (!DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), TRUE))
|
1998-12-03 17:29:56 +01:00
|
|
|
|
{
|
|
|
|
|
SET_ZFLAG(context);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RESET_ZFLAG(context);
|
|
|
|
|
}
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2001-12-04 20:54:44 +01:00
|
|
|
|
case 0x02: /* Get Shift Flags */
|
1999-03-25 17:41:35 +01:00
|
|
|
|
AL_reg(context) = 0;
|
|
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(VK_RSHIFT))
|
|
|
|
|
AL_reg(context) |= 0x01;
|
|
|
|
|
if (GetAsyncKeyState(VK_LSHIFT))
|
|
|
|
|
AL_reg(context) |= 0x02;
|
|
|
|
|
if (GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL))
|
|
|
|
|
AL_reg(context) |= 0x04;
|
|
|
|
|
if (GetAsyncKeyState(VK_LMENU) || GetAsyncKeyState(VK_RMENU))
|
|
|
|
|
AL_reg(context) |= 0x08;
|
|
|
|
|
if (GetAsyncKeyState(VK_SCROLL))
|
|
|
|
|
AL_reg(context) |= 0x10;
|
|
|
|
|
if (GetAsyncKeyState(VK_NUMLOCK))
|
|
|
|
|
AL_reg(context) |= 0x20;
|
|
|
|
|
if (GetAsyncKeyState(VK_CAPITAL))
|
|
|
|
|
AL_reg(context) |= 0x40;
|
|
|
|
|
if (GetAsyncKeyState(VK_INSERT))
|
|
|
|
|
AL_reg(context) |= 0x80;
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context));
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x03: /* Set Typematic Rate and Delay */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
FIXME("Set Typematic Rate and Delay - Not Supported\n");
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x09: /* Get Keyboard Functionality */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
FIXME("Get Keyboard Functionality - Not Supported\n");
|
1998-10-17 13:55:07 +02:00
|
|
|
|
/* As a temporary measure, say that "nothing" is supported... */
|
|
|
|
|
AL_reg(context) = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0a: /* Get Keyboard ID */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
FIXME("Get Keyboard ID - Not Supported\n");
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x10: /* Get Enhanced Keystroke */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Get Enhanced Keystroke - Partially supported\n");
|
1999-03-17 16:29:06 +01:00
|
|
|
|
/* Returns: AH = Scan code
|
2001-12-04 20:54:44 +01:00
|
|
|
|
AL = ASCII character */
|
|
|
|
|
DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), FALSE);
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
2001-12-04 20:54:44 +01:00
|
|
|
|
|
1998-10-17 13:55:07 +02:00
|
|
|
|
|
|
|
|
|
case 0x11: /* Check for Enhanced Keystroke */
|
1999-03-17 16:29:06 +01:00
|
|
|
|
/* Returns: ZF set if no keystroke */
|
|
|
|
|
/* AH = Scan code */
|
|
|
|
|
/* AL = ASCII character */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
TRACE("Check for Enhanced Keystroke - Partially supported\n");
|
2001-12-04 20:54:44 +01:00
|
|
|
|
if (!DOSVM_Int16ReadChar(&AL_reg(context), &AH_reg(context), TRUE))
|
1999-03-17 16:29:06 +01:00
|
|
|
|
{
|
|
|
|
|
SET_ZFLAG(context);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RESET_ZFLAG(context);
|
|
|
|
|
}
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x12: /* Get Extended Shift States */
|
1999-06-26 21:09:08 +02:00
|
|
|
|
FIXME("Get Extended Shift States - Not Supported\n");
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
2001-12-04 20:54:44 +01:00
|
|
|
|
|
1998-10-17 13:55:07 +02:00
|
|
|
|
default:
|
2001-12-04 20:54:44 +01:00
|
|
|
|
FIXME("Unknown INT 16 function - 0x%x\n", AH_reg(context));
|
1998-10-17 13:55:07 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-04 20:54:44 +01:00
|
|
|
|
int WINAPI DOSVM_Int16ReadChar(BYTE*ascii,BYTE*scan,BOOL peek)
|
2000-02-03 01:47:01 +01:00
|
|
|
|
{
|
|
|
|
|
BIOSDATA *data = DOSMEM_BiosData();
|
|
|
|
|
WORD CurOfs = data->NextKbdCharPtr;
|
|
|
|
|
|
|
|
|
|
/* check if there's data in buffer */
|
|
|
|
|
if (peek) {
|
|
|
|
|
if (CurOfs == data->FirstKbdCharPtr)
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
while (CurOfs == data->FirstKbdCharPtr) {
|
|
|
|
|
/* no input available yet, so wait... */
|
2001-12-04 20:54:44 +01:00
|
|
|
|
DOSVM_Wait( -1, 0 );
|
2000-02-03 01:47:01 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* read from keyboard queue */
|
|
|
|
|
TRACE("(%p,%p,%d) -> %02x %02x\n",ascii,scan,peek,((BYTE*)data)[CurOfs],((BYTE*)data)[CurOfs+1]);
|
|
|
|
|
if (ascii) *ascii = ((BYTE*)data)[CurOfs];
|
|
|
|
|
if (scan) *scan = ((BYTE*)data)[CurOfs+1];
|
|
|
|
|
if (!peek) {
|
|
|
|
|
CurOfs += 2;
|
|
|
|
|
if (CurOfs >= data->KbdBufferEnd) CurOfs = data->KbdBufferStart;
|
|
|
|
|
data->NextKbdCharPtr = CurOfs;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-04 20:54:44 +01:00
|
|
|
|
int WINAPI DOSVM_Int16AddChar(BYTE ascii,BYTE scan)
|
1999-05-22 13:27:40 +02:00
|
|
|
|
{
|
|
|
|
|
BIOSDATA *data = DOSMEM_BiosData();
|
|
|
|
|
WORD CurOfs = data->FirstKbdCharPtr;
|
|
|
|
|
WORD NextOfs = CurOfs + 2;
|
|
|
|
|
|
2000-02-03 01:47:01 +01:00
|
|
|
|
TRACE("(%02x,%02x)\n",ascii,scan);
|
1999-05-22 13:27:40 +02:00
|
|
|
|
if (NextOfs >= data->KbdBufferEnd) NextOfs = data->KbdBufferStart;
|
|
|
|
|
/* check if buffer is full */
|
|
|
|
|
if (NextOfs == data->NextKbdCharPtr) return 0;
|
|
|
|
|
|
|
|
|
|
/* okay, insert character in ring buffer */
|
|
|
|
|
((BYTE*)data)[CurOfs] = ascii;
|
|
|
|
|
((BYTE*)data)[CurOfs+1] = scan;
|
|
|
|
|
|
|
|
|
|
data->FirstKbdCharPtr = NextOfs;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|