Commit | Line | Data |
---|---|---|
6869a338 | 1 | #ifndef lint |
adb609f3 | 2 | static char *sccsid = "@(#)tth19.c 3.10 83/12/02"; |
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 | ||
3130283e EW |
20 | #define NCOL 80 |
21 | #define NROW 24 | |
22 | ||
6869a338 EW |
23 | char h19_frame[16] = { |
24 | ' ', '`'|0x80, 'a'|0x80, 'e'|0x80, | |
25 | '`'|0x80, '`'|0x80, 'f'|0x80, 'v'|0x80, | |
26 | 'a'|0x80, 'd'|0x80, 'a'|0x80, 'u'|0x80, | |
27 | 'c'|0x80, 't'|0x80, 's'|0x80, 'b'|0x80 | |
28 | }; | |
29 | ||
3130283e EW |
30 | extern char *gen_VS; |
31 | extern char *gen_VE; | |
32 | ||
33 | char h19_graphics; /* in graphics mode */ | |
6869a338 EW |
34 | short h19_msp10c; |
35 | ||
36 | #define pc(c) putchar('c') | |
37 | #define esc() pc(\033) | |
38 | #define PAD(ms10) { \ | |
39 | register i; \ | |
40 | for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ | |
41 | pc(\0); \ | |
42 | } | |
3130283e EW |
43 | #define ICPAD() PAD((NCOL - tt.tt_col) * 1) /* 0.1 ms per char */ |
44 | #define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ | |
6869a338 EW |
45 | |
46 | #define SETINSERT(m) \ | |
3130283e EW |
47 | ((m) != tt.tt_insert \ |
48 | ? (esc(), (tt.tt_insert = (m)) ? pc(@) : pc(O)) : 0) | |
6869a338 | 49 | #define SETMODES(m) \ |
3130283e EW |
50 | ((m) != tt.tt_modes \ |
51 | ? (esc(), (tt.tt_modes = (m)) ? pc(p) : pc(q)) : 0) | |
6869a338 EW |
52 | #define SETGRAPHICS(m) \ |
53 | ((m) != h19_graphics \ | |
54 | ? (esc(), (h19_graphics = (m)) ? pc(F) : pc(G)) : 0) | |
55 | ||
6869a338 EW |
56 | h19_insline() |
57 | { | |
58 | esc(); | |
59 | pc(L); | |
60 | ILPAD(); | |
61 | } | |
62 | ||
63 | h19_delline() | |
64 | { | |
65 | esc(); | |
66 | pc(M); | |
67 | ILPAD(); | |
68 | } | |
69 | ||
70 | h19_putc(c) | |
71 | register char c; | |
72 | { | |
3130283e EW |
73 | SETMODES(tt.tt_nmodes); |
74 | SETINSERT(tt.tt_ninsert); | |
6869a338 EW |
75 | if (c & 0x80) { |
76 | SETGRAPHICS(1); | |
77 | putchar(c & 0x7f); | |
78 | } else { | |
79 | SETGRAPHICS(0); | |
80 | putchar(c); | |
81 | } | |
3130283e | 82 | if (tt.tt_insert) |
6869a338 | 83 | ICPAD(); |
3130283e EW |
84 | if (++tt.tt_col == NCOL) |
85 | tt.tt_col = NCOL - 1; | |
6869a338 EW |
86 | } |
87 | ||
3130283e EW |
88 | h19_write(p, n) |
89 | register char *p; | |
90 | register n; | |
6869a338 EW |
91 | { |
92 | register char c; | |
93 | ||
3130283e EW |
94 | SETMODES(tt.tt_nmodes); |
95 | SETINSERT(tt.tt_ninsert); | |
96 | if (tt.tt_insert) { | |
97 | while (--n >= 0) { | |
98 | if ((c = *p++) & 0x80) { | |
6869a338 EW |
99 | SETGRAPHICS(1); |
100 | putchar(c & 0x7f); | |
101 | } else { | |
102 | SETGRAPHICS(0); | |
103 | putchar(c); | |
104 | } | |
105 | ICPAD(); | |
3130283e | 106 | tt.tt_col++; |
6869a338 EW |
107 | } |
108 | } else { | |
3130283e EW |
109 | tt.tt_col += n; |
110 | while (--n >= 0) | |
111 | if ((c = *p++) & 0x80) { | |
6869a338 EW |
112 | SETGRAPHICS(1); |
113 | putchar(c & 0x7f); | |
114 | } else { | |
115 | SETGRAPHICS(0); | |
116 | putchar(c); | |
117 | } | |
118 | } | |
3130283e EW |
119 | if (tt.tt_col == NCOL) |
120 | tt.tt_col = NCOL - 1; | |
6869a338 EW |
121 | } |
122 | ||
123 | h19_move(row, col) | |
124 | register char row, col; | |
125 | { | |
3130283e EW |
126 | if (tt.tt_row == row) { |
127 | if (tt.tt_col == col) | |
6869a338 | 128 | return; |
3130283e | 129 | if (tt.tt_col == col - 1) { |
6869a338 EW |
130 | esc(); |
131 | pc(C); | |
132 | goto out; | |
3130283e | 133 | } else if (tt.tt_col == col + 1) { |
6869a338 EW |
134 | pc(\b); |
135 | goto out; | |
136 | } | |
137 | } | |
3130283e EW |
138 | if (tt.tt_col == col) { |
139 | if (tt.tt_row == row + 1) { | |
6869a338 EW |
140 | esc(); |
141 | pc(A); | |
142 | goto out; | |
adb609f3 | 143 | } else if (tt.tt_row == row - 1) { |
6869a338 EW |
144 | pc(\n); |
145 | goto out; | |
146 | } | |
147 | } | |
7aefc9fe | 148 | if (col == 0 && row == 0) { |
6869a338 EW |
149 | esc(); |
150 | pc(H); | |
151 | goto out; | |
152 | } | |
153 | esc(); | |
154 | pc(Y); | |
155 | putchar(' ' + row); | |
156 | putchar(' ' + col); | |
157 | out: | |
3130283e EW |
158 | tt.tt_col = col; |
159 | tt.tt_row = row; | |
6869a338 EW |
160 | } |
161 | ||
162 | h19_init() | |
6869a338 | 163 | { |
3130283e EW |
164 | if (gen_VS) |
165 | fputs(gen_VS, stdout); | |
6869a338 | 166 | esc(); |
c3f80cb5 | 167 | pc(w); |
6869a338 EW |
168 | esc(); |
169 | pc(E); | |
3130283e EW |
170 | tt.tt_col = tt.tt_row = 0; |
171 | tt.tt_ninsert = tt.tt_insert = 0; | |
172 | tt.tt_nmodes = tt.tt_modes = 0; | |
6869a338 | 173 | h19_graphics = 0; |
6869a338 EW |
174 | } |
175 | ||
e908bfac | 176 | h19_end() |
6869a338 EW |
177 | { |
178 | SETMODES(0); | |
179 | SETINSERT(0); | |
180 | SETGRAPHICS(0); | |
3130283e EW |
181 | if (gen_VE) |
182 | fputs(gen_VE, stdout); | |
6869a338 EW |
183 | esc(); |
184 | pc(v); | |
185 | } | |
186 | ||
187 | h19_clreol() | |
188 | { | |
189 | esc(); | |
190 | pc(K); | |
191 | } | |
192 | ||
193 | h19_clreos() | |
194 | { | |
195 | esc(); | |
196 | pc(J); | |
197 | } | |
198 | ||
199 | h19_clear() | |
200 | { | |
201 | esc(); | |
202 | pc(E); | |
203 | } | |
204 | ||
205 | h19_delchar() | |
206 | { | |
207 | esc(); | |
208 | pc(N); | |
209 | } | |
210 | ||
211 | tt_h19() | |
212 | { | |
e908bfac EW |
213 | float cpms = (float) wwbaud / 10000; /* char per ms */ |
214 | ||
215 | h19_msp10c = 10 / cpms; /* ms per 10 char */ | |
3130283e EW |
216 | gen_VS = tt_xgetstr("vs"); |
217 | gen_VE = tt_xgetstr("ve"); | |
218 | ||
219 | tt.tt_init = h19_init; | |
220 | tt.tt_end = h19_end; | |
221 | ||
6869a338 EW |
222 | tt.tt_insline = h19_insline; |
223 | tt.tt_delline = h19_delline; | |
224 | tt.tt_delchar = h19_delchar; | |
6869a338 EW |
225 | tt.tt_clreol = h19_clreol; |
226 | tt.tt_clreos = h19_clreos; | |
227 | tt.tt_clear = h19_clear; | |
228 | tt.tt_move = h19_move; | |
6869a338 EW |
229 | tt.tt_write = h19_write; |
230 | tt.tt_putc = h19_putc; | |
3130283e EW |
231 | |
232 | tt.tt_ncol = NCOL; | |
233 | tt.tt_nrow = NROW; | |
234 | tt.tt_hasinsert = 1; | |
6fc023ad | 235 | tt.tt_availmodes = WWM_REV; |
6869a338 EW |
236 | tt.tt_frame = h19_frame; |
237 | return 0; | |
238 | } |