File: emxvga.trm

package info (click to toggle)
gnuplot 3.7.2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,212 kB
  • ctags: 4,635
  • sloc: ansic: 43,538; cpp: 970; makefile: 883; lisp: 661; sh: 578; asm: 539; objc: 379; csh: 297; pascal: 192; perl: 138
file content (486 lines) | stat: -rw-r--r-- 16,499 bytes parent folder | download | duplicates (2)
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/*
 * $Id: emxvga.trm,v 1.6 1998/12/14 18:38:51 lhecking Exp $
 */

/* GNUPLOT - emxvga.trm */

/*[
 * Copyright 1994, 1998
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  SVGA 1024x768x256 for PC's running DOS or OS/2
 *
 * AUTHOR
 *   David J. Liu (liudj0@minerva.cis.yale.edu)
 */
/*
 * Compile with GCC (emx) with VESA and SVGAKIT maintained by
 * Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
 * with additions by David J. Liu (liudj0@minerva.cis.yale.edu)
 * supports VESA, Trident, Cirrus, ET4000, WD and S3.
 */
/* 
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
#ifdef EMXVESA
register_term(vesa)
#endif /* EMXVESA */
register_term(emxvga)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void EMXVGA_init __PROTO((void));
TERM_PUBLIC void EMXVGA_reset __PROTO((void));
TERM_PUBLIC void EMXVGA_text __PROTO((void));
TERM_PUBLIC void EMXVGA_graphics __PROTO((void));
TERM_PUBLIC void EMXVGA_linetype __PROTO((int));
TERM_PUBLIC void EMXVGA_move __PROTO((unsigned int, unsigned int));
TERM_PUBLIC void EMXVGA_vector __PROTO((unsigned int, unsigned int));
TERM_PUBLIC int EMXVGA_text_angle __PROTO((int));
TERM_PUBLIC void EMXVGA_put_text __PROTO((unsigned int, unsigned int, char *));
#define EMXVGA_VCHAR 8
#define EMXVGA_HCHAR 8
#define EMXVGA_VTIC 4
#define EMXVGA_HTIC 4
#define EMXVGA_XMAX 0		/* These two entries are just place holders. */
#define EMXVGA_YMAX 0		/* The actual values will be filled in init. */
#ifdef EMXVESA
TERM_PUBLIC void EMXVESA_options __PROTO((void));
TERM_PUBLIC void EMXVESA_init __PROTO((void));
TERM_PUBLIC void EMXVESA_graphics __PROTO((void));
TERM_PUBLIC void EMXVESA_text __PROTO((void));
TERM_PUBLIC void EMXVESA_reset __PROTO((void));
#endif
#endif /* TERM_PROTO */
#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
/* avoid name clash with graph.h - lets hope that no following
 * driver needs these symbols !
 */
#ifdef RIGHT
#undef RIGHT
#endif
#ifdef DOWN
#undef DOWN
#endif
#include <vesa.h>
#include <jmgraph.h>
#include <conio.h>		/* for getch()            -SB */
#include <stdlib.h>
#include <dos.h>
/*
 * Some versions of graph.h (e.g. jmgraph.h) define RIGHT to be 0
 * colliding with enum JUSTIFY. We don't need this define anyway,
 * just undef it.			-SB
 */
#ifdef RIGHT
#undef RIGHT
#endif
#ifdef DOWN
#undef DOWN
#endif
static int EMXVGA_vmode = G640x480x256;		/* default mode */
static int vgacolor[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 };
static int graphics_on = FALSE;
int startx, starty, lasty;
int EMXVGA_angle, EMXVGA_color;
char *EMXVGA_buf;
void emx_getch()
{
    union REGS reg;
    char c;
    if (_osmode == OS2_MODE)
	VesaGetCharacter(&c);
    else {
	reg.x.ax = 0x0000;
	_int86(0x16, &reg, &reg);
	if (reg.h.al == 0) {
	    reg.x.ax = 0x0000;
	    _int86(0x16, &reg, &reg);
	}
    }
}

/* gstring.c (emx+gcc) -- Copyright (c) 1994 by David J. Liu */
unsigned char font[128][8] =
{				/* 8x8 font */
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E},
    {0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E},
    {0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00},
    {0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00},
    {0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C},
    {0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C},
    {0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00},
    {0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF},
    {0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00},
    {0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF},
    {0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78},
    {0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18},
    {0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0},
    {0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0},
    {0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99},
    {0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00},
    {0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00},
    {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18},
    {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00},
    {0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00},
    {0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC},
    {0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00},
    {0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF},
    {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00},
    {0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00},
    {0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00},
    {0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00},
    {0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00},
    {0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00},
    {0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00},
    {0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00},
    {0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00},
    {0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00},
    {0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00},
    {0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00},
    {0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00},
    {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00},
    {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00},
    {0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30},
    {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00},
    {0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00},
    {0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00},
    {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00},
    {0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00},
    {0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00},
    {0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00},
    {0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00},
    {0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00},
    {0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00},
    {0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00},
    {0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00},
    {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00},
    {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30},
    {0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00},
    {0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00},
    {0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00},
    {0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00},
    {0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00},
    {0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00},
    {0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00},
    {0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00},
    {0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00},
    {0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00},
    {0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00},
    {0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00},
    {0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00},
    {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
    {0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00},
    {0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00},
    {0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00},
    {0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00},
    {0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00},
    {0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00},
    {0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00},
    {0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00},
    {0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00},
    {0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00},
    {0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
    {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00},
    {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00},
    {0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00},
    {0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00},
    {0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00},
    {0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00},
    {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00},
    {0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00},
    {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00},
    {0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00},
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
    {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00},
    {0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00},
    {0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00},
    {0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00},
    {0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00},
    {0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00},
    {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8},
    {0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00},
    {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},
    {0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78},
    {0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00},
    {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
    {0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00},
    {0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00},
    {0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00},
    {0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0},
    {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E},
    {0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00},
    {0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00},
    {0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00},
    {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00},
    {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00},
    {0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00},
    {0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00},
    {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8},
    {0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00},
    {0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00},
    {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},
    {0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00},
    {0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    {0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00}
};

void g_set(int x, int y, int color);	/* part of SVGA */

void g_string(x0, y0, color, angle, s)
/* upper left corner of text, color and angle */
int x0, y0, color, angle;
char *s;
{
    int i, j, k;
    float sa, ca, x, y;
    k = 0;
    x = 0.5 + x0;
    y = 0.5 + y0;
    sa = sin(-Pi * angle / 180);
    ca = cos(Pi * angle / 180);
    while (s[k]) {
	for (i = 0; i < 8; i++)
	    for (j = 0; j < 8; j++)
		g_set(x + ca * j - sa * i, y + ca * i + sa * j, (font[(int) s[k]][i] & (1 << (7 - j))) ? color : 0);
	k++;
	x += ca * 8;
	y += sa * 8;
    }
}

/* end of gstring.c */

TERM_PUBLIC void EMXVGA_init()
{
    if (!g_mode(EMXVGA_vmode)) {
	fputs("Unable to initiate graphics.\n", stderr);
	return;
    }
    term->xmax = g_xsize;
    term->ymax = g_ysize;
    lasty = g_ysize - 1;
}
TERM_PUBLIC void EMXVGA_reset()
{
    g_mode(GTEXT);
    graphics_on = FALSE;
}
TERM_PUBLIC void EMXVGA_text()
{
    if (graphics_on) {
	emx_getch();
	g_mode(GTEXT);
	graphics_on = FALSE;
    }
}
TERM_PUBLIC void EMXVGA_graphics()
{
    if (!graphics_on) {
	g_mode(EMXVGA_vmode);
	graphics_on = TRUE;
    }
}
TERM_PUBLIC void EMXVGA_linetype(linetype)
int linetype;
{
    EMXVGA_color = vgacolor[(linetype % 13) + 2];
}
TERM_PUBLIC void EMXVGA_move(x, y)
unsigned int x, y;
{
    startx = x;
    starty = y;
}
TERM_PUBLIC void EMXVGA_vector(x, y)
unsigned int x, y;
{
    g_line(startx, lasty - starty, x, lasty - y, EMXVGA_color);
    startx = x;
    starty = y;
}
TERM_PUBLIC int EMXVGA_text_angle(ang)
int ang;
{
    EMXVGA_angle = ang * 90;
    return (TRUE);
}
TERM_PUBLIC void EMXVGA_put_text(x, y, str)
unsigned int x, y;
char *str;
{
    g_string(x, lasty - y - 3, EMXVGA_color, EMXVGA_angle, str);
}
TERM_PUBLIC void EMXVGA_suspend()
{
    if (EMXVGA_buf)
	free(EMXVGA_buf);	/* do this just for safety */
    EMXVGA_buf = (char *) malloc(g_memsize);
    g_save(EMXVGA_buf);
    emx_getch();
    g_mode(GTEXT);
}
TERM_PUBLIC void EMXVGA_resume()
{
    g_mode(EMXVGA_vmode);
    g_restore(EMXVGA_buf);
    free(EMXVGA_buf);
}

#ifdef EMXVESA
int emx_vesamode = G640x480x256;
int emx_xlast, emx_ylast;
TERM_PUBLIC void EMXVESA_options()
{
    if (!END_OF_COMMAND) {
	if (almost_equals(c_token, "d$efault")) {
	    emx_vesamode = G640x480x256;
	    c_token++;
	}
    }
    if (!END_OF_COMMAND) {
	/* We have a vesa mode specified */
	struct value a;
	emx_vesamode = (int) real(const_express(&a));
    }
    sprintf(term_options, "%d", emx_vesamode);
}
TERM_PUBLIC void EMXVESA_init()
{
    if (!g_mode(emx_vesamode))
	int_error("Couldn't select graphics mode", NO_CARET);
    emx_xlast = g_xsize - 1;
    term->xmax = emx_xlast + 1;
    emx_ylast = g_ysize - 1;
    term->ymax = emx_ylast + 1;
    g_mode(GTEXT);
}
TERM_PUBLIC void EMXVESA_graphics()
{
    g_mode(emx_vesamode);
}
TERM_PUBLIC void EMXVESA_text()
{
    int ch;
    ch = getch();
    g_mode(GTEXT);
    if (ch == 3)
	int_error("Interrupt", NO_CARET);
}
TERM_PUBLIC void EMXVESA_reset()
{
}

#endif /* VESA */
#endif /* TERM_BODY */

#ifdef TERM_TABLE
#ifdef EMXVESA
TERM_TABLE_START(vesa_driver)
    "vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]",
    EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
    EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset,
    EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector,
    EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(vesa_driver)

#undef LAST_TERM
#define LAST_TERM vesa_driver

#endif /* VESA */

TERM_TABLE_START(emxvga_driver)
    "emxvga", "PC with VGA running DOS or OS/2",
    EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
    EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
    EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move,
    EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null,
    0,				/* pointsize */
    TERM_CAN_MULTIPLOT, EMXVGA_suspend, EMXVGA_resume
TERM_TABLE_END(emxvga_driver)

#undef LAST_TERM
#define LAST_TERM emxvga_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */
#ifdef TERM_HELP
START_HELP(emxvga)
"1 emxvga",
"?commands set terminal emxvga",
"?set terminal emxvga",
"?set term emxvga",
"?terminal emxvga",
"?term emxvga",
"?emxvga",
"?commands set terminal emxvesa",
"?set terminal emxvesa",
"?set term emxvesa",
"?terminal emxvesa",
"?term emxvesa",
"?emxvesa",
"?commands set terminal vgal",
"?set terminal vgal",
"?set term vgal",
"?terminal vgal",
"?term vgal",
"?vgal",
" The `emxvga`, `emxvesa` and `vgal` terminal drivers support PCs with SVGA,",
" vesa SVGA and VGA graphics boards, respectively.  They are intended to be",
" compiled with \"emx-gcc\" under either DOS or OS/2.  They also need VESA and",
" SVGAKIT maintained by Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE) with",
" additions by David J. Liu (liu@phri.nyu.edu).",
"",
" Syntax:",
"       set terminal emxvga",
"       set terminal emxvesa {vesa-mode}",
"       set terminal vgal",
"",
" The only option is the vesa mode for `emxvesa`, which defaults to G640x480x256."
END_HELP(emxvga)
#endif /* TERM_HELP */