141480Smckusick /*
241480Smckusick * Copyright (c) 1988 University of Utah.
3*63151Sbostic * Copyright (c) 1990, 1993
4*63151Sbostic * The Regents of the University of California. All rights reserved.
541480Smckusick *
641480Smckusick * This code is derived from software contributed to Berkeley by
741480Smckusick * the Systems Programming Group of the University of Utah Computer
841480Smckusick * Science Department.
941480Smckusick *
1041480Smckusick * %sccs.include.redist.c%
1141480Smckusick *
1257325Shibler * from: Utah $Hdr: ite_gb.c 1.20 92/12/20$
1341480Smckusick *
14*63151Sbostic * @(#)ite_gb.c 8.1 (Berkeley) 06/10/93
1541480Smckusick */
1641480Smckusick
1741480Smckusick #include "ite.h"
1841480Smckusick #if NITE > 0
1941480Smckusick
2056507Sbostic #include <sys/param.h>
2156507Sbostic #include <sys/conf.h>
2256507Sbostic #include <sys/proc.h>
2356507Sbostic #include <sys/ioctl.h>
2456507Sbostic #include <sys/tty.h>
2556507Sbostic #include <sys/systm.h>
2641480Smckusick
2756507Sbostic #include <hp/dev/itevar.h>
2856507Sbostic #include <hp/dev/itereg.h>
2956507Sbostic #include <hp300/dev/grf_gbreg.h>
3041480Smckusick
3156507Sbostic #include <machine/cpu.h>
3241480Smckusick
3341480Smckusick /* XXX */
3456507Sbostic #include <hp/dev/grfioctl.h>
3556507Sbostic #include <hp/dev/grfvar.h>
3641480Smckusick
3741480Smckusick #define REGBASE ((struct gboxfb *)(ip->regbase))
3853929Shibler #define WINDOWMOVER gbox_windowmove
3941480Smckusick
gbox_init(ip)4053929Shibler gbox_init(ip)
4141480Smckusick register struct ite_softc *ip;
4241480Smckusick {
4341480Smckusick /* XXX */
4441480Smckusick if (ip->regbase == 0) {
4553929Shibler struct grf_softc *gp = ip->grf;
4653929Shibler
4749312Shibler ip->regbase = gp->g_regkva;
4849312Shibler ip->fbbase = gp->g_fbkva;
4953929Shibler ip->fbwidth = gp->g_display.gd_fbwidth;
5053929Shibler ip->fbheight = gp->g_display.gd_fbheight;
5153929Shibler ip->dwidth = gp->g_display.gd_dwidth;
5253929Shibler ip->dheight = gp->g_display.gd_dheight;
5341480Smckusick }
5441480Smckusick
5541480Smckusick REGBASE->write_protect = 0x0;
5641480Smckusick REGBASE->interrupt = 0x4;
5741480Smckusick REGBASE->rep_rule = RR_COPY;
5841480Smckusick REGBASE->blink1 = 0xff;
5941480Smckusick REGBASE->blink2 = 0xff;
6053929Shibler gb_microcode(ip->regbase);
6141480Smckusick REGBASE->sec_interrupt = 0x01;
6241480Smckusick
6341480Smckusick /*
6441480Smckusick * Set up the color map entries. We use three entries in the
6541480Smckusick * color map. The first, is for black, the second is for
6641480Smckusick * white, and the very last entry is for the inverted cursor.
6741480Smckusick */
6841480Smckusick REGBASE->creg_select = 0x00;
6941480Smckusick REGBASE->cmap_red = 0x00;
7041480Smckusick REGBASE->cmap_grn = 0x00;
7141480Smckusick REGBASE->cmap_blu = 0x00;
7241480Smckusick REGBASE->cmap_write = 0x00;
7353929Shibler gbcm_waitbusy(ip->regbase);
7441480Smckusick
7541480Smckusick REGBASE->creg_select = 0x01;
7641480Smckusick REGBASE->cmap_red = 0xFF;
7741480Smckusick REGBASE->cmap_grn = 0xFF;
7841480Smckusick REGBASE->cmap_blu = 0xFF;
7941480Smckusick REGBASE->cmap_write = 0x01;
8053929Shibler gbcm_waitbusy(ip->regbase);
8141480Smckusick
8241480Smckusick REGBASE->creg_select = 0xFF;
8341480Smckusick REGBASE->cmap_red = 0xFF;
8441480Smckusick REGBASE->cmap_grn = 0xFF;
8541480Smckusick REGBASE->cmap_blu = 0xFF;
8641480Smckusick REGBASE->cmap_write = 0x01;
8753929Shibler gbcm_waitbusy(ip->regbase);
8841480Smckusick
8953929Shibler ite_fontinfo(ip);
9041480Smckusick ite_fontinit(ip);
9141480Smckusick
9241480Smckusick /*
9341480Smckusick * Clear the display. This used to be before the font unpacking
9441480Smckusick * but it crashes. Figure it out later.
9541480Smckusick */
9653929Shibler gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
9753929Shibler tile_mover_waitbusy(ip->regbase);
9841480Smckusick
9941480Smckusick /*
10041480Smckusick * Stash the inverted cursor.
10141480Smckusick */
10253929Shibler gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
10353929Shibler ip->cblanky, ip->cblankx, ip->ftheight,
10453929Shibler ip->ftwidth, RR_COPYINVERTED);
10541480Smckusick }
10641480Smckusick
10753929Shibler gbox_deinit(ip)
10841480Smckusick struct ite_softc *ip;
10941480Smckusick {
11053929Shibler gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
11153929Shibler tile_mover_waitbusy(ip->regbase);
11241480Smckusick
11341480Smckusick ip->flags &= ~ITE_INITED;
11441480Smckusick }
11541480Smckusick
gbox_putc(ip,c,dy,dx,mode)11653929Shibler gbox_putc(ip, c, dy, dx, mode)
11741480Smckusick register struct ite_softc *ip;
11841480Smckusick register int dy, dx;
11941480Smckusick int c, mode;
12041480Smckusick {
12141480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
12241480Smckusick
12353929Shibler gbox_windowmove(ip, charY(ip, c), charX(ip, c),
12441480Smckusick dy * ip->ftheight, dx * ip->ftwidth,
12541480Smckusick ip->ftheight, ip->ftwidth, wrr);
12641480Smckusick }
12741480Smckusick
gbox_cursor(ip,flag)12853929Shibler gbox_cursor(ip, flag)
12941480Smckusick register struct ite_softc *ip;
13041480Smckusick register int flag;
13141480Smckusick {
13241480Smckusick if (flag == DRAW_CURSOR)
13341480Smckusick draw_cursor(ip)
13441480Smckusick else if (flag == MOVE_CURSOR) {
13541480Smckusick erase_cursor(ip)
13641480Smckusick draw_cursor(ip)
13741480Smckusick }
13841480Smckusick else
13941480Smckusick erase_cursor(ip)
14041480Smckusick }
14141480Smckusick
14253929Shibler gbox_clear(ip, sy, sx, h, w)
14341480Smckusick struct ite_softc *ip;
14441480Smckusick register int sy, sx, h, w;
14541480Smckusick {
14653929Shibler gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
14753929Shibler sy * ip->ftheight, sx * ip->ftwidth,
14853929Shibler h * ip->ftheight, w * ip->ftwidth,
14953929Shibler RR_CLEAR);
15041480Smckusick }
15153929Shibler #define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
15253929Shibler gbox_windowmove((ip), \
15353929Shibler (sy) * ip->ftheight, \
15453929Shibler (sx) * ip->ftwidth, \
15553929Shibler (dy) * ip->ftheight, \
15653929Shibler (dx) * ip->ftwidth, \
15753929Shibler (h) * ip->ftheight, \
15853929Shibler (w) * ip->ftwidth, \
15953929Shibler RR_COPY)
16041480Smckusick
gbox_scroll(ip,sy,sx,count,dir)16153929Shibler gbox_scroll(ip, sy, sx, count, dir)
16241480Smckusick register struct ite_softc *ip;
16341480Smckusick register int sy;
16441480Smckusick int dir, sx, count;
16541480Smckusick {
16641480Smckusick register int height, dy, i;
16741480Smckusick
16853929Shibler tile_mover_waitbusy(ip->regbase);
16941480Smckusick REGBASE->write_protect = 0x0;
17041480Smckusick
17141480Smckusick if (dir == SCROLL_UP) {
17241480Smckusick dy = sy - count;
17341480Smckusick height = ip->rows - sy;
17441480Smckusick for (i = 0; i < height; i++)
17553929Shibler gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
17641480Smckusick }
17741480Smckusick else if (dir == SCROLL_DOWN) {
17841480Smckusick dy = sy + count;
17941480Smckusick height = ip->rows - dy;
18041480Smckusick for (i = (height - 1); i >= 0; i--)
18153929Shibler gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
18241480Smckusick }
18341480Smckusick else if (dir == SCROLL_RIGHT) {
18453929Shibler gbox_blockmove(ip, sy, sx, sy, sx + count,
18553929Shibler 1, ip->cols - (sx + count));
18641480Smckusick }
18741480Smckusick else {
18853929Shibler gbox_blockmove(ip, sy, sx, sy, sx - count,
18953929Shibler 1, ip->cols - sx);
19041480Smckusick }
19141480Smckusick }
19241480Smckusick
gbox_windowmove(ip,sy,sx,dy,dx,h,w,mask)19353929Shibler gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
19441480Smckusick register struct ite_softc *ip;
19541480Smckusick int sy, sx, dy, dx, mask;
19641480Smckusick register int h, w;
19741480Smckusick {
19841480Smckusick register int src, dest;
19941480Smckusick
20041480Smckusick src = (sy * 1024) + sx; /* upper left corner in pixels */
20141480Smckusick dest = (dy * 1024) + dx;
20241480Smckusick
20353929Shibler tile_mover_waitbusy(ip->regbase);
20441480Smckusick REGBASE->width = -(w / 4);
20541480Smckusick REGBASE->height = -(h / 4);
20641480Smckusick if (src < dest)
20741480Smckusick REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
20841480Smckusick else {
20941480Smckusick REGBASE->rep_rule = MOVE_UP_LEFT|mask;
21041480Smckusick /*
21141480Smckusick * Adjust to top of lower right tile of the block.
21241480Smckusick */
21341480Smckusick src = src + ((h - 4) * 1024) + (w - 4);
21441480Smckusick dest= dest + ((h - 4) * 1024) + (w - 4);
21541480Smckusick }
21641480Smckusick FBBASE[dest] = FBBASE[src];
21741480Smckusick }
21841480Smckusick #endif
219