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