141480Smckusick /* 241480Smckusick * Copyright (c) 1988 University of Utah. 341480Smckusick * Copyright (c) 1990 The Regents of the University of California. 441480Smckusick * 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 * 12*53929Shibler * from: Utah $Hdr: ite_rb.c 1.17 92/01/21$ 1341480Smckusick * 14*53929Shibler * @(#)ite_rb.c 7.6 (Berkeley) 06/05/92 1541480Smckusick */ 1641480Smckusick 1741480Smckusick #include "ite.h" 1841480Smckusick #if NITE > 0 1941480Smckusick 2049132Skarels #include "param.h" 2149132Skarels #include "conf.h" 2249132Skarels #include "proc.h" 2349132Skarels #include "ioctl.h" 2449132Skarels #include "tty.h" 2549132Skarels #include "systm.h" 2641480Smckusick 27*53929Shibler #include "hp/dev/itevar.h" 28*53929Shibler #include "hp/dev/itereg.h" 2941480Smckusick #include "grf_rbreg.h" 3041480Smckusick 3149132Skarels #include "machine/cpu.h" 3241480Smckusick 3341480Smckusick /* XXX */ 34*53929Shibler #include "hp/dev/grfioctl.h" 35*53929Shibler #include "hp/dev/grfvar.h" 3641480Smckusick 3741480Smckusick #define REGBASE ((struct rboxfb *)(ip->regbase)) 3841480Smckusick #define WINDOWMOVER rbox_windowmove 3941480Smckusick 4041480Smckusick rbox_init(ip) 4141480Smckusick struct ite_softc *ip; 4241480Smckusick { 4341480Smckusick register int i; 4441480Smckusick 4541480Smckusick /* XXX */ 4641480Smckusick if (ip->regbase == 0) { 47*53929Shibler struct grf_softc *gp = ip->grf; 48*53929Shibler 4949312Shibler ip->regbase = gp->g_regkva; 5049312Shibler ip->fbbase = gp->g_fbkva; 51*53929Shibler ip->fbwidth = gp->g_display.gd_fbwidth; 52*53929Shibler ip->fbheight = gp->g_display.gd_fbheight; 53*53929Shibler ip->dwidth = gp->g_display.gd_dwidth; 54*53929Shibler ip->dheight = gp->g_display.gd_dheight; 5541480Smckusick } 5641480Smckusick 57*53929Shibler rb_waitbusy(ip->regbase); 5841480Smckusick 5941480Smckusick REGBASE->reset = 0x39; 6041480Smckusick DELAY(1000); 6141480Smckusick 6241480Smckusick REGBASE->interrupt = 0x04; 6341480Smckusick REGBASE->display_enable = 0x01; 6441480Smckusick REGBASE->video_enable = 0x01; 6541480Smckusick REGBASE->drive = 0x01; 6641480Smckusick REGBASE->vdrive = 0x0; 6741480Smckusick 68*53929Shibler ite_fontinfo(ip); 6941480Smckusick 7041480Smckusick REGBASE->opwen = 0xFF; 7141480Smckusick 7241480Smckusick /* 7341480Smckusick * Clear the framebuffer. 7441480Smckusick */ 7541480Smckusick rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 76*53929Shibler rb_waitbusy(ip->regbase); 7741480Smckusick 7841480Smckusick for(i = 0; i < 16; i++) { 79*53929Shibler *(ip->regbase + 0x63c3 + i*4) = 0x0; 80*53929Shibler *(ip->regbase + 0x6403 + i*4) = 0x0; 81*53929Shibler *(ip->regbase + 0x6803 + i*4) = 0x0; 82*53929Shibler *(ip->regbase + 0x6c03 + i*4) = 0x0; 83*53929Shibler *(ip->regbase + 0x73c3 + i*4) = 0x0; 84*53929Shibler *(ip->regbase + 0x7403 + i*4) = 0x0; 85*53929Shibler *(ip->regbase + 0x7803 + i*4) = 0x0; 86*53929Shibler *(ip->regbase + 0x7c03 + i*4) = 0x0; 8741480Smckusick } 8841480Smckusick 8941480Smckusick REGBASE->rep_rule = 0x33; 9041480Smckusick 9141480Smckusick /* 9241480Smckusick * I cannot figure out how to make the blink planes stop. So, we 9341480Smckusick * must set both colormaps so that when the planes blink, and 9441480Smckusick * the secondary colormap is active, we still get text. 9541480Smckusick */ 9641480Smckusick CM1RED[0x00].value = 0x00; 9741480Smckusick CM1GRN[0x00].value = 0x00; 9841480Smckusick CM1BLU[0x00].value = 0x00; 9941480Smckusick CM1RED[0x01].value = 0xFF; 10041480Smckusick CM1GRN[0x01].value = 0xFF; 10141480Smckusick CM1BLU[0x01].value = 0xFF; 10241480Smckusick 10341480Smckusick CM2RED[0x00].value = 0x00; 10441480Smckusick CM2GRN[0x00].value = 0x00; 10541480Smckusick CM2BLU[0x00].value = 0x00; 10641480Smckusick CM2RED[0x01].value = 0xFF; 10741480Smckusick CM2GRN[0x01].value = 0xFF; 10841480Smckusick CM2BLU[0x01].value = 0xFF; 10941480Smckusick 11041480Smckusick REGBASE->blink = 0x00; 11141480Smckusick REGBASE->write_enable = 0x01; 11241480Smckusick REGBASE->opwen = 0x00; 11341480Smckusick 11441480Smckusick ite_fontinit(ip); 11541480Smckusick 11641480Smckusick /* 11741480Smckusick * Stash the inverted cursor. 11841480Smckusick */ 11941480Smckusick rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '), 12041480Smckusick ip->cblanky, ip->cblankx, ip->ftheight, 12141480Smckusick ip->ftwidth, RR_COPYINVERTED); 12241480Smckusick } 12341480Smckusick 12441480Smckusick rbox_deinit(ip) 12541480Smckusick struct ite_softc *ip; 12641480Smckusick { 12741480Smckusick rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); 128*53929Shibler rb_waitbusy(ip->regbase); 12941480Smckusick 13041480Smckusick ip->flags &= ~ITE_INITED; 13141480Smckusick } 13241480Smckusick 13341480Smckusick rbox_putc(ip, c, dy, dx, mode) 13441480Smckusick register struct ite_softc *ip; 13541480Smckusick register int dy, dx; 13641480Smckusick int c, mode; 13741480Smckusick { 13841480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); 13941480Smckusick 14041480Smckusick rbox_windowmove(ip, charY(ip, c), charX(ip, c), 14141480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 14241480Smckusick ip->ftheight, ip->ftwidth, wrr); 14341480Smckusick } 14441480Smckusick 14541480Smckusick rbox_cursor(ip, flag) 14641480Smckusick register struct ite_softc *ip; 14741480Smckusick register int flag; 14841480Smckusick { 14941480Smckusick if (flag == DRAW_CURSOR) 15041480Smckusick draw_cursor(ip) 15141480Smckusick else if (flag == MOVE_CURSOR) { 15241480Smckusick erase_cursor(ip) 15341480Smckusick draw_cursor(ip) 15441480Smckusick } 15541480Smckusick else 15641480Smckusick erase_cursor(ip) 15741480Smckusick } 15841480Smckusick 15941480Smckusick rbox_clear(ip, sy, sx, h, w) 16041480Smckusick struct ite_softc *ip; 16141480Smckusick register int sy, sx, h, w; 16241480Smckusick { 16341480Smckusick rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 16441480Smckusick sy * ip->ftheight, sx * ip->ftwidth, 16541480Smckusick h * ip->ftheight, w * ip->ftwidth, 16641480Smckusick RR_CLEAR); 16741480Smckusick } 16841480Smckusick 16941480Smckusick rbox_scroll(ip, sy, sx, count, dir) 17041480Smckusick register struct ite_softc *ip; 17141480Smckusick register int sy, count; 17241480Smckusick int dir, sx; 17341480Smckusick { 17441480Smckusick register int dy; 17541480Smckusick register int dx = sx; 17641480Smckusick register int height = 1; 17741480Smckusick register int width = ip->cols; 17841480Smckusick 17941480Smckusick rbox_cursor(ip, ERASE_CURSOR); 18041480Smckusick 18141480Smckusick if (dir == SCROLL_UP) { 18241480Smckusick dy = sy - count; 18341480Smckusick height = ip->rows - sy; 18441480Smckusick } 18541480Smckusick else if (dir == SCROLL_DOWN) { 18641480Smckusick dy = sy + count; 18741480Smckusick height = ip->rows - dy - 1; 18841480Smckusick } 18941480Smckusick else if (dir == SCROLL_RIGHT) { 19041480Smckusick dy = sy; 19141480Smckusick dx = sx + count; 19241480Smckusick width = ip->cols - dx; 19341480Smckusick } 19441480Smckusick else { 19541480Smckusick dy = sy; 19641480Smckusick dx = sx - count; 19741480Smckusick width = ip->cols - sx; 19841480Smckusick } 19941480Smckusick 20041480Smckusick rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, 20141480Smckusick dy * ip->ftheight, dx * ip->ftwidth, 20241480Smckusick height * ip->ftheight, 20341480Smckusick width * ip->ftwidth, RR_COPY); 20441480Smckusick } 20541480Smckusick 20641480Smckusick rbox_windowmove(ip, sy, sx, dy, dx, h, w, func) 20741480Smckusick struct ite_softc *ip; 20841480Smckusick int sy, sx, dy, dx, h, w, func; 20941480Smckusick { 21041480Smckusick register struct rboxfb *rp = REGBASE; 21141480Smckusick if (h == 0 || w == 0) 21241480Smckusick return; 21341480Smckusick 214*53929Shibler rb_waitbusy(ip->regbase); 21541480Smckusick rp->rep_rule = func << 4 | func; 21641480Smckusick rp->source_y = sy; 21741480Smckusick rp->source_x = sx; 21841480Smckusick rp->dest_y = dy; 21941480Smckusick rp->dest_x = dx; 22041480Smckusick rp->wheight = h; 22141480Smckusick rp->wwidth = w; 22241480Smckusick rp->wmove = 1; 22341480Smckusick } 22441480Smckusick #endif 225