bmd.c revision 1.3 1 1.3 tsutsui /* $NetBSD: bmd.c,v 1.3 2014/01/02 20:02:00 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 <luna68k/stand/boot/samachdep.h>
82 1.1 tsutsui
83 1.1 tsutsui /*
84 1.1 tsutsui * RFCNT register
85 1.1 tsutsui */
86 1.1 tsutsui
87 1.1 tsutsui union bmd_rfcnt {
88 1.1 tsutsui struct {
89 1.1 tsutsui short rfc_hcnt;
90 1.1 tsutsui short rfc_vcnt;
91 1.1 tsutsui } p;
92 1.1 tsutsui uint32_t u;
93 1.1 tsutsui };
94 1.1 tsutsui
95 1.3 tsutsui #define isprint(c) ((c) >= 0x20 && (c) < 0x7f)
96 1.1 tsutsui
97 1.1 tsutsui /*
98 1.3 tsutsui * Width & Height
99 1.1 tsutsui */
100 1.1 tsutsui
101 1.3 tsutsui #define PB_WIDTH 2048 /* Plane Width (Bit) */
102 1.3 tsutsui #define PB_HEIGHT 1024 /* Plane Hight (Bit) */
103 1.3 tsutsui #define PL_WIDTH 64 /* Plane Width (long) */
104 1.3 tsutsui #define PS_WIDTH 128 /* Plane Width (long) */
105 1.3 tsutsui #define P_WIDTH 256 /* Plane Width (Byte) */
106 1.1 tsutsui
107 1.3 tsutsui #define SB_WIDTH 1280 /* Screen Width (Bit) */
108 1.3 tsutsui #define SB_HEIGHT 1024 /* Screen Hight (Bit) */
109 1.3 tsutsui #define SL_WIDTH 40 /* Screen Width (Long) */
110 1.3 tsutsui #define S_WIDTH 160 /* Screen Width (Byte) */
111 1.1 tsutsui
112 1.3 tsutsui #define FB_WIDTH 12 /* Font Width (Bit) */
113 1.3 tsutsui #define FB_HEIGHT 20 /* Font Hight (Bit) */
114 1.1 tsutsui
115 1.1 tsutsui
116 1.3 tsutsui #define NEXT_LINE(addr) ( addr + (PL_WIDTH * FB_HEIGHT) )
117 1.3 tsutsui #define SKIP_NEXT_LINE(addr) ( addr += (PL_WIDTH - SL_WIDTH) )
118 1.1 tsutsui
119 1.1 tsutsui
120 1.1 tsutsui void bmd_draw_char(char *, char *, int, int, int);
121 1.1 tsutsui void bmd_reverse_char(char *, char *, int, int);
122 1.1 tsutsui void bmd_erase_char(char *, char *, int, int);
123 1.3 tsutsui void bmd_erase_screen(volatile uint32_t *);
124 1.3 tsutsui void bmd_scroll_screen(volatile uint32_t *, volatile uint32_t *,
125 1.1 tsutsui int, int, int, int);
126 1.1 tsutsui
127 1.1 tsutsui
128 1.1 tsutsui struct bmd_linec {
129 1.1 tsutsui struct bmd_linec *bl_next;
130 1.1 tsutsui struct bmd_linec *bl_prev;
131 1.1 tsutsui int bl_col;
132 1.1 tsutsui int bl_end;
133 1.1 tsutsui u_char bl_line[128];
134 1.1 tsutsui };
135 1.1 tsutsui
136 1.1 tsutsui struct bmd_softc {
137 1.1 tsutsui int bc_stat;
138 1.1 tsutsui char *bc_raddr;
139 1.1 tsutsui char *bc_waddr;
140 1.1 tsutsui int bc_xmin;
141 1.1 tsutsui int bc_xmax;
142 1.1 tsutsui int bc_ymin;
143 1.1 tsutsui int bc_ymax;
144 1.1 tsutsui int bc_col;
145 1.1 tsutsui int bc_row;
146 1.1 tsutsui struct bmd_linec *bc_bl;
147 1.1 tsutsui char bc_escseq[8];
148 1.1 tsutsui char *bc_esc;
149 1.1 tsutsui void (*bc_escape)(int);
150 1.1 tsutsui };
151 1.1 tsutsui
152 1.3 tsutsui #define STAT_NORMAL 0x0000
153 1.3 tsutsui #define STAT_ESCAPE 0x0001
154 1.3 tsutsui #define STAT_INSERT 0x0100
155 1.1 tsutsui
156 1.1 tsutsui struct bmd_softc bmd_softc;
157 1.1 tsutsui struct bmd_linec bmd_linec[52];
158 1.1 tsutsui
159 1.1 tsutsui void bmd_escape(int);
160 1.1 tsutsui void bmd_escape_0(int);
161 1.1 tsutsui void bmd_escape_1(int);
162 1.1 tsutsui
163 1.1 tsutsui
164 1.1 tsutsui /*
165 1.1 tsutsui * Escape-Sequence
166 1.1 tsutsui */
167 1.1 tsutsui
168 1.1 tsutsui void
169 1.1 tsutsui bmd_escape(int c)
170 1.1 tsutsui {
171 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
172 1.1 tsutsui
173 1.1 tsutsui switch (c) {
174 1.1 tsutsui
175 1.1 tsutsui case '[':
176 1.1 tsutsui bp->bc_escape = bmd_escape_0;
177 1.1 tsutsui break;
178 1.1 tsutsui
179 1.1 tsutsui default:
180 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
181 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
182 1.1 tsutsui bp->bc_escape = bmd_escape;
183 1.1 tsutsui break;
184 1.1 tsutsui }
185 1.1 tsutsui }
186 1.1 tsutsui
187 1.1 tsutsui void
188 1.1 tsutsui bmd_escape_0(int c)
189 1.1 tsutsui {
190 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
191 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
192 1.1 tsutsui
193 1.1 tsutsui switch (c) {
194 1.1 tsutsui
195 1.1 tsutsui case 'A':
196 1.1 tsutsui if (bp->bc_row > bp->bc_ymin) {
197 1.1 tsutsui bp->bc_row--;
198 1.1 tsutsui }
199 1.1 tsutsui break;
200 1.1 tsutsui
201 1.1 tsutsui case 'C':
202 1.1 tsutsui if (bq->bl_col < bp->bc_xmax - 1) {
203 1.1 tsutsui bq->bl_col++;
204 1.1 tsutsui }
205 1.1 tsutsui break;
206 1.1 tsutsui
207 1.1 tsutsui case 'K':
208 1.1 tsutsui if (bq->bl_col < bp->bc_xmax) {
209 1.1 tsutsui int col;
210 1.1 tsutsui for (col = bq->bl_col; col < bp->bc_xmax; col++)
211 1.1 tsutsui bmd_erase_char(bp->bc_raddr,
212 1.1 tsutsui bp->bc_waddr,
213 1.1 tsutsui col, bp->bc_row);
214 1.1 tsutsui }
215 1.1 tsutsui bq->bl_end = bq->bl_col;
216 1.1 tsutsui break;
217 1.1 tsutsui
218 1.1 tsutsui case 'H':
219 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
220 1.1 tsutsui bp->bc_row = bp->bc_ymin;
221 1.1 tsutsui break;
222 1.1 tsutsui
223 1.1 tsutsui default:
224 1.3 tsutsui #if 0
225 1.1 tsutsui *bp->bc_esc++ = c;
226 1.1 tsutsui bp->bc_escape = bmd_escape_1;
227 1.1 tsutsui return;
228 1.3 tsutsui #endif
229 1.1 tsutsui break;
230 1.1 tsutsui }
231 1.1 tsutsui
232 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
233 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
234 1.1 tsutsui bp->bc_escape = bmd_escape;
235 1.1 tsutsui }
236 1.1 tsutsui
237 1.1 tsutsui void
238 1.1 tsutsui bmd_escape_1(int c)
239 1.1 tsutsui {
240 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
241 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
242 1.1 tsutsui int col = 0, row = 0;
243 1.1 tsutsui char *p;
244 1.1 tsutsui
245 1.1 tsutsui switch (c) {
246 1.1 tsutsui
247 1.1 tsutsui case 'J':
248 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
249 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
250 1.1 tsutsui bp->bc_escape = bmd_escape;
251 1.1 tsutsui break;
252 1.1 tsutsui
253 1.1 tsutsui case 'H':
254 1.1 tsutsui for (p = &bp->bc_escseq[0]; *p != ';'; p++)
255 1.1 tsutsui row = (row * 10) + (*p - 0x30);
256 1.1 tsutsui p++;
257 1.1 tsutsui for (p = &bp->bc_escseq[0]; p != bp->bc_esc; p++)
258 1.1 tsutsui col = (col * 10) + (*p - 0x30);
259 1.1 tsutsui
260 1.1 tsutsui bq->bl_col = col + bp->bc_xmin;
261 1.1 tsutsui bp->bc_row = row + bp->bc_ymin;
262 1.1 tsutsui
263 1.1 tsutsui bp->bc_stat &= ~STAT_ESCAPE;
264 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
265 1.1 tsutsui bp->bc_escape = bmd_escape;
266 1.1 tsutsui break;
267 1.1 tsutsui
268 1.1 tsutsui default:
269 1.1 tsutsui *bp->bc_esc++ = c;
270 1.1 tsutsui break;
271 1.1 tsutsui }
272 1.1 tsutsui }
273 1.1 tsutsui
274 1.1 tsutsui
275 1.1 tsutsui /*
276 1.1 tsutsui * Entry Routine
277 1.1 tsutsui */
278 1.1 tsutsui
279 1.1 tsutsui void
280 1.1 tsutsui bmdinit(void)
281 1.1 tsutsui {
282 1.1 tsutsui volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000;
283 1.1 tsutsui volatile long *bmd_bmsel = (long *)0xB1040000;
284 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
285 1.1 tsutsui struct bmd_linec *bq;
286 1.1 tsutsui int i;
287 1.1 tsutsui union bmd_rfcnt rfcnt;
288 1.1 tsutsui
289 1.1 tsutsui /*
290 1.1 tsutsui * adjust plane position
291 1.1 tsutsui */
292 1.1 tsutsui
293 1.3 tsutsui bp->bc_raddr = (char *) 0xB10C0008; /* plane-0 hardware address */
294 1.3 tsutsui bp->bc_waddr = (char *) 0xB1080008; /* common bitmap hardware address */
295 1.3 tsutsui rfcnt.p.rfc_hcnt = 7; /* shift left 16 dot */
296 1.3 tsutsui rfcnt.p.rfc_vcnt = -27; /* shift down 1 dot */
297 1.1 tsutsui *bmd_rfcnt = rfcnt.u;
298 1.1 tsutsui
299 1.1 tsutsui bp->bc_stat = STAT_NORMAL;
300 1.1 tsutsui
301 1.1 tsutsui bp->bc_xmin = 8;
302 1.1 tsutsui bp->bc_xmax = 96;
303 1.1 tsutsui bp->bc_ymin = 2;
304 1.1 tsutsui bp->bc_ymax = 48;
305 1.1 tsutsui
306 1.1 tsutsui bp->bc_row = bp->bc_ymin;
307 1.1 tsutsui
308 1.1 tsutsui for (i = bp->bc_ymin; i < bp->bc_ymax; i++) {
309 1.1 tsutsui bmd_linec[i].bl_next = &bmd_linec[i+1];
310 1.1 tsutsui bmd_linec[i].bl_prev = &bmd_linec[i-1];
311 1.1 tsutsui }
312 1.1 tsutsui bmd_linec[bp->bc_ymax-1].bl_next = &bmd_linec[bp->bc_ymin];
313 1.1 tsutsui bmd_linec[bp->bc_ymin].bl_prev = &bmd_linec[bp->bc_ymax-1];
314 1.1 tsutsui
315 1.1 tsutsui bq = bp->bc_bl = &bmd_linec[bp->bc_ymin];
316 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
317 1.1 tsutsui
318 1.1 tsutsui bp->bc_col = bp->bc_xmin;
319 1.1 tsutsui
320 1.1 tsutsui bp->bc_esc = &bp->bc_escseq[0];
321 1.1 tsutsui bp->bc_escape = bmd_escape;
322 1.1 tsutsui
323 1.1 tsutsui *bmd_bmsel = 0xff; /* all planes */
324 1.3 tsutsui bmd_erase_screen((uint32_t *)bp->bc_waddr); /* clear screen */
325 1.1 tsutsui *bmd_bmsel = 0x01; /* 1 plane */
326 1.1 tsutsui
327 1.1 tsutsui /* turn on cursole */
328 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
329 1.1 tsutsui bp->bc_waddr,
330 1.1 tsutsui bq->bl_col, bp->bc_row);
331 1.1 tsutsui }
332 1.1 tsutsui
333 1.1 tsutsui void
334 1.1 tsutsui bmdadjust(short hcnt, short vcnt)
335 1.1 tsutsui {
336 1.1 tsutsui volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000;
337 1.1 tsutsui union bmd_rfcnt rfcnt;
338 1.1 tsutsui
339 1.1 tsutsui printf("bmdadjust: hcnt = %d, vcnt = %d\n", hcnt, vcnt);
340 1.1 tsutsui
341 1.1 tsutsui rfcnt.p.rfc_hcnt = hcnt; /* shift left 16 dot */
342 1.1 tsutsui rfcnt.p.rfc_vcnt = vcnt; /* shift down 1 dot */
343 1.1 tsutsui
344 1.1 tsutsui *bmd_rfcnt = rfcnt.u;
345 1.1 tsutsui }
346 1.1 tsutsui
347 1.1 tsutsui int
348 1.1 tsutsui bmdputc(int c)
349 1.1 tsutsui {
350 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
351 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
352 1.1 tsutsui int i;
353 1.1 tsutsui
354 1.1 tsutsui c &= 0x7F;
355 1.1 tsutsui /* turn off cursole */
356 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
357 1.1 tsutsui bp->bc_waddr,
358 1.1 tsutsui bq->bl_col, bp->bc_row);
359 1.1 tsutsui /* do escape-sequence */
360 1.1 tsutsui if (bp->bc_stat & STAT_ESCAPE) {
361 1.1 tsutsui *bp->bc_esc++ = c;
362 1.1 tsutsui (*bp->bc_escape)(c);
363 1.1 tsutsui goto done;
364 1.1 tsutsui }
365 1.1 tsutsui
366 1.1 tsutsui if (isprint(c)) {
367 1.1 tsutsui bmd_draw_char(bp->bc_raddr, bp->bc_waddr,
368 1.1 tsutsui bq->bl_col, bp->bc_row, c);
369 1.1 tsutsui bq->bl_col++;
370 1.1 tsutsui bq->bl_end++;
371 1.1 tsutsui if (bq->bl_col >= bp->bc_xmax) {
372 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
373 1.1 tsutsui bp->bc_row++;
374 1.1 tsutsui if (bp->bc_row >= bp->bc_ymax) {
375 1.3 tsutsui bmd_scroll_screen((uint32_t *)bp->bc_raddr,
376 1.3 tsutsui (uint32_t *)bp->bc_waddr,
377 1.1 tsutsui bp->bc_xmin, bp->bc_xmax,
378 1.1 tsutsui bp->bc_ymin, bp->bc_ymax);
379 1.1 tsutsui
380 1.1 tsutsui bp->bc_row = bp->bc_ymax - 1;
381 1.1 tsutsui }
382 1.1 tsutsui }
383 1.1 tsutsui } else {
384 1.1 tsutsui switch (c) {
385 1.1 tsutsui case 0x08: /* BS */
386 1.1 tsutsui if (bq->bl_col > bp->bc_xmin) {
387 1.1 tsutsui bq->bl_col--;
388 1.1 tsutsui }
389 1.1 tsutsui break;
390 1.1 tsutsui
391 1.1 tsutsui case 0x09: /* HT */
392 1.1 tsutsui case 0x0B: /* VT */
393 1.1 tsutsui i = ((bq->bl_col / 8) + 1) * 8;
394 1.1 tsutsui if (i < bp->bc_xmax) {
395 1.1 tsutsui bq->bl_col = bq->bl_end = i;
396 1.1 tsutsui }
397 1.1 tsutsui break;
398 1.1 tsutsui
399 1.1 tsutsui case 0x0A: /* NL */
400 1.1 tsutsui bp->bc_row++;
401 1.1 tsutsui if (bp->bc_row >= bp->bc_ymax) {
402 1.3 tsutsui bmd_scroll_screen((uint32_t *)bp->bc_raddr,
403 1.3 tsutsui (uint32_t *)bp->bc_waddr,
404 1.1 tsutsui bp->bc_xmin, bp->bc_xmax,
405 1.1 tsutsui bp->bc_ymin, bp->bc_ymax);
406 1.1 tsutsui
407 1.1 tsutsui bp->bc_row = bp->bc_ymax - 1;
408 1.1 tsutsui }
409 1.1 tsutsui break;
410 1.1 tsutsui
411 1.1 tsutsui case 0x0D: /* CR */
412 1.1 tsutsui bq->bl_col = bp->bc_xmin;
413 1.1 tsutsui break;
414 1.1 tsutsui
415 1.1 tsutsui case 0x1b: /* ESC */
416 1.1 tsutsui bp->bc_stat |= STAT_ESCAPE;
417 1.1 tsutsui *bp->bc_esc++ = 0x1b;
418 1.1 tsutsui break;
419 1.1 tsutsui
420 1.1 tsutsui case 0x7F: /* DEL */
421 1.1 tsutsui if (bq->bl_col > bp->bc_xmin) {
422 1.1 tsutsui bq->bl_col--;
423 1.1 tsutsui bmd_erase_char(bp->bc_raddr,
424 1.1 tsutsui bp->bc_waddr,
425 1.1 tsutsui bq->bl_col, bp->bc_row);
426 1.1 tsutsui }
427 1.1 tsutsui break;
428 1.1 tsutsui
429 1.1 tsutsui default:
430 1.1 tsutsui break;
431 1.1 tsutsui }
432 1.1 tsutsui }
433 1.1 tsutsui
434 1.1 tsutsui done:
435 1.1 tsutsui /* turn on cursole */
436 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
437 1.1 tsutsui bp->bc_waddr,
438 1.1 tsutsui bq->bl_col, bp->bc_row);
439 1.1 tsutsui
440 1.1 tsutsui return(c);
441 1.1 tsutsui }
442 1.1 tsutsui
443 1.1 tsutsui void
444 1.1 tsutsui bmdclear(void)
445 1.1 tsutsui {
446 1.1 tsutsui struct bmd_softc *bp = &bmd_softc;
447 1.1 tsutsui struct bmd_linec *bq = bp->bc_bl;
448 1.1 tsutsui
449 1.3 tsutsui bmd_erase_screen((uint32_t *)bp->bc_waddr); /* clear screen */
450 1.1 tsutsui
451 1.1 tsutsui bq->bl_col = bq->bl_end = bp->bc_xmin;
452 1.1 tsutsui bp->bc_row = bp->bc_ymin;
453 1.1 tsutsui
454 1.1 tsutsui bmd_reverse_char(bp->bc_raddr,
455 1.1 tsutsui bp->bc_waddr,
456 1.1 tsutsui bq->bl_col, bp->bc_row); /* turn on cursole */
457 1.1 tsutsui }
458 1.1 tsutsui
459 1.1 tsutsui
460 1.1 tsutsui /*
461 1.1 tsutsui * charactor operation routines
462 1.1 tsutsui */
463 1.1 tsutsui
464 1.1 tsutsui void
465 1.1 tsutsui bmd_draw_char(char *raddr, char *waddr, int col, int row, int c)
466 1.1 tsutsui {
467 1.3 tsutsui volatile uint16_t *p, *q;
468 1.3 tsutsui volatile uint32_t *lp, *lq;
469 1.3 tsutsui const uint16_t *fp;
470 1.1 tsutsui int i;
471 1.1 tsutsui
472 1.1 tsutsui fp = &bmdfont[c][0];
473 1.1 tsutsui
474 1.1 tsutsui switch (col % 4) {
475 1.1 tsutsui
476 1.1 tsutsui case 0:
477 1.3 tsutsui p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
478 1.3 tsutsui + ((col / 4) * 6));
479 1.3 tsutsui q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
480 1.3 tsutsui + ((col / 4) * 6));
481 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
482 1.1 tsutsui *q = (*p & 0x000F) | (*fp & 0xFFF0);
483 1.1 tsutsui p += 128;
484 1.1 tsutsui q += 128;
485 1.1 tsutsui fp++;
486 1.1 tsutsui }
487 1.1 tsutsui break;
488 1.1 tsutsui
489 1.1 tsutsui case 1:
490 1.3 tsutsui lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
491 1.3 tsutsui + ((col / 4) * 6));
492 1.3 tsutsui lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
493 1.3 tsutsui + ((col / 4) * 6));
494 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
495 1.3 tsutsui *lq = (*lp & 0xFFF000FF) |
496 1.3 tsutsui ((uint32_t)(*fp & 0xFFF0) << 4);
497 1.1 tsutsui lp += 64;
498 1.1 tsutsui lq += 64;
499 1.1 tsutsui fp++;
500 1.1 tsutsui }
501 1.1 tsutsui break;
502 1.1 tsutsui
503 1.1 tsutsui case 2:
504 1.3 tsutsui lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
505 1.3 tsutsui + ((col / 4) * 6) + 2);
506 1.3 tsutsui lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
507 1.3 tsutsui + ((col / 4) * 6) + 2);
508 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
509 1.3 tsutsui *lq = (*lp & 0xFF000FFF) |
510 1.3 tsutsui ((uint32_t)(*fp & 0xFFF0) << 8);
511 1.1 tsutsui lp += 64;
512 1.1 tsutsui lq += 64;
513 1.1 tsutsui fp++;
514 1.1 tsutsui }
515 1.1 tsutsui break;
516 1.1 tsutsui
517 1.1 tsutsui case 3:
518 1.3 tsutsui p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
519 1.3 tsutsui + ((col / 4) * 6) + 4);
520 1.3 tsutsui q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
521 1.3 tsutsui + ((col / 4) * 6) + 4);
522 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
523 1.1 tsutsui *q = (*p & 0xF000) | ((*fp & 0xFFF0) >> 4);
524 1.1 tsutsui p += 128;
525 1.1 tsutsui q += 128;
526 1.1 tsutsui fp++;
527 1.1 tsutsui }
528 1.1 tsutsui break;
529 1.1 tsutsui
530 1.1 tsutsui default:
531 1.1 tsutsui break;
532 1.1 tsutsui }
533 1.1 tsutsui }
534 1.1 tsutsui
535 1.1 tsutsui void
536 1.1 tsutsui bmd_reverse_char(char *raddr, char *waddr, int col, int row)
537 1.1 tsutsui {
538 1.3 tsutsui volatile uint16_t *p, *q;
539 1.3 tsutsui volatile uint32_t *lp, *lq;
540 1.1 tsutsui int i;
541 1.1 tsutsui
542 1.3 tsutsui switch (col % 4) {
543 1.1 tsutsui
544 1.1 tsutsui case 0:
545 1.3 tsutsui p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
546 1.3 tsutsui + ((col / 4) * 6));
547 1.3 tsutsui q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
548 1.3 tsutsui + ((col / 4) * 6));
549 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
550 1.1 tsutsui *q = (*p & 0x000F) | (~(*p) & 0xFFF0);
551 1.1 tsutsui p += 128;
552 1.1 tsutsui q += 128;
553 1.1 tsutsui }
554 1.1 tsutsui break;
555 1.1 tsutsui
556 1.1 tsutsui case 1:
557 1.3 tsutsui lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
558 1.3 tsutsui + ((col / 4) * 6));
559 1.3 tsutsui lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
560 1.3 tsutsui + ((col / 4) * 6));
561 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
562 1.1 tsutsui *lq = (*lp & 0xFFF000FF) | (~(*lp) & 0x000FFF00);
563 1.1 tsutsui lp += 64;
564 1.1 tsutsui lq += 64;
565 1.1 tsutsui }
566 1.1 tsutsui break;
567 1.1 tsutsui
568 1.1 tsutsui case 2:
569 1.3 tsutsui lp = (uint32_t *)(raddr + ((row * FB_HEIGHT) << 8)
570 1.3 tsutsui + ((col / 4) * 6) + 2);
571 1.3 tsutsui lq = (uint32_t *)(waddr + ((row * FB_HEIGHT) << 8)
572 1.3 tsutsui + ((col / 4) * 6) + 2);
573 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
574 1.1 tsutsui *lq = (*lp & 0xFF000FFF) | (~(*lp) & 0x00FFF000);
575 1.1 tsutsui lp += 64;
576 1.1 tsutsui lq += 64;
577 1.1 tsutsui }
578 1.1 tsutsui break;
579 1.1 tsutsui
580 1.1 tsutsui case 3:
581 1.3 tsutsui p = (uint16_t *)(raddr + ((row * FB_HEIGHT) << 8)
582 1.3 tsutsui + ((col / 4) * 6) + 4);
583 1.3 tsutsui q = (uint16_t *)(waddr + ((row * FB_HEIGHT) << 8)
584 1.3 tsutsui + ((col / 4) * 6) + 4);
585 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
586 1.1 tsutsui *q = (*p & 0xF000) | (~(*p) & 0x0FFF);
587 1.1 tsutsui p += 128;
588 1.1 tsutsui q += 128;
589 1.1 tsutsui }
590 1.1 tsutsui break;
591 1.1 tsutsui
592 1.1 tsutsui default:
593 1.1 tsutsui break;
594 1.1 tsutsui }
595 1.1 tsutsui }
596 1.1 tsutsui
597 1.1 tsutsui void
598 1.1 tsutsui bmd_erase_char(char *raddr, char *waddr, int col, int row)
599 1.1 tsutsui {
600 1.3 tsutsui
601 1.1 tsutsui bmd_draw_char(raddr, waddr, col, row, 0);
602 1.1 tsutsui }
603 1.1 tsutsui
604 1.1 tsutsui
605 1.1 tsutsui /*
606 1.1 tsutsui * screen operation routines
607 1.1 tsutsui */
608 1.1 tsutsui
609 1.1 tsutsui void
610 1.3 tsutsui bmd_erase_screen(volatile uint32_t *lp)
611 1.1 tsutsui {
612 1.1 tsutsui int i, j;
613 1.1 tsutsui
614 1.3 tsutsui for (i = 0; i < SB_HEIGHT; i++) {
615 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++)
616 1.1 tsutsui *lp++ = 0;
617 1.1 tsutsui SKIP_NEXT_LINE(lp);
618 1.1 tsutsui }
619 1.1 tsutsui }
620 1.1 tsutsui
621 1.1 tsutsui void
622 1.3 tsutsui bmd_scroll_screen(volatile uint32_t *lp, volatile uint32_t *lq,
623 1.1 tsutsui int xmin, int xmax, int ymin, int ymax)
624 1.1 tsutsui {
625 1.1 tsutsui int i, j;
626 1.1 tsutsui
627 1.3 tsutsui lp += ((PL_WIDTH * FB_HEIGHT) * (ymin + 1));
628 1.3 tsutsui lq += ((PL_WIDTH * FB_HEIGHT) * ymin);
629 1.1 tsutsui
630 1.3 tsutsui for (i = 0; i < ((ymax - ymin -1) * FB_HEIGHT); i++) {
631 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++) {
632 1.1 tsutsui *lq++ = *lp++;
633 1.1 tsutsui }
634 1.1 tsutsui lp += (PL_WIDTH - SL_WIDTH);
635 1.1 tsutsui lq += (PL_WIDTH - SL_WIDTH);
636 1.1 tsutsui }
637 1.1 tsutsui
638 1.3 tsutsui for (i = 0; i < FB_HEIGHT; i++) {
639 1.1 tsutsui for (j = 0; j < SL_WIDTH; j++) {
640 1.1 tsutsui *lq++ = 0;
641 1.1 tsutsui }
642 1.1 tsutsui lq += (PL_WIDTH - SL_WIDTH);
643 1.1 tsutsui }
644 1.1 tsutsui }
645