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