|
|
1.1 root 1: /***************************************************************************
2: * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne. JOVE *
3: * is provided to you without charge, and with no warranty. You may give *
4: * away copies of JOVE, including sources, provided that this notice is *
5: * included in all the files. *
6: ***************************************************************************/
7:
8: #include "tune.h"
9:
10: #ifdef MSDOS
11:
12: #include <bios.h>
13: #include <dos.h>
14:
15: #include "jove.h"
16:
17: private void waitfun proto((void));
18:
19: extern int UpdModLine;
20: #ifdef IBMPC
21: static char last = 0;
22: extern int specialkey;
23: #endif
24:
25: getrawinchar()
26: {
27: #ifdef RAINBOW
28: union REGS regs;
29: #endif /* RAINBOW */
30: #ifdef IBMPC
31: unsigned scan;
32:
33: if (specialkey = last) {
34: scan = last;
35: last = 0;
36: return scan;
37: }
38: #endif /* IBMPC */
39:
40: while (!rawkey_ready())
41: waitfun();
42:
43: #ifdef IBMPC
44: scan = _bios_keybrd(_KEYBRD_READ);
45: if ((scan&0xff) == 0) {
46: last = (char) (scan >> 8);
47: return 0xff;
48: }
49: return scan&0xff;
50: #else /* IBMPC */
51: #ifdef RAINBOW
52: waitloop:
53: regs.x.di = 2;
54: int86(0x18, ®s, ®s);
55: if (regs.h.al != 0) /* should never happen, but who knows */
56: return regs.h.al;
57: else
58: goto waitloop;
59: #else /* RAINBOW */
60: return bdos(0x06, 0x00ff, 0xff) & 0xff;
61: #endif /* RAINBOW */
62: #endif /* IBMPC */
63: }
64:
65: static int waiting = 0;
66:
67: rawkey_ready()
68: {
69: #ifndef IBMPC
70: union REGS regs;
71: #endif
72:
73: if (waiting)
74: return 0;
75: #ifdef IBMPC
76: if (last)
77: return 1;
78:
79: return _bios_keybrd(_KEYBRD_READY);
80: #else /* IBMPC */
81: #ifdef RAINBOW
82: regs.x.di = 4;
83: int86(0x18, ®s, ®s);
84: return regs.h.cl != 0;
85: #else /* RAINBOW */
86: regs.h.ah = 0x44; /* ioctl call */
87: regs.x.bx = 0; /* stdin file handle */
88: regs.h.al = 0x06; /* get input status */
89: intdos(®s, ®s);
90: return regs.h.al & 1;
91: #endif /* RAINBOW */
92: #endif /* IBMPC */
93: }
94:
95: #ifdef IBMPC
96: static long timecount, lastcount = 0;
97: #else
98: static char lastmin = 0;
99: #endif
100:
101:
102: private void
103: waitfun()
104: {
105: #ifndef IBMPC
106: struct dostime_t tc;
107: #endif
108:
109: if (UpdModLine) {
110: waiting = 1;
111: redisplay();
112: waiting = 0;
113: return;
114: }
115: #ifdef IBMPC
116: if (_bios_timeofday(_TIME_GETCLOCK, &timecount) || /* after midnight */
117: (timecount > lastcount + 0x444) ) {
118: lastcount = timecount;
119: UpdModLine = 1;
120: }
121: #else
122: _dos_gettime(&tc);
123: if (tc.minute != lastmin) {
124: UpdModLine = 1;
125: lastmin = tc.minute;
126: }
127: #endif
128: }
129:
130: #endif /* MSDOS */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.