1 /* This file is part of the GNU plotutils package.  Copyright (C) 1995,
2    1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
3 
4    The GNU plotutils package is free software.  You may redistribute it
5    and/or modify it under the terms of the GNU General Public License as
6    published by the Free Software foundation; either version 2, or (at your
7    option) any later version.
8 
9    The GNU plotutils package is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with the GNU plotutils package; see the file COPYING.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17    Boston, MA 02110-1301, USA. */
18 
19 /* This file contains a low-level routine for shifting a Tektronix graphics
20    device to a specified display mode, by emitting an escape sequence if
21    necessary. */
22 
23 /* Basic Tektronix modes are alpha mode (for drawing alphanumeric
24    characters in any of four character sizes), ``graph mode'' i.e. vector
25    plot mode (for drawing line segments), and GIN (graphics input) mode,
26    which requests a cursor location from the user.  The EGM (enhanced
27    graphics module), besides increasing the addressable point from 0..1023
28    x 0..1023 to 0..4095 x 0..4095, added three additional modes: point plot
29    mode, special point plot mode, and incremental plot mode.
30 
31    Switching among the three basic modes is accomplished thus:
32 
33    US, CR, or ESC FF: enter alpha mode (CR repositions cursor to left edge,
34    	and ESC FF homes it)
35    GS: enter graph mode
36    ESC ENQ: enquire cursor location (works in both alpha, graph mode),
37 	i.e. temporarily enter GIN mode and back out.  In alpha mode
38 	cursor location is lower left corner of flickerint 8x9 cursor.
39    ESC SUB: enter GIN mode, turn on positionable crosshair cursor
40         and send address in response to ESC ENQ.  Thumbwheels
41 	(potentiometers located on the keyboard) were used for positioning.
42 
43    Getting back to alpha / graph mode from GIN is complicated; it's
44    best to send a US or GS to ensure this happens.
45 
46    A genuine 4014 doesn't normally plot the first vector drawn after graph
47    mode is entered via GS (it's ``dark vector'').  To get it plotted, you
48    need to issue a BEL, VT, HT, LF, CR or BS immediately after issuing the
49    GS.  Only the first of these (BEL) won't disturb the location of the
50    graphics cursor.
51 
52    If the EGM is present, we also have:
53 
54    FS: enter point plot mode
55    RS: enter incremental mode
56    ESC FS: enter special point plot mode
57 
58    Point plot commands are identical to vector plot commands (the endpoint
59    of the vector is drawn).  Incremental plot mode allows motion by one
60    unit in any of 8 directions, on receipt of a single byte.  First byte
61    after RS must be a beam-off or beam-on command.
62 
63    In special point plot mode, the byte after the ESC FS (and the byte
64    which precedes every point address thereafter) is interpreted as an
65    intensity character, which determines the on-time of the beam.  It is
66    loaded into an intensity register.  This allows control of the dot size
67    (focused vs. unfocused), and brightness, in any of these three new
68    modes.
69 
70    The user can also control the trichotomy normal z-axis (i.e. focused
71    beam) / defocused z-axis (i.e. defocused beam) / write-thru mode (see
72    tek2plot.c for the control codes used for this).  Write-thru simply
73    means that written data, whether alpha characters or vectors, are
74    written to screen but are not refreshed.  So they appear briefly and
75    then vanish (unless they are refreshed under user control, by drawing
76    them repeatedly).
77 
78    WARNING: it is a peculiarity of the 4014 that in the following list,
79    one can mode-switch only _downward_, not upward!  The exception is
80    that one can always switch up to alpha mode.
81 
82    	alpha mode
83 	vector mode
84 	point plot mode
85 	special point plot mode
86 	incremental plot mode.
87 
88    Control codes that would switch `upward' are ignored.  GIN mode can be
89    switched into from any mode, however.
90 */
91 
92 #include "sys-defines.h"
93 #include "extern.h"
94 
95 void
_pl_t_tek_mode(R___ (Plotter * _plotter)int newmode)96 _pl_t_tek_mode(R___(Plotter *_plotter) int newmode)
97 {
98   if (_plotter->tek_mode_is_unknown || _plotter->tek_mode != newmode)
99     /* need to emit escape sequence */
100     {
101       switch (newmode)
102 	{
103 	case TEK_MODE_ALPHA:
104 	  /* ASCII US, i.e. ^_ (enter alpha mode) */
105 	  _write_byte (_plotter->data, '\037');
106 	  break;
107 	case TEK_MODE_PLOT:
108 	  if ((_plotter->tek_mode_is_unknown)
109 	      || (_plotter->tek_mode == TEK_MODE_POINT)
110 	      || (_plotter->tek_mode == TEK_MODE_INCREMENTAL))
111 	    /* ASCII US, i.e. ^_ (enter alpha) */
112 	    _write_byte (_plotter->data, '\037');
113 	  /* ASCII GS, i.e. ^] (enter vector mode)*/
114 	  _write_byte (_plotter->data, '\035');
115 	  break;
116 	case TEK_MODE_POINT:
117 	  if ((_plotter->tek_mode_is_unknown) ||
118 	      (_plotter->tek_mode == TEK_MODE_INCREMENTAL))
119 	    /* ASCII US, i.e. ^_ (enter alpha) */
120 	    _write_byte (_plotter->data, '\037');
121 	  /* ASCII FS, i.e. ^\ (enter point mode) */
122 	  _write_byte (_plotter->data, '\034');
123 	  break;
124 	case TEK_MODE_INCREMENTAL:
125 	  /* ASCII RS, i.e. ^^ (enter incplot mode)*/
126 	  _write_byte (_plotter->data, '\036');
127 	  break;
128 	default:
129 	  break;
130 	}
131 
132       /* Tektronix is now in specified internal state */
133       _plotter->tek_mode = newmode;
134       _plotter->tek_mode_is_unknown = false;
135     }
136 }
137