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_tc.c 1.11 92/01/20$ 13 * 14 * @(#)ite_tc.c 7.4 (Berkeley) 10/11/92 15 */ 16 17 #include <hp300/stand/samachdep.h> 18 19 #ifdef ITECONSOLE 20 21 #include <sys/param.h> 22 #include <hp/dev/itevar.h> 23 #include <hp/dev/itereg.h> 24 #include <hp/dev/grfreg.h> 25 #include <hp300/dev/grf_tcreg.h> 26 27 #define REGBASE ((struct tcboxfb *)(ip->regbase)) 28 #define WINDOWMOVER topcat_windowmove 29 30 topcat_init(ip) 31 register struct ite_softc *ip; 32 { 33 34 /* 35 * Catseye looks a lot like a topcat, but not completely. 36 * So, we set some bits to make it work. 37 */ 38 if (REGBASE->fbid != GID_TOPCAT) { 39 while ((REGBASE->catseye_status & 1)) 40 ; 41 REGBASE->catseye_status = 0x0; 42 REGBASE->vb_select = 0x0; 43 REGBASE->tcntrl = 0x0; 44 REGBASE->acntrl = 0x0; 45 REGBASE->pncntrl = 0x0; 46 REGBASE->rug_cmdstat = 0x90; 47 } 48 49 /* 50 * Determine the number of planes by writing to the first frame 51 * buffer display location, then reading it back. 52 */ 53 REGBASE->wen = ~0; 54 REGBASE->fben = ~0; 55 REGBASE->prr = RR_COPY; 56 *FBBASE = 0xFF; 57 ip->planemask = *FBBASE; 58 59 /* 60 * Enable reading/writing of all the planes. 61 */ 62 REGBASE->fben = ip->planemask; 63 REGBASE->wen = ip->planemask; 64 REGBASE->ren = ip->planemask; 65 REGBASE->prr = RR_COPY; 66 67 ite_fontinfo(ip); 68 69 /* 70 * Clear the framebuffer on all planes. 71 */ 72 topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 73 tc_waitbusy(ip->regbase, ip->planemask); 74 75 ite_fontinit(ip); 76 77 /* 78 * Stash the inverted cursor. 79 */ 80 topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 81 ip->cblanky, ip->cblankx, ip->ftheight, 82 ip->ftwidth, RR_COPYINVERTED); 83 } 84 85 topcat_putc(ip, c, dy, dx, mode) 86 register struct ite_softc *ip; 87 register int dy, dx; 88 int c, mode; 89 { 90 topcat_windowmove(ip, charY(ip, c), charX(ip, c), 91 dy * ip->ftheight, dx * ip->ftwidth, 92 ip->ftheight, ip->ftwidth, RR_COPY); 93 } 94 95 topcat_cursor(ip, flag) 96 register struct ite_softc *ip; 97 register int flag; 98 { 99 if (flag == DRAW_CURSOR) 100 draw_cursor(ip) 101 else if (flag == MOVE_CURSOR) { 102 erase_cursor(ip) 103 draw_cursor(ip) 104 } 105 else 106 erase_cursor(ip) 107 } 108 109 topcat_clear(ip, sy, sx, h, w) 110 struct ite_softc *ip; 111 register int sy, sx, h, w; 112 { 113 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 114 sy * ip->ftheight, sx * ip->ftwidth, 115 h * ip->ftheight, w * ip->ftwidth, 116 RR_CLEAR); 117 } 118 119 topcat_scroll(ip, sy, sx, count, dir) 120 register struct ite_softc *ip; 121 register int sy, count; 122 int dir, sx; 123 { 124 register int dy = sy - count; 125 register int height = ip->rows - sy; 126 127 topcat_cursor(ip, ERASE_CURSOR); 128 129 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 130 dy * ip->ftheight, sx * ip->ftwidth, 131 height * ip->ftheight, 132 ip->cols * ip->ftwidth, RR_COPY); 133 } 134 135 topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 136 struct ite_softc *ip; 137 int sy, sx, dy, dx, h, w, func; 138 { 139 register struct tcboxfb *rp = REGBASE; 140 141 if (h == 0 || w == 0) 142 return; 143 tc_waitbusy(ip->regbase, ip->planemask); 144 rp->wmrr = func; 145 rp->source_y = sy; 146 rp->source_x = sx; 147 rp->dest_y = dy; 148 rp->dest_x = dx; 149 rp->wheight = h; 150 rp->wwidth = w; 151 rp->wmove = ip->planemask; 152 } 153 #endif 154