1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* vga.c - driver for VGA graphics adaptor under MS-DOS |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include <stdio.h> |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
+ |
#include "standard.h" |
11 |
+ |
|
12 |
|
#include <graph.h> |
13 |
|
|
14 |
|
#include "driver.h" |
18 |
|
#define GAMMA 2.2 /* exponent for color correction */ |
19 |
|
|
20 |
|
|
21 |
< |
int vga_close(), vga_clear(), vga_paintr(), vga_comout(), vga_comin(); |
21 |
> |
int vga_close(), vga_clear(), vga_paintr(), vga_comout(), vga_errout(), |
22 |
> |
vga_comin(); |
23 |
|
|
24 |
|
static struct driver vga_driver = { |
25 |
|
vga_close, vga_clear, vga_paintr, NULL, |
26 |
< |
vga_comout, vga_comin, NULL |
26 |
> |
vga_comout, vga_comin, NULL, 1.0 |
27 |
|
}; |
28 |
|
|
29 |
+ |
static char fatalerr[128]; |
30 |
+ |
|
31 |
|
static struct videoconfig config; |
32 |
|
|
33 |
+ |
extern char *getenv(); |
34 |
|
|
35 |
+ |
|
36 |
|
struct driver * |
37 |
|
vga_init(name, id) /* open VGA */ |
38 |
|
char *name, *id; |
39 |
|
{ |
40 |
< |
if (_setvideomode(_MRES256COLOR) == 0) |
40 |
> |
static short mode_pref[] = {_MRES256COLOR, -1}; |
41 |
> |
static short smode_pref[] = {_XRES256COLOR, _SVRES256COLOR, |
42 |
> |
_VRES256COLOR, _MRES256COLOR, -1}; |
43 |
> |
char *ep; |
44 |
> |
register short *mp; |
45 |
> |
|
46 |
> |
mp = !strcmp(name, "vga") ? mode_pref : smode_pref; |
47 |
> |
for ( ; *mp != -1; mp++) |
48 |
> |
if (_setvideomode(*mp)) |
49 |
> |
break; |
50 |
> |
if (*mp == -1) { |
51 |
> |
_setvideomode(_DEFAULTMODE); |
52 |
> |
eputs(name); |
53 |
> |
eputs(": card not present or insufficient VGA memory\n"); |
54 |
|
return(NULL); |
55 |
+ |
} |
56 |
|
_getvideoconfig(&config); |
57 |
|
_settextwindow(config.numtextrows-2, 1, |
58 |
|
config.numtextrows, config.numtextcols); |
59 |
|
vga_driver.xsiz = config.numxpixels; |
60 |
< |
vga_driver.ysiz = config.numypixels*(config.numtextrows-3) |
60 |
> |
vga_driver.ysiz = (long)config.numypixels*(config.numtextrows-3) |
61 |
|
/config.numtextrows; |
62 |
< |
vga_driver.pixaspect = .75*config.numxpixels/config.numypixels; |
62 |
> |
switch (config.mode) { /* correct problems */ |
63 |
> |
case _XRES256COLOR: |
64 |
> |
vga_driver.ysiz -= 16; |
65 |
> |
break; |
66 |
> |
case _MRES256COLOR: |
67 |
> |
vga_driver.pixaspect = 1.2; |
68 |
> |
break; |
69 |
> |
} |
70 |
|
_setviewport(0, 0, vga_driver.xsiz, vga_driver.ysiz); |
71 |
< |
make_gmap(GAMMA); /* make color map */ |
72 |
< |
_remappalette(1, 0x303030L); |
71 |
> |
if ((ep = getenv("GAMMA")) != NULL) /* make gamma map */ |
72 |
> |
make_gmap(atof(ep)); |
73 |
> |
else |
74 |
> |
make_gmap(GAMMA); |
75 |
> |
_remappalette(1, _BRIGHTWHITE); |
76 |
|
_settextcolor(1); |
77 |
< |
errvec = vga_comout; |
78 |
< |
cmdvec = vga_comout; |
79 |
< |
if (wrnvec != NULL) |
80 |
< |
wrnvec = vga_comout; |
77 |
> |
ms_gcinit(&vga_driver); |
78 |
> |
erract[USER].pf = |
79 |
> |
erract[SYSTEM].pf = |
80 |
> |
erract[INTERNAL].pf = |
81 |
> |
erract[CONSISTENCY].pf = vga_errout; |
82 |
> |
erract[COMMAND].pf = vga_comout; |
83 |
> |
if (erract[WARNING].pf != NULL) |
84 |
> |
erract[WARNING].pf = vga_comout; |
85 |
|
return(&vga_driver); |
86 |
|
} |
87 |
|
|
89 |
|
static |
90 |
|
vga_close() /* close VGA */ |
91 |
|
{ |
92 |
< |
errvec = stderr_v; /* reset error vector */ |
61 |
< |
cmdvec = NULL; |
62 |
< |
if (wrnvec != NULL) |
63 |
< |
wrnvec = stderr_v; |
92 |
> |
ms_gcdone(&vga_driver); |
93 |
|
_setvideomode(_DEFAULTMODE); |
94 |
+ |
erract[USER].pf = /* reset error vector */ |
95 |
+ |
erract[SYSTEM].pf = |
96 |
+ |
erract[INTERNAL].pf = |
97 |
+ |
erract[CONSISTENCY].pf = eputs; |
98 |
+ |
erract[COMMAND].pf = NULL; |
99 |
+ |
if (erract[WARNING].pf != NULL) |
100 |
+ |
erract[WARNING].pf = wputs; |
101 |
+ |
if (fatalerr[0]) |
102 |
+ |
eputs(fatalerr); /* repeat error message */ |
103 |
|
} |
104 |
|
|
105 |
|
|
146 |
|
if (*s == '\0') |
147 |
|
break; |
148 |
|
tpos = _gettextposition(); |
149 |
< |
_settextposition(tpos.row, *s=='\r' ? 0 : tpos.col-1); |
149 |
> |
_settextposition(tpos.row, *s=='\r' ? 1 : tpos.col-1); |
150 |
|
continue; |
151 |
|
default: |
152 |
|
*cp++ = *s; |
154 |
|
} |
155 |
|
return(0); |
156 |
|
} |
157 |
+ |
fatalerr[0] = '\0'; |
158 |
+ |
} |
159 |
+ |
|
160 |
+ |
|
161 |
+ |
static |
162 |
+ |
vga_errout(msg) |
163 |
+ |
register char *msg; |
164 |
+ |
{ |
165 |
+ |
static char *fep = fatalerr; |
166 |
+ |
|
167 |
+ |
_outtext(msg); |
168 |
+ |
while (*msg) |
169 |
+ |
*fep++ = *msg++; |
170 |
+ |
*fep = '\0'; |
171 |
+ |
if (fep > fatalerr && fep[-1] == '\n') |
172 |
+ |
fep = fatalerr; |
173 |
|
} |
174 |
|
|
175 |
|
|