Commit | Line | Data |
---|---|---|
6869a338 | 1 | #ifndef lint |
14f251df | 2 | static char *sccsid = "@(#)tth19.c 3.2 83/08/11"; |
6869a338 EW |
3 | #endif |
4 | ||
5 | #include "ww.h" | |
6 | ||
7 | /* | |
8 | kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith: | |
9 | cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK: | |
10 | cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB: | |
11 | ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms: | |
12 | ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4: | |
13 | kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH: | |
14 | kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW: | |
15 | l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER: | |
16 | es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1: | |
17 | */ | |
18 | ||
19 | char h19_frame[16] = { | |
20 | ' ', '`'|0x80, 'a'|0x80, 'e'|0x80, | |
21 | '`'|0x80, '`'|0x80, 'f'|0x80, 'v'|0x80, | |
22 | 'a'|0x80, 'd'|0x80, 'a'|0x80, 'u'|0x80, | |
23 | 'c'|0x80, 't'|0x80, 's'|0x80, 'b'|0x80 | |
24 | }; | |
25 | ||
26 | char h19_row, h19_col; | |
27 | char h19_modes, h19_nmodes; | |
28 | char h19_insert, h19_ninsert; | |
29 | char h19_graphics; | |
30 | short h19_msp10c; | |
31 | ||
32 | #define pc(c) putchar('c') | |
33 | #define esc() pc(\033) | |
34 | #define PAD(ms10) { \ | |
35 | register i; \ | |
36 | for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ | |
37 | pc(\0); \ | |
38 | } | |
39 | #define ICPAD() PAD((80 - h19_col) * 1) /* 0.1 ms per char */ | |
40 | #define ILPAD() PAD((24 - h19_row) * 10); /* 1 ms per char */ | |
41 | ||
42 | #define SETINSERT(m) \ | |
43 | ((m) != h19_insert \ | |
44 | ? (esc(), (h19_insert = (m)) ? pc(@) : pc(O)) : 0) | |
45 | #define SETMODES(m) \ | |
46 | ((m) != h19_modes \ | |
47 | ? (esc(), (h19_modes = (m)) ? pc(p) : pc(q)) : 0) | |
48 | #define SETGRAPHICS(m) \ | |
49 | ((m) != h19_graphics \ | |
50 | ? (esc(), (h19_graphics = (m)) ? pc(F) : pc(G)) : 0) | |
51 | ||
52 | h19_setinsert(new) | |
53 | char new; | |
54 | { | |
55 | h19_ninsert = new; | |
56 | } | |
57 | ||
58 | h19_setmodes(new) | |
59 | { | |
60 | h19_nmodes = new & WWM_REV; | |
61 | } | |
62 | ||
63 | h19_insline() | |
64 | { | |
65 | esc(); | |
66 | pc(L); | |
67 | ILPAD(); | |
68 | } | |
69 | ||
70 | h19_delline() | |
71 | { | |
72 | esc(); | |
73 | pc(M); | |
74 | ILPAD(); | |
75 | } | |
76 | ||
77 | h19_putc(c) | |
78 | register char c; | |
79 | { | |
80 | SETMODES(h19_nmodes); | |
81 | SETINSERT(h19_ninsert); | |
82 | if (c & 0x80) { | |
83 | SETGRAPHICS(1); | |
84 | putchar(c & 0x7f); | |
85 | } else { | |
86 | SETGRAPHICS(0); | |
87 | putchar(c); | |
88 | } | |
89 | if (h19_insert) | |
90 | ICPAD(); | |
91 | h19_col++; | |
92 | } | |
93 | ||
94 | h19_write(start, end) | |
95 | register char *start, *end; | |
96 | { | |
97 | register char c; | |
98 | ||
99 | SETMODES(h19_nmodes); | |
100 | SETINSERT(h19_ninsert); | |
101 | if (h19_insert) { | |
102 | while (start <= end) { | |
103 | if ((c = *start++) & 0x80) { | |
104 | SETGRAPHICS(1); | |
105 | putchar(c & 0x7f); | |
106 | } else { | |
107 | SETGRAPHICS(0); | |
108 | putchar(c); | |
109 | } | |
110 | ICPAD(); | |
111 | h19_col++; | |
112 | } | |
113 | } else { | |
114 | h19_col += end - start + 1; | |
115 | while (start <= end) | |
116 | if ((c = *start++) & 0x80) { | |
117 | SETGRAPHICS(1); | |
118 | putchar(c & 0x7f); | |
119 | } else { | |
120 | SETGRAPHICS(0); | |
121 | putchar(c); | |
122 | } | |
123 | } | |
124 | } | |
125 | ||
126 | h19_blank(n) | |
127 | register n; | |
128 | { | |
129 | if (n <= 0) | |
130 | return; | |
131 | SETMODES(h19_nmodes); | |
132 | SETINSERT(h19_ninsert); | |
133 | if (h19_insert) { | |
134 | while (--n >= 0) { | |
135 | putchar(' '); | |
136 | ICPAD(); | |
137 | h19_col++; | |
138 | } | |
139 | } else { | |
140 | h19_col += n; | |
141 | while (--n >= 0) | |
142 | putchar(' '); | |
143 | } | |
144 | } | |
145 | ||
146 | h19_move(row, col) | |
147 | register char row, col; | |
148 | { | |
149 | if (h19_row == row) { | |
150 | if (h19_col == col) | |
151 | return; | |
152 | if (h19_col == col - 1) { | |
153 | esc(); | |
154 | pc(C); | |
155 | goto out; | |
156 | } else if (h19_col == col + 1) { | |
157 | pc(\b); | |
158 | goto out; | |
159 | } | |
160 | } | |
161 | if (h19_col == col) { | |
162 | if (h19_row == row + 1) { | |
163 | esc(); | |
164 | pc(A); | |
165 | goto out; | |
166 | } else if (h19_row == row + 1) { | |
167 | pc(\n); | |
168 | goto out; | |
169 | } | |
170 | } | |
171 | if (col == 1 && row == 1) { | |
172 | esc(); | |
173 | pc(H); | |
174 | goto out; | |
175 | } | |
176 | esc(); | |
177 | pc(Y); | |
178 | putchar(' ' + row); | |
179 | putchar(' ' + col); | |
180 | out: | |
181 | h19_col = col; | |
182 | h19_row = row; | |
183 | } | |
184 | ||
185 | h19_init() | |
186 | { | |
187 | float cpms = (float) wwbaud / 10000; /* char per ms */ | |
188 | ||
189 | h19_msp10c = 10 / cpms; /* ms per 10 char */ | |
190 | #ifdef notdef | |
191 | tt.tt_ILmf = cpms; /* 1 ms */ | |
192 | tt.tt_ILov = 2; | |
193 | tt.tt_ICmf = cpms * 1.5 ; /* 1.5 ms */ | |
194 | tt.tt_ICov = 2; | |
195 | tt.tt_DCmf = 0; | |
196 | tt.tt_DCov = 2; | |
197 | #endif | |
198 | return 0; | |
199 | } | |
200 | ||
201 | h19_reset() | |
202 | { | |
203 | esc(); | |
204 | pc(x); | |
205 | pc(4); | |
206 | esc(); | |
207 | pc(E); | |
208 | esc(); | |
209 | pc(w); | |
210 | h19_col = h19_row = 0; | |
211 | h19_insert = 0; | |
212 | h19_graphics = 0; | |
213 | h19_modes = 0; | |
214 | } | |
215 | ||
216 | h19_cleanup() | |
217 | { | |
218 | SETMODES(0); | |
219 | SETINSERT(0); | |
220 | SETGRAPHICS(0); | |
221 | esc(); | |
222 | pc(y); | |
223 | pc(4); | |
224 | esc(); | |
225 | pc(v); | |
226 | } | |
227 | ||
228 | h19_clreol() | |
229 | { | |
230 | esc(); | |
231 | pc(K); | |
232 | } | |
233 | ||
234 | h19_clreos() | |
235 | { | |
236 | esc(); | |
237 | pc(J); | |
238 | } | |
239 | ||
240 | h19_clear() | |
241 | { | |
242 | esc(); | |
243 | pc(E); | |
244 | } | |
245 | ||
246 | h19_delchar() | |
247 | { | |
248 | esc(); | |
249 | pc(N); | |
250 | } | |
251 | ||
252 | tt_h19() | |
253 | { | |
254 | tt.tt_setinsert = h19_setinsert; | |
255 | tt.tt_setmodes = h19_setmodes; | |
256 | tt.tt_insline = h19_insline; | |
257 | tt.tt_delline = h19_delline; | |
258 | tt.tt_delchar = h19_delchar; | |
259 | tt.tt_blank = h19_blank; | |
260 | tt.tt_init = h19_init; | |
261 | tt.tt_cleanup = h19_cleanup; | |
262 | tt.tt_clreol = h19_clreol; | |
263 | tt.tt_clreos = h19_clreos; | |
264 | tt.tt_clear = h19_clear; | |
265 | tt.tt_move = h19_move; | |
266 | tt.tt_reset = h19_reset; | |
267 | tt.tt_write = h19_write; | |
268 | tt.tt_putc = h19_putc; | |
269 | tt.tt_ncol = 80; | |
270 | tt.tt_nrow = 24; | |
271 | tt.tt_frame = h19_frame; | |
272 | return 0; | |
273 | } |