1 /*-
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)open.c 8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11
12 /*
13 * Displays plot files on a AED512 graphics terminal.
14 */
15
16 #include "aed.h"
17
18 char dbuf[BUFSIZ]; /* Used to buffer display characters */
19 struct sgttyb sgttyb; /* Used to save terminal control bits */
20 int curx, cury; /* Current screen position */
21 int xbot, ybot; /* Coordinates of screen lower-left corner */
22 int scale; /* The number of pixels per 2**12 units
23 * of world coordinates.
24 */
25
26 /*
27 * The following is the color map, containing reg, green, and blue
28 * values for color locations 0 and 1.
29 */
30
31 static int colors[] = {200, 200, 200, 0, 0, 125, 125, 0, 0, 125, 0, 0};
32
33 /*---------------------------------------------------------
34 * Openpl initializes the graphics display and clears its screen.
35 *
36 * Results: None.
37 *
38 * Side Effects:
39 * The display is re-initialized and the file is remembered for
40 * use in all subsequent calls to this module. The display's
41 * color map is reset. The display is put into raw mode, but
42 * the previous mode bits are saved.
43 *
44 * Errors: None.
45 *---------------------------------------------------------
46 */
openpl()47 openpl()
48 {
49 int flags, *p, i;
50 char dum[4];
51
52 /* First, grab up the display modes, then reset them to put it
53 * into cooked mode. Also, lock the terminal.
54 */
55
56 (void) gtty(fileno(stdout), &sgttyb);
57 flags = sgttyb.sg_flags;
58 sgttyb.sg_flags = (sgttyb.sg_flags & ~(RAW | CBREAK)) | EVENP | ODDP;
59 (void) stty(fileno(stdout), &sgttyb);
60 sgttyb.sg_flags = flags;
61
62 /* Save the file pointer around for later use, then output an
63 * initialization string to the display. The initialization
64 * string resets the terminal, sets formats, clears the display,
65 * initializes the read and write masks, and sets the color map.
66 */
67
68 setbuf(stdout, dbuf);
69 fputs("\33\33G1HHHN[00LFFCFFMFFFFFFFF", stdout);
70 fputs("K0004", stdout);
71 p = colors;
72 for (i=0; i<12; i++)
73 {
74 chex(*p++, dum, 2);
75 fputs(dum, stdout);
76 }
77 fputs("^15060AL", stdout);
78 scale = 1<<12;
79 curx = cury = xbot = ybot = 0;
80 (void) fflush(stdout);
81 }
82