ite_cc.c revision 1.14.14.1 1 /* $NetBSD: ite_cc.c,v 1.14.14.1 2000/11/20 20:05:26 bouyer Exp $ */
2
3 /*
4 * Copyright (c) 1996 Leo Weppelman
5 * Copyright (c) 1994 Christian E. Hopps
6 * All rights reserved.
7 *
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 Christian E. Hopps.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <sys/param.h>
35 #include <sys/conf.h>
36 #include <sys/proc.h>
37 #include <sys/ioctl.h>
38 #include <sys/tty.h>
39 #include <sys/systm.h>
40 #include <sys/queue.h>
41 #include <sys/termios.h>
42 #include <sys/malloc.h>
43 #include <sys/device.h>
44 #include <dev/cons.h>
45 #include <machine/cpu.h>
46 #include <atari/atari/device.h>
47 #include <atari/dev/itevar.h>
48 #include <atari/dev/iteioctl.h>
49 #include <atari/dev/grfioctl.h>
50 #include <atari/dev/grfabs_reg.h>
51 #include <atari/dev/grfvar.h>
52 #include <atari/dev/font.h>
53 #include <atari/dev/viewioctl.h>
54 #include <atari/dev/viewvar.h>
55
56 #include "grfcc.h"
57
58 /*
59 * This is what ip->priv points to;
60 * it contains local variables for custom-chip ites.
61 */
62 struct ite_priv {
63 u_char **row_ptr; /* array of pointers into the bitmap */
64 u_long row_bytes;
65 u_long cursor_opt;
66 u_short *column_offset; /* array of offsets for columns */
67 u_int row_offset; /* the row offset */
68 u_short width; /* the bitmap width */
69 u_short underline; /* where the underline goes */
70 u_short ft_x; /* the font width */
71 u_short ft_y; /* the font height */
72 u_char *font_cell[256];/* the font pointer */
73 };
74 typedef struct ite_priv ipriv_t;
75
76 /*
77 * We need the following space to get an ite-console setup before
78 * the VM-system is brought up. We setup for a 1280x960 monitor with
79 * an 8x8 font.
80 */
81 #define CONS_MAXROW 120 /* Max. number of rows on console */
82 #define CONS_MAXCOL 160 /* Max. number of columns on console */
83 static u_short con_columns[CONS_MAXCOL];
84 static u_char *con_rows[CONS_MAXROW];
85 static ipriv_t con_ipriv;
86
87 extern font_info font_info_8x8;
88 extern font_info font_info_8x16;
89
90 static void view_init __P((struct ite_softc *));
91 static void view_deinit __P((struct ite_softc *));
92 static int itecc_ioctl __P((struct ite_softc *, u_long, caddr_t, int,
93 struct proc *));
94 static int ite_newsize __P((struct ite_softc *, struct itewinsize *));
95 static void cursor32 __P((struct ite_softc *, int));
96 static void putc8 __P((struct ite_softc *, int, int, int, int));
97 static void clear8 __P((struct ite_softc *, int, int, int, int));
98 static void scroll8 __P((struct ite_softc *, int, int, int, int));
99 static void scrollbmap __P((bmap_t *, u_short, u_short, u_short, u_short,
100 short, short));
101
102 /*
103 * grfcc config stuff
104 */
105 void grfccattach __P((struct device *, struct device *, void *));
106 int grfccmatch __P((struct device *, struct cfdata *, void *));
107 int grfccprint __P((void *, const char *));
108
109 struct cfattach grfcc_ca = {
110 sizeof(struct grf_softc), grfccmatch, grfccattach
111 };
112
113 /*
114 * only used in console init.
115 */
116 static struct cfdata *cfdata_grf = NULL;
117
118 /*
119 * Probe functions we can use:
120 */
121 #ifdef TT_VIDEO
122 void tt_probe_video __P((MODES *));
123 #endif /* TT_VIDEO */
124 #ifdef FALCON_VIDEO
125 void falcon_probe_video __P((MODES *));
126 #endif /* FALCON_VIDEO */
127
128 int
129 grfccmatch(pdp, cfp, auxp)
130 struct device *pdp;
131 struct cfdata *cfp;
132 void *auxp;
133 {
134 static int must_probe = 1;
135 grf_auxp_t *grf_auxp = auxp;
136
137 if (must_probe) {
138 /*
139 * Check if the layers we depend on exist
140 */
141 if (!(machineid & (ATARI_TT|ATARI_FALCON)))
142 return (0);
143 #ifdef TT_VIDEO
144 if ((machineid & ATARI_TT) && !grfabs_probe(&tt_probe_video))
145 return (0);
146 #endif /* TT_VIDEO */
147 #ifdef FALCON_VIDEO
148 if ((machineid & ATARI_FALCON)
149 && !grfabs_probe(&falcon_probe_video))
150 return (0);
151 #endif /* FALCON_VIDEO */
152
153 viewprobe();
154 must_probe = 0;
155 }
156
157 if (atari_realconfig == 0) {
158 /*
159 * Early console init. Only match unit 0.
160 */
161 if (cfp->cf_unit != 0)
162 return(0);
163 if (viewopen(0, 0, 0, NULL))
164 return(0);
165 cfdata_grf = cfp;
166 return (1);
167 }
168
169 /*
170 * Normal config. When we are called directly from the grfbus,
171 * we only match unit 0. The attach function will call us for
172 * the other configured units.
173 */
174 if (grf_auxp->from_bus_match && (cfp->cf_unit != 0))
175 return (0);
176
177 if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
178 return (0);
179
180 /*
181 * Final constraint: each grf needs a view....
182 */
183 if((cfdata_grf == NULL) || (cfp->cf_unit != 0)) {
184 if(viewopen(cfp->cf_unit, 0, 0, NULL))
185 return(0);
186 }
187 return(1);
188 }
189
190 /*
191 * attach: initialize the grf-structure and try to attach an ite to us.
192 * note : dp is NULL during early console init.
193 */
194 void
195 grfccattach(pdp, dp, auxp)
196 struct device *pdp, *dp;
197 void *auxp;
198 {
199 static struct grf_softc congrf;
200 grf_auxp_t *grf_bus_auxp = auxp;
201 grf_auxp_t grf_auxp;
202 struct grf_softc *gp;
203 int maj;
204
205 /*
206 * find our major device number
207 */
208 for(maj = 0; maj < nchrdev; maj++)
209 if (cdevsw[maj].d_open == grfopen)
210 break;
211
212 /*
213 * Handle exeption case: early console init
214 */
215 if(dp == NULL) {
216 congrf.g_unit = 0;
217 congrf.g_itedev = (dev_t)-1;
218 congrf.g_grfdev = makedev(maj, 0);
219 congrf.g_flags = GF_ALIVE;
220 congrf.g_mode = grf_mode;
221 congrf.g_conpri = grfcc_cnprobe();
222 congrf.g_viewdev = congrf.g_unit;
223 grfcc_iteinit(&congrf);
224 grf_viewsync(&congrf);
225
226 /* Attach console ite */
227 atari_config_found(cfdata_grf, NULL, &congrf, grfccprint);
228 return;
229 }
230
231 gp = (struct grf_softc *)dp;
232 gp->g_unit = gp->g_device.dv_unit;
233 grfsp[gp->g_unit] = gp;
234
235 if((cfdata_grf != NULL) && (gp->g_unit == 0)) {
236 /*
237 * We inited earlier just copy the info, take care
238 * not to copy the device struct though.
239 */
240 bcopy(&congrf.g_display, &gp->g_display,
241 (char *)&gp[1] - (char *)&gp->g_display);
242 }
243 else {
244 gp->g_grfdev = makedev(maj, gp->g_unit);
245 gp->g_itedev = (dev_t)-1;
246 gp->g_flags = GF_ALIVE;
247 gp->g_mode = grf_mode;
248 gp->g_conpri = 0;
249 gp->g_viewdev = gp->g_unit;
250 grfcc_iteinit(gp);
251 grf_viewsync(gp);
252 }
253
254 printf(": width %d height %d", gp->g_display.gd_dwidth,
255 gp->g_display.gd_dheight);
256 if(gp->g_display.gd_colors == 2)
257 printf(" monochrome\n");
258 else printf(" colors %d\n", gp->g_display.gd_colors);
259
260 /*
261 * try and attach an ite
262 */
263 config_found(dp, gp, grfccprint);
264
265 /*
266 * If attaching unit 0, go ahead and 'find' the rest of us
267 */
268 if (gp->g_unit == 0) {
269 grf_auxp.from_bus_match = 0;
270 for (grf_auxp.unit=1; grf_auxp.unit < NGRFCC; grf_auxp.unit++) {
271 config_found(pdp, (void*)&grf_auxp, grf_bus_auxp->busprint);
272 }
273 }
274 }
275
276 int
277 grfccprint(auxp, pnp)
278 void *auxp;
279 const char *pnp;
280 {
281 if(pnp)
282 printf("ite at %s", pnp);
283 return(UNCONF);
284 }
285
286 /*
287 * called from grf_cc to return console priority
288 */
289 int
290 grfcc_cnprobe()
291 {
292 return(CN_INTERNAL);
293 }
294 /*
295 * called from grf_cc to init ite portion of
296 * grf_softc struct
297 */
298 void
299 grfcc_iteinit(gp)
300 struct grf_softc *gp;
301 {
302
303 gp->g_itecursor = cursor32;
304 gp->g_iteputc = putc8;
305 gp->g_iteclear = clear8;
306 gp->g_itescroll = scroll8;
307 gp->g_iteinit = view_init;
308 gp->g_itedeinit = view_deinit;
309 }
310
311 static void
312 view_deinit(ip)
313 struct ite_softc *ip;
314 {
315 ip->flags &= ~ITE_INITED;
316 }
317
318 static void
319 view_init(ip)
320 register struct ite_softc *ip;
321 {
322 struct itewinsize wsz;
323 ipriv_t *cci;
324
325 if((cci = ip->priv) != NULL)
326 return;
327
328 ip->itexx_ioctl = itecc_ioctl;
329
330 #if defined(KFONT_8X8)
331 ip->font = font_info_8x8;
332 #else
333 ip->font = font_info_8x16;
334 #endif
335
336 /* Find the correct set of rendering routines for this font. */
337 if(ip->font.width != 8)
338 panic("kernel font size not supported");
339
340 if(!atari_realconfig)
341 ip->priv = cci = &con_ipriv;
342 else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
343 if(cci == NULL)
344 panic("No memory for ite-view");
345 bzero(cci, sizeof(*cci));
346
347 cci->cursor_opt = 0;
348 cci->row_ptr = NULL;
349 cci->column_offset = NULL;
350
351 wsz.x = ite_default_x;
352 wsz.y = ite_default_y;
353 wsz.width = ite_default_width;
354 wsz.height = ite_default_height;
355 wsz.depth = ite_default_depth;
356
357 ite_newsize (ip, &wsz);
358
359 /*
360 * Only console will be turned on by default..
361 */
362 if(ip->flags & ITE_ISCONS)
363 ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
364 }
365
366 static int
367 ite_newsize(ip, winsz)
368 struct ite_softc *ip;
369 struct itewinsize *winsz;
370 {
371 struct view_size vs;
372 ipriv_t *cci = ip->priv;
373 u_long i, j;
374 int error = 0;
375 view_t *view;
376
377 vs.x = winsz->x;
378 vs.y = winsz->y;
379 vs.width = winsz->width;
380 vs.height = winsz->height;
381 vs.depth = winsz->depth;
382
383 error = viewioctl(ip->grf->g_viewdev, VIOCSSIZE, (caddr_t)&vs, 0,
384 NOPROC);
385 view = viewview(ip->grf->g_viewdev);
386
387 /*
388 * Reinitialize our structs
389 */
390 ip->cols = view->display.width / ip->font.width;
391 ip->rows = view->display.height / ip->font.height;
392
393 /*
394 * save new values so that future opens use them
395 * this may not be correct when we implement Virtual Consoles
396 */
397 ite_default_height = view->display.height;
398 ite_default_width = view->display.width;
399 ite_default_x = view->display.x;
400 ite_default_y = view->display.y;
401 ite_default_depth = view->bitmap->depth;
402
403 if(cci->row_ptr && (cci->row_ptr != con_rows)) {
404 free(cci->row_ptr, M_DEVBUF);
405 cci->row_ptr = NULL;
406 }
407 if(cci->column_offset && (cci->column_offset != con_columns)) {
408 free(cci->column_offset, M_DEVBUF);
409 cci->column_offset = NULL;
410 }
411
412 if(!atari_realconfig) {
413 cci->row_ptr = con_rows;
414 cci->column_offset = con_columns;
415 }
416 else {
417 cci->row_ptr = malloc(sizeof(u_char *) * ip->rows,M_DEVBUF,M_NOWAIT);
418 cci->column_offset = malloc(sizeof(u_int)*ip->cols,M_DEVBUF,M_NOWAIT);
419 }
420
421 if(!cci->row_ptr || !cci->column_offset)
422 panic("No memory for ite-view");
423
424 cci->width = view->bitmap->bytes_per_row << 3;
425 cci->underline = ip->font.baseline + 1;
426 cci->row_offset = view->bitmap->bytes_per_row;
427 cci->ft_x = ip->font.width;
428 cci->ft_y = ip->font.height;
429 cci->row_bytes = cci->row_offset * cci->ft_y;
430 cci->row_ptr[0] = view->bitmap->plane;
431 for(i = 1; i < ip->rows; i++)
432 cci->row_ptr[i] = cci->row_ptr[i-1] + cci->row_bytes;
433
434 /*
435 * Initialize the column offsets to point at the correct location
436 * in the first plane. This definitely assumes a font width of 8!
437 */
438 j = view->bitmap->depth * 2;
439 cci->column_offset[0] = 0;
440 for(i = 1; i < ip->cols; i++)
441 cci->column_offset[i] = ((i >> 1) * j) + (i & 1);
442
443 /* initialize the font cell pointers */
444 cci->font_cell[ip->font.font_lo] = ip->font.font_p;
445 for(i = ip->font.font_lo+1; i <= ip->font.font_hi; i++)
446 cci->font_cell[i] = cci->font_cell[i-1] + ip->font.height;
447
448 return(error);
449 }
450
451 int
452 itecc_ioctl(ip, cmd, addr, flag, p)
453 struct ite_softc *ip;
454 u_long cmd;
455 caddr_t addr;
456 int flag;
457 struct proc *p;
458 {
459 struct winsize ws;
460 struct itewinsize *is;
461 int error = 0;
462 view_t *view = viewview(ip->grf->g_viewdev);
463
464 switch (cmd) {
465 case ITEIOCSWINSZ:
466 is = (struct itewinsize *)addr;
467
468 if(ite_newsize(ip, is))
469 error = ENOMEM;
470 else {
471 view = viewview(ip->grf->g_viewdev);
472 ws.ws_row = ip->rows;
473 ws.ws_col = ip->cols;
474 ws.ws_xpixel = view->display.width;
475 ws.ws_ypixel = view->display.height;
476 ite_reset(ip);
477 /*
478 * XXX tell tty about the change
479 * XXX this is messy, but works
480 */
481 iteioctl(ip->grf->g_itedev,TIOCSWINSZ,(caddr_t)&ws,0,p);
482 }
483 break;
484 case VIOCSCMAP:
485 case VIOCGCMAP:
486 /*
487 * XXX watchout for that NOPROC. its not really the kernel
488 * XXX talking these two commands don't use the proc pointer
489 * XXX though.
490 */
491 error = viewioctl(ip->grf->g_viewdev, cmd, addr, flag, NOPROC);
492 break;
493 default:
494 error = -1;
495 break;
496 }
497 return (error);
498 }
499
500 static void
501 cursor32(struct ite_softc *ip, int flag)
502 {
503 int cend;
504 u_char *pl;
505 ipriv_t *cci;
506
507 cci = ip->priv;
508
509 if(flag == END_CURSOROPT)
510 cci->cursor_opt--;
511 else if(flag == START_CURSOROPT) {
512 if(!cci->cursor_opt)
513 cursor32(ip, ERASE_CURSOR);
514 cci->cursor_opt++;
515 return; /* if we are already opted. */
516 }
517
518 if(cci->cursor_opt)
519 return; /* if we are still nested. */
520 /* else we draw the cursor. */
521
522 if(flag != DRAW_CURSOR && flag != END_CURSOROPT) {
523 /*
524 * erase the cursor
525 */
526 cend = ip->font.height-1;
527 pl = cci->column_offset[ip->cursorx]
528 + cci->row_ptr[ip->cursory];
529 __asm__ __volatile__
530 ("1: notb %0@ ; addaw %4,%0\n\t"
531 "dbra %1,1b"
532 : "=a" (pl), "=d" (cend)
533 : "0" (pl), "1" (cend),
534 "d" (cci->row_offset)
535 );
536 }
537
538 if(flag != DRAW_CURSOR && flag != MOVE_CURSOR && flag != END_CURSOROPT)
539 return;
540
541 /*
542 * draw the cursor
543 */
544 cend = min(ip->curx, ip->cols-1);
545 if (flag == DRAW_CURSOR
546 && ip->cursorx == cend && ip->cursory == ip->cury)
547 return;
548 ip->cursorx = cend;
549 ip->cursory = ip->cury;
550 cend = ip->font.height-1;
551 pl = cci->column_offset[ip->cursorx]
552 + cci->row_ptr[ip->cursory];
553
554 __asm__ __volatile__
555 ("1: notb %0@ ; addaw %4,%0\n\t"
556 "dbra %1,1b"
557 : "=a" (pl), "=d" (cend)
558 : "0" (pl), "1" (cend),
559 "d" (cci->row_offset)
560 );
561 }
562
563 static void
564 putc8(struct ite_softc *ip, int c, int dy, int dx, int mode)
565 {
566 register ipriv_t *cci = (ipriv_t *)ip->priv;
567 register u_char *pl = cci->column_offset[dx] + cci->row_ptr[dy];
568 register u_int fh = cci->ft_y;
569 register u_int ro = cci->row_offset;
570 register u_char eor_mask;
571 register u_char bl, tmp, ul;
572 register u_char *ft;
573
574 if(c < ip->font.font_lo || c > ip->font.font_hi)
575 return;
576
577 ft = cci->font_cell[c];
578
579 if(!mode) {
580 while(fh--) {
581 *pl = *ft++; pl += ro;
582 }
583 return;
584 }
585
586 eor_mask = (mode & ATTR_INV) ? 0xff : 0x00;
587 bl = (mode & ATTR_BOLD) ? 1 : 0;
588 ul = (mode & ATTR_UL) ? fh - cci->underline : fh;
589 for(; fh--; pl += ro) {
590 if(fh != ul) {
591 tmp = *ft++;
592 if(bl)
593 tmp |= (tmp >> 1);
594 *pl = tmp ^ eor_mask;
595 }
596 else {
597 *pl = 0xff ^ eor_mask;
598 ft++;
599 }
600 }
601 }
602
603 static void
604 clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
605 {
606 ipriv_t *cci = (ipriv_t *) ip->priv;
607 view_t *v = viewview(ip->grf->g_viewdev);
608 bmap_t *bm = v->bitmap;
609
610 if((sx == 0) && (w == ip->cols)) {
611 /* common case: clearing whole lines */
612 while (h--) {
613 int i;
614 u_char *ptr = cci->row_ptr[sy];
615 for(i = 0; i < ip->font.height; i++) {
616 bzero(ptr, bm->bytes_per_row);
617 ptr += bm->bytes_per_row;
618 }
619 sy++;
620 }
621 }
622 else {
623 /*
624 * clearing only part of a line
625 * XXX could be optimized MUCH better, but is it worth the
626 * trouble?
627 */
628
629 int i;
630 u_char *pls, *ple;
631
632 pls = cci->row_ptr[sy];
633 ple = pls + cci->column_offset[sx + w-1];
634 pls = pls + cci->column_offset[sx];
635
636 for(i = ((ip->font.height) * h)-1; i >= 0; i--) {
637 u_char *p = pls;
638 while(p <= ple)
639 *p++ = 0;
640 pls += bm->bytes_per_row;
641 ple += bm->bytes_per_row;
642 }
643 }
644 }
645
646 /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT. */
647 static void
648 scroll8(ip, sy, sx, count, dir)
649 register struct ite_softc *ip;
650 register int sy;
651 int dir, sx, count;
652 {
653 bmap_t *bm = viewview(ip->grf->g_viewdev)->bitmap;
654 u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
655
656 if(dir == SCROLL_UP) {
657 int dy = sy - count;
658
659 cursor32(ip, ERASE_CURSOR);
660 scrollbmap(bm, 0, dy*ip->font.height, bm->bytes_per_row >> 3,
661 (ip->bottom_margin-dy+1)*ip->font.height,
662 0, -(count*ip->font.height));
663 }
664 else if(dir == SCROLL_DOWN) {
665 cursor32(ip, ERASE_CURSOR);
666 scrollbmap(bm, 0, sy*ip->font.height, bm->bytes_per_row >> 3,
667 (ip->bottom_margin-sy+1)*ip->font.height,
668 0, count*ip->font.height);
669 }
670 else if(dir == SCROLL_RIGHT) {
671 int sofs = (ip->cols - count) * ip->font.width;
672 int dofs = (ip->cols) * ip->font.width;
673 int i, j;
674
675 cursor32(ip, ERASE_CURSOR);
676 for(j = ip->font.height-1; j >= 0; j--) {
677 int sofs2 = sofs, dofs2 = dofs;
678 for (i = (ip->cols - (sx + count))-1; i >= 0; i--) {
679 int t;
680 sofs2 -= ip->font.width;
681 dofs2 -= ip->font.width;
682 asm("bfextu %1@{%2:%3},%0" : "=d" (t)
683 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
684 asm("bfins %3,%0@{%1:%2}" :
685 : "a" (pl), "d" (dofs2), "d" (ip->font.width),
686 "d" (t));
687 }
688 pl += bm->bytes_per_row;
689 }
690 }
691 else { /* SCROLL_LEFT */
692 int sofs = (sx) * ip->font.width;
693 int dofs = (sx - count) * ip->font.width;
694 int i, j;
695
696 cursor32(ip, ERASE_CURSOR);
697 for(j = ip->font.height-1; j >= 0; j--) {
698 int sofs2 = sofs, dofs2 = dofs;
699 for(i = (ip->cols - sx)-1; i >= 0; i--) {
700 int t;
701
702 asm("bfextu %1@{%2:%3},%0" : "=d" (t)
703 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
704 asm("bfins %3,%0@{%1:%2}"
705 : : "a" (pl), "d" (dofs2),"d" (ip->font.width),
706 "d" (t));
707 sofs2 += ip->font.width;
708 dofs2 += ip->font.width;
709 }
710 pl += bm->bytes_per_row;
711 }
712 }
713 }
714
715 static void
716 scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy)
717 {
718 u_short lwpr = bm->bytes_per_row >> 2;
719
720 if(dx) {
721 /* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
722 }
723
724 if(dy == 0) {
725 return;
726 }
727 if(dy > 0) {
728 u_long *pl = (u_long *)bm->plane;
729 u_long *src_y = pl + (lwpr*y);
730 u_long *dest_y = pl + (lwpr*(y+dy));
731 u_long count = lwpr*(height-dy);
732 u_long *clr_y = src_y;
733 u_long clr_count = dest_y - src_y;
734 u_long bc, cbc;
735
736 src_y += count - 1;
737 dest_y += count - 1;
738
739 bc = count >> 4;
740 count &= 0xf;
741
742 while (bc--) {
743 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
744 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
745 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
746 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
747 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
748 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
749 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
750 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
751 }
752 while (count--)
753 *dest_y-- = *src_y--;
754
755 cbc = clr_count >> 4;
756 clr_count &= 0xf;
757
758 while (cbc--) {
759 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
760 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
761 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
762 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
763 }
764 while(clr_count--)
765 *clr_y++ = 0;
766 }
767 else {
768 u_long *pl = (u_long *)bm->plane;
769 u_long *src_y = pl + (lwpr*(y-dy));
770 u_long *dest_y = pl + (lwpr*y);
771 long count = lwpr*(height + dy);
772 u_long *clr_y = dest_y + count;
773 u_long clr_count = src_y - dest_y;
774 u_long bc, cbc;
775
776 bc = count >> 4;
777 count &= 0xf;
778
779 while(bc--) {
780 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
781 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
782 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
783 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
784 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
785 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
786 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
787 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
788 }
789 while(count--)
790 *dest_y++ = *src_y++;
791
792 cbc = clr_count >> 4;
793 clr_count &= 0xf;
794
795 while (cbc--) {
796 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
797 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
798 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
799 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
800 }
801 while (clr_count--)
802 *clr_y++ = 0;
803 }
804 }
805