141480Smckusick /*
241480Smckusick * Copyright (c) 1988 University of Utah.
363148Sbostic * Copyright (c) 1990, 1993
463148Sbostic * 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 *
1253923Shibler * from: Utah $Hdr: ite_subr.c 1.4 92/01/21$
1341480Smckusick *
14*65699Shibler * @(#)ite_subr.c 8.2 (Berkeley) 01/12/94
1541480Smckusick */
1641480Smckusick
1741480Smckusick #include "ite.h"
1841480Smckusick #if NITE > 0
1941480Smckusick
2056504Sbostic #include <sys/param.h>
2156504Sbostic #include <sys/conf.h>
2256504Sbostic #include <sys/proc.h>
2356504Sbostic #include <sys/ioctl.h>
2456504Sbostic #include <sys/tty.h>
2556504Sbostic #include <sys/systm.h>
2641480Smckusick
2756504Sbostic #include <hp/dev/itevar.h>
2856504Sbostic #include <hp/dev/itereg.h>
2941480Smckusick
3056504Sbostic #include <machine/cpu.h>
3141480Smckusick
3253923Shibler ite_fontinfo(ip)
3341480Smckusick struct ite_softc *ip;
3441480Smckusick {
3553923Shibler u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
3641480Smckusick
3753923Shibler ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
3853923Shibler ip->ftwidth = getbyte(ip, fontaddr + FONTWIDTH);
3941480Smckusick ip->rows = ip->dheight / ip->ftheight;
4041480Smckusick ip->cols = ip->dwidth / ip->ftwidth;
4141480Smckusick
4241480Smckusick if (ip->fbwidth > ip->dwidth) {
4341480Smckusick /*
4441480Smckusick * Stuff goes to right of display.
4541480Smckusick */
4641480Smckusick ip->fontx = ip->dwidth;
4741480Smckusick ip->fonty = 0;
4841480Smckusick ip->cpl = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
4941480Smckusick ip->cblankx = ip->dwidth;
5041480Smckusick ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
5141480Smckusick }
5241480Smckusick else {
5341480Smckusick /*
5441480Smckusick * Stuff goes below the display.
5541480Smckusick */
5641480Smckusick ip->fontx = 0;
5741480Smckusick ip->fonty = ip->dheight;
5841480Smckusick ip->cpl = ip->fbwidth / ip->ftwidth;
5941480Smckusick ip->cblankx = 0;
6041480Smckusick ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
6141480Smckusick }
6241480Smckusick }
6341480Smckusick
ite_fontinit(ip)6441480Smckusick ite_fontinit(ip)
6541480Smckusick register struct ite_softc *ip;
6641480Smckusick {
6753923Shibler int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
6853923Shibler int glyphsize = bytewidth * ip->ftheight;
6953923Shibler u_char fontbuf[500]; /* XXX malloc not initialize yet */
7053923Shibler u_char *dp, *fbmem;
7153923Shibler int c, i, romp;
7253923Shibler
7353923Shibler romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
7453923Shibler for (c = 0; c < 128; c++) {
7553923Shibler fbmem = (u_char *)
7653923Shibler (FBBASE +
7753923Shibler (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
7853923Shibler (ip->fontx + (c % ip->cpl) * ip->ftwidth));
7953923Shibler dp = fontbuf;
8053923Shibler for (i = 0; i < glyphsize; i++) {
8153923Shibler *dp++ = getbyte(ip, romp);
8253923Shibler romp += 2;
8353923Shibler }
8453923Shibler writeglyph(ip, fbmem, fontbuf);
8553923Shibler }
8653923Shibler }
8753923Shibler
8853923Shibler /*
8953923Shibler * Display independent versions of the readbyte and writeglyph routines.
9053923Shibler */
9153923Shibler u_char
ite_readbyte(ip,disp)9253923Shibler ite_readbyte(ip, disp)
9353923Shibler struct ite_softc *ip;
9453923Shibler int disp;
9553923Shibler {
9653923Shibler return((u_char) *(((u_char *)ip->regbase) + disp));
9753923Shibler }
9853923Shibler
ite_writeglyph(ip,fbmem,glyphp)9953923Shibler ite_writeglyph(ip, fbmem, glyphp)
10053923Shibler register struct ite_softc *ip;
10153923Shibler register u_char *fbmem, *glyphp;
10253923Shibler {
10341480Smckusick register int bn;
104*65699Shibler int l, b;
10541480Smckusick
10653923Shibler for (l = 0; l < ip->ftheight; l++) {
10753923Shibler bn = 7;
10853923Shibler for (b = 0; b < ip->ftwidth; b++) {
10953923Shibler if ((1 << bn) & *glyphp)
11053923Shibler *fbmem++ = 1;
11153923Shibler else
11253923Shibler *fbmem++ = 0;
11353923Shibler if (--bn < 0) {
11453923Shibler bn = 7;
11553923Shibler glyphp++;
11641480Smckusick }
11741480Smckusick }
11853923Shibler if (bn < 7)
11953923Shibler glyphp++;
12053923Shibler fbmem -= ip->ftwidth;
12153923Shibler fbmem += ip->fbwidth;
12241480Smckusick }
12341480Smckusick }
12441480Smckusick #endif
125