bmd.c revision 1.1 1 1.1 tsutsui /* $NetBSD: bmd.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */
2 1.1 tsutsui
3 1.1 tsutsui /*
4 1.1 tsutsui * Copyright (c) 1992 OMRON Corporation.
5 1.1 tsutsui *
6 1.1 tsutsui * This code is derived from software contributed to Berkeley by
7 1.1 tsutsui * OMRON Corporation.
8 1.1 tsutsui *
9 1.1 tsutsui * Redistribution and use in source and binary forms, with or without
10 1.1 tsutsui * modification, are permitted provided that the following conditions
11 1.1 tsutsui * are met:
12 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright
13 1.1 tsutsui * notice, this list of conditions and the following disclaimer.
14 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the
16 1.1 tsutsui * documentation and/or other materials provided with the distribution.
17 1.1 tsutsui * 3. All advertising materials mentioning features or use of this software
18 1.1 tsutsui * must display the following acknowledgement:
19 1.1 tsutsui * This product includes software developed by the University of
20 1.1 tsutsui * California, Berkeley and its contributors.
21 1.1 tsutsui * 4. Neither the name of the University nor the names of its contributors
22 1.1 tsutsui * may be used to endorse or promote products derived from this software
23 1.1 tsutsui * without specific prior written permission.
24 1.1 tsutsui *
25 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 tsutsui * SUCH DAMAGE.
36 1.1 tsutsui *
37 1.1 tsutsui * @(#)bmd.c 8.2 (Berkeley) 8/15/93
38 1.1 tsutsui */
39 1.1 tsutsui /*
40 1.1 tsutsui * Copyright (c) 1992, 1993
41 1.1 tsutsui * The Regents of the University of California. All rights reserved.
42 1.1 tsutsui *
43 1.1 tsutsui * This code is derived from software contributed to Berkeley by
44 1.1 tsutsui * OMRON Corporation.
45 1.1 tsutsui *
46 1.1 tsutsui * Redistribution and use in source and binary forms, with or without
47 1.1 tsutsui * modification, are permitted provided that the following conditions
48 1.1 tsutsui * are met:
49 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright
50 1.1 tsutsui * notice, this list of conditions and the following disclaimer.
51 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the
53 1.1 tsutsui * documentation and/or other materials provided with the distribution.
54 1.1 tsutsui * 3. Neither the name of the University nor the names of its contributors
55 1.1 tsutsui * may be used to endorse or promote products derived from this software
56 1.1 tsutsui * without specific prior written permission.
57 1.1 tsutsui *
58 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.1 tsutsui * SUCH DAMAGE.
69 1.1 tsutsui *
70 1.1 tsutsui * @(#)bmd.c 8.2 (Berkeley) 8/15/93
71 1.1 tsutsui */
72 1.1 tsutsui /*
73 1.1 tsutsui
74 1.1 tsutsui * bmd.c --- Bitmap-Display raw-level driver routines
75 1.1 tsutsui *
76 1.1 tsutsui * by A.Fujita, SEP-09-1992
77 1.1 tsutsui */
78 1.1 tsutsui
79 1.1 tsutsui
80 1.1 tsutsui #include <sys/param.h>
81 1.1 tsutsui #include <sys/systm.h>
82 1.1 tsutsui #include <luna68k/stand/boot/samachdep.h>
83 1.1 tsutsui
84 1.1 tsutsui #define isprint(c) ( c < 0x20 ? 0 : 1)
85 1.1 tsutsui
86 1.1 tsutsui /*
87 1.1 tsutsui * RFCNT register
88 1.1 tsutsui */
89 1.1 tsutsui
90 1.1 tsutsui union bmd_rfcnt {
91 1.1 tsutsui struct {
92 1.1 tsutsui short rfc_hcnt;
93 1.1 tsutsui short rfc_vcnt;
94 1.1 tsutsui } p;
95 1.1 tsutsui uint32_t u;
96 1.1 tsutsui };
97 1.1 tsutsui
98 1.1 tsutsui
99 1.1 tsutsui /*
100 1.1 tsutsui * Width & Hight
101 1.1 tsutsui */
102 1.1 tsutsui
103 1.1 tsutsui #define PB_WIDTH 2048 /* Plane Width (Bit) */
104 1.1 tsutsui #define PB_HIGHT 1024 /* Plane Hight (Bit) */
105 1.1 tsutsui #define PL_WIDTH 64 /* Plane Width (long) */
106 1.1 tsutsui #define PS_WIDTH 128 /* Plane Width (long) */
107 1.1 tsutsui #define P_WIDTH 256 /* Plane Width (Byte) */
108 1.1 tsutsui
109 1.1 tsutsui #define SB_WIDTH 1280 /* Screen Width (Bit) */
110 1.1 tsutsui #define SB_HIGHT 1024 /* Screen Hight (Bit) */
111 1.1 tsutsui #define SL_WIDTH 40 /* Screen Width (Long) */
112 1.1 tsutsui #define S_WIDTH 160 /* Screen Width (Byte) */
113 1.1 tsutsui
114 1.1 tsutsui #define FB_WIDTH 12 /* Font Width (Bit) */
115 1.1 tsutsui #define FB_HIGHT 20 /* Font Hight (Bit) */
116 1.1 tsutsui
117 1.1 tsutsui
118 1.1 tsutsui #define NEXT_LINE(addr) ( addr + (PL_WIDTH * FB_HIGHT) )
119 1.1 tsutsui #define SKIP_NEXT_LINE(addr) ( addr += (PL_WIDTH - SL_WIDTH) )
120 1.1 tsutsui
121 1.1 tsutsui
122 1.1 tsutsui void bmd_add_new_line(void);
123 1.1 tsutsui
124 1.1 tsutsui void bmd_draw_char(char *, char *, int, int, int);
125 1.1 tsutsui void bmd_reverse_char(char *, char *, int, int);
126 1.1 tsutsui void bmd_erase_char(char *, char *, int, int);
127 1.1 tsutsui void bmd_erase_screen(volatile u_long *);
128 1.1 tsutsui void bmd_scroll_screen(volatile u_long *, volatile u_long *,
129 1.1 tsutsui int, int, int, int);
130 1.1 tsutsui
131 1.1 tsutsui
132 1.1 tsutsui struct bmd_linec {
133 1.1 tsutsui struct bmd_linec *bl_next;
134 1.1 tsutsui struct bmd_linec *bl_prev;
135 1.1 tsutsui int bl_col;
136 1.1 tsutsui int bl_end;
137 1.1 tsutsui u_char bl_line[128];
138 1.1 tsutsui };
139 1.1 tsutsui
140 1.1 tsutsui struct bmd_softc {
141 1.1 tsutsui int bc_stat;
142 1.1 tsutsui char *bc_raddr;
143 1.1 tsutsui char *bc_waddr;
144 1.1 tsutsui int bc_xmin;
145 1.1 tsutsui int bc_xmax;
146 1.1 tsutsui int bc_ymin;
147 1.1 tsutsui int bc_ymax;
148 1.1 tsutsui int bc_col;
149 1.1 tsutsui int bc_row;
150 1.1 tsutsui struct bmd_linec *bc_bl;
151 1.1 tsutsui char bc_escseq[8];
152 1.1 tsutsui char *bc_esc;
153 1.1 tsutsui void (*bc_escape)(int);
154 1.1 tsutsui };
155 1.1 tsutsui
156 1.1 tsutsui #define STAT_NORMAL 0x0000
157 1.1 tsutsui #define STAT_ESCAPE 0x0001
158 1.1 tsutsui #define STAT_INSERT 0x0100
159 1.1 tsutsui
160 1.1 tsutsui struct bmd_softc bmd_softc;
161 1.1 tsutsui struct bmd_linec bmd_linec[52];
162 1.1 tsutsui
163 1.1 tsutsui void bmd_escape(int);
164 1.1 tsutsui void bmd_escape_0(int);
165 1.1 tsutsui void bmd_escape_1(int);
166 1.1 tsutsui
167 1.1 tsutsui
168 1.1 tsutsui /*
169 1.1 tsutsui * Escape-Sequence
170 1.1 tsutsui */
171 1.1 tsutsui
172 1.1 tsutsui void
173 1.1 tsutsui bmd_escape(int c)
174 1.1 tsutsui {
175 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
176 1.1 tsutsui
177 1.1 tsutsui switch (c) {
178 1.1 tsutsui
179 1.1 tsutsui case '[':
180 1.1 tsutsui bp->bc_escape = bmd_escape_0;
181 1.1 tsutsui break;
182 1.1 tsutsui
183 1.1 tsutsui default:
184 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
185 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
186 1.1 tsutsui bp->bc_escape = bmd_escape;
187 1.1 tsutsui break;
188 1.1 tsutsui }
189 1.1 tsutsui }
190 1.1 tsutsui
191 1.1 tsutsui void
192 1.1 tsutsui bmd_escape_0(int c)
193 1.1 tsutsui {
194 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
195 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
196 1.1 tsutsui
197 1.1 tsutsui switch (c) {
198 1.1 tsutsui
199 1.1 tsutsui case 'A':
200 1.1 tsutsui if (bp->bc_row > bp->bc_ymin) {
201 1.1 tsutsui bp->bc_row--;
202 1.1 tsutsui }
203 1.1 tsutsui break;
204 1.1 tsutsui
205 1.1 tsutsui case 'C':
206 1.1 tsutsui if (bq->bl_col < bp->bc_xmax - 1) {
207 1.1 tsutsui bq->bl_col++;
208 1.1 tsutsui }
209 1.1 tsutsui break;
210 1.1 tsutsui
211 1.1 tsutsui case 'K':
212 1.1 tsutsui if (bq->bl_col < bp->bc_xmax) {
213 1.1 tsutsui int col;
214 1.1 tsutsui for (col = bq->bl_col; col < bp->bc_xmax; col++)
215 1.1 tsutsui bmd_erase_char(bp->bc_raddr,
216 1.1 tsutsui bp->bc_waddr,
217 1.1 tsutsui col, bp->bc_row);
218 1.1 tsutsui }
219 1.1 tsutsui bq->bl_end = bq->bl_col;
220 1.1 tsutsui break;
221 1.1 tsutsui
222 1.1 tsutsui case 'H':
223 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
224 1.1 tsutsui bp->bc_row = bp->bc_ymin;
225 1.1 tsutsui break;
226 1.1 tsutsui
227 1.1 tsutsui default:
228 1.1 tsutsui /*
229 1.1 tsutsui *bp->bc_esc++ = c;
230 1.1 tsutsui bp->bc_escape = bmd_escape_1;
231 1.1 tsutsui return;
232 1.1 tsutsui */
233 1.1 tsutsui break;
234 1.1 tsutsui }
235 1.1 tsutsui
236 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
237 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
238 1.1 tsutsui bp->bc_escape = bmd_escape;
239 1.1 tsutsui }
240 1.1 tsutsui
241 1.1 tsutsui void
242 1.1 tsutsui bmd_escape_1(int c)
243 1.1 tsutsui {
244 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
245 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
246 1.1 tsutsui int col = 0, row = 0;
247 1.1 tsutsui char *p;
248 1.1 tsutsui
249 1.1 tsutsui switch (c) {
250 1.1 tsutsui
251 1.1 tsutsui case 'J':
252 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
253 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
254 1.1 tsutsui bp->bc_escape = bmd_escape;
255 1.1 tsutsui break;
256 1.1 tsutsui
257 1.1 tsutsui case 'H':
258 1.1 tsutsui for (p = &bp->bc_escseq[0]; *p != ';'; p++)
259 1.1 tsutsui row = (row * 10) + (*p - 0x30);
260 1.1 tsutsui p++;
261 1.1 tsutsui for (p = &bp->bc_escseq[0]; p != bp->bc_esc; p++)
262 1.1 tsutsui col = (col * 10) + (*p - 0x30);
263 1.1 tsutsui
264 1.1 tsutsui bq->bl_col = col + bp->bc_xmin;
265 1.1 tsutsui bp->bc_row = row + bp->bc_ymin;
266 1.1 tsutsui
267 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
268 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
269 1.1 tsutsui bp->bc_escape = bmd_escape;
270 1.1 tsutsui break;
271 1.1 tsutsui
272 1.1 tsutsui default:
273 1.1 tsutsui *bp->bc_esc++ = c;
274 1.1 tsutsui break;
275 1.1 tsutsui }
276 1.1 tsutsui }
277 1.1 tsutsui
278 1.1 tsutsui
279 1.1 tsutsui /*
280 1.1 tsutsui * Entry Routine
281 1.1 tsutsui */
282 1.1 tsutsui
283 1.1 tsutsui void
284 1.1 tsutsui bmdinit(void)
285 1.1 tsutsui {
286 1.1 tsutsui volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000;
287 1.1 tsutsui volatile long *bmd_bmsel = (long *)0xB1040000;
288 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
289 1.1 tsutsui struct bmd_linec *bq;
290 1.1 tsutsui int i;
291 1.1 tsutsui union bmd_rfcnt rfcnt;
292 1.1 tsutsui
293 1.1 tsutsui /*
294 1.1 tsutsui * adjust plane position
295 1.1 tsutsui */
296 1.1 tsutsui
297 1.1 tsutsui bp->bc_raddr = (char *) 0xB10C0008; /* plane-0 hardware address */
298 1.1 tsutsui bp->bc_waddr = (char *) 0xB1080008; /* common bitmap hardware address */
299 1.1 tsutsui rfcnt.p.rfc_hcnt = 7; /* shift left 16 dot */
300 1.1 tsutsui rfcnt.p.rfc_vcnt = -27; /* shift down 1 dot */
301 1.1 tsutsui *bmd_rfcnt = rfcnt.u;
302 1.1 tsutsui
303 1.1 tsutsui bp->bc_stat = STAT_NORMAL;
304 1.1 tsutsui
305 1.1 tsutsui bp->bc_xmin = 8;
306 1.1 tsutsui bp->bc_xmax = 96;
307 1.1 tsutsui bp->bc_ymin = 2;
308 1.1 tsutsui bp->bc_ymax = 48;
309 1.1 tsutsui
310 1.1 tsutsui bp->bc_row = bp->bc_ymin;
311 1.1 tsutsui
312 1.1 tsutsui for (i = bp->bc_ymin; i < bp->bc_ymax; i++) {
313 1.1 tsutsui bmd_linec[i].bl_next = &bmd_linec[i+1];
314 1.1 tsutsui bmd_linec[i].bl_prev = &bmd_linec[i-1];
315 1.1 tsutsui }
316 1.1 tsutsui bmd_linec[bp->bc_ymax-1].bl_next = &bmd_linec[bp->bc_ymin];
317 1.1 tsutsui bmd_linec[bp->bc_ymin].bl_prev = &bmd_linec[bp->bc_ymax-1];
318 1.1 tsutsui
319 1.1 tsutsui bq = bp->bc_bl = &bmd_linec[bp->bc_ymin];
320 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
321 1.1 tsutsui
322 1.1 tsutsui bp->bc_col = bp->bc_xmin;
323 1.1 tsutsui
324 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
325 1.1 tsutsui bp->bc_escape = bmd_escape;
326 1.1 tsutsui
327 1.1 tsutsui *bmd_bmsel = 0xff; /* all planes */
328 1.1 tsutsui bmd_erase_screen((u_long *) bp->bc_waddr); /* clear screen */
329 1.1 tsutsui *bmd_bmsel = 0x01; /* 1 plane */
330 1.1 tsutsui
331 1.1 tsutsui /* turn on cursole */
332 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
333 1.1 tsutsui bp->bc_waddr,
334 1.1 tsutsui bq->bl_col, bp->bc_row);
335 1.1 tsutsui }
336 1.1 tsutsui
337 1.1 tsutsui void
338 1.1 tsutsui bmdadjust(short hcnt, short vcnt)
339 1.1 tsutsui {
340 1.1 tsutsui volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000;
341 1.1 tsutsui union bmd_rfcnt rfcnt;
342 1.1 tsutsui
343 1.1 tsutsui printf("bmdadjust: hcnt = %d, vcnt = %d\n", hcnt, vcnt);
344 1.1 tsutsui
345 1.1 tsutsui rfcnt.p.rfc_hcnt = hcnt; /* shift left 16 dot */
346 1.1 tsutsui rfcnt.p.rfc_vcnt = vcnt; /* shift down 1 dot */
347 1.1 tsutsui
348 1.1 tsutsui *bmd_rfcnt = rfcnt.u;
349 1.1 tsutsui }
350 1.1 tsutsui
351 1.1 tsutsui int
352 1.1 tsutsui bmdputc(int c)
353 1.1 tsutsui {
354 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
355 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
356 1.1 tsutsui int i;
357 1.1 tsutsui
358 1.1 tsutsui c &= 0x7F;
359 1.1 tsutsui /* turn off cursole */
360 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
361 1.1 tsutsui bp->bc_waddr,
362 1.1 tsutsui bq->bl_col, bp->bc_row);
363 1.1 tsutsui /* do escape-sequence */
364 1.1 tsutsui if (bp->bc_stat & STAT_ESCAPE) {
365 1.1 tsutsui *bp->bc_esc++ = c;
366 1.1 tsutsui (*bp->bc_escape)(c);
367 1.1 tsutsui goto done;
368 1.1 tsutsui }
369 1.1 tsutsui
370 1.1 tsutsui if (isprint(c)) {
371 1.1 tsutsui bmd_draw_char(bp->bc_raddr, bp->bc_waddr,
372 1.1 tsutsui bq->bl_col, bp->bc_row, c);
373 1.1 tsutsui bq->bl_col++;
374 1.1 tsutsui bq->bl_end++;
375 1.1 tsutsui if (bq->bl_col >= bp->bc_xmax) {
376 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
377 1.1 tsutsui bp->bc_row++;
378 1.1 tsutsui if (bp->bc_row >= bp->bc_ymax) {
379 1.1 tsutsui bmd_scroll_screen((u_long *) bp->bc_raddr,
380 1.1 tsutsui (u_long *) bp->bc_waddr,
381 1.1 tsutsui bp->bc_xmin, bp->bc_xmax,
382 1.1 tsutsui bp->bc_ymin, bp->bc_ymax);
383 1.1 tsutsui
384 1.1 tsutsui bp->bc_row = bp->bc_ymax - 1;
385 1.1 tsutsui }
386 1.1 tsutsui }
387 1.1 tsutsui } else {
388 1.1 tsutsui switch (c) {
389 1.1 tsutsui case 0x08: /* BS */
390 1.1 tsutsui if (bq->bl_col > bp->bc_xmin) {
391 1.1 tsutsui bq->bl_col--;
392 1.1 tsutsui }
393 1.1 tsutsui break;
394 1.1 tsutsui
395 1.1 tsutsui case 0x09: /* HT */
396 1.1 tsutsui case 0x0B: /* VT */
397 1.1 tsutsui i = ((bq->bl_col / 8) + 1) * 8;
398 1.1 tsutsui if (i < bp->bc_xmax) {
399 1.1 tsutsui bq->bl_col = bq->bl_end = i;
400 1.1 tsutsui }
401 1.1 tsutsui break;
402 1.1 tsutsui
403 1.1 tsutsui case 0x0A: /* NL */
404 1.1 tsutsui bp->bc_row++;
405 1.1 tsutsui if (bp->bc_row >= bp->bc_ymax) {
406 1.1 tsutsui bmd_scroll_screen((u_long *) bp->bc_raddr,
407 1.1 tsutsui (u_long *) bp->bc_waddr,
408 1.1 tsutsui bp->bc_xmin, bp->bc_xmax,
409 1.1 tsutsui bp->bc_ymin, bp->bc_ymax);
410 1.1 tsutsui
411 1.1 tsutsui bp->bc_row = bp->bc_ymax - 1;
412 1.1 tsutsui }
413 1.1 tsutsui break;
414 1.1 tsutsui
415 1.1 tsutsui case 0x0D: /* CR */
416 1.1 tsutsui bq->bl_col = bp->bc_xmin;
417 1.1 tsutsui break;
418 1.1 tsutsui
419 1.1 tsutsui case 0x1b: /* ESC */
420 1.1 tsutsui bp->bc_stat |= STAT_ESCAPE;
421 1.1 tsutsui *bp->bc_esc++ = 0x1b;
422 1.1 tsutsui break;
423 1.1 tsutsui
424 1.1 tsutsui case 0x7F: /* DEL */
425 1.1 tsutsui if (bq->bl_col > bp->bc_xmin) {
426 1.1 tsutsui bq->bl_col--;
427 1.1 tsutsui bmd_erase_char(bp->bc_raddr,
428 1.1 tsutsui bp->bc_waddr,
429 1.1 tsutsui bq->bl_col, bp->bc_row);
430 1.1 tsutsui }
431 1.1 tsutsui break;
432 1.1 tsutsui
433 1.1 tsutsui default:
434 1.1 tsutsui break;
435 1.1 tsutsui }
436 1.1 tsutsui }
437 1.1 tsutsui
438 1.1 tsutsui done:
439 1.1 tsutsui /* turn on cursole */
440 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
441 1.1 tsutsui bp->bc_waddr,
442 1.1 tsutsui bq->bl_col, bp->bc_row);
443 1.1 tsutsui
444 1.1 tsutsui return(c);
445 1.1 tsutsui }
446 1.1 tsutsui
447 1.1 tsutsui void
448 1.1 tsutsui bmdclear(void)
449 1.1 tsutsui {
450 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
451 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
452 1.1 tsutsui
453 1.1 tsutsui bmd_erase_screen((u_long *) bp->bc_waddr); /* clear screen */
454 1.1 tsutsui
455 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
456 1.1 tsutsui bp->bc_row = bp->bc_ymin;
457 1.1 tsutsui
458 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
459 1.1 tsutsui bp->bc_waddr,
460 1.1 tsutsui bq->bl_col, bp->bc_row); /* turn on cursole */
461 1.1 tsutsui }
462 1.1 tsutsui
463 1.1 tsutsui
464 1.1 tsutsui /*
465 1.1 tsutsui *
466 1.1 tsutsui */
467 1.1 tsutsui
468 1.1 tsutsui void
469 1.1 tsutsui bmd_add_new_line(void)
470 1.1 tsutsui {
471 1.1 tsutsui }
472 1.1 tsutsui
473 1.1 tsutsui
474 1.1 tsutsui /*
475 1.1 tsutsui * charactor operation routines
476 1.1 tsutsui */
477 1.1 tsutsui
478 1.1 tsutsui void
479 1.1 tsutsui bmd_draw_char(char *raddr, char *waddr, int col, int row, int c)
480 1.1 tsutsui {
481 1.1 tsutsui volatile u_short *p, *q, *fp;
482 1.1 tsutsui volatile u_long *lp, *lq;
483 1.1 tsutsui int i;
484 1.1 tsutsui
485 1.1 tsutsui fp = &bmdfont[c][0];
486 1.1 tsutsui
487 1.1 tsutsui switch (col % 4) {
488 1.1 tsutsui
489 1.1 tsutsui case 0:
490 1.1 tsutsui p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
491 1.1 tsutsui q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
492 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
493 1.1 tsutsui *q = (*p & 0x000F) | (*fp & 0xFFF0);
494 1.1 tsutsui p += 128;
495 1.1 tsutsui q += 128;
496 1.1 tsutsui fp++;
497 1.1 tsutsui }
498 1.1 tsutsui break;
499 1.1 tsutsui
500 1.1 tsutsui case 1:
501 1.1 tsutsui lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
502 1.1 tsutsui lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
503 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
504 1.1 tsutsui *lq = (*lp & 0xFFF000FF) | ((u_long)(*fp & 0xFFF0) << 4);
505 1.1 tsutsui lp += 64;
506 1.1 tsutsui lq += 64;
507 1.1 tsutsui fp++;
508 1.1 tsutsui }
509 1.1 tsutsui break;
510 1.1 tsutsui
511 1.1 tsutsui case 2:
512 1.1 tsutsui lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
513 1.1 tsutsui lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
514 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
515 1.1 tsutsui *lq = (*lp & 0xFF000FFF) | ((u_long)(*fp & 0xFFF0) << 8);
516 1.1 tsutsui lp += 64;
517 1.1 tsutsui lq += 64;
518 1.1 tsutsui fp++;
519 1.1 tsutsui }
520 1.1 tsutsui break;
521 1.1 tsutsui
522 1.1 tsutsui case 3:
523 1.1 tsutsui p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
524 1.1 tsutsui q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
525 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
526 1.1 tsutsui *q = (*p & 0xF000) | ((*fp & 0xFFF0) >> 4);
527 1.1 tsutsui p += 128;
528 1.1 tsutsui q += 128;
529 1.1 tsutsui fp++;
530 1.1 tsutsui }
531 1.1 tsutsui break;
532 1.1 tsutsui
533 1.1 tsutsui default:
534 1.1 tsutsui break;
535 1.1 tsutsui }
536 1.1 tsutsui }
537 1.1 tsutsui
538 1.1 tsutsui void
539 1.1 tsutsui bmd_reverse_char(char *raddr, char *waddr, int col, int row)
540 1.1 tsutsui {
541 1.1 tsutsui volatile u_short *p, *q;
542 1.1 tsutsui volatile u_long *lp, *lq;
543 1.1 tsutsui int i;
544 1.1 tsutsui
545 1.1 tsutsui switch (col%4) {
546 1.1 tsutsui
547 1.1 tsutsui case 0:
548 1.1 tsutsui p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
549 1.1 tsutsui q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
550 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
551 1.1 tsutsui *q = (*p & 0x000F) | (~(*p) & 0xFFF0);
552 1.1 tsutsui p += 128;
553 1.1 tsutsui q += 128;
554 1.1 tsutsui }
555 1.1 tsutsui break;
556 1.1 tsutsui
557 1.1 tsutsui case 1:
558 1.1 tsutsui lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
559 1.1 tsutsui lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ));
560 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
561 1.1 tsutsui *lq = (*lp & 0xFFF000FF) | (~(*lp) & 0x000FFF00);
562 1.1 tsutsui lp += 64;
563 1.1 tsutsui lq += 64;
564 1.1 tsutsui }
565 1.1 tsutsui break;
566 1.1 tsutsui
567 1.1 tsutsui case 2:
568 1.1 tsutsui lp = (u_long *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
569 1.1 tsutsui lq = (u_long *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 2 );
570 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
571 1.1 tsutsui *lq = (*lp & 0xFF000FFF) | (~(*lp) & 0x00FFF000);
572 1.1 tsutsui lp += 64;
573 1.1 tsutsui lq += 64;
574 1.1 tsutsui }
575 1.1 tsutsui break;
576 1.1 tsutsui
577 1.1 tsutsui case 3:
578 1.1 tsutsui p = (u_short *) ( raddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
579 1.1 tsutsui q = (u_short *) ( waddr + (( row * FB_HIGHT ) << 8 ) + (( col / 4 ) * 6 ) + 4 );
580 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
581 1.1 tsutsui *q = (*p & 0xF000) | (~(*p) & 0x0FFF);
582 1.1 tsutsui p += 128;
583 1.1 tsutsui q += 128;
584 1.1 tsutsui }
585 1.1 tsutsui break;
586 1.1 tsutsui
587 1.1 tsutsui default:
588 1.1 tsutsui break;
589 1.1 tsutsui }
590 1.1 tsutsui }
591 1.1 tsutsui
592 1.1 tsutsui void
593 1.1 tsutsui bmd_erase_char(char *raddr, char *waddr, int col, int row)
594 1.1 tsutsui {
595 1.1 tsutsui bmd_draw_char(raddr, waddr, col, row, 0);
596 1.1 tsutsui
597 1.1 tsutsui return;
598 1.1 tsutsui }
599 1.1 tsutsui
600 1.1 tsutsui
601 1.1 tsutsui /*
602 1.1 tsutsui * screen operation routines
603 1.1 tsutsui */
604 1.1 tsutsui
605 1.1 tsutsui void
606 1.1 tsutsui bmd_erase_screen(volatile u_long *lp)
607 1.1 tsutsui {
608 1.1 tsutsui int i, j;
609 1.1 tsutsui
610 1.1 tsutsui for (i = 0; i < SB_HIGHT; i++) {
611 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++)
612 1.1 tsutsui *lp++ = 0;
613 1.1 tsutsui SKIP_NEXT_LINE(lp);
614 1.1 tsutsui }
615 1.1 tsutsui
616 1.1 tsutsui return;
617 1.1 tsutsui }
618 1.1 tsutsui
619 1.1 tsutsui void
620 1.1 tsutsui bmd_scroll_screen(volatile u_long *lp, volatile u_long *lq,
621 1.1 tsutsui int xmin, int xmax, int ymin, int ymax)
622 1.1 tsutsui {
623 1.1 tsutsui int i, j;
624 1.1 tsutsui
625 1.1 tsutsui lp += ((PL_WIDTH * FB_HIGHT) * (ymin + 1));
626 1.1 tsutsui lq += ((PL_WIDTH * FB_HIGHT) * ymin);
627 1.1 tsutsui
628 1.1 tsutsui for (i = 0; i < ((ymax - ymin -1) * FB_HIGHT); i++) {
629 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++) {
630 1.1 tsutsui *lq++ = *lp++;
631 1.1 tsutsui }
632 1.1 tsutsui lp += (PL_WIDTH - SL_WIDTH);
633 1.1 tsutsui lq += (PL_WIDTH - SL_WIDTH);
634 1.1 tsutsui }
635 1.1 tsutsui
636 1.1 tsutsui for (i = 0; i < FB_HIGHT; i++) {
637 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++) {
638 1.1 tsutsui *lq++ = 0;
639 1.1 tsutsui }
640 1.1 tsutsui lq += (PL_WIDTH - SL_WIDTH);
641 1.1 tsutsui }
642 1.1 tsutsui
643 1.1 tsutsui }
644