xref: /csrg-svn/sys/hp300/stand/ite_tc.c (revision 63165)
141488Smckusick /*
241488Smckusick  * Copyright (c) 1988 University of Utah.
3*63165Sbostic  * Copyright (c) 1990, 1993
4*63165Sbostic  *	The Regents of the University of California.  All rights reserved.
541488Smckusick  *
641488Smckusick  * This code is derived from software contributed to Berkeley by
741488Smckusick  * the Systems Programming Group of the University of Utah Computer
841488Smckusick  * Science Department.
941488Smckusick  *
1041488Smckusick  * %sccs.include.redist.c%
1141488Smckusick  *
1254073Shibler  * from: Utah $Hdr: ite_tc.c 1.11 92/01/20$
1341488Smckusick  *
14*63165Sbostic  *	@(#)ite_tc.c	8.1 (Berkeley) 06/10/93
1541488Smckusick  */
1641488Smckusick 
1756510Sbostic #include <hp300/stand/samachdep.h>
1841488Smckusick 
1941488Smckusick #ifdef ITECONSOLE
2041488Smckusick 
2156510Sbostic #include <sys/param.h>
2256510Sbostic #include <hp/dev/itevar.h>
2356510Sbostic #include <hp/dev/itereg.h>
2456510Sbostic #include <hp/dev/grfreg.h>
2556510Sbostic #include <hp300/dev/grf_tcreg.h>
2641488Smckusick 
2741488Smckusick #define REGBASE	    	((struct tcboxfb *)(ip->regbase))
2841488Smckusick #define WINDOWMOVER 	topcat_windowmove
2941488Smckusick 
topcat_init(ip)3041488Smckusick topcat_init(ip)
3141488Smckusick 	register struct ite_softc *ip;
3241488Smckusick {
3341488Smckusick 
3441488Smckusick 	/*
3554073Shibler 	 * Catseye looks a lot like a topcat, but not completely.
3654073Shibler 	 * So, we set some bits to make it work.
3754073Shibler 	 */
3854073Shibler 	if (REGBASE->fbid != GID_TOPCAT) {
3954073Shibler 		while ((REGBASE->catseye_status & 1))
4054073Shibler 			;
4154073Shibler 		REGBASE->catseye_status = 0x0;
4254073Shibler 		REGBASE->vb_select      = 0x0;
4354073Shibler 		REGBASE->tcntrl         = 0x0;
4454073Shibler 		REGBASE->acntrl         = 0x0;
4554073Shibler 		REGBASE->pncntrl        = 0x0;
4654073Shibler 		REGBASE->rug_cmdstat    = 0x90;
4754073Shibler 	}
4854073Shibler 
4954073Shibler 	/*
5041488Smckusick 	 * Determine the number of planes by writing to the first frame
5141488Smckusick 	 * buffer display location, then reading it back.
5241488Smckusick 	 */
5341488Smckusick 	REGBASE->wen = ~0;
5441488Smckusick 	REGBASE->fben = ~0;
5541488Smckusick 	REGBASE->prr = RR_COPY;
5641488Smckusick 	*FBBASE = 0xFF;
5741488Smckusick 	ip->planemask = *FBBASE;
5841488Smckusick 
5941488Smckusick 	/*
6041488Smckusick 	 * Enable reading/writing of all the planes.
6141488Smckusick 	 */
6241488Smckusick 	REGBASE->fben = ip->planemask;
6341488Smckusick 	REGBASE->wen  = ip->planemask;
6441488Smckusick 	REGBASE->ren  = ip->planemask;
6541488Smckusick 	REGBASE->prr  = RR_COPY;
6641488Smckusick 
6754073Shibler 	ite_fontinfo(ip);
6841488Smckusick 
6941488Smckusick 	/*
7041488Smckusick 	 * Clear the framebuffer on all planes.
7141488Smckusick 	 */
7241488Smckusick 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
7354073Shibler 	tc_waitbusy(ip->regbase, ip->planemask);
7441488Smckusick 
7541488Smckusick 	ite_fontinit(ip);
7641488Smckusick 
7741488Smckusick 	/*
7841488Smckusick 	 * Stash the inverted cursor.
7941488Smckusick 	 */
8041488Smckusick 	topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
8141488Smckusick 			  ip->cblanky, ip->cblankx, ip->ftheight,
8241488Smckusick 			  ip->ftwidth, RR_COPYINVERTED);
8341488Smckusick }
8441488Smckusick 
topcat_putc(ip,c,dy,dx,mode)8541488Smckusick topcat_putc(ip, c, dy, dx, mode)
8641488Smckusick 	register struct ite_softc *ip;
8741488Smckusick         register int dy, dx;
8841488Smckusick 	int c, mode;
8941488Smckusick {
9041488Smckusick 	topcat_windowmove(ip, charY(ip, c), charX(ip, c),
9141488Smckusick 			  dy * ip->ftheight, dx * ip->ftwidth,
9241488Smckusick 			  ip->ftheight, ip->ftwidth, RR_COPY);
9341488Smckusick }
9441488Smckusick 
topcat_cursor(ip,flag)9541488Smckusick topcat_cursor(ip, flag)
9641488Smckusick 	register struct ite_softc *ip;
9741488Smckusick         register int flag;
9841488Smckusick {
9941488Smckusick 	if (flag == DRAW_CURSOR)
10041488Smckusick 		draw_cursor(ip)
10141488Smckusick 	else if (flag == MOVE_CURSOR) {
10241488Smckusick 		erase_cursor(ip)
10341488Smckusick 		draw_cursor(ip)
10441488Smckusick 	}
10541488Smckusick 	else
10641488Smckusick 		erase_cursor(ip)
10741488Smckusick }
10841488Smckusick 
10941488Smckusick topcat_clear(ip, sy, sx, h, w)
11041488Smckusick 	struct ite_softc *ip;
11141488Smckusick 	register int sy, sx, h, w;
11241488Smckusick {
11341488Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
11441488Smckusick 			  sy * ip->ftheight, sx * ip->ftwidth,
11541488Smckusick 			  h  * ip->ftheight, w  * ip->ftwidth,
11641488Smckusick 			  RR_CLEAR);
11741488Smckusick }
11841488Smckusick 
topcat_scroll(ip,sy,sx,count,dir)11941488Smckusick topcat_scroll(ip, sy, sx, count, dir)
12041488Smckusick         register struct ite_softc *ip;
12141488Smckusick         register int sy, count;
12241488Smckusick         int dir, sx;
12341488Smckusick {
12441488Smckusick 	register int dy = sy - count;
12541488Smckusick 	register int height = ip->rows - sy;
12641488Smckusick 
12741488Smckusick 	topcat_cursor(ip, ERASE_CURSOR);
12841488Smckusick 
12941488Smckusick 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
13041488Smckusick 			  dy * ip->ftheight, sx * ip->ftwidth,
13141488Smckusick 			  height * ip->ftheight,
13241488Smckusick 			  ip->cols  * ip->ftwidth, RR_COPY);
13341488Smckusick }
13441488Smckusick 
13541488Smckusick topcat_windowmove(ip, sy, sx, dy, dx, h, w, func)
13641488Smckusick 	struct ite_softc *ip;
13741488Smckusick 	int sy, sx, dy, dx, h, w, func;
13841488Smckusick {
13941488Smckusick   	register struct tcboxfb *rp = REGBASE;
14041488Smckusick 
14141488Smckusick 	if (h == 0 || w == 0)
14241488Smckusick 		return;
14354073Shibler 	tc_waitbusy(ip->regbase, ip->planemask);
14441488Smckusick 	rp->wmrr     = func;
14541488Smckusick 	rp->source_y = sy;
14641488Smckusick 	rp->source_x = sx;
14741488Smckusick 	rp->dest_y   = dy;
14841488Smckusick 	rp->dest_x   = dx;
14941488Smckusick 	rp->wheight  = h;
15041488Smckusick 	rp->wwidth   = w;
15141488Smckusick 	rp->wmove    = ip->planemask;
15241488Smckusick }
15341488Smckusick #endif
154