Do not set EH_NONCONTINUABLE.
[wine.git] / msdos / int16.c
blob1ef4c2b776f4e4a2affdbe8d93e2a04fc0448651
1 /*
2 * DOS interrupt 16h handler
3 */
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
9 #include "config.h"
10 #include "module.h"
11 #include "console.h"
12 #include "wincon.h"
13 #include "debugtools.h"
14 #include "winuser.h"
15 #include "miscemu.h"
17 DEFAULT_DEBUG_CHANNEL(int16)
19 /**********************************************************************
20 * INT_Int16Handler
22 * Handler for int 16h (keyboard)
24 * NOTE:
26 * KEYB.COM (DOS >3.2) adds functions to this interrupt, they are
27 * not currently listed here.
30 void WINAPI INT_Int16Handler( CONTEXT86 *context )
32 switch AH_reg(context) {
34 case 0x00: /* Get Keystroke */
35 /* Returns: AH = Scan code
36 AL = ASCII character */
37 TRACE("Get Keystroke\n");
38 CONSOLE_GetKeystroke(&AH_reg(context), &AL_reg(context));
39 break;
41 case 0x01: /* Check for Keystroke */
42 /* Returns: ZF set if no keystroke */
43 /* AH = Scan code */
44 /* AL = ASCII character */
45 TRACE("Check for Keystroke\n");
46 if (!CONSOLE_CheckForKeystroke(&AH_reg(context), &AL_reg(context)))
48 SET_ZFLAG(context);
50 else
52 RESET_ZFLAG(context);
54 break;
56 case 0x02: /* Get Shift Flags */
57 AL_reg(context) = 0;
59 if (GetAsyncKeyState(VK_RSHIFT))
60 AL_reg(context) |= 0x01;
61 if (GetAsyncKeyState(VK_LSHIFT))
62 AL_reg(context) |= 0x02;
63 if (GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL))
64 AL_reg(context) |= 0x04;
65 if (GetAsyncKeyState(VK_LMENU) || GetAsyncKeyState(VK_RMENU))
66 AL_reg(context) |= 0x08;
67 if (GetAsyncKeyState(VK_SCROLL))
68 AL_reg(context) |= 0x10;
69 if (GetAsyncKeyState(VK_NUMLOCK))
70 AL_reg(context) |= 0x20;
71 if (GetAsyncKeyState(VK_CAPITAL))
72 AL_reg(context) |= 0x40;
73 if (GetAsyncKeyState(VK_INSERT))
74 AL_reg(context) |= 0x80;
75 TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context));
76 break;
78 case 0x03: /* Set Typematic Rate and Delay */
79 FIXME("Set Typematic Rate and Delay - Not Supported\n");
80 break;
82 case 0x09: /* Get Keyboard Functionality */
83 FIXME("Get Keyboard Functionality - Not Supported\n");
84 /* As a temporary measure, say that "nothing" is supported... */
85 AL_reg(context) = 0;
86 break;
88 case 0x0a: /* Get Keyboard ID */
89 FIXME("Get Keyboard ID - Not Supported\n");
90 break;
92 case 0x10: /* Get Enhanced Keystroke */
93 TRACE("Get Enhanced Keystroke - Partially supported\n");
94 /* Returns: AH = Scan code
95 AL = ASCII character */
96 CONSOLE_GetKeystroke(&AH_reg(context), &AL_reg(context));
97 break;
100 case 0x11: /* Check for Enhanced Keystroke */
101 /* Returns: ZF set if no keystroke */
102 /* AH = Scan code */
103 /* AL = ASCII character */
104 TRACE("Check for Enhanced Keystroke - Partially supported\n");
105 if (!CONSOLE_CheckForKeystroke(&AH_reg(context), &AL_reg(context)))
107 SET_ZFLAG(context);
109 else
111 RESET_ZFLAG(context);
113 break;
115 case 0x12: /* Get Extended Shift States */
116 FIXME("Get Extended Shift States - Not Supported\n");
117 break;
119 default:
120 FIXME("Unknown INT 16 function - 0x%x\n", AH_reg(context));
121 break;
126 int WINAPI INT_Int16AddChar(BYTE ascii,BYTE scan)
128 BIOSDATA *data = DOSMEM_BiosData();
129 WORD CurOfs = data->FirstKbdCharPtr;
130 WORD NextOfs = CurOfs + 2;
132 if (NextOfs >= data->KbdBufferEnd) NextOfs = data->KbdBufferStart;
133 /* check if buffer is full */
134 if (NextOfs == data->NextKbdCharPtr) return 0;
136 /* okay, insert character in ring buffer */
137 ((BYTE*)data)[CurOfs] = ascii;
138 ((BYTE*)data)[CurOfs+1] = scan;
140 data->FirstKbdCharPtr = NextOfs;
141 return 1;