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