wscons_rops.c revision 1.1 1 /* $NetBSD: wscons_rops.c,v 1.1 1998/03/22 14:24:02 drochner Exp $ */
2
3 /*
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
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.
10 *
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.
15 *
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. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the University of
27 * California, Berkeley and its contributors.
28 * 4. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 *
44 * @(#)rcons_subr.c 8.1 (Berkeley) 6/11/93
45 */
46
47 #include <sys/param.h>
48 #include <sys/device.h>
49
50 #include <dev/rcons/raster.h>
51 #include <dev/wscons/wscons_raster.h>
52
53 /*
54 * Paint (or unpaint) the cursor.
55 * Pays no lip service to hardware cursors.
56 */
57 void
58 rcons_cursor(id, on, row, col)
59 void *id;
60 int on, row, col;
61 {
62 register struct rcons *rc = id;
63 register int x, y;
64
65 /* turn the cursor off */
66 if (!on) {
67 /* make sure it's on */
68 if ((rc->rc_bits & RC_CURSOR) == 0)
69 return;
70
71 row = *rc->rc_crowp;
72 col = *rc->rc_ccolp;
73 } else {
74 /* unpaint the old copy. */
75 *rc->rc_crowp = row;
76 *rc->rc_ccolp = col;
77 }
78
79 x = col * rc->rc_font->width + rc->rc_xorigin;
80 y = row * rc->rc_font->height + rc->rc_yorigin;
81
82 raster_op(rc->rc_sp, x, y,
83 #ifdef notdef
84 /* XXX This is the right way but too slow */
85 rc->rc_font->chars[(int)' '].r->width,
86 rc->rc_font->chars[(int)' '].r->height,
87 #else
88 rc->rc_font->width, rc->rc_font->height,
89 #endif
90 RAS_INVERT,
91 (struct raster *) 0, 0, 0);
92
93 rc->rc_bits ^= RC_CURSOR;
94 }
95
96 /*
97 * Actually write a string to the frame buffer.
98 */
99 void
100 rcons_putstr(id, row, col, str, n)
101 void *id;
102 int row, col, n;
103 char *str;
104 {
105 struct rcons *rc = id;
106 register int x, y, op;
107
108 x = col * rc->rc_font->width + rc->rc_xorigin;
109 y = row * rc->rc_font->height + rc->rc_font_ascent + rc->rc_yorigin;
110
111 op = RAS_SRC;
112 if (((rc->rc_bits & RC_STANDOUT) != 0) ^
113 ((rc->rc_bits & RC_INVERT) != 0))
114 op = RAS_NOT(op);
115 raster_textn(rc->rc_sp, x, y, op, rc->rc_font, str, n);
116 }
117
118 /*
119 * Possibly change to white-on-black or black-on-white modes.
120 */
121 void
122 rcons_invert(id, inverted)
123 void *id;
124 int inverted;
125 {
126 struct rcons *rc = id;
127
128 if (((rc->rc_bits & RC_INVERT) != 0) ^ inverted) {
129 /* Invert the display */
130 raster_op(rc->rc_sp, 0, 0, rc->rc_sp->width, rc->rc_sp->height,
131 RAS_INVERT, (struct raster *) 0, 0, 0);
132
133 /* Swap things around */
134 rc->rc_ras_blank = RAS_NOT(rc->rc_ras_blank);
135 rc->rc_bits ^= RC_INVERT;
136 }
137 }
138
139 /*
140 * Copy columns (characters) in a row (line).
141 */
142 void
143 rcons_copycols(id, row, srccol, dstcol, ncols)
144 void *id;
145 int row, srccol, dstcol, ncols;
146 {
147 struct rcons *rc = id;
148 int y, srcx, dstx, nx;
149
150 y = rc->rc_yorigin + rc->rc_font->height * row;
151 srcx = rc->rc_xorigin + rc->rc_font->width * srccol;
152 dstx = rc->rc_xorigin + rc->rc_font->width * dstcol;
153 nx = rc->rc_font->width * ncols;
154
155 raster_op(rc->rc_sp, dstx, y,
156 nx, rc->rc_font->height, RAS_SRC,
157 rc->rc_sp, srcx, y);
158 }
159
160 /*
161 * Clear columns (characters) in a row (line).
162 */
163 void
164 rcons_erasecols(id, row, startcol, ncols)
165 void *id;
166 int row, startcol, ncols;
167 {
168 struct rcons *rc = id;
169 int y, startx, nx;
170
171 y = rc->rc_yorigin + rc->rc_font->height * row;
172 startx = rc->rc_xorigin + rc->rc_font->width * startcol;
173 nx = rc->rc_font->width * ncols;
174
175 raster_op(rc->rc_sp, startx, y,
176 nx, rc->rc_font->height, rc->rc_ras_blank,
177 (struct raster *) 0, 0, 0);
178 }
179
180 /*
181 * Copy rows (lines).
182 */
183 void
184 rcons_copyrows(id, srcrow, dstrow, nrows)
185 void *id;
186 int srcrow, dstrow, nrows;
187 {
188 struct rcons *rc = id;
189 int srcy, dsty, ny;
190
191 srcy = rc->rc_yorigin + rc->rc_font->height * srcrow;
192 dsty = rc->rc_yorigin + rc->rc_font->height * dstrow;
193 ny = rc->rc_font->height * nrows;
194
195 raster_op(rc->rc_sp, rc->rc_xorigin, dsty,
196 rc->rc_raswidth, ny, RAS_SRC,
197 rc->rc_sp, rc->rc_xorigin, srcy);
198 }
199
200 /*
201 * Erase rows (lines).
202 */
203 void
204 rcons_eraserows(id, startrow, nrows)
205 void *id;
206 int startrow, nrows;
207 {
208 struct rcons *rc = id;
209 int starty, ny;
210
211 starty = rc->rc_yorigin + rc->rc_font->height * startrow;
212 ny = rc->rc_font->height * nrows;
213
214 raster_op(rc->rc_sp, rc->rc_xorigin, starty,
215 rc->rc_raswidth, ny, rc->rc_ras_blank,
216 (struct raster *) 0, 0, 0);
217 }
218