-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnec.c.bak
419 lines (351 loc) · 8.44 KB
/
nec.c.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
/* NEC: NEC PC-9801vm driver for
MicroEMACS 4.00
(C)Copyright 1995 by Daniel M. Lawrence
*/
#define termdef 1 /* don't define term external */
#include <stdio.h>
#include "estruct.h"
#include "eproto.h"
#include "edef.h"
#include "elang.h"
#if NEC
#include <dos.h>
#if PROTO
int PASCAL NEAR fnclabel(int f, int n);
int PASCAL NEAR readparam( int *v);
void PASCAL NEAR dobbnmouse(void);
void PASCAL NEAR docsi( int oh);
void PASCAL NEAR ttputs(char *string);
#else
int PASCAL NEAR fnclabel();
int PASCAL NEAR readparam();
void PASCAL NEAR dobbnmouse();
void PASCAL NEAR docsi();
void PASCAL NEAR ttputs();
#endif
#define NROW 24 /* Screen size. */
#define NCOL 80 /* Edit if you want to. */
#define NPAUSE 100 /* # times thru update to pause */
#define MARGIN 8 /* size of minimim margin and */
#define SCRSIZ 64 /* scroll size for extended lines */
#define BEL 0x07 /* BEL character. */
#define ESC 0x1B /* ESC character. */
/* Forward references. */
extern int PASCAL NEAR necmove();
extern int PASCAL NEAR neceeol();
extern int PASCAL NEAR neceeop();
extern int PASCAL NEAR necbeep();
extern int PASCAL NEAR necopen();
extern int PASCAL NEAR necrev();
extern int PASCAL NEAR necclose();
extern int PASCAL NEAR neckopen();
extern int PASCAL NEAR neckclose();
extern int PASCAL NEAR neccres();
extern int PASCAL NEAR necparm();
extern int PASCAL NEAR necgetc();
#if INSDEL
extern int PASCAL NEAR necins();
extern int PASCAL NEAR necdel();
#endif
#if COLOR
extern int PASCAL NEAR necfcol();
extern int PASCAL NEAR necbcol();
static int cfcolor = -1; /* current forground color */
static int cbcolor = -1; /* current background color */
#endif
#if FLABEL
#define FSIZE 392 /* save of function key save buffer */
static unsigned char oldkeys[FSIZE]; /* original key save buffer */
static unsigned char curkeys[FSIZE] = { /* current key save buffer */
/* function keys F1 - F10 */
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 59, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 60, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 61, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 62, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 63, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 64, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 65, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 66, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 67, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 68, 0, 0, 0, 0, 0, 0, 0, 0,
/* function keys F11 - F20 */
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 84, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 85, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 86, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 87, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 88, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 89, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 90, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 91, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 92, 0, 0, 0, 0, 0, 0, 0, 0,
0xfe, ' ', ' ', ' ', ' ', ' ', 0x1d, 93, 0, 0, 0, 0, 0, 0, 0, 0,
/* other unlabeled keys */
0x1d, 73, 0, 0, 0, 0, /* roll up */
0x1d, 81, 0, 0, 0, 0, /* roll down */
0x1d, 82, 0, 0, 0, 0, /* insert */
0x1d, 83, 0, 0, 0, 0, /* delete */
0x1d, 72, 0, 0, 0, 0, /* up */
0x1d, 75, 0, 0, 0, 0, /* left */
0x1d, 77, 0, 0, 0, 0, /* right */
0x1d, 80, 0, 0, 0, 0, /* down */
0x1d, 78, 0, 0, 0, 0, /* clear */
12, 0, 0, 0, 0, 0, /* help */
0x1d, 71, 0, 0, 0, 0, /* home */
0x1d, 0, 0, 0, 0, 0, /* end */
};
extern union REGS rg; /* cpu register for use of DOS calls */
#endif
/*
* Standard terminal interface dispatch table. Most of the fields point into
* "termio" code.
*/
NOSHARE TERM term = {
NROW-1,
NROW-1,
NCOL,
NCOL,
0, 0,
MARGIN,
SCRSIZ,
NPAUSE,
necopen,
necclose,
neckopen,
neckclose,
necgetc,
ttputc,
ttflush,
necmove,
neceeol,
neceeop,
neceeop,
necbeep,
necrev,
neccres
#if COLOR
, necfcol,
necbcol
#endif
#if INSDEL
, necins,
necdel
#endif
};
#if COLOR
PASCAL NEAR necfcol(color) /* set the current output color */
int color; /* color to set */
{
if (color == cfcolor)
return;
ttputc(ESC);
ttputc('[');
necparm((7 & color)+30);
ttputc('m');
cfcolor = color;
}
PASCAL NEAR necbcol(color) /* set the current background color */
int color; /* color to set */
{
if (color == cbcolor)
return;
#if 1
ttputc(ESC);
ttputc('[');
necparm((7 & color)+40);
ttputc('m');
#endif
cbcolor = color;
}
#endif
#if INSDEL
PASCAL NEAR necins(lines) /* insert some screen lines */
int lines; /* number of lines to insert */
{
if (lines < 1)
return;
ttputc(ESC);
ttputc('[');
necparm(lines);
ttputc('L');
}
PASCAL NEAR necdel(lines) /* delete some screen lines */
int lines; /* number of lines to delete */
{
if (lines < 1)
return;
ttputc(ESC);
ttputc('[');
necparm(lines);
ttputc('M');
}
#endif
PASCAL NEAR necmove(row, col)
{
ttputc(ESC);
ttputc('[');
necparm(row+1);
ttputc(';');
necparm(col+1);
ttputc('H');
}
PASCAL NEAR neceeol()
{
ttputc(ESC);
ttputc('[');
ttputc('K');
}
PASCAL NEAR neceeop()
{
#if COLOR
necfcol(gfcolor);
necbcol(gbcolor);
#endif
ttputc(ESC);
ttputc('[');
ttputc('J');
}
PASCAL NEAR necrev(state) /* change reverse video state */
int state; /* TRUE = reverse, FALSE = normal */
{
#if COLOR
int ftmp, btmp; /* temporaries for colors */
#endif
ttputc(ESC);
ttputc('[');
ttputc(state ? '7': '0');
ttputc('m');
#if COLOR & 0
if (state == FALSE) {
ftmp = cfcolor;
btmp = cbcolor;
cfcolor = -1;
cbcolor = -1;
necfcol(ftmp);
necbcol(btmp);
}
#endif
}
PASCAL NEAR neccres() /* change screen resolution */
{
return(TRUE);
}
PASCAL NEAR spal(char *dummy) /* change pallette settings */
{
/* none for now */
}
PASCAL NEAR necbeep()
{
ttputc(BEL);
ttflush();
}
PASCAL NEAR necparm(n)
register int n;
{
register int q,r;
q = n/10;
if (q != 0) {
r = q/10;
if (r != 0) {
ttputc((r%10)+'0');
}
ttputc((q%10) + '0');
}
ttputc((n%10) + '0');
}
PASCAL NEAR necopen()
{
strcpy(sres, "NORMAL");
revexist = TRUE;
ttopen();
ttputc(ESC);
ttputc(')');
ttputc('0');
#if FLABEL
getkeys(oldkeys); /* save original function keys */
#endif
}
PASCAL NEAR necclose()
{
#if COLOR
necfcol(7);
necbcol(0);
#endif
ttclose();
}
PASCAL NEAR neckopen() /* open the keyboard (a noop here) */
{
#if FLABEL
setkeys(curkeys); /* and reset them to new values */
#endif
}
PASCAL NEAR neckclose() /* close the keyboard (a noop here) */
{
#if FLABEL
setkeys(oldkeys); /* restore the original function key block */
#endif
}
PASCAL NEAR necgetc()
{
return(ttgetc());
}
#if FLABEL
int PASCAL NEAR fnclabel(f, n) /* label a function key */
int f,n; /* default flag, numeric argument [unused] */
{
char *ptr; /* ptr into function key string */
char lbl[6]; /* returned label contents */
int status;
int index;
/* must have a numeric argument */
if (f == FALSE) {
mlwrite(TEXT159);
/* "%Need function key number" */
return(FALSE);
}
/* and it must be a legal key number */
if (n < 1 || n > 10) {
mlwrite(TEXT50);
/* "%Function key number out of range" */
return(FALSE);
}
/* get the string to send */
status = mlreply(TEXT51, lbl, 6);
/* "Label contents: " */
if (status != TRUE)
return(status);
/* pad the label out */
for (index=0; index < 5; index++) {
if (lbl[index] == 0)
break;
}
for (; index < 5; index++)
lbl[index] = ' ';
lbl[5] = 0;
/* label the key! */
ptr = &curkeys[(n - 1) * 16 + 1];
movmem(lbl, ptr, 5);
setkeys(curkeys);
return(TRUE);
}
getkeys(keys) /* read the function key labels and definitions */
unsigned char *keys; /* function key block */
{
rg.h.cl = 0x0c;
rg.x.ax = 0;
rg.x.dx = (int)keys;
int86(0xdc, &rg, &rg);
}
setkeys(keys) /* reset the function key labels and definitions */
unsigned char *keys; /* function key block */
{
rg.h.cl = 0x0d;
rg.x.ax = 0;
rg.x.dx = (int)keys;
int86(0xdc, &rg, &rg);
}
#endif
#else
nechello()
{
}
#endif