-
Notifications
You must be signed in to change notification settings - Fork 12
/
TrmTEK4025.c
198 lines (173 loc) · 4.22 KB
/
TrmTEK4025.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* Terminal control module for Tektronix 4025 */
/******** THIS CODE HAS NOT BEEN FULLY DEBUGGED *********/
/* Tektronix makes great scopes, but their terminals are another thing */
/* entirely. This was written so no one else will have to waste their */
/* time on it. -- TVR/Feb81 */
/* Rewritten from Concept-100 driver (which was copyright 1981,1980 by */
/* James Gosling) */
/* Modified: 26 Feb 81 (JCMogul) - defines null HLmode rather than as zero */
#include <stdio.h>
#include "display.h"
static
int curX, curY;
static
int WindowSize;
static
char tekesc;
static
enum IDmode { m_insert = 1, m_overwrite = 0 }
CurMode;
static
INSmode (new)
enum IDmode new; {
CurMode = new;
};
static
HLmodeNull(on)
{ /* TVR - I don't know how to do this */
}
static
inslines (n) {
/* Stupid TEK4025 does insert AFTER cursor. Can't insert at line 1!!! */
/* We compensate by putting line 1 offscreen. Sigh... See 'topos' */
if (curY>1)
printf ("\013%cILI %d\r",tekesc,n);
else
printf ("\013%cILI %d%cRUP\r",tekesc,n,tekesc);
};
static
dellines (n) {
printf ("%cDLI %d\r",tekesc,n);
};
static
writechars (start, end)
register char *start,
*end; {
if (CurMode == m_insert) {
printf ("%cICH\r",tekesc);
}
while (start <= end) {
putchar (*start++);
curX++;
}
if (CurMode == m_insert) {
printf("%cICH\r",tekesc);
}
};
static
blanks (n) {
/* See 'writechars' for remarks about insert mode. */
/* We could optimize here by sending tabs, which erase. */
if (CurMode == m_insert) {
printf ("%cICH\r",tekesc);
}
while (--n >=0) {
putchar (' ');
curX++;
}
if (CurMode == m_insert) {
printf("%cICH\r", tekesc);
}
};
static float BaudFactor;
static pad(n,f)
float f; {
register k = n * f * BaudFactor;
while (--k >= 0)
putchar (0);
};
static
topos (row, column) register row, column; {
/* CAUTION: Because Insert Line won't work on the top line, display is */
/* used with screen rolled up one line, so logical line 1 is */
/* the terminal's line 2. But either due to a firmware bug */
/* (or brain damage in the microprogrammer), it can't do abs. */
/* cursor positioning anyway. However, it can go move the */
/* cursor by a numeric amount. */
if (curX > 80) {
curX = curX - 80;
curY++;
}
if (curY == row) {
if (curX == column)
return;
if (curX == column + 1) {
putchar (010);
goto done;
}
}
/* I couldn't get LF to do the right thing, although i'm not sure */
/* why. Maybe you know more than i. TVR/Feb81 */
if (row < curY) printf("%cUP %d\r",tekesc,curY-row);
else if (row > curY) printf("%cDOW %d\r",tekesc,row-curY);
if (column > curX) printf("%cRIG %d\r",tekesc,column-curX);
else if (column < curX - 7) printf("%cLEF %d\r",tekesc,curX-column);
else while (column < curX) {
putchar(010);
curX--;
};
done:
curX = column;
curY = row;
};
static
init (BaudRate) {
BaudFactor = 1 / (1 - (.45 +.3 * BaudRate / 9600.)) * (BaudRate / 10000.);
};
static
reset () {
tekesc = 28; /* What VI uses. We could use something else. */
printf ("%cCLE",tekesc);
wipescreen();
CurMode = m_overwrite;
};
static
cleanup () {
wipescreen();
};
static
wipeline () {
register cnt = 80 - curX;
if (curX == 1) {
dellines (1);
inslines (1);
}
else {
while (--cnt >= 0) { putchar(' '); };
printf("%cLEF %d\r",tekesc,80 - curX);
}
};
static
wipescreen () {
printf ("%cERA%cDOW 35%cUP 34\r",tekesc,tekesc,tekesc);
curX = curY = 1;
};
static
delchars (n) {
printf ("%cDCH %d\r",tekesc,n);
};
TrmTEK4025 () {
tt.t_INSmode = INSmode;
tt.t_HLmode = HLmodeNull;
tt.t_inslines = inslines;
tt.t_dellines = dellines;
tt.t_blanks = blanks;
tt.t_init = init;
tt.t_cleanup = cleanup;
tt.t_wipeline = wipeline;
tt.t_wipescreen = wipescreen;
tt.t_topos = topos;
tt.t_reset = reset;
tt.t_delchars = delchars;
tt.t_writechars = writechars;
tt.t_window = 0;
tt.t_ILmf = 0;
tt.t_ILov = 9;
tt.t_ICmf = 1;
tt.t_ICov = 4;
tt.t_DCmf = 2;
tt.t_DCov = 0;
tt.t_length = 34;
tt.t_width = 80;
tt.t_modeline = 0; /* no highlighting anyway */
}