141488Smckusick /*
241488Smckusick * Copyright (c) 1988 University of Utah.
3*63163Sbostic * Copyright (c) 1990, 1993
4*63163Sbostic * 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_gb.c 1.9 92/01/20$
1341488Smckusick *
14*63163Sbostic * @(#)ite_gb.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>
2241488Smckusick
2356510Sbostic #include <hp/dev/itevar.h>
2456510Sbostic #include <hp/dev/itereg.h>
2556510Sbostic #include <hp300/dev/grf_gbreg.h>
2641488Smckusick
2741488Smckusick #define REGBASE ((struct gboxfb *)(ip->regbase))
2854073Shibler #define WINDOWMOVER gbox_windowmove
2941488Smckusick
gbox_init(ip)3054073Shibler gbox_init(ip)
3141488Smckusick register struct ite_softc *ip;
3241488Smckusick {
3341488Smckusick REGBASE->write_protect = 0x0;
3441488Smckusick REGBASE->interrupt = 0x4;
3541488Smckusick REGBASE->rep_rule = RR_COPY;
3641488Smckusick REGBASE->blink1 = 0xff;
3741488Smckusick REGBASE->blink2 = 0xff;
3841488Smckusick REGBASE->sec_interrupt = 0x01;
3941488Smckusick
4041488Smckusick /*
4141488Smckusick * Set up the color map entries. We use three entries in the
4241488Smckusick * color map. The first, is for black, the second is for
4341488Smckusick * white, and the very last entry is for the inverted cursor.
4441488Smckusick */
4541488Smckusick REGBASE->creg_select = 0x00;
4641488Smckusick REGBASE->cmap_red = 0x00;
4741488Smckusick REGBASE->cmap_grn = 0x00;
4841488Smckusick REGBASE->cmap_blu = 0x00;
4941488Smckusick REGBASE->cmap_write = 0x00;
5054073Shibler gbcm_waitbusy(ip->regbase);
5141488Smckusick
5241488Smckusick REGBASE->creg_select = 0x01;
5341488Smckusick REGBASE->cmap_red = 0xFF;
5441488Smckusick REGBASE->cmap_grn = 0xFF;
5541488Smckusick REGBASE->cmap_blu = 0xFF;
5641488Smckusick REGBASE->cmap_write = 0x01;
5754073Shibler gbcm_waitbusy(ip->regbase);
5841488Smckusick
5941488Smckusick REGBASE->creg_select = 0xFF;
6041488Smckusick REGBASE->cmap_red = 0xFF;
6141488Smckusick REGBASE->cmap_grn = 0xFF;
6241488Smckusick REGBASE->cmap_blu = 0xFF;
6341488Smckusick REGBASE->cmap_write = 0x01;
6454073Shibler gbcm_waitbusy(ip->regbase);
6541488Smckusick
6654073Shibler ite_fontinfo(ip);
6741488Smckusick ite_fontinit(ip);
6841488Smckusick
6941488Smckusick /*
7041488Smckusick * Clear the display. This used to be before the font unpacking
7141488Smckusick * but it crashes. Figure it out later.
7241488Smckusick */
7354073Shibler gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
7454073Shibler tile_mover_waitbusy(ip->regbase);
7541488Smckusick
7641488Smckusick /*
7741488Smckusick * Stash the inverted cursor.
7841488Smckusick */
7954073Shibler gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
8054073Shibler ip->cblanky, ip->cblankx, ip->ftheight,
8154073Shibler ip->ftwidth, RR_COPYINVERTED);
8241488Smckusick }
8341488Smckusick
gbox_putc(ip,c,dy,dx,mode)8454073Shibler gbox_putc(ip, c, dy, dx, mode)
8541488Smckusick register struct ite_softc *ip;
8641488Smckusick register int dy, dx;
8741488Smckusick int c, mode;
8841488Smckusick {
8954073Shibler gbox_windowmove(ip, charY(ip, c), charX(ip, c),
9054073Shibler dy * ip->ftheight, dx * ip->ftwidth,
9154073Shibler ip->ftheight, ip->ftwidth, RR_COPY);
9241488Smckusick }
9341488Smckusick
gbox_cursor(ip,flag)9454073Shibler gbox_cursor(ip, flag)
9541488Smckusick register struct ite_softc *ip;
9641488Smckusick register int flag;
9741488Smckusick {
9841488Smckusick if (flag == DRAW_CURSOR)
9941488Smckusick draw_cursor(ip)
10041488Smckusick else if (flag == MOVE_CURSOR) {
10141488Smckusick erase_cursor(ip)
10241488Smckusick draw_cursor(ip)
10341488Smckusick }
10441488Smckusick else
10541488Smckusick erase_cursor(ip)
10641488Smckusick }
10741488Smckusick
10854073Shibler gbox_clear(ip, sy, sx, h, w)
10941488Smckusick struct ite_softc *ip;
11041488Smckusick register int sy, sx, h, w;
11141488Smckusick {
11254073Shibler gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
11354073Shibler sy * ip->ftheight, sx * ip->ftwidth,
11454073Shibler h * ip->ftheight, w * ip->ftwidth,
11554073Shibler RR_CLEAR);
11641488Smckusick }
11741488Smckusick
11854073Shibler #define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
11954073Shibler gbox_windowmove((ip), \
12054073Shibler (sy) * ip->ftheight, \
12154073Shibler (sx) * ip->ftwidth, \
12254073Shibler (dy) * ip->ftheight, \
12354073Shibler (dx) * ip->ftwidth, \
12454073Shibler (h) * ip->ftheight, \
12554073Shibler (w) * ip->ftwidth, \
12654073Shibler RR_COPY)
12741488Smckusick
gbox_scroll(ip,sy,sx,count,dir)12854073Shibler gbox_scroll(ip, sy, sx, count, dir)
12941488Smckusick register struct ite_softc *ip;
13041488Smckusick register int sy;
13141488Smckusick int dir, sx, count;
13241488Smckusick {
13341488Smckusick register int height, dy, i;
13441488Smckusick
13554073Shibler tile_mover_waitbusy(ip->regbase);
13641488Smckusick REGBASE->write_protect = 0x0;
13741488Smckusick
13854073Shibler gbox_cursor(ip, ERASE_CURSOR);
13941488Smckusick
14041488Smckusick dy = sy - count;
14141488Smckusick height = ip->rows - sy;
14241488Smckusick for (i = 0; i < height; i++)
14354073Shibler gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
14441488Smckusick }
14541488Smckusick
gbox_windowmove(ip,sy,sx,dy,dx,h,w,mask)14654073Shibler gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
14741488Smckusick register struct ite_softc *ip;
14841488Smckusick int sy, sx, dy, dx, mask;
14941488Smckusick register int h, w;
15041488Smckusick {
15141488Smckusick register int src, dest;
15241488Smckusick
15341488Smckusick src = (sy * 1024) + sx; /* upper left corner in pixels */
15441488Smckusick dest = (dy * 1024) + dx;
15541488Smckusick
15654073Shibler tile_mover_waitbusy(ip->regbase);
15741488Smckusick REGBASE->width = -(w / 4);
15841488Smckusick REGBASE->height = -(h / 4);
15941488Smckusick if (src < dest)
16041488Smckusick REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
16141488Smckusick else {
16241488Smckusick REGBASE->rep_rule = MOVE_UP_LEFT|mask;
16341488Smckusick /*
16441488Smckusick * Adjust to top of lower right tile of the block.
16541488Smckusick */
16641488Smckusick src = src + ((h - 4) * 1024) + (w - 4);
16741488Smckusick dest= dest + ((h - 4) * 1024) + (w - 4);
16841488Smckusick }
16941488Smckusick FBBASE[dest] = FBBASE[src];
17041488Smckusick }
17141488Smckusick #endif
172