nata: process interrupt even if busmaster active bit is set
[dragonfly.git] / usr.bin / window / tth19.c
blob240bf6683d4859d67f61e38fe2148b105e276c18
1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * @(#)tth19.c 8.1 (Berkeley) 6/6/93
37 * $FreeBSD: src/usr.bin/window/tth19.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $
38 * $DragonFly: src/usr.bin/window/tth19.c,v 1.2 2003/06/17 04:29:34 dillon Exp $
41 #include "ww.h"
42 #include "tt.h"
43 #include "char.h"
46 kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith:
47 cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK:
48 cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB:
49 ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms:
50 ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:
51 kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:
52 kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:
53 l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:
54 es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1:
57 #define NCOL 80
58 #define NROW 24
60 #define G (WWM_GRP << WWC_MSHIFT)
61 short h19_frame[16] = {
62 ' ', '`'|G, 'a'|G, 'e'|G,
63 '`'|G, '`'|G, 'f'|G, 'v'|G,
64 'a'|G, 'd'|G, 'a'|G, 'u'|G,
65 'c'|G, 't'|G, 's'|G, 'b'|G
68 extern struct tt_str *gen_VS;
69 extern struct tt_str *gen_VE;
71 int h19_msp10c;
73 #define PAD(ms10) { \
74 register i; \
75 for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
76 ttputc('\0'); \
78 #define ICPAD() PAD((NCOL - tt.tt_col) * 1) /* 0.1 ms per char */
79 #define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
81 #define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O')
83 h19_setmodes(new)
84 register new;
86 register diff;
88 diff = new ^ tt.tt_modes;
89 if (diff & WWM_REV)
90 ttesc(new & WWM_REV ? 'p' : 'q');
91 if (diff & WWM_GRP)
92 ttesc(new & WWM_REV ? 'F' : 'G');
93 tt.tt_modes = new;
96 h19_insline(n)
98 while (--n >= 0) {
99 ttesc('L');
100 ILPAD();
104 h19_delline(n)
106 while (--n >= 0) {
107 ttesc('M');
108 ILPAD();
112 h19_putc(c)
113 register char c;
115 if (tt.tt_nmodes != tt.tt_modes)
116 (*tt.tt_setmodes)(tt.tt_nmodes);
117 if (tt.tt_insert)
118 H19_SETINSERT(0);
119 ttputc(c);
120 if (++tt.tt_col == NCOL)
121 tt.tt_col = NCOL - 1;
124 h19_write(p, n)
125 register char *p;
126 register n;
128 if (tt.tt_nmodes != tt.tt_modes)
129 (*tt.tt_setmodes)(tt.tt_nmodes);
130 if (tt.tt_insert)
131 H19_SETINSERT(0);
132 ttwrite(p, n);
133 tt.tt_col += n;
134 if (tt.tt_col == NCOL)
135 tt.tt_col = NCOL - 1;
138 h19_move(row, col)
139 register char row, col;
141 if (tt.tt_row == row) {
142 if (tt.tt_col == col)
143 return;
144 if (col == 0) {
145 ttctrl('m');
146 goto out;
148 if (tt.tt_col == col - 1) {
149 ttesc('C');
150 goto out;
152 if (tt.tt_col == col + 1) {
153 ttctrl('h');
154 goto out;
157 if (tt.tt_col == col) {
158 if (tt.tt_row == row + 1) {
159 ttesc('A');
160 goto out;
162 if (tt.tt_row == row - 1) {
163 ttctrl('j');
164 goto out;
167 if (col == 0 && row == 0) {
168 ttesc('H');
169 goto out;
171 ttesc('Y');
172 ttputc(' ' + row);
173 ttputc(' ' + col);
174 out:
175 tt.tt_col = col;
176 tt.tt_row = row;
179 h19_start()
181 if (gen_VS)
182 ttxputs(gen_VS);
183 ttesc('w');
184 ttesc('E');
185 tt.tt_col = tt.tt_row = 0;
186 tt.tt_insert = 0;
187 tt.tt_nmodes = tt.tt_modes = 0;
190 h19_end()
192 if (tt.tt_insert)
193 H19_SETINSERT(0);
194 if (gen_VE)
195 ttxputs(gen_VE);
196 ttesc('v');
199 h19_clreol()
201 ttesc('K');
204 h19_clreos()
206 ttesc('J');
209 h19_clear()
211 ttesc('E');
214 h19_inschar(c)
215 register char c;
217 if (tt.tt_nmodes != tt.tt_modes)
218 (*tt.tt_setmodes)(tt.tt_nmodes);
219 if (!tt.tt_insert)
220 H19_SETINSERT(1);
221 ttputc(c);
222 if (tt.tt_insert)
223 ICPAD();
224 if (++tt.tt_col == NCOL)
225 tt.tt_col = NCOL - 1;
228 h19_delchar(n)
230 while (--n >= 0)
231 ttesc('N');
234 h19_scroll_down(n)
236 h19_move(NROW - 1, 0);
237 while (--n >= 0)
238 ttctrl('j');
241 h19_scroll_up(n)
243 h19_move(0, 0);
244 while (--n >= 0)
245 ttesc('I');
248 tt_h19()
250 float cpms = (float) wwbaud / 10000; /* char per ms */
252 h19_msp10c = 10 / cpms; /* ms per 10 char */
253 gen_VS = ttxgetstr("vs");
254 gen_VE = ttxgetstr("ve");
256 tt.tt_start = h19_start;
257 tt.tt_end = h19_end;
259 tt.tt_insline = h19_insline;
260 tt.tt_delline = h19_delline;
261 tt.tt_inschar = h19_inschar;
262 tt.tt_delchar = h19_delchar;
263 tt.tt_clreol = h19_clreol;
264 tt.tt_clreos = h19_clreos;
265 tt.tt_clear = h19_clear;
266 tt.tt_move = h19_move;
267 tt.tt_write = h19_write;
268 tt.tt_putc = h19_putc;
269 tt.tt_scroll_down = h19_scroll_down;
270 tt.tt_scroll_up = h19_scroll_up;
271 tt.tt_setmodes = h19_setmodes;
273 tt.tt_ncol = NCOL;
274 tt.tt_nrow = NROW;
275 tt.tt_availmodes = WWM_REV|WWM_GRP;
276 tt.tt_frame = h19_frame;
277 return 0;