1 /* $NetBSD: ite_tc.c,v 1.1 1997/02/04 03:52:37 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1988 University of Utah. 5 * Copyright (c) 1990, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * the Systems Programming Group of the University of Utah Computer 10 * Science Department. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the University of 23 * California, Berkeley and its contributors. 24 * 4. Neither the name of the University nor the names of its contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 * 40 * from: Utah $Hdr: ite_tc.c 1.11 92/01/20$ 41 * 42 * @(#)ite_tc.c 8.1 (Berkeley) 6/10/93 43 */ 44 45 #ifdef ITECONSOLE 46 47 #include <sys/param.h> 48 49 #include <hp300/dev/itereg.h> 50 #include <hp300/dev/grfreg.h> 51 #include <hp300/dev/grf_tcreg.h> 52 53 #include <hp300/stand/common/samachdep.h> 54 #include <hp300/stand/common/itevar.h> 55 56 #define REGBASE ((struct tcboxfb *)(ip->regbase)) 57 #define WINDOWMOVER topcat_windowmove 58 59 void topcat_windowmove __P((struct ite_data *, int, int, int, int, 60 int, int, int)); 61 62 void 63 topcat_init(ip) 64 register struct ite_data *ip; 65 { 66 67 /* 68 * Catseye looks a lot like a topcat, but not completely. 69 * So, we set some bits to make it work. 70 */ 71 if (REGBASE->fbid != GID_TOPCAT) { 72 while ((REGBASE->catseye_status & 1)) 73 ; 74 REGBASE->catseye_status = 0x0; 75 REGBASE->vb_select = 0x0; 76 REGBASE->tcntrl = 0x0; 77 REGBASE->acntrl = 0x0; 78 REGBASE->pncntrl = 0x0; 79 REGBASE->rug_cmdstat = 0x90; 80 } 81 82 /* 83 * Determine the number of planes by writing to the first frame 84 * buffer display location, then reading it back. 85 */ 86 REGBASE->wen = ~0; 87 REGBASE->fben = ~0; 88 REGBASE->prr = RR_COPY; 89 *FBBASE = 0xFF; 90 ip->planemask = *FBBASE; 91 92 /* 93 * Enable reading/writing of all the planes. 94 */ 95 REGBASE->fben = ip->planemask; 96 REGBASE->wen = ip->planemask; 97 REGBASE->ren = ip->planemask; 98 REGBASE->prr = RR_COPY; 99 100 ite_fontinfo(ip); 101 102 /* 103 * Clear the framebuffer on all planes. 104 */ 105 topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 106 tc_waitbusy(ip->regbase, ip->planemask); 107 108 ite_fontinit(ip); 109 110 /* 111 * Stash the inverted cursor. 112 */ 113 topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 114 ip->cblanky, ip->cblankx, ip->ftheight, 115 ip->ftwidth, RR_COPYINVERTED); 116 } 117 118 void 119 topcat_putc(ip, c, dy, dx, mode) 120 register struct ite_data *ip; 121 register int dy, dx; 122 int c, mode; 123 { 124 topcat_windowmove(ip, charY(ip, c), charX(ip, c), 125 dy * ip->ftheight, dx * ip->ftwidth, 126 ip->ftheight, ip->ftwidth, RR_COPY); 127 } 128 129 void 130 topcat_cursor(ip, flag) 131 register struct ite_data *ip; 132 register int flag; 133 { 134 if (flag == DRAW_CURSOR) 135 draw_cursor(ip) 136 else if (flag == MOVE_CURSOR) { 137 erase_cursor(ip) 138 draw_cursor(ip) 139 } 140 else 141 erase_cursor(ip) 142 } 143 144 void 145 topcat_clear(ip, sy, sx, h, w) 146 struct ite_data *ip; 147 register int sy, sx, h, w; 148 { 149 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 150 sy * ip->ftheight, sx * ip->ftwidth, 151 h * ip->ftheight, w * ip->ftwidth, 152 RR_CLEAR); 153 } 154 155 void 156 topcat_scroll(ip, sy, sx, count, dir) 157 register struct ite_data *ip; 158 register int sy, count; 159 int dir, sx; 160 { 161 register int dy = sy - count; 162 register int height = ip->rows - sy; 163 164 topcat_cursor(ip, ERASE_CURSOR); 165 166 topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 167 dy * ip->ftheight, sx * ip->ftwidth, 168 height * ip->ftheight, 169 ip->cols * ip->ftwidth, RR_COPY); 170 } 171 172 void 173 topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) 174 struct ite_data *ip; 175 int sy, sx, dy, dx, h, w, func; 176 { 177 register struct tcboxfb *rp = REGBASE; 178 179 if (h == 0 || w == 0) 180 return; 181 tc_waitbusy(ip->regbase, ip->planemask); 182 rp->wmrr = func; 183 rp->source_y = sy; 184 rp->source_x = sx; 185 rp->dest_y = dy; 186 rp->dest_x = dx; 187 rp->wheight = h; 188 rp->wwidth = w; 189 rp->wmove = ip->planemask; 190 } 191 #endif 192