wscons_rinit.c revision 1.1 1 1.1 drochner /* $NetBSD: wscons_rinit.c,v 1.1 1998/03/22 14:24:02 drochner Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1991, 1993
5 1.1 drochner * The Regents of the University of California. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * This software was developed by the Computer Systems Engineering group
8 1.1 drochner * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 1.1 drochner * contributed to Berkeley.
10 1.1 drochner *
11 1.1 drochner * All advertising materials mentioning features or use of this software
12 1.1 drochner * must display the following acknowledgement:
13 1.1 drochner * This product includes software developed by the University of
14 1.1 drochner * California, Lawrence Berkeley Laboratory.
15 1.1 drochner *
16 1.1 drochner * Redistribution and use in source and binary forms, with or without
17 1.1 drochner * modification, are permitted provided that the following conditions
18 1.1 drochner * are met:
19 1.1 drochner * 1. Redistributions of source code must retain the above copyright
20 1.1 drochner * notice, this list of conditions and the following disclaimer.
21 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
22 1.1 drochner * notice, this list of conditions and the following disclaimer in the
23 1.1 drochner * documentation and/or other materials provided with the distribution.
24 1.1 drochner * 3. All advertising materials mentioning features or use of this software
25 1.1 drochner * must display the following acknowledgement:
26 1.1 drochner * This product includes software developed by the University of
27 1.1 drochner * California, Berkeley and its contributors.
28 1.1 drochner * 4. Neither the name of the University nor the names of its contributors
29 1.1 drochner * may be used to endorse or promote products derived from this software
30 1.1 drochner * without specific prior written permission.
31 1.1 drochner *
32 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 1.1 drochner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 1.1 drochner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 1.1 drochner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 1.1 drochner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1 drochner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1 drochner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1 drochner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 1.1 drochner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 1.1 drochner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 1.1 drochner * SUCH DAMAGE.
43 1.1 drochner *
44 1.1 drochner * @(#)rcons_font.c 8.1 (Berkeley) 6/11/93
45 1.1 drochner */
46 1.1 drochner
47 1.1 drochner #include <sys/param.h>
48 1.1 drochner #include <sys/systm.h>
49 1.1 drochner #include <sys/device.h>
50 1.1 drochner
51 1.1 drochner #include <dev/rcons/raster.h>
52 1.1 drochner #include <dev/wscons/wscons_raster.h>
53 1.1 drochner
54 1.1 drochner #include <dev/wscons/wscons_rfont.h>
55 1.1 drochner
56 1.1 drochner void rcons_initfont __P((struct rcons *, struct raster_font *));
57 1.1 drochner
58 1.1 drochner void
59 1.1 drochner rcons_initfont(rc, fp)
60 1.1 drochner struct rcons *rc;
61 1.1 drochner struct raster_font *fp;
62 1.1 drochner {
63 1.1 drochner static int initfontdone;
64 1.1 drochner
65 1.1 drochner rc->rc_font = fp;
66 1.1 drochner
67 1.1 drochner /* Get distance to top and bottom of font from font origin */
68 1.1 drochner rc->rc_font_ascent = -(rc->rc_font->chars)['a'].homey;
69 1.1 drochner
70 1.1 drochner #if !defined(MSBYTE_FIRST) && !defined(MSBIT_FIRST) /* XXX other cases */
71 1.1 drochner /* swap byte order on font data. ick. */
72 1.1 drochner if (!initfontdone) {
73 1.1 drochner int ch, i, n, bit;
74 1.1 drochner u_int32_t *pix, npix;
75 1.1 drochner
76 1.1 drochner for (ch = 0; ch < 256; ch++) {
77 1.1 drochner if (rc->rc_font->chars[ch].r == 0)
78 1.1 drochner continue;
79 1.1 drochner
80 1.1 drochner n = rc->rc_font->chars[ch].r->linelongs *
81 1.1 drochner rc->rc_font->chars[ch].r->height;
82 1.1 drochner pix = rc->rc_font->chars[ch].r->pixels;
83 1.1 drochner
84 1.1 drochner for (i = 0; i < n; i++) {
85 1.1 drochner npix = 0;
86 1.1 drochner for (bit = 0; bit < 32; bit++)
87 1.1 drochner if (pix[i] & (1 << bit))
88 1.1 drochner npix |= (1 << (31 - bit));
89 1.1 drochner pix[i] = npix;
90 1.1 drochner }
91 1.1 drochner }
92 1.1 drochner }
93 1.1 drochner #endif
94 1.1 drochner
95 1.1 drochner initfontdone = 1;
96 1.1 drochner }
97 1.1 drochner
98 1.1 drochner void
99 1.1 drochner rcons_init(rc, mrow, mcol)
100 1.1 drochner struct rcons *rc;
101 1.1 drochner int mrow, mcol;
102 1.1 drochner {
103 1.1 drochner struct raster *rp = rc->rc_sp;
104 1.1 drochner int i;
105 1.1 drochner
106 1.1 drochner rcons_initfont(rc, &gallant19);
107 1.1 drochner
108 1.1 drochner i = rp->height / rc->rc_font->height;
109 1.1 drochner rc->rc_maxrow = min(i, mrow);
110 1.1 drochner
111 1.1 drochner i = rp->width / rc->rc_font->width;
112 1.1 drochner rc->rc_maxcol = min(i, mcol);
113 1.1 drochner
114 1.1 drochner /* Center emulator screen (but align x origin to 32 bits) */
115 1.1 drochner rc->rc_xorigin =
116 1.1 drochner ((rp->width - rc->rc_maxcol * rc->rc_font->width) / 2) & ~0x1f;
117 1.1 drochner rc->rc_yorigin =
118 1.1 drochner (rp->height - rc->rc_maxrow * rc->rc_font->height) / 2;
119 1.1 drochner
120 1.1 drochner /* Raster width used for row copies */
121 1.1 drochner rc->rc_raswidth = rc->rc_maxcol * rc->rc_font->width;
122 1.1 drochner if (rc->rc_raswidth & 0x1f) {
123 1.1 drochner /* Pad to 32 bits */
124 1.1 drochner i = (rc->rc_raswidth + 0x1f) & ~0x1f;
125 1.1 drochner /* Make sure width isn't too wide */
126 1.1 drochner if (rc->rc_xorigin + i <= rp->width)
127 1.1 drochner rc->rc_raswidth = i;
128 1.1 drochner }
129 1.1 drochner
130 1.1 drochner rc->rc_ras_blank = RAS_CLEAR;
131 1.1 drochner rc->rc_bits = 0;
132 1.1 drochner
133 1.1 drochner /* If cursor position given, assume it's there and drawn. */
134 1.1 drochner if (*rc->rc_crowp != -1 && *rc->rc_ccolp != -1)
135 1.1 drochner rc->rc_bits |= RC_CURSOR;
136 1.1 drochner }
137