MCPcopy Create free account
hub / github.com/NetHack/NetHack / DOSgetch

Function DOSgetch

sys/msdos/msdos.c:313–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313static char
314DOSgetch(void)
315{
316 union REGS regs;
317 char ch;
318 struct pad(*kpad)[PADKEYS];
319
320 regs.h.ah = DIRECT_INPUT;
321 intdos(&regs, &regs);
322 ch = regs.h.al;
323
324#ifdef PC9800
325 if (ch < 0) /* KANA letters and GRPH-shifted letters(?) */
326 ch = 0; /* munch it */
327#else
328 /*
329 * The extended codes for Alt-shifted letters, and unshifted keypad
330 * and function keys, correspond to the scan codes. So we can still
331 * translate the unshifted cursor keys and Alt-letters. -3.
332 */
333 if (ch == 0) { /* an extended key */
334 regs.h.ah = DIRECT_INPUT;
335 intdos(&regs, &regs); /* get the extended key code */
336 ch = regs.h.al;
337
338 if (iskeypad(ch)) { /* unshifted keypad keys */
339 kpad = (void *) (iflags.num_pad ? numpad : keypad);
340 ch = (*kpad)[ch - KEYPADLO].normal;
341 } else if (inmap(ch)) { /* Alt-letters */
342 ch = scanmap[ch - SCANLO];
343 if (isprint(ch))
344 ch = M(ch);
345 } else
346 ch = 0; /* munch it */
347 }
348#endif
349 return (ch);
350}
351
352char
353switchar(void)

Callers 1

tgetchFunction · 0.70

Calls 1

isprintFunction · 0.85

Tested by

no test coverage detected