1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$ 13 * 14 * @(#)ite_gb.c 8.1 (Berkeley) 06/10/93 15 */ 16 17 #include <hp300/stand/samachdep.h> 18 19 #ifdef ITECONSOLE 20 21 #include <sys/param.h> 22 23 #include <hp/dev/itevar.h> 24 #include <hp/dev/itereg.h> 25 #include <hp300/dev/grf_gbreg.h> 26 27 #define REGBASE ((struct gboxfb *)(ip->regbase)) 28 #define WINDOWMOVER gbox_windowmove 29 30 gbox_init(ip) 31 register struct ite_softc *ip; 32 { 33 REGBASE->write_protect = 0x0; 34 REGBASE->interrupt = 0x4; 35 REGBASE->rep_rule = RR_COPY; 36 REGBASE->blink1 = 0xff; 37 REGBASE->blink2 = 0xff; 38 REGBASE->sec_interrupt = 0x01; 39 40 /* 41 * Set up the color map entries. We use three entries in the 42 * color map. The first, is for black, the second is for 43 * white, and the very last entry is for the inverted cursor. 44 */ 45 REGBASE->creg_select = 0x00; 46 REGBASE->cmap_red = 0x00; 47 REGBASE->cmap_grn = 0x00; 48 REGBASE->cmap_blu = 0x00; 49 REGBASE->cmap_write = 0x00; 50 gbcm_waitbusy(ip->regbase); 51 52 REGBASE->creg_select = 0x01; 53 REGBASE->cmap_red = 0xFF; 54 REGBASE->cmap_grn = 0xFF; 55 REGBASE->cmap_blu = 0xFF; 56 REGBASE->cmap_write = 0x01; 57 gbcm_waitbusy(ip->regbase); 58 59 REGBASE->creg_select = 0xFF; 60 REGBASE->cmap_red = 0xFF; 61 REGBASE->cmap_grn = 0xFF; 62 REGBASE->cmap_blu = 0xFF; 63 REGBASE->cmap_write = 0x01; 64 gbcm_waitbusy(ip->regbase); 65 66 ite_fontinfo(ip); 67 ite_fontinit(ip); 68 69 /* 70 * Clear the display. This used to be before the font unpacking 71 * but it crashes. Figure it out later. 72 */ 73 gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 74 tile_mover_waitbusy(ip->regbase); 75 76 /* 77 * Stash the inverted cursor. 78 */ 79 gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 80 ip->cblanky, ip->cblankx, ip->ftheight, 81 ip->ftwidth, RR_COPYINVERTED); 82 } 83 84 gbox_putc(ip, c, dy, dx, mode) 85 register struct ite_softc *ip; 86 register int dy, dx; 87 int c, mode; 88 { 89 gbox_windowmove(ip, charY(ip, c), charX(ip, c), 90 dy * ip->ftheight, dx * ip->ftwidth, 91 ip->ftheight, ip->ftwidth, RR_COPY); 92 } 93 94 gbox_cursor(ip, flag) 95 register struct ite_softc *ip; 96 register int flag; 97 { 98 if (flag == DRAW_CURSOR) 99 draw_cursor(ip) 100 else if (flag == MOVE_CURSOR) { 101 erase_cursor(ip) 102 draw_cursor(ip) 103 } 104 else 105 erase_cursor(ip) 106 } 107 108 gbox_clear(ip, sy, sx, h, w) 109 struct ite_softc *ip; 110 register int sy, sx, h, w; 111 { 112 gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 113 sy * ip->ftheight, sx * ip->ftwidth, 114 h * ip->ftheight, w * ip->ftwidth, 115 RR_CLEAR); 116 } 117 118 #define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \ 119 gbox_windowmove((ip), \ 120 (sy) * ip->ftheight, \ 121 (sx) * ip->ftwidth, \ 122 (dy) * ip->ftheight, \ 123 (dx) * ip->ftwidth, \ 124 (h) * ip->ftheight, \ 125 (w) * ip->ftwidth, \ 126 RR_COPY) 127 128 gbox_scroll(ip, sy, sx, count, dir) 129 register struct ite_softc *ip; 130 register int sy; 131 int dir, sx, count; 132 { 133 register int height, dy, i; 134 135 tile_mover_waitbusy(ip->regbase); 136 REGBASE->write_protect = 0x0; 137 138 gbox_cursor(ip, ERASE_CURSOR); 139 140 dy = sy - count; 141 height = ip->rows - sy; 142 for (i = 0; i < height; i++) 143 gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); 144 } 145 146 gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) 147 register struct ite_softc *ip; 148 int sy, sx, dy, dx, mask; 149 register int h, w; 150 { 151 register int src, dest; 152 153 src = (sy * 1024) + sx; /* upper left corner in pixels */ 154 dest = (dy * 1024) + dx; 155 156 tile_mover_waitbusy(ip->regbase); 157 REGBASE->width = -(w / 4); 158 REGBASE->height = -(h / 4); 159 if (src < dest) 160 REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask; 161 else { 162 REGBASE->rep_rule = MOVE_UP_LEFT|mask; 163 /* 164 * Adjust to top of lower right tile of the block. 165 */ 166 src = src + ((h - 4) * 1024) + (w - 4); 167 dest= dest + ((h - 4) * 1024) + (w - 4); 168 } 169 FBBASE[dest] = FBBASE[src]; 170 } 171 #endif 172