xref: /original-bsd/sys/hp/dev/ite_subr.c (revision acda45c0)
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 90/07/09$
13  *
14  *	@(#)ite_subr.c	7.3 (Berkeley) 12/16/90
15  */
16 
17 #include "ite.h"
18 #if NITE > 0
19 
20 #include "sys/param.h"
21 #include "sys/conf.h"
22 #include "sys/user.h"
23 #include "sys/proc.h"
24 #include "sys/ioctl.h"
25 #include "sys/tty.h"
26 #include "sys/systm.h"
27 #include "sys/uio.h"
28 
29 #include "itevar.h"
30 #include "itereg.h"
31 
32 #include "../include/cpu.h"
33 
34 ite_devinfo(ip)
35 	struct ite_softc *ip;
36 {
37 	struct fontinfo *fi;
38 	struct font *fd;
39 
40 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
41 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
42 
43 	ip->ftheight = fd->fh;
44 	ip->ftwidth  = fd->fw;
45 	ip->fbwidth  = ITEREGS->fbwidth_h << 8 | ITEREGS->fbwidth_l;
46 	ip->fbheight = ITEREGS->fbheight_h << 8 | ITEREGS->fbheight_l;
47 	ip->dwidth   = ITEREGS->dispwidth_h << 8 | ITEREGS->dispwidth_l;
48 	ip->dheight  = ITEREGS->dispheight_h << 8 | ITEREGS->dispheight_l;
49 	ip->rows     = ip->dheight / ip->ftheight;
50 	ip->cols     = ip->dwidth / ip->ftwidth;
51 
52 	if (ip->fbwidth > ip->dwidth) {
53 		/*
54 		 * Stuff goes to right of display.
55 		 */
56 		ip->fontx    = ip->dwidth;
57 		ip->fonty    = 0;
58 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
59 		ip->cblankx  = ip->dwidth;
60 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
61 	}
62 	else {
63 		/*
64 		 * Stuff goes below the display.
65 		 */
66 		ip->fontx   = 0;
67 		ip->fonty   = ip->dheight;
68 		ip->cpl     = ip->fbwidth / ip->ftwidth;
69 		ip->cblankx = 0;
70 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
71 	}
72 }
73 
74 ite_fontinit(ip)
75 	register struct ite_softc *ip;
76 {
77 	struct fontinfo *fi;
78 	struct font *fd;
79 	register u_char *fbmem, *dp;
80 	register int bn;
81 	int c, l, b;
82 
83 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
84 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
85 
86 	dp = fd->data;
87 
88 	for (c = 0; c < 128; c++) {
89 		fbmem = (u_char *) FBBASE +
90 			(ip->fonty + (c / ip->cpl) * ip->ftheight) *
91 			ip->fbwidth;
92 		fbmem += ip->fontx + (c % ip->cpl) * ip->ftwidth;
93 		for (l = 0; l < ip->ftheight; l++) {
94 			bn = 7;
95 			for (b = 0; b < ip->ftwidth; b++) {
96 				if ((1 << bn) & *dp)
97 					*fbmem++ = 1;
98 				else
99 					*fbmem++ = 0;
100 				if (--bn < 0) {
101 					bn = 7;
102 					dp += 2;
103 				}
104 			}
105 			if (bn < 7)
106 				dp += 2;
107 			fbmem -= ip->ftwidth;
108 			fbmem += ip->fbwidth;
109 		}
110 	}
111 
112 }
113 #endif
114