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