1 /*
2  *     dcl graphic driver for tektronix emulator
3  *
4  *                         91/08/10 by S. Takehiro
5  *                         91/10/15 by M. Shiotani
6  *                         93/04/15 by A. Numaguti (wait option)
7  *                         01/08/11 by E. Toyoda
8  *
9  *    Copyright (C) 2000-2004 GFD Dennou Club. All rights reserved.
10  *
11  */
12 
13 #include <unistd.h>
14 #include "../../../config.h"
15 
16 #define WSXMNZ   30.0        /* x-coord. of w.s. window lower-left  corner */
17 #define WSXMXZ 1000.0        /* y-coord. of w.s. window lower-left  corner */
18 #define WSYMNZ   30.0        /* x-coord. of w.s. window upper-right corner */
19 #define WSYMXZ  750.0        /* y-coord. of w.s. window upper-right corner */
20 #define FACTZ     2.0        /* scaling factor */
21 #define TRUE   1             /* numeric value for true  */
22 #define FALSE  0             /* numeric value for false */
23 #define LWDATR TRUE          /* line width  capability */
24 #define LCLATR FALSE         /* line color  capability */
25 #define LTNATR FALSE         /* hard fill   capability */
26 #define LIMATR FALSE         /* bit image   capability */
27 #define LPTATR FALSE         /* mouse point capability */
28 
29 #define FF   12
30 #define CR   13
31 #define ES   27
32 #define GS   29
33 #define OP   "[?38h"
34 #define EX   "[?38l"
35 #define CL    3
36 
37 #define fgetc sys_etc
38 #define fputc sys_ptc
39 #define fputs sys_puts
40 #define puts  sys_putln
41 
42 static int iwdidz, iclidz, iwtroz, lwait;
43 
44 /* system call input/output, avoid stdio */
45 
46 #define stdin 0
47 #define stdout 1
48 
fgetc(int handle)49 int fgetc(int handle) {
50   char dummy;
51   if (read(handle, &dummy, 1) < 1)
52     return -1;
53   return dummy;
54 }
55 
fputc(int ch,int handle)56 int fputc(int ch, int handle) {
57   char c;
58   c = ch;
59   if (write(handle, &c, 1) < 1)
60     return -1;
61   return c;
62 }
63 
fputs(const char * c,int handle)64 void fputs(const char *c, int handle) {
65   size_t len, strlen();
66   len = strlen(c);
67   write(handle, c, len);
68 }
69 
puts(const char * c)70 void puts(const char *c) {
71   size_t len, strlen();
72   len = strlen(c);
73   write(1, c, len);
74   write(1, "\n", 1);
75 }
76 
77 /*---------------------internal function ------------------*/
78 
ztixiy(int ix,int iy)79 void ztixiy(int ix, int iy)
80 {
81     fputc ((iy / 32) + 32, stdout);
82     fputc ((iy % 32) + 96, stdout);
83     fputc ((ix / 32) + 32, stdout);
84     fputc ((ix % 32) + 64, stdout);
85 }
86 
87 /*------------------------- device ------------------------*/
88 
ztdopn_(DCL_INT * iwait)89 void ztdopn_(DCL_INT *iwait)
90 {
91     int C;
92 
93 /* open ( and activate ) workstation */
94 
95     lwait = *iwait;
96     if (lwait) {
97 	puts("<CR> to start Tek");
98 	C = fgetc (stdin);
99     }
100     fputc (ES, stdout);
101     fputs (OP, stdout);
102     fputc (CR, stdout);
103 }
104 
ztdcls_(void)105 void ztdcls_(void)
106 {
107 
108 /* ( deactivate and ) close workstation */
109 
110     fputc (ES, stdout);
111     fputc (CL, stdout);
112     fputc (CR, stdout);
113 
114     fputc (ES, stdout);
115     fputc (FF, stdout);
116     fputc (CR, stdout);
117 
118     fputc (ES, stdout);
119     fputs (EX, stdout);
120     fputc (CR, stdout);
121 }
122 
123 /*------------------------- page --------------------------*/
124 
ztpopn_(void)125 void ztpopn_(void)
126 {
127 
128 /* open page ( or screen ) */
129 
130     fputc (ES, stdout);
131     fputc (FF, stdout);
132     fputc (CR, stdout);
133 }
134 
ztpcls_(void)135 void ztpcls_(void)
136 {
137     int C;
138     void ztixiy();
139 
140 /* close page ( or screen ) */
141 
142     fputc (GS, stdout);
143     ztixiy (0, 50);
144     if (lwait) {
145 	puts ("\n<CR> to continue");
146 	C = fgetc (stdin);
147     }
148 }
149 
150 /*------------------------- object ------------------------*/
151 
ztoopn_(char * objname,char * comment)152 void ztoopn_(char *objname, char *comment)
153 {
154 
155 }
156 
ztocls_(char * objname)157 void ztocls_(char *objname)
158 {
159 
160 }
161 
162 /*------------------------- line --------------------------*/
163 
ztswdi_(DCL_INT * iwdidx)164 void ztswdi_(DCL_INT *iwdidx)
165 {
166 
167 /* set line width index */
168 
169 }
170 
ztscli_(DCL_INT * iclidx)171 void ztscli_(DCL_INT *iclidx)
172 {
173 
174 /* set line color index */
175 
176 }
177 
ztgopn_(void)178 void ztgopn_(void)
179 {
180 
181 /* open graphic segment */
182 
183 }
184 
ztgmov_(DCL_REAL * wx,DCL_REAL * wy)185 void ztgmov_(DCL_REAL *wx, DCL_REAL *wy)
186 {
187     int iwx, iwy;
188     void ztixiy();
189 
190 /* pen-up move */
191 
192     iwx = *wx;
193     iwy = *wy;
194     fputc (GS, stdout);
195     ztixiy (iwx, iwy);
196 }
197 
ztgplt_(DCL_REAL * wx,DCL_REAL * wy)198 void ztgplt_(DCL_REAL *wx, DCL_REAL *wy)
199 {
200     int iwx, iwy;
201     void ztixiy();
202 
203 /* pen-down move */
204 
205     iwx = *wx;
206     iwy = *wy;
207     ztixiy (iwx, iwy);
208 }
209 
ztgcls_(void)210 void ztgcls_(void)
211 {
212 
213 /* close graphic segment */
214 
215     fputc (CR, stdout);
216 }
217 
218 /*------------------------- tone --------------------------*/
219 
ztgton_(DCL_INT * np,DCL_REAL wpx[],DCL_REAL wpy[],DCL_INT * itpat)220 void ztgton_(DCL_INT *np, DCL_REAL wpx[], DCL_REAL wpy[], DCL_INT *itpat)
221 {
222 
223 /* hard fill */
224 
225 }
226 
227 /*------------------------- image -------------------------*/
228 
ztiopn_(DCL_INT * iwx,DCL_INT * iwy,DCL_INT * iwidth,DCL_INT * iheight)229 void ztiopn_(DCL_INT *iwx, DCL_INT *iwy, DCL_INT *iwidth, DCL_INT *iheight)
230 {
231 
232 }
233 
ztidat_(DCL_INT image[],DCL_INT * nlen)234 void ztidat_(DCL_INT image[], DCL_INT *nlen)
235 {
236 
237 }
238 
zticls_(void)239 void zticls_(void)
240 {
241 
242 }
243 
244 /*------------------------- mouse -------------------------*/
245 
ztqpnt_(DCL_REAL * wx,DCL_REAL * wy,DCL_INT * mb)246 void ztqpnt_(DCL_REAL *wx, DCL_REAL *wy, DCL_INT *mb)
247 {
248 
249 }
250 
251 /*---------------------- transformation -------------------*/
252 
ztfint_(DCL_REAL * wx,DCL_REAL * wy,DCL_INT * iwx,DCL_INT * iwy)253 void ztfint_(DCL_REAL *wx, DCL_REAL *wy, DCL_INT *iwx, DCL_INT *iwy)
254 {
255     *iwx = *wx;
256     *iwy = *wy;
257 }
258 
ztiint_(DCL_INT * iwx,DCL_INT * iwy,DCL_REAL * wx,DCL_REAL * wy)259 void ztiint_(DCL_INT *iwx, DCL_INT *iwy, DCL_REAL *wx, DCL_REAL *wy)
260 {
261     *wx = *iwx;
262     *wy = *iwy;
263 }
264 
265 /*------------------------- inquiry -----------------------*/
266 
ztqwdc_(DCL_INT * lwdatr)267 void ztqwdc_(DCL_INT *lwdatr)
268 {
269 
270 /* inquire line width capability */
271 
272     *lwdatr = LWDATR;
273 }
274 
ztqclc_(DCL_INT * lclatr)275 void ztqclc_(DCL_INT *lclatr)
276 {
277 
278 /* inquire line color capability */
279 
280     *lclatr = LCLATR;
281 }
282 
ztqtnc_(DCL_INT * ltnatr)283 void ztqtnc_(DCL_INT *ltnatr)
284 {
285 
286 /* inquire hard fill capability */
287 
288     *ltnatr = LTNATR;
289 }
290 
ztqimc_(DCL_INT * limatr)291 void ztqimc_(DCL_INT *limatr)
292 {
293 
294 /* inquire bit image capability */
295 
296     *limatr = LIMATR;
297 }
298 
ztqptc_(DCL_INT * lptatr)299 void ztqptc_(DCL_INT *lptatr)
300 {
301 
302 /* inquire mouse point capability */
303 
304     *lptatr = LPTATR;
305 }
306 
ztqrct_(DCL_REAL * wsxmn,DCL_REAL * wsxmx,DCL_REAL * wsymn,DCL_REAL * wsymx,DCL_REAL * fact)307 void ztqrct_(DCL_REAL *wsxmn, DCL_REAL *wsxmx, DCL_REAL *wsymn, DCL_REAL *wsymx, DCL_REAL *fact)
308 {
309 
310 /* inquire workstation rectangle */
311 
312     *wsxmn = WSXMNZ;
313     *wsxmx = WSXMXZ;
314     *wsymn = WSYMNZ;
315     *wsymx = WSYMXZ;
316     *fact  = FACTZ;
317 }
318 
ztsrot_(DCL_INT * iwtrot)319 void ztsrot_(DCL_INT *iwtrot)
320 {
321 
322 /* set frame rotation flag */
323 
324     iwtroz = *iwtrot;
325 }
326