1 /* $NetBSD: wscons_rops.c,v 1.9.6.3 2004/09/21 13:34:29 skrll Exp $ */
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
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
40 * @(#)rcons_subr.c 8.1 (Berkeley) 6/11/93
43 #include <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: wscons_rops.c,v 1.9.6.3 2004/09/21 13:34:29 skrll Exp $");
46 #include <sys/param.h>
47 #include <sys/device.h>
49 #include <dev/rcons/raster.h>
50 #include <dev/wscons/wscons_raster.h>
51 #include <dev/wscons/wsdisplayvar.h>
54 * Paint (or unpaint) the cursor.
55 * Pays no lip service to hardware cursors.
58 rcons_cursor(void *id
, int on
, int row
, int col
)
60 struct rcons
*rc
= id
;
63 /* turn the cursor off */
65 /* make sure it's on */
66 if ((rc
->rc_bits
& RC_CURSOR
) == 0)
72 /* unpaint the old copy. */
77 x
= col
* rc
->rc_font
->width
+ rc
->rc_xorigin
;
78 y
= row
* rc
->rc_font
->height
+ rc
->rc_yorigin
;
80 raster_op(rc
->rc_sp
, x
, y
,
82 /* XXX This is the right way but too slow */
83 rc
->rc_font
->chars
[(int)' '].r
->width
,
84 rc
->rc_font
->chars
[(int)' '].r
->height
,
86 rc
->rc_font
->width
, rc
->rc_font
->height
,
89 (struct raster
*) 0, 0, 0);
91 rc
->rc_bits
^= RC_CURSOR
;
95 rcons_mapchar(void *id
, int uni
, unsigned int *index
)
107 * Actually write a string to the frame buffer.
110 rcons_putchar(void *id
, int row
, int col
, u_int uc
, long attr
)
112 struct rcons
*rc
= id
;
116 x
= col
* rc
->rc_font
->width
+ rc
->rc_xorigin
;
117 y
= row
* rc
->rc_font
->height
+ rc
->rc_font_ascent
+ rc
->rc_yorigin
;
120 if ((attr
!= 0) ^ ((rc
->rc_bits
& RC_INVERT
) != 0))
123 raster_textn(rc
->rc_sp
, x
, y
, op
, rc
->rc_font
, &help
, 1);
127 * Possibly change to white-on-black or black-on-white modes.
130 rcons_invert(void *id
, int inverted
)
132 struct rcons
*rc
= id
;
134 if (((rc
->rc_bits
& RC_INVERT
) != 0) ^ inverted
) {
135 /* Invert the display */
136 raster_op(rc
->rc_sp
, 0, 0, rc
->rc_sp
->width
, rc
->rc_sp
->height
,
137 RAS_INVERT
, (struct raster
*) 0, 0, 0);
139 /* Swap things around */
140 rc
->rc_bits
^= RC_INVERT
;
145 * Copy columns (characters) in a row (line).
148 rcons_copycols(void *id
, int row
, int srccol
, int dstcol
, int ncols
)
150 struct rcons
*rc
= id
;
151 int y
, srcx
, dstx
, nx
;
153 y
= rc
->rc_yorigin
+ rc
->rc_font
->height
* row
;
154 srcx
= rc
->rc_xorigin
+ rc
->rc_font
->width
* srccol
;
155 dstx
= rc
->rc_xorigin
+ rc
->rc_font
->width
* dstcol
;
156 nx
= rc
->rc_font
->width
* ncols
;
158 raster_op(rc
->rc_sp
, dstx
, y
,
159 nx
, rc
->rc_font
->height
, RAS_SRC
,
164 * Clear columns (characters) in a row (line).
167 rcons_erasecols(void *id
, int row
, int startcol
, int ncols
, long fillattr
)
169 struct rcons
*rc
= id
;
170 int y
, startx
, nx
, op
;
172 y
= rc
->rc_yorigin
+ rc
->rc_font
->height
* row
;
173 startx
= rc
->rc_xorigin
+ rc
->rc_font
->width
* startcol
;
174 nx
= rc
->rc_font
->width
* ncols
;
177 if ((fillattr
!= 0) ^ ((rc
->rc_bits
& RC_INVERT
) != 0))
179 raster_op(rc
->rc_sp
, startx
, y
,
180 nx
, rc
->rc_font
->height
, op
,
181 (struct raster
*) 0, 0, 0);
188 rcons_copyrows(void *id
, int srcrow
, int dstrow
, int nrows
)
190 struct rcons
*rc
= id
;
193 srcy
= rc
->rc_yorigin
+ rc
->rc_font
->height
* srcrow
;
194 dsty
= rc
->rc_yorigin
+ rc
->rc_font
->height
* dstrow
;
195 ny
= rc
->rc_font
->height
* nrows
;
197 raster_op(rc
->rc_sp
, rc
->rc_xorigin
, dsty
,
198 rc
->rc_raswidth
, ny
, RAS_SRC
,
199 rc
->rc_sp
, rc
->rc_xorigin
, srcy
);
203 * Erase rows (lines).
206 rcons_eraserows(void *id
, int startrow
, int nrows
, long fillattr
)
208 struct rcons
*rc
= id
;
211 starty
= rc
->rc_yorigin
+ rc
->rc_font
->height
* startrow
;
212 ny
= rc
->rc_font
->height
* nrows
;
215 if ((fillattr
!= 0) ^ ((rc
->rc_bits
& RC_INVERT
) != 0))
217 raster_op(rc
->rc_sp
, rc
->rc_xorigin
, starty
,
218 rc
->rc_raswidth
, ny
, op
,
219 (struct raster
*) 0, 0, 0);
223 rcons_allocattr(void *id
, int fg
, int bg
, int flags
, long *attrp
)
225 if (flags
& (WSATTR_HILIT
| WSATTR_BLINK
|
226 WSATTR_UNDERLINE
| WSATTR_WSCOLORS
))
228 if (flags
& WSATTR_REVERSE
)