1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: emxvga.trm,v 1.15 2006/07/21 02:35:46 sfeam Exp $
5 /* GNUPLOT - emxvga.trm */
8 * Copyright 1994, 1998, 2004
10 * Permission to use, copy, and distribute this software and its
11 * documentation for any purpose with or without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and
13 * that both that copyright notice and this permission notice appear
14 * in supporting documentation.
16 * Permission to modify the software is granted, but not the right to
17 * distribute the complete modified source code. Modifications are to
18 * be distributed as patches to the released version. Permission to
19 * distribute binaries produced by compiling modified sources is granted,
21 * 1. distribute the corresponding source modifications from the
22 * released version in the form of a patch file along with the binaries,
23 * 2. add special version identification to distinguish your version
24 * in addition to the base release version number,
25 * 3. provide your name and address as the primary contact for the
26 * support of your modified version, and
27 * 4. retain our contact information in regard to use of the base
29 * Permission to distribute the released version of the source code along
30 * with corresponding source modifications in the form of a patch file is
31 * granted with same provisions 2 through 4 for binary distributions.
33 * This software is provided "as is" without express or implied warranty
34 * to the extent permitted by applicable law.
38 * This file is included by ../term.c.
40 * This terminal driver supports:
41 * SVGA 1024x768x256 for PC's running DOS or OS/2
44 * David J. Liu (liudj0@minerva.cis.yale.edu)
47 * Compile with GCC (emx) with VESA and SVGAKIT maintained by
48 * Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE)
49 * with additions by David J. Liu (liudj0@minerva.cis.yale.edu)
50 * supports VESA, Trident, Cirrus, ET4000, WD and S3.
53 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
66 TERM_PUBLIC void EMXVGA_init __PROTO((void));
67 TERM_PUBLIC void EMXVGA_reset __PROTO((void));
68 TERM_PUBLIC void EMXVGA_text __PROTO((void));
69 TERM_PUBLIC void EMXVGA_graphics __PROTO((void));
70 TERM_PUBLIC void EMXVGA_linetype __PROTO((int));
71 TERM_PUBLIC void EMXVGA_move __PROTO((unsigned int, unsigned int));
72 TERM_PUBLIC void EMXVGA_vector __PROTO((unsigned int, unsigned int));
73 TERM_PUBLIC int EMXVGA_text_angle __PROTO((int));
74 TERM_PUBLIC void EMXVGA_put_text __PROTO((unsigned int, unsigned int, const char *));
75 #define EMXVGA_VCHAR 8
76 #define EMXVGA_HCHAR 8
79 #define EMXVGA_XMAX 0 /* These two entries are just place holders. */
80 #define EMXVGA_YMAX 0 /* The actual values will be filled in init. */
82 TERM_PUBLIC void EMXVESA_options __PROTO((void));
83 TERM_PUBLIC void EMXVESA_init __PROTO((void));
84 TERM_PUBLIC void EMXVESA_graphics __PROTO((void));
85 TERM_PUBLIC void EMXVESA_text __PROTO((void));
86 TERM_PUBLIC void EMXVESA_reset __PROTO((void));
88 #endif /* TERM_PROTO */
89 #ifndef TERM_PROTO_ONLY
91 /* avoid name clash with graph.h - lets hope that no following
92 * driver needs these symbols !
102 #include <conio.h> /* for getch() -SB */
106 * Some versions of graph.h (e.g. jmgraph.h) define RIGHT to be 0
107 * colliding with enum JUSTIFY. We don't need this define anyway,
116 static int EMXVGA_vmode = G640x480x256; /* default mode */
117 static int vgacolor[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 };
118 static int graphics_on = FALSE;
119 int startx, starty, lasty;
120 int EMXVGA_angle, EMXVGA_color;
128 if (_osmode == OS2_MODE)
129 VesaGetCharacter(&c);
132 _int86(0x16, ®, ®);
135 _int86(0x16, ®, ®);
140 /* gstring.c (emx+gcc) -- Copyright (c) 1994 by David J. Liu */
141 unsigned char font[128][8] =
143 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
144 {0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E},
145 {0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E},
146 {0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00},
147 {0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00},
148 {0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C},
149 {0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C},
150 {0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00},
151 {0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF},
152 {0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00},
153 {0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF},
154 {0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78},
155 {0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18},
156 {0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0},
157 {0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0},
158 {0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99},
159 {0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00},
160 {0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00},
161 {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18},
162 {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00},
163 {0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00},
164 {0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC},
165 {0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00},
166 {0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF},
167 {0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00},
168 {0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00},
169 {0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00},
170 {0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00},
171 {0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00},
172 {0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00},
173 {0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00},
174 {0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00},
175 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
176 {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00},
177 {0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00},
178 {0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00},
179 {0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00},
180 {0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00},
181 {0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00},
182 {0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00},
183 {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00},
184 {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00},
185 {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00},
186 {0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00},
187 {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30},
188 {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00},
189 {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00},
190 {0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00},
191 {0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00},
192 {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00},
193 {0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00},
194 {0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00},
195 {0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00},
196 {0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00},
197 {0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00},
198 {0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00},
199 {0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00},
200 {0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00},
201 {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00},
202 {0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30},
203 {0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00},
204 {0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00},
205 {0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00},
206 {0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00},
207 {0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00},
208 {0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00},
209 {0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00},
210 {0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00},
211 {0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00},
212 {0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00},
213 {0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00},
214 {0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00},
215 {0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00},
216 {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
217 {0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00},
218 {0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00},
219 {0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00},
220 {0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00},
221 {0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00},
222 {0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00},
223 {0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00},
224 {0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00},
225 {0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00},
226 {0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00},
227 {0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
228 {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00},
229 {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00},
230 {0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00},
231 {0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00},
232 {0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00},
233 {0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00},
234 {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00},
235 {0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00},
236 {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00},
237 {0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00},
238 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF},
239 {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},
240 {0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00},
241 {0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00},
242 {0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00},
243 {0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00},
244 {0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00},
245 {0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00},
246 {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8},
247 {0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00},
248 {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},
249 {0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78},
250 {0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00},
251 {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},
252 {0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00},
253 {0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00},
254 {0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00},
255 {0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0},
256 {0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E},
257 {0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00},
258 {0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00},
259 {0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00},
260 {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00},
261 {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00},
262 {0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00},
263 {0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00},
264 {0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8},
265 {0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00},
266 {0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00},
267 {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},
268 {0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00},
269 {0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
270 {0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00}
273 void g_set(int x, int y, int color); /* part of SVGA */
276 g_string(int x0, int y0, int color, int angle, char *s)
283 sa = sin(- DEG2RAD * angle);
284 ca = cos(DEG2RAD * angle);
286 for (i = 0; i < 8; i++)
287 for (j = 0; j < 8; j++)
288 g_set(x + ca * j - sa * i, y + ca * i + sa * j, (font[(int) s[k]][i] & (1 << (7 - j))) ? color : 0);
295 /* end of gstring.c */
300 if (!g_mode(EMXVGA_vmode)) {
301 fputs("Unable to initiate graphics.\n", stderr);
304 term->xmax = g_xsize;
305 term->ymax = g_ysize;
330 g_mode(EMXVGA_vmode);
336 EMXVGA_linetype(int linetype)
338 EMXVGA_color = vgacolor[(linetype % 13) + 2];
342 EMXVGA_move(unsigned int x, unsigned int y)
349 EMXVGA_vector(unsigned int x, unsigned int y)
351 g_line(startx, lasty - starty, x, lasty - y, EMXVGA_color);
357 EMXVGA_text_angle(int ang)
359 EMXVGA_angle = (ang ? 90 : 0);
364 EMXVGA_put_text(unsigned int x, unsigned int y, const char *str)
366 g_string(x, lasty - y - 3, EMXVGA_color, EMXVGA_angle, str);
373 free(EMXVGA_buf); /* do this just for safety */
374 EMXVGA_buf = (char *) malloc(g_memsize);
383 g_mode(EMXVGA_vmode);
384 g_restore(EMXVGA_buf);
389 int emx_vesamode = G640x480x256;
390 int emx_xlast, emx_ylast;
394 if (!END_OF_COMMAND) {
395 if (almost_equals(c_token, "d$efault")) {
396 emx_vesamode = G640x480x256;
400 if (!END_OF_COMMAND) {
401 /* We have a vesa mode specified */
403 emx_vesamode = (int) real(const_express(&a));
405 sprintf(term_options, "%d", emx_vesamode);
411 if (!g_mode(emx_vesamode))
412 int_error(NO_CARET, "Couldn't select graphics mode");
413 emx_xlast = g_xsize - 1;
414 term->xmax = emx_xlast + 1;
415 emx_ylast = g_ysize - 1;
416 term->ymax = emx_ylast + 1;
423 g_mode(emx_vesamode);
433 int_error(NO_CARET, "Interrupt");
442 #endif /* TERM_BODY */
446 TERM_TABLE_START(vesa_driver)
447 "vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]",
448 EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
449 EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset,
450 EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector,
451 EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
452 null_justify_text, do_point, do_arrow, set_font_null
453 TERM_TABLE_END(vesa_driver)
456 #define LAST_TERM vesa_driver
460 TERM_TABLE_START(emxvga_driver)
461 "emxvga", "PC with VGA running DOS or OS/2",
462 EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
463 EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
464 EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move,
465 EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
466 null_justify_text, do_point, do_arrow, set_font_null,
468 TERM_CAN_MULTIPLOT, EMXVGA_suspend, EMXVGA_resume
469 TERM_TABLE_END(emxvga_driver)
472 #define LAST_TERM emxvga_driver
474 #endif /* TERM_TABLE */
475 #endif /* TERM_PROTO_ONLY */
479 "?commands set terminal emxvga",
480 "?set terminal emxvga",
485 "?commands set terminal emxvesa",
486 "?set terminal emxvesa",
491 "?commands set terminal vgal",
492 "?set terminal vgal",
497 " The `emxvga`, `emxvesa` and `vgal` terminal drivers support PCs with SVGA,",
498 " vesa SVGA and VGA graphics boards, respectively. They are intended to be",
499 " compiled with \"emx-gcc\" under either DOS or OS/2. They also need VESA and",
500 " SVGAKIT maintained by Johannes Martin (JMARTIN@GOOFY.ZDV.UNI-MAINZ.DE) with",
501 " additions by David J. Liu (liu@phri.nyu.edu).",
504 " set terminal emxvga",
505 " set terminal emxvesa {vesa-mode}",
506 " set terminal vgal",
508 " The only option is the vesa mode for `emxvesa`, which defaults to G640x480x256."
510 #endif /* TERM_HELP */