1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * 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.18 91/01/21$ 13 * 14 * @(#)ite_gb.c 7.5 (Berkeley) 05/07/91 15 */ 16 17 #include "ite.h" 18 #if NITE > 0 19 20 #include "param.h" 21 #include "conf.h" 22 #include "proc.h" 23 #include "ioctl.h" 24 #include "tty.h" 25 #include "systm.h" 26 27 #include "itevar.h" 28 #include "itereg.h" 29 #include "grf_gbreg.h" 30 31 #include "machine/cpu.h" 32 33 /* XXX */ 34 #include "grfioctl.h" 35 #include "grfvar.h" 36 37 #define REGBASE ((struct gboxfb *)(ip->regbase)) 38 #define WINDOWMOVER gatorbox_windowmove 39 40 gatorbox_init(ip) 41 register struct ite_softc *ip; 42 { 43 /* XXX */ 44 if (ip->regbase == 0) { 45 struct grf_softc *gp = &grf_softc[ip - ite_softc]; 46 ip->regbase = gp->g_regkva; 47 ip->fbbase = gp->g_fbkva; 48 } 49 50 REGBASE->write_protect = 0x0; 51 REGBASE->interrupt = 0x4; 52 REGBASE->rep_rule = RR_COPY; 53 REGBASE->blink1 = 0xff; 54 REGBASE->blink2 = 0xff; 55 gb_microcode(REGADDR); 56 REGBASE->sec_interrupt = 0x01; 57 58 /* 59 * Set up the color map entries. We use three entries in the 60 * color map. The first, is for black, the second is for 61 * white, and the very last entry is for the inverted cursor. 62 */ 63 REGBASE->creg_select = 0x00; 64 REGBASE->cmap_red = 0x00; 65 REGBASE->cmap_grn = 0x00; 66 REGBASE->cmap_blu = 0x00; 67 REGBASE->cmap_write = 0x00; 68 gbcm_waitbusy(REGADDR); 69 70 REGBASE->creg_select = 0x01; 71 REGBASE->cmap_red = 0xFF; 72 REGBASE->cmap_grn = 0xFF; 73 REGBASE->cmap_blu = 0xFF; 74 REGBASE->cmap_write = 0x01; 75 gbcm_waitbusy(REGADDR); 76 77 REGBASE->creg_select = 0xFF; 78 REGBASE->cmap_red = 0xFF; 79 REGBASE->cmap_grn = 0xFF; 80 REGBASE->cmap_blu = 0xFF; 81 REGBASE->cmap_write = 0x01; 82 gbcm_waitbusy(REGADDR); 83 84 ite_devinfo(ip); 85 ite_fontinit(ip); 86 87 /* 88 * Clear the display. This used to be before the font unpacking 89 * but it crashes. Figure it out later. 90 */ 91 gatorbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); 92 tile_mover_waitbusy(REGADDR); 93 94 /* 95 * Stash the inverted cursor. 96 */ 97 gatorbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 98 ip->cblanky, ip->cblankx, ip->ftheight, 99 ip->ftwidth, RR_COPYINVERTED); 100 } 101 102 gatorbox_deinit(ip) 103 struct ite_softc *ip; 104 { 105 gatorbox_windowmove(ip, 0, 0, 0, 0, 106 ip->dheight, ip->dwidth, RR_CLEAR); 107 tile_mover_waitbusy(REGADDR); 108 109 ip->flags &= ~ITE_INITED; 110 } 111 112 gatorbox_putc(ip, c, dy, dx, mode) 113 register struct ite_softc *ip; 114 register int dy, dx; 115 int c, mode; 116 { 117 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 118 119 gatorbox_windowmove(ip, charY(ip, c), charX(ip, c), 120 dy * ip->ftheight, dx * ip->ftwidth, 121 ip->ftheight, ip->ftwidth, wrr); 122 } 123 124 gatorbox_cursor(ip, flag) 125 register struct ite_softc *ip; 126 register int flag; 127 { 128 if (flag == DRAW_CURSOR) 129 draw_cursor(ip) 130 else if (flag == MOVE_CURSOR) { 131 erase_cursor(ip) 132 draw_cursor(ip) 133 } 134 else 135 erase_cursor(ip) 136 } 137 138 gatorbox_clear(ip, sy, sx, h, w) 139 struct ite_softc *ip; 140 register int sy, sx, h, w; 141 { 142 gatorbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 143 sy * ip->ftheight, sx * ip->ftwidth, 144 h * ip->ftheight, w * ip->ftwidth, 145 RR_CLEAR); 146 } 147 #define gatorbox_blockmove(ip, sy, sx, dy, dx, h, w) \ 148 gatorbox_windowmove((ip), \ 149 (sy) * ip->ftheight, \ 150 (sx) * ip->ftwidth, \ 151 (dy) * ip->ftheight, \ 152 (dx) * ip->ftwidth, \ 153 (h) * ip->ftheight, \ 154 (w) * ip->ftwidth, \ 155 RR_COPY) 156 157 gatorbox_scroll(ip, sy, sx, count, dir) 158 register struct ite_softc *ip; 159 register int sy; 160 int dir, sx, count; 161 { 162 register int height, dy, i; 163 164 tile_mover_waitbusy(REGADDR); 165 REGBASE->write_protect = 0x0; 166 167 gatorbox_cursor(ip, ERASE_CURSOR); 168 169 if (dir == SCROLL_UP) { 170 dy = sy - count; 171 height = ip->rows - sy; 172 for (i = 0; i < height; i++) 173 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0, 174 1, ip->cols); 175 } 176 else if (dir == SCROLL_DOWN) { 177 dy = sy + count; 178 height = ip->rows - dy; 179 for (i = (height - 1); i >= 0; i--) 180 gatorbox_blockmove(ip, sy + i, sx, dy + i, 0, 181 1, ip->cols); 182 } 183 else if (dir == SCROLL_RIGHT) { 184 gatorbox_blockmove(ip, sy, sx, sy, sx + count, 185 1, ip->cols - (sx + count)); 186 } 187 else { 188 gatorbox_blockmove(ip, sy, sx, sy, sx - count, 189 1, ip->cols - sx); 190 } 191 } 192 193 gatorbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) 194 register struct ite_softc *ip; 195 int sy, sx, dy, dx, mask; 196 register int h, w; 197 { 198 register int src, dest; 199 200 src = (sy * 1024) + sx; /* upper left corner in pixels */ 201 dest = (dy * 1024) + dx; 202 203 tile_mover_waitbusy(REGADDR); 204 REGBASE->width = -(w / 4); 205 REGBASE->height = -(h / 4); 206 if (src < dest) 207 REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask; 208 else { 209 REGBASE->rep_rule = MOVE_UP_LEFT|mask; 210 /* 211 * Adjust to top of lower right tile of the block. 212 */ 213 src = src + ((h - 4) * 1024) + (w - 4); 214 dest= dest + ((h - 4) * 1024) + (w - 4); 215 } 216 FBBASE[dest] = FBBASE[src]; 217 } 218 #endif 219