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*53923Shibler * from: Utah $Hdr: ite_subr.c 1.4 92/01/21$ 1341480Smckusick * 14*53923Shibler * @(#)ite_subr.c 7.5 (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 2741480Smckusick #include "itevar.h" 2841480Smckusick #include "itereg.h" 2941480Smckusick 3049132Skarels #include "machine/cpu.h" 3141480Smckusick 32*53923Shibler ite_fontinfo(ip) 3341480Smckusick struct ite_softc *ip; 3441480Smckusick { 35*53923Shibler u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR); 3641480Smckusick 37*53923Shibler ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT); 38*53923Shibler 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 6441480Smckusick ite_fontinit(ip) 6541480Smckusick register struct ite_softc *ip; 6641480Smckusick { 67*53923Shibler int bytewidth = (((ip->ftwidth - 1) / 8) + 1); 68*53923Shibler int glyphsize = bytewidth * ip->ftheight; 69*53923Shibler u_char fontbuf[500]; /* XXX malloc not initialize yet */ 70*53923Shibler u_char *dp, *fbmem; 71*53923Shibler int c, i, romp; 72*53923Shibler 73*53923Shibler romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA; 74*53923Shibler for (c = 0; c < 128; c++) { 75*53923Shibler fbmem = (u_char *) 76*53923Shibler (FBBASE + 77*53923Shibler (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth + 78*53923Shibler (ip->fontx + (c % ip->cpl) * ip->ftwidth)); 79*53923Shibler dp = fontbuf; 80*53923Shibler for (i = 0; i < glyphsize; i++) { 81*53923Shibler *dp++ = getbyte(ip, romp); 82*53923Shibler romp += 2; 83*53923Shibler } 84*53923Shibler writeglyph(ip, fbmem, fontbuf); 85*53923Shibler } 86*53923Shibler } 87*53923Shibler 88*53923Shibler /* 89*53923Shibler * Display independent versions of the readbyte and writeglyph routines. 90*53923Shibler */ 91*53923Shibler u_char 92*53923Shibler ite_readbyte(ip, disp) 93*53923Shibler struct ite_softc *ip; 94*53923Shibler int disp; 95*53923Shibler { 96*53923Shibler return((u_char) *(((u_char *)ip->regbase) + disp)); 97*53923Shibler } 98*53923Shibler 99*53923Shibler ite_writeglyph(ip, fbmem, glyphp) 100*53923Shibler register struct ite_softc *ip; 101*53923Shibler register u_char *fbmem, *glyphp; 102*53923Shibler { 10341480Smckusick register int bn; 10441480Smckusick int c, l, b; 10541480Smckusick 106*53923Shibler for (l = 0; l < ip->ftheight; l++) { 107*53923Shibler bn = 7; 108*53923Shibler for (b = 0; b < ip->ftwidth; b++) { 109*53923Shibler if ((1 << bn) & *glyphp) 110*53923Shibler *fbmem++ = 1; 111*53923Shibler else 112*53923Shibler *fbmem++ = 0; 113*53923Shibler if (--bn < 0) { 114*53923Shibler bn = 7; 115*53923Shibler glyphp++; 11641480Smckusick } 11741480Smckusick } 118*53923Shibler if (bn < 7) 119*53923Shibler glyphp++; 120*53923Shibler fbmem -= ip->ftwidth; 121*53923Shibler fbmem += ip->fbwidth; 12241480Smckusick } 12341480Smckusick } 12441480Smckusick #endif 125