xref: /original-bsd/sys/hp300/stand/ite_subr.c (revision b3f911e0)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: ite_subr.c 1.1 89/02/17$
13  *
14  *	@(#)ite_subr.c	7.1 (Berkeley) 05/08/90
15  */
16 
17 #include "samachdep.h"
18 
19 #ifdef ITECONSOLE
20 
21 #include "param.h"
22 #include "../hpdev/itevar.h"
23 #include "../hpdev/itereg.h"
24 
25 ite_devinfo(ip)
26 	struct ite_softc *ip;
27 {
28 	struct fontinfo *fi;
29 	struct font *fd;
30 
31 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
32 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
33 
34 	ip->ftheight = fd->fh;
35 	ip->ftwidth  = fd->fw;
36 	ip->fbwidth  = ITEREGS->fbwidth_h << 8 | ITEREGS->fbwidth_l;
37 	ip->fbheight = ITEREGS->fbheight_h << 8 | ITEREGS->fbheight_l;
38 	ip->dwidth   = ITEREGS->dispwidth_h << 8 | ITEREGS->dispwidth_l;
39 	ip->dheight  = ITEREGS->dispheight_h << 8 | ITEREGS->dispheight_l;
40 	ip->rows     = ip->dheight / ip->ftheight;
41 	ip->cols     = ip->dwidth / ip->ftwidth;
42 
43 	if (ip->fbwidth > ip->dwidth) {
44 		/*
45 		 * Stuff goes to right of display.
46 		 */
47 		ip->fontx    = ip->dwidth;
48 		ip->fonty    = 0;
49 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
50 		ip->cblankx  = ip->dwidth;
51 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
52 	}
53 	else {
54 		/*
55 		 * Stuff goes below the display.
56 		 */
57 		ip->fontx   = 0;
58 		ip->fonty   = ip->dheight;
59 		ip->cpl     = ip->fbwidth / ip->ftwidth;
60 		ip->cblankx = 0;
61 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
62 	}
63 }
64 
65 ite_fontinit(ip)
66 	register struct ite_softc *ip;
67 {
68 	struct fontinfo *fi;
69 	struct font *fd;
70 	register u_char *fbmem, *dp;
71 	register int bn;
72 	int c, l, b;
73 
74 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
75 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
76 
77 	dp = fd->data;
78 
79 	for (c = 0; c < 128; c++) {
80 		fbmem = (u_char *) FBBASE +
81 			(ip->fonty + (c / ip->cpl) * ip->ftheight) *
82 			ip->fbwidth;
83 		fbmem += ip->fontx + (c % ip->cpl) * ip->ftwidth;
84 		for (l = 0; l < ip->ftheight; l++) {
85 			bn = 7;
86 			for (b = 0; b < ip->ftwidth; b++) {
87 				if ((1 << bn) & *dp)
88 					*fbmem++ = 1;
89 				else
90 					*fbmem++ = 0;
91 				if (--bn < 0) {
92 					bn = 7;
93 					dp += 2;
94 				}
95 			}
96 			if (bn < 7)
97 				dp += 2;
98 			fbmem -= ip->ftwidth;
99 			fbmem += ip->fbwidth;
100 		}
101 	}
102 
103 }
104 #endif
105