omrasops.c revision 1.11.2.2 1 1.11.2.2 yamt /* $NetBSD: omrasops.c,v 1.11.2.2 2014/05/22 11:39:55 yamt Exp $ */
2 1.1 nisimura
3 1.1 nisimura /*-
4 1.1 nisimura * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1 nisimura * All rights reserved.
6 1.1 nisimura *
7 1.1 nisimura * This code is derived from software contributed to The NetBSD Foundation
8 1.1 nisimura * by Tohru Nishimura.
9 1.1 nisimura *
10 1.1 nisimura * Redistribution and use in source and binary forms, with or without
11 1.1 nisimura * modification, are permitted provided that the following conditions
12 1.1 nisimura * are met:
13 1.1 nisimura * 1. Redistributions of source code must retain the above copyright
14 1.1 nisimura * notice, this list of conditions and the following disclaimer.
15 1.1 nisimura * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 nisimura * notice, this list of conditions and the following disclaimer in the
17 1.1 nisimura * documentation and/or other materials provided with the distribution.
18 1.1 nisimura *
19 1.1 nisimura * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 nisimura * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 nisimura * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 nisimura * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 nisimura * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 nisimura * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 nisimura * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 nisimura * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 nisimura * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 nisimura * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 nisimura * POSSIBILITY OF SUCH DAMAGE.
30 1.1 nisimura */
31 1.1 nisimura
32 1.1 nisimura #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
33 1.1 nisimura
34 1.11.2.2 yamt __KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.11.2.2 2014/05/22 11:39:55 yamt Exp $");
35 1.1 nisimura
36 1.1 nisimura /*
37 1.1 nisimura * Designed speficically for 'm68k bitorder';
38 1.1 nisimura * - most significant byte is stored at lower address,
39 1.1 nisimura * - most significant bit is displayed at left most on screen.
40 1.11.2.1 yamt * Implementation relies on;
41 1.11.2.2 yamt * - first column is at 32bit aligned address,
42 1.1 nisimura * - font glyphs are stored in 32bit padded.
43 1.1 nisimura */
44 1.1 nisimura
45 1.1 nisimura #include <sys/param.h>
46 1.1 nisimura #include <sys/systm.h>
47 1.1 nisimura #include <sys/device.h>
48 1.1 nisimura
49 1.11.2.1 yamt #include <dev/wscons/wsconsio.h>
50 1.1 nisimura #include <dev/wscons/wsdisplayvar.h>
51 1.11.2.1 yamt #include <dev/rasops/rasops.h>
52 1.1 nisimura
53 1.11.2.1 yamt #include <arch/luna68k/dev/omrasopsvar.h>
54 1.1 nisimura
55 1.1 nisimura /* wscons emulator operations */
56 1.11.2.2 yamt static void om1_cursor(void *, int, int, int);
57 1.11.2.2 yamt static void om4_cursor(void *, int, int, int);
58 1.7 dsl static int om_mapchar(void *, int, unsigned int *);
59 1.11.2.2 yamt static void om1_putchar(void *, int, int, u_int, long);
60 1.11.2.2 yamt static void om4_putchar(void *, int, int, u_int, long);
61 1.11.2.2 yamt static void om1_copycols(void *, int, int, int, int);
62 1.11.2.2 yamt static void om4_copycols(void *, int, int, int, int);
63 1.11.2.2 yamt static void om1_copyrows(void *, int, int, int num);
64 1.11.2.2 yamt static void om4_copyrows(void *, int, int, int num);
65 1.11.2.2 yamt static void om1_erasecols(void *, int, int, int, long);
66 1.11.2.2 yamt static void om4_erasecols(void *, int, int, int, long);
67 1.11.2.2 yamt static void om1_eraserows(void *, int, int, long);
68 1.11.2.2 yamt static void om4_eraserows(void *, int, int, long);
69 1.11.2.2 yamt static int om1_allocattr(void *, int, int, int, long *);
70 1.11.2.2 yamt static int om4_allocattr(void *, int, int, int, long *);
71 1.11.2.2 yamt
72 1.11.2.2 yamt static int omrasops_init(struct rasops_info *, int, int);
73 1.1 nisimura
74 1.1 nisimura #define ALL1BITS (~0U)
75 1.1 nisimura #define ALL0BITS (0U)
76 1.1 nisimura #define BLITWIDTH (32)
77 1.1 nisimura #define ALIGNMASK (0x1f)
78 1.1 nisimura #define BYTESDONE (4)
79 1.1 nisimura
80 1.11 tsutsui #define W(p) (*(uint32_t *)(p))
81 1.11 tsutsui #define R(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
82 1.11.2.2 yamt #define P0(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
83 1.11.2.2 yamt #define P1(p) (*(uint32_t *)((uint8_t *)(p) + 0x80000))
84 1.11.2.2 yamt #define P2(p) (*(uint32_t *)((uint8_t *)(p) + 0xc0000))
85 1.11.2.2 yamt #define P3(p) (*(uint32_t *)((uint8_t *)(p) + 0x100000))
86 1.11.2.2 yamt
87 1.11.2.2 yamt /*
88 1.11.2.2 yamt * macros to handle unaligned bit copy ops.
89 1.11.2.2 yamt * See src/sys/dev/rasops/rasops_mask.h for MI version.
90 1.11.2.2 yamt * Also refer src/sys/arch/hp300/dev/maskbits.h.
91 1.11.2.2 yamt * (which was implemented for ancient src/sys/arch/hp300/dev/grf_hy.c)
92 1.11.2.2 yamt */
93 1.11.2.2 yamt
94 1.11.2.2 yamt /* luna68k version GETBITS() that gets w bits from bit x at psrc memory */
95 1.11.2.2 yamt #define FASTGETBITS(psrc, x, w, dst) \
96 1.11.2.2 yamt asm("bfextu %3{%1:%2},%0" \
97 1.11.2.2 yamt : "=d" (dst) \
98 1.11.2.2 yamt : "di" (x), "di" (w), "o" ((uint32_t *)(psrc)))
99 1.11.2.2 yamt
100 1.11.2.2 yamt /* luna68k version PUTBITS() that puts w bits from bit x at pdst memory */
101 1.11.2.2 yamt /* XXX this macro assumes (x + w) <= 32 to handle unaligned residual bits */
102 1.11.2.2 yamt #define FASTPUTBITS(src, x, w, pdst) \
103 1.11.2.2 yamt asm("bfins %3,%0{%1:%2}" \
104 1.11.2.2 yamt : "+o" ((uint32_t *)(pdst)) \
105 1.11.2.2 yamt : "di" (x), "di" (w), "d" (src) \
106 1.11.2.2 yamt : "memory" );
107 1.11.2.2 yamt
108 1.11.2.2 yamt #define GETBITS(psrc, x, w, dst) FASTGETBITS(psrc, x, w, dst)
109 1.11.2.2 yamt #define PUTBITS(src, x, w, pdst) FASTPUTBITS(src, x, w, pdst)
110 1.1 nisimura
111 1.1 nisimura /*
112 1.1 nisimura * Blit a character at the specified co-ordinates.
113 1.1 nisimura */
114 1.1 nisimura static void
115 1.11.2.2 yamt om1_putchar(void *cookie, int row, int startcol, u_int uc, long attr)
116 1.1 nisimura {
117 1.11.2.1 yamt struct rasops_info *ri = cookie;
118 1.5 tsutsui uint8_t *p;
119 1.1 nisimura int scanspan, startx, height, width, align, y;
120 1.11 tsutsui uint32_t lmask, rmask, glyph, inverse;
121 1.11.2.1 yamt int i;
122 1.11.2.1 yamt uint8_t *fb;
123 1.1 nisimura
124 1.11.2.1 yamt scanspan = ri->ri_stride;
125 1.11.2.1 yamt y = ri->ri_font->fontheight * row;
126 1.11.2.1 yamt startx = ri->ri_font->fontwidth * startcol;
127 1.11.2.1 yamt height = ri->ri_font->fontheight;
128 1.11.2.1 yamt fb = (uint8_t *)ri->ri_font->data +
129 1.11.2.1 yamt (uc - ri->ri_font->firstchar) * ri->ri_fontscale;
130 1.11.2.2 yamt inverse = ((attr & 0x00000001) != 0) ? ALL1BITS : ALL0BITS;
131 1.1 nisimura
132 1.11.2.1 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
133 1.1 nisimura align = startx & ALIGNMASK;
134 1.11.2.1 yamt width = ri->ri_font->fontwidth + align;
135 1.1 nisimura lmask = ALL1BITS >> align;
136 1.1 nisimura rmask = ALL1BITS << (-width & ALIGNMASK);
137 1.1 nisimura if (width <= BLITWIDTH) {
138 1.1 nisimura lmask &= rmask;
139 1.1 nisimura while (height > 0) {
140 1.11.2.1 yamt glyph = 0;
141 1.11.2.1 yamt for (i = ri->ri_font->stride; i != 0; i--)
142 1.11.2.1 yamt glyph = (glyph << 8) | *fb++;
143 1.11.2.1 yamt glyph <<= (4 - ri->ri_font->stride) * NBBY;
144 1.1 nisimura glyph = (glyph >> align) ^ inverse;
145 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | (glyph & lmask);
146 1.1 nisimura p += scanspan;
147 1.1 nisimura height--;
148 1.1 nisimura }
149 1.11 tsutsui } else {
150 1.5 tsutsui uint8_t *q = p;
151 1.11 tsutsui uint32_t lhalf, rhalf;
152 1.1 nisimura
153 1.1 nisimura while (height > 0) {
154 1.11.2.1 yamt glyph = 0;
155 1.11.2.1 yamt for (i = ri->ri_font->stride; i != 0; i--)
156 1.11.2.1 yamt glyph = (glyph << 8) | *fb++;
157 1.11.2.1 yamt glyph <<= (4 - ri->ri_font->stride) * NBBY;
158 1.1 nisimura lhalf = (glyph >> align) ^ inverse;
159 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | (lhalf & lmask);
160 1.1 nisimura p += BYTESDONE;
161 1.1 nisimura rhalf = (glyph << (BLITWIDTH - align)) ^ inverse;
162 1.11.2.2 yamt P0(p) = (rhalf & rmask) | (P0(p) & ~rmask);
163 1.1 nisimura
164 1.1 nisimura p = (q += scanspan);
165 1.1 nisimura height--;
166 1.1 nisimura }
167 1.1 nisimura }
168 1.1 nisimura }
169 1.1 nisimura
170 1.1 nisimura static void
171 1.11.2.2 yamt om4_putchar(void *cookie, int row, int startcol, u_int uc, long attr)
172 1.11.2.2 yamt {
173 1.11.2.2 yamt struct rasops_info *ri = cookie;
174 1.11.2.2 yamt uint8_t *p;
175 1.11.2.2 yamt int scanspan, startx, height, width, align, y;
176 1.11.2.2 yamt uint32_t lmask, rmask, glyph;
177 1.11.2.2 yamt uint32_t glyphbg, fg, bg;
178 1.11.2.2 yamt int i;
179 1.11.2.2 yamt uint8_t *fb;
180 1.11.2.2 yamt
181 1.11.2.2 yamt scanspan = ri->ri_stride;
182 1.11.2.2 yamt y = ri->ri_font->fontheight * row;
183 1.11.2.2 yamt startx = ri->ri_font->fontwidth * startcol;
184 1.11.2.2 yamt height = ri->ri_font->fontheight;
185 1.11.2.2 yamt fb = (uint8_t *)ri->ri_font->data +
186 1.11.2.2 yamt (uc - ri->ri_font->firstchar) * ri->ri_fontscale;
187 1.11.2.2 yamt
188 1.11.2.2 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
189 1.11.2.2 yamt align = startx & ALIGNMASK;
190 1.11.2.2 yamt width = ri->ri_font->fontwidth + align;
191 1.11.2.2 yamt lmask = ALL1BITS >> align;
192 1.11.2.2 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
193 1.11.2.2 yamt if (width <= BLITWIDTH) {
194 1.11.2.2 yamt lmask &= rmask;
195 1.11.2.2 yamt while (height > 0) {
196 1.11.2.2 yamt glyph = 0;
197 1.11.2.2 yamt for (i = ri->ri_font->stride; i != 0; i--)
198 1.11.2.2 yamt glyph = (glyph << 8) | *fb++;
199 1.11.2.2 yamt glyph <<= (4 - ri->ri_font->stride) * NBBY;
200 1.11.2.2 yamt glyph = (glyph >> align);
201 1.11.2.2 yamt glyphbg = glyph ^ ALL1BITS;
202 1.11.2.2 yamt fg = (attr & 0x01000000) ? glyph : 0;
203 1.11.2.2 yamt bg = (attr & 0x00010000) ? glyphbg : 0;
204 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
205 1.11.2.2 yamt fg = (attr & 0x02000000) ? glyph : 0;
206 1.11.2.2 yamt bg = (attr & 0x00020000) ? glyphbg : 0;
207 1.11.2.2 yamt P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
208 1.11.2.2 yamt fg = (attr & 0x04000000) ? glyph : 0;
209 1.11.2.2 yamt bg = (attr & 0x00040000) ? glyphbg : 0;
210 1.11.2.2 yamt P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
211 1.11.2.2 yamt fg = (attr & 0x08000000) ? glyph : 0;
212 1.11.2.2 yamt bg = (attr & 0x00080000) ? glyphbg : 0;
213 1.11.2.2 yamt P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
214 1.11.2.2 yamt p += scanspan;
215 1.11.2.2 yamt height--;
216 1.11.2.2 yamt }
217 1.11.2.2 yamt } else {
218 1.11.2.2 yamt uint8_t *q = p;
219 1.11.2.2 yamt uint32_t lhalf, rhalf;
220 1.11.2.2 yamt uint32_t lhalfbg, rhalfbg;
221 1.11.2.2 yamt
222 1.11.2.2 yamt while (height > 0) {
223 1.11.2.2 yamt glyph = 0;
224 1.11.2.2 yamt for (i = ri->ri_font->stride; i != 0; i--)
225 1.11.2.2 yamt glyph = (glyph << 8) | *fb++;
226 1.11.2.2 yamt glyph <<= (4 - ri->ri_font->stride) * NBBY;
227 1.11.2.2 yamt lhalf = (glyph >> align);
228 1.11.2.2 yamt lhalfbg = lhalf ^ ALL1BITS;
229 1.11.2.2 yamt fg = (attr & 0x01000000) ? lhalf : 0;
230 1.11.2.2 yamt bg = (attr & 0x00010000) ? lhalfbg : 0;
231 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
232 1.11.2.2 yamt fg = (attr & 0x02000000) ? lhalf : 0;
233 1.11.2.2 yamt bg = (attr & 0x00020000) ? lhalfbg : 0;
234 1.11.2.2 yamt P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
235 1.11.2.2 yamt fg = (attr & 0x04000000) ? lhalf : 0;
236 1.11.2.2 yamt bg = (attr & 0x00040000) ? lhalfbg : 0;
237 1.11.2.2 yamt P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
238 1.11.2.2 yamt fg = (attr & 0x08000000) ? lhalf : 0;
239 1.11.2.2 yamt bg = (attr & 0x00080000) ? lhalfbg : 0;
240 1.11.2.2 yamt P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
241 1.11.2.2 yamt p += BYTESDONE;
242 1.11.2.2 yamt rhalf = (glyph << (BLITWIDTH - align));
243 1.11.2.2 yamt rhalfbg = rhalf ^ ALL1BITS;
244 1.11.2.2 yamt fg = (attr & 0x01000000) ? rhalf : 0;
245 1.11.2.2 yamt bg = (attr & 0x00010000) ? rhalfbg : 0;
246 1.11.2.2 yamt P0(p) = ((fg | bg) & rmask) | (P0(p) & ~rmask);
247 1.11.2.2 yamt fg = (attr & 0x02000000) ? rhalf : 0;
248 1.11.2.2 yamt bg = (attr & 0x00020000) ? rhalfbg : 0;
249 1.11.2.2 yamt P1(p) = ((fg | bg) & rmask) | (P1(p) & ~rmask);
250 1.11.2.2 yamt fg = (attr & 0x04000000) ? rhalf : 0;
251 1.11.2.2 yamt bg = (attr & 0x00040000) ? rhalfbg : 0;
252 1.11.2.2 yamt P2(p) = ((fg | bg) & rmask) | (P2(p) & ~rmask);
253 1.11.2.2 yamt fg = (attr & 0x08000000) ? rhalf : 0;
254 1.11.2.2 yamt bg = (attr & 0x00080000) ? rhalfbg : 0;
255 1.11.2.2 yamt P3(p) = ((fg | bg) & rmask) | (P3(p) & ~rmask);
256 1.11.2.2 yamt
257 1.11.2.2 yamt p = (q += scanspan);
258 1.11.2.2 yamt height--;
259 1.11.2.2 yamt }
260 1.11.2.2 yamt }
261 1.11.2.2 yamt }
262 1.11.2.2 yamt
263 1.11.2.2 yamt static void
264 1.11.2.2 yamt om1_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
265 1.1 nisimura {
266 1.11.2.1 yamt struct rasops_info *ri = cookie;
267 1.11.2.1 yamt uint8_t *p;
268 1.11.2.1 yamt int scanspan, startx, height, width, align, w, y;
269 1.11.2.1 yamt uint32_t lmask, rmask, fill;
270 1.11.2.1 yamt
271 1.11.2.1 yamt scanspan = ri->ri_stride;;
272 1.11.2.1 yamt y = ri->ri_font->fontheight * row;
273 1.11.2.1 yamt startx = ri->ri_font->fontwidth * startcol;
274 1.11.2.1 yamt height = ri->ri_font->fontheight;
275 1.11.2.1 yamt w = ri->ri_font->fontwidth * ncols;
276 1.11.2.2 yamt fill = ((attr & 0x00000001) != 0) ? ALL1BITS : ALL0BITS;
277 1.1 nisimura
278 1.11.2.1 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
279 1.1 nisimura align = startx & ALIGNMASK;
280 1.1 nisimura width = w + align;
281 1.1 nisimura lmask = ALL1BITS >> align;
282 1.1 nisimura rmask = ALL1BITS << (-width & ALIGNMASK);
283 1.1 nisimura if (width <= BLITWIDTH) {
284 1.1 nisimura lmask &= rmask;
285 1.11.2.2 yamt fill &= lmask;
286 1.1 nisimura while (height > 0) {
287 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | fill;
288 1.1 nisimura p += scanspan;
289 1.1 nisimura height--;
290 1.1 nisimura }
291 1.11 tsutsui } else {
292 1.5 tsutsui uint8_t *q = p;
293 1.1 nisimura while (height > 0) {
294 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | (fill & lmask);
295 1.1 nisimura width -= 2 * BLITWIDTH;
296 1.1 nisimura while (width > 0) {
297 1.1 nisimura p += BYTESDONE;
298 1.11.2.2 yamt P0(p) = fill;
299 1.1 nisimura width -= BLITWIDTH;
300 1.1 nisimura }
301 1.1 nisimura p += BYTESDONE;
302 1.11.2.2 yamt P0(p) = (fill & rmask) | (P0(p) & ~rmask);
303 1.1 nisimura
304 1.1 nisimura p = (q += scanspan);
305 1.1 nisimura width = w + align;
306 1.1 nisimura height--;
307 1.1 nisimura }
308 1.1 nisimura }
309 1.1 nisimura }
310 1.1 nisimura
311 1.1 nisimura static void
312 1.11.2.2 yamt om4_erasecols(void *cookie, int row, int startcol, int ncols, long attr)
313 1.11.2.2 yamt {
314 1.11.2.2 yamt struct rasops_info *ri = cookie;
315 1.11.2.2 yamt uint8_t *p;
316 1.11.2.2 yamt int scanspan, startx, height, width, align, w, y;
317 1.11.2.2 yamt uint32_t lmask, rmask, fill0, fill1, fill2, fill3;
318 1.11.2.2 yamt
319 1.11.2.2 yamt scanspan = ri->ri_stride;;
320 1.11.2.2 yamt y = ri->ri_font->fontheight * row;
321 1.11.2.2 yamt startx = ri->ri_font->fontwidth * startcol;
322 1.11.2.2 yamt height = ri->ri_font->fontheight;
323 1.11.2.2 yamt w = ri->ri_font->fontwidth * ncols;
324 1.11.2.2 yamt fill0 = ((attr & 0x00010000) != 0) ? ALL1BITS : ALL0BITS;
325 1.11.2.2 yamt fill1 = ((attr & 0x00020000) != 0) ? ALL1BITS : ALL0BITS;
326 1.11.2.2 yamt fill2 = ((attr & 0x00040000) != 0) ? ALL1BITS : ALL0BITS;
327 1.11.2.2 yamt fill3 = ((attr & 0x00080000) != 0) ? ALL1BITS : ALL0BITS;
328 1.11.2.2 yamt
329 1.11.2.2 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
330 1.11.2.2 yamt align = startx & ALIGNMASK;
331 1.11.2.2 yamt width = w + align;
332 1.11.2.2 yamt lmask = ALL1BITS >> align;
333 1.11.2.2 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
334 1.11.2.2 yamt if (width <= BLITWIDTH) {
335 1.11.2.2 yamt lmask &= rmask;
336 1.11.2.2 yamt fill0 &= lmask;
337 1.11.2.2 yamt fill1 &= lmask;
338 1.11.2.2 yamt fill2 &= lmask;
339 1.11.2.2 yamt fill3 &= lmask;
340 1.11.2.2 yamt while (height > 0) {
341 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | fill0;
342 1.11.2.2 yamt P1(p) = (P1(p) & ~lmask) | fill1;
343 1.11.2.2 yamt P2(p) = (P2(p) & ~lmask) | fill2;
344 1.11.2.2 yamt P3(p) = (P3(p) & ~lmask) | fill3;
345 1.11.2.2 yamt p += scanspan;
346 1.11.2.2 yamt height--;
347 1.11.2.2 yamt }
348 1.11.2.2 yamt } else {
349 1.11.2.2 yamt uint8_t *q = p;
350 1.11.2.2 yamt while (height > 0) {
351 1.11.2.2 yamt P0(p) = (P0(p) & ~lmask) | (fill0 & lmask);
352 1.11.2.2 yamt P1(p) = (P1(p) & ~lmask) | (fill1 & lmask);
353 1.11.2.2 yamt P2(p) = (P2(p) & ~lmask) | (fill2 & lmask);
354 1.11.2.2 yamt P3(p) = (P3(p) & ~lmask) | (fill3 & lmask);
355 1.11.2.2 yamt width -= 2 * BLITWIDTH;
356 1.11.2.2 yamt while (width > 0) {
357 1.11.2.2 yamt p += BYTESDONE;
358 1.11.2.2 yamt P0(p) = fill0;
359 1.11.2.2 yamt P1(p) = fill1;
360 1.11.2.2 yamt P2(p) = fill2;
361 1.11.2.2 yamt P3(p) = fill3;
362 1.11.2.2 yamt width -= BLITWIDTH;
363 1.11.2.2 yamt }
364 1.11.2.2 yamt p += BYTESDONE;
365 1.11.2.2 yamt P0(p) = (fill0 & rmask) | (P0(p) & ~rmask);
366 1.11.2.2 yamt P1(p) = (fill1 & rmask) | (P1(p) & ~rmask);
367 1.11.2.2 yamt P2(p) = (fill2 & rmask) | (P2(p) & ~rmask);
368 1.11.2.2 yamt P3(p) = (fill3 & rmask) | (P3(p) & ~rmask);
369 1.11.2.2 yamt
370 1.11.2.2 yamt p = (q += scanspan);
371 1.11.2.2 yamt width = w + align;
372 1.11.2.2 yamt height--;
373 1.11.2.2 yamt }
374 1.11.2.2 yamt }
375 1.11.2.2 yamt }
376 1.11.2.2 yamt
377 1.11.2.2 yamt static void
378 1.11.2.2 yamt om1_eraserows(void *cookie, int startrow, int nrows, long attr)
379 1.1 nisimura {
380 1.11.2.1 yamt struct rasops_info *ri = cookie;
381 1.5 tsutsui uint8_t *p, *q;
382 1.1 nisimura int scanspan, starty, height, width, w;
383 1.11 tsutsui uint32_t rmask, fill;
384 1.1 nisimura
385 1.11.2.1 yamt scanspan = ri->ri_stride;
386 1.11.2.1 yamt starty = ri->ri_font->fontheight * startrow;
387 1.11.2.1 yamt height = ri->ri_font->fontheight * nrows;
388 1.11.2.1 yamt w = ri->ri_emuwidth;
389 1.11.2.2 yamt fill = ((attr & 0x00000001) != 0) ? ALL1BITS : ALL0BITS;
390 1.11.2.2 yamt
391 1.11.2.2 yamt p = (uint8_t *)ri->ri_bits + starty * scanspan;
392 1.11.2.2 yamt width = w;
393 1.11.2.2 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
394 1.11.2.2 yamt q = p;
395 1.11.2.2 yamt while (height > 0) {
396 1.11.2.2 yamt P0(p) = fill; /* always aligned */
397 1.11.2.2 yamt width -= 2 * BLITWIDTH;
398 1.11.2.2 yamt while (width > 0) {
399 1.11.2.2 yamt p += BYTESDONE;
400 1.11.2.2 yamt P0(p) = fill;
401 1.11.2.2 yamt width -= BLITWIDTH;
402 1.11.2.2 yamt }
403 1.11.2.2 yamt p += BYTESDONE;
404 1.11.2.2 yamt P0(p) = (fill & rmask) | (P0(p) & ~rmask);
405 1.11.2.2 yamt p = (q += scanspan);
406 1.11.2.2 yamt width = w;
407 1.11.2.2 yamt height--;
408 1.11.2.2 yamt }
409 1.11.2.2 yamt }
410 1.11.2.2 yamt
411 1.11.2.2 yamt static void
412 1.11.2.2 yamt om4_eraserows(void *cookie, int startrow, int nrows, long attr)
413 1.11.2.2 yamt {
414 1.11.2.2 yamt struct rasops_info *ri = cookie;
415 1.11.2.2 yamt uint8_t *p, *q;
416 1.11.2.2 yamt int scanspan, starty, height, width, w;
417 1.11.2.2 yamt uint32_t rmask, fill0, fill1, fill2, fill3;
418 1.11.2.2 yamt
419 1.11.2.2 yamt scanspan = ri->ri_stride;
420 1.11.2.2 yamt starty = ri->ri_font->fontheight * startrow;
421 1.11.2.2 yamt height = ri->ri_font->fontheight * nrows;
422 1.11.2.2 yamt w = ri->ri_emuwidth;
423 1.11.2.2 yamt fill0 = ((attr & 0x00010000) != 0) ? ALL1BITS : ALL0BITS;
424 1.11.2.2 yamt fill1 = ((attr & 0x00020000) != 0) ? ALL1BITS : ALL0BITS;
425 1.11.2.2 yamt fill2 = ((attr & 0x00040000) != 0) ? ALL1BITS : ALL0BITS;
426 1.11.2.2 yamt fill3 = ((attr & 0x00080000) != 0) ? ALL1BITS : ALL0BITS;
427 1.1 nisimura
428 1.11.2.1 yamt p = (uint8_t *)ri->ri_bits + starty * scanspan;
429 1.1 nisimura width = w;
430 1.11.2.1 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
431 1.1 nisimura q = p;
432 1.1 nisimura while (height > 0) {
433 1.11.2.2 yamt P0(p) = fill0; /* always aligned */
434 1.11.2.2 yamt P1(p) = fill1;
435 1.11.2.2 yamt P2(p) = fill2;
436 1.11.2.2 yamt P3(p) = fill3;
437 1.11.2.2 yamt width -= 2 * BLITWIDTH;
438 1.11.2.2 yamt while (width > 0) {
439 1.11.2.2 yamt p += BYTESDONE;
440 1.11.2.2 yamt P0(p) = fill0;
441 1.11.2.2 yamt P1(p) = fill1;
442 1.11.2.2 yamt P2(p) = fill2;
443 1.11.2.2 yamt P3(p) = fill3;
444 1.11.2.2 yamt width -= BLITWIDTH;
445 1.11.2.2 yamt }
446 1.11.2.2 yamt p += BYTESDONE;
447 1.11.2.2 yamt P0(p) = (fill0 & rmask) | (P0(p) & ~rmask);
448 1.11.2.2 yamt P1(p) = (fill1 & rmask) | (P1(p) & ~rmask);
449 1.11.2.2 yamt P2(p) = (fill2 & rmask) | (P2(p) & ~rmask);
450 1.11.2.2 yamt P3(p) = (fill3 & rmask) | (P3(p) & ~rmask);
451 1.11.2.2 yamt p = (q += scanspan);
452 1.11.2.2 yamt width = w;
453 1.11.2.2 yamt height--;
454 1.11.2.2 yamt }
455 1.11.2.2 yamt }
456 1.11.2.2 yamt
457 1.11.2.2 yamt static void
458 1.11.2.2 yamt om1_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
459 1.11.2.2 yamt {
460 1.11.2.2 yamt struct rasops_info *ri = cookie;
461 1.11.2.2 yamt uint8_t *p, *q;
462 1.11.2.2 yamt int scanspan, offset, srcy, height, width, w;
463 1.11.2.2 yamt uint32_t rmask;
464 1.11.2.2 yamt
465 1.11.2.2 yamt scanspan = ri->ri_stride;
466 1.11.2.2 yamt height = ri->ri_font->fontheight * nrows;
467 1.11.2.2 yamt offset = (dstrow - srcrow) * scanspan * ri->ri_font->fontheight;
468 1.11.2.2 yamt srcy = ri->ri_font->fontheight * srcrow;
469 1.11.2.2 yamt if (srcrow < dstrow && srcrow + nrows > dstrow) {
470 1.11.2.2 yamt scanspan = -scanspan;
471 1.11.2.2 yamt srcy = srcy + height - 1;
472 1.11.2.2 yamt }
473 1.11.2.2 yamt
474 1.11.2.2 yamt p = (uint8_t *)ri->ri_bits + srcy * ri->ri_stride;
475 1.11.2.2 yamt w = ri->ri_emuwidth;
476 1.11.2.2 yamt width = w;
477 1.11.2.2 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
478 1.11.2.2 yamt q = p;
479 1.11.2.2 yamt while (height > 0) {
480 1.11.2.2 yamt P0(p + offset) = P0(p); /* always aligned */
481 1.1 nisimura width -= 2 * BLITWIDTH;
482 1.1 nisimura while (width > 0) {
483 1.1 nisimura p += BYTESDONE;
484 1.11.2.2 yamt P0(p + offset) = P0(p);
485 1.1 nisimura width -= BLITWIDTH;
486 1.1 nisimura }
487 1.1 nisimura p += BYTESDONE;
488 1.11.2.2 yamt P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask);
489 1.11.2.2 yamt
490 1.1 nisimura p = (q += scanspan);
491 1.1 nisimura width = w;
492 1.1 nisimura height--;
493 1.1 nisimura }
494 1.1 nisimura }
495 1.1 nisimura
496 1.1 nisimura static void
497 1.11.2.2 yamt om4_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
498 1.1 nisimura {
499 1.11.2.1 yamt struct rasops_info *ri = cookie;
500 1.11.2.1 yamt uint8_t *p, *q;
501 1.1 nisimura int scanspan, offset, srcy, height, width, w;
502 1.11.2.1 yamt uint32_t rmask;
503 1.11.2.1 yamt
504 1.11.2.1 yamt scanspan = ri->ri_stride;
505 1.11.2.1 yamt height = ri->ri_font->fontheight * nrows;
506 1.11.2.1 yamt offset = (dstrow - srcrow) * scanspan * ri->ri_font->fontheight;
507 1.11.2.1 yamt srcy = ri->ri_font->fontheight * srcrow;
508 1.1 nisimura if (srcrow < dstrow && srcrow + nrows > dstrow) {
509 1.1 nisimura scanspan = -scanspan;
510 1.11.2.2 yamt srcy = srcy + height - 1;
511 1.1 nisimura }
512 1.1 nisimura
513 1.11.2.1 yamt p = (uint8_t *)ri->ri_bits + srcy * ri->ri_stride;
514 1.11.2.1 yamt w = ri->ri_emuwidth;
515 1.1 nisimura width = w;
516 1.1 nisimura rmask = ALL1BITS << (-width & ALIGNMASK);
517 1.1 nisimura q = p;
518 1.1 nisimura while (height > 0) {
519 1.11.2.2 yamt P0(p + offset) = P0(p); /* always aligned */
520 1.11.2.2 yamt P1(p + offset) = P1(p);
521 1.11.2.2 yamt P2(p + offset) = P2(p);
522 1.11.2.2 yamt P3(p + offset) = P3(p);
523 1.1 nisimura width -= 2 * BLITWIDTH;
524 1.1 nisimura while (width > 0) {
525 1.1 nisimura p += BYTESDONE;
526 1.11.2.2 yamt P0(p + offset) = P0(p);
527 1.11.2.2 yamt P1(p + offset) = P1(p);
528 1.11.2.2 yamt P2(p + offset) = P2(p);
529 1.11.2.2 yamt P3(p + offset) = P3(p);
530 1.1 nisimura width -= BLITWIDTH;
531 1.1 nisimura }
532 1.1 nisimura p += BYTESDONE;
533 1.11.2.2 yamt P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask);
534 1.11.2.2 yamt P1(p + offset) = (P1(p) & rmask) | (P1(p + offset) & ~rmask);
535 1.11.2.2 yamt P2(p + offset) = (P2(p) & rmask) | (P2(p + offset) & ~rmask);
536 1.11.2.2 yamt P3(p + offset) = (P3(p) & rmask) | (P3(p + offset) & ~rmask);
537 1.1 nisimura
538 1.1 nisimura p = (q += scanspan);
539 1.1 nisimura width = w;
540 1.1 nisimura height--;
541 1.1 nisimura }
542 1.1 nisimura }
543 1.1 nisimura
544 1.1 nisimura static void
545 1.11.2.2 yamt om1_copycols(void *cookie, int startrow, int srccol, int dstcol, int ncols)
546 1.1 nisimura {
547 1.11.2.1 yamt struct rasops_info *ri = cookie;
548 1.11.2.2 yamt uint8_t *sp, *dp, *sq, *dq, *basep;
549 1.11.2.2 yamt int scanspan, height, w, y, srcx, dstx;
550 1.11.2.2 yamt int sb, eb, db, sboff, full, cnt, lnum, rnum;
551 1.11.2.2 yamt uint32_t lmask, rmask, tmp;
552 1.11.2.2 yamt bool sbover;
553 1.1 nisimura
554 1.11.2.1 yamt scanspan = ri->ri_stride;
555 1.11.2.1 yamt y = ri->ri_font->fontheight * startrow;
556 1.11.2.1 yamt srcx = ri->ri_font->fontwidth * srccol;
557 1.11.2.1 yamt dstx = ri->ri_font->fontwidth * dstcol;
558 1.11.2.1 yamt height = ri->ri_font->fontheight;
559 1.11.2.1 yamt w = ri->ri_font->fontwidth * ncols;
560 1.11.2.1 yamt basep = (uint8_t *)ri->ri_bits + y * scanspan;
561 1.1 nisimura
562 1.11.2.2 yamt sb = srcx & ALIGNMASK;
563 1.11.2.2 yamt db = dstx & ALIGNMASK;
564 1.1 nisimura
565 1.11.2.2 yamt if (db + w <= BLITWIDTH) {
566 1.11.2.2 yamt /* Destination is contained within a single word */
567 1.11.2.2 yamt sp = basep + (srcx / 32) * 4;
568 1.11.2.2 yamt dp = basep + (dstx / 32) * 4;
569 1.1 nisimura
570 1.1 nisimura while (height > 0) {
571 1.11.2.2 yamt GETBITS(P0(sp), sb, w, tmp);
572 1.11.2.2 yamt PUTBITS(tmp, db, w, P0(dp));
573 1.1 nisimura dp += scanspan;
574 1.1 nisimura sp += scanspan;
575 1.1 nisimura height--;
576 1.1 nisimura }
577 1.11.2.2 yamt return;
578 1.1 nisimura }
579 1.1 nisimura
580 1.11.2.2 yamt lmask = (db == 0) ? 0 : ALL1BITS >> db;
581 1.11.2.2 yamt eb = (db + w) & ALIGNMASK;
582 1.11.2.2 yamt rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb);
583 1.11.2.2 yamt lnum = (32 - db) & ALIGNMASK;
584 1.11.2.2 yamt rnum = (dstx + w) & ALIGNMASK;
585 1.11.2.2 yamt
586 1.11.2.2 yamt if (lmask != 0)
587 1.11.2.2 yamt full = (w - (32 - db)) / 32;
588 1.11.2.2 yamt else
589 1.11.2.2 yamt full = w / 32;
590 1.11.2.2 yamt
591 1.11.2.2 yamt sbover = (sb + lnum) >= 32;
592 1.11.2.2 yamt
593 1.11.2.2 yamt if (dstcol < srccol || srccol + ncols < dstcol) {
594 1.11.2.2 yamt /* copy forward (left-to-right) */
595 1.11.2.2 yamt sp = basep + (srcx / 32) * 4;
596 1.11.2.2 yamt dp = basep + (dstx / 32) * 4;
597 1.11.2.2 yamt
598 1.11.2.2 yamt if (lmask != 0) {
599 1.11.2.2 yamt sboff = sb + lnum;
600 1.11.2.2 yamt if (sboff >= 32)
601 1.11.2.2 yamt sboff -= 32;
602 1.11.2.2 yamt } else
603 1.11.2.2 yamt sboff = sb;
604 1.11.2.2 yamt
605 1.11.2.2 yamt sq = sp;
606 1.11.2.2 yamt dq = dp;
607 1.1 nisimura while (height > 0) {
608 1.11.2.2 yamt if (lmask != 0) {
609 1.11.2.2 yamt GETBITS(P0(sp), sb, lnum, tmp);
610 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P0(dp));
611 1.11.2.2 yamt dp += BYTESDONE;
612 1.11.2.2 yamt if (sbover)
613 1.11.2.2 yamt sp += BYTESDONE;
614 1.11.2.2 yamt }
615 1.11.2.2 yamt
616 1.11.2.2 yamt for (cnt = full; cnt; cnt--) {
617 1.11.2.2 yamt GETBITS(P0(sp), sboff, 32, tmp);
618 1.11.2.2 yamt P0(dp) = tmp;
619 1.1 nisimura sp += BYTESDONE;
620 1.1 nisimura dp += BYTESDONE;
621 1.1 nisimura }
622 1.11.2.2 yamt
623 1.11.2.2 yamt if (rmask != 0) {
624 1.11.2.2 yamt GETBITS(P0(sp), sboff, rnum, tmp);
625 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P0(dp));
626 1.11.2.2 yamt }
627 1.11.2.2 yamt
628 1.1 nisimura sp = (sq += scanspan);
629 1.1 nisimura dp = (dq += scanspan);
630 1.1 nisimura height--;
631 1.1 nisimura }
632 1.11.2.2 yamt } else {
633 1.11.2.2 yamt /* copy backward (right-to-left) */
634 1.11.2.2 yamt sp = basep + ((srcx + w) / 32) * 4;
635 1.11.2.2 yamt dp = basep + ((dstx + w) / 32) * 4;
636 1.11.2.2 yamt
637 1.11.2.2 yamt sboff = (srcx + w) & ALIGNMASK;
638 1.11.2.2 yamt sboff -= rnum;
639 1.11.2.2 yamt if (sboff < 0) {
640 1.11.2.2 yamt sp -= BYTESDONE;
641 1.11.2.2 yamt sboff += 32;
642 1.11.2.2 yamt }
643 1.1 nisimura
644 1.11.2.2 yamt sq = sp;
645 1.11.2.2 yamt dq = dp;
646 1.1 nisimura while (height > 0) {
647 1.11.2.2 yamt if (rnum != 0) {
648 1.11.2.2 yamt GETBITS(P0(sp), sboff, rnum, tmp);
649 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P0(dp));
650 1.11.2.2 yamt }
651 1.11.2.2 yamt
652 1.11.2.2 yamt for (cnt = full; cnt; cnt--) {
653 1.1 nisimura sp -= BYTESDONE;
654 1.1 nisimura dp -= BYTESDONE;
655 1.11.2.2 yamt GETBITS(P0(sp), sboff, 32, tmp);
656 1.11.2.2 yamt P0(dp) = tmp;
657 1.11.2.2 yamt }
658 1.11.2.2 yamt
659 1.11.2.2 yamt if (lmask != 0) {
660 1.11.2.2 yamt if (sbover)
661 1.11.2.2 yamt sp -= BYTESDONE;
662 1.11.2.2 yamt dp -= BYTESDONE;
663 1.11.2.2 yamt GETBITS(P0(sp), sb, lnum, tmp);
664 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P0(dp));
665 1.1 nisimura }
666 1.1 nisimura
667 1.1 nisimura sp = (sq += scanspan);
668 1.1 nisimura dp = (dq += scanspan);
669 1.1 nisimura height--;
670 1.1 nisimura }
671 1.1 nisimura }
672 1.11.2.2 yamt }
673 1.11.2.2 yamt
674 1.11.2.2 yamt static void
675 1.11.2.2 yamt om4_copycols(void *cookie, int startrow, int srccol, int dstcol, int ncols)
676 1.11.2.2 yamt {
677 1.11.2.2 yamt struct rasops_info *ri = cookie;
678 1.11.2.2 yamt uint8_t *sp, *dp, *sq, *dq, *basep;
679 1.11.2.2 yamt int scanspan, height, w, y, srcx, dstx;
680 1.11.2.2 yamt int sb, eb, db, sboff, full, cnt, lnum, rnum;
681 1.11.2.2 yamt uint32_t lmask, rmask, tmp;
682 1.11.2.2 yamt bool sbover;
683 1.11.2.2 yamt
684 1.11.2.2 yamt scanspan = ri->ri_stride;
685 1.11.2.2 yamt y = ri->ri_font->fontheight * startrow;
686 1.11.2.2 yamt srcx = ri->ri_font->fontwidth * srccol;
687 1.11.2.2 yamt dstx = ri->ri_font->fontwidth * dstcol;
688 1.11.2.2 yamt height = ri->ri_font->fontheight;
689 1.11.2.2 yamt w = ri->ri_font->fontwidth * ncols;
690 1.11.2.2 yamt basep = (uint8_t *)ri->ri_bits + y * scanspan;
691 1.11.2.2 yamt
692 1.11.2.2 yamt sb = srcx & ALIGNMASK;
693 1.11.2.2 yamt db = dstx & ALIGNMASK;
694 1.11.2.2 yamt
695 1.11.2.2 yamt if (db + w <= BLITWIDTH) {
696 1.11.2.2 yamt /* Destination is contained within a single word */
697 1.11.2.2 yamt sp = basep + (srcx / 32) * 4;
698 1.11.2.2 yamt dp = basep + (dstx / 32) * 4;
699 1.11.2.2 yamt
700 1.11.2.2 yamt while (height > 0) {
701 1.11.2.2 yamt GETBITS(P0(sp), sb, w, tmp);
702 1.11.2.2 yamt PUTBITS(tmp, db, w, P0(dp));
703 1.11.2.2 yamt GETBITS(P1(sp), sb, w, tmp);
704 1.11.2.2 yamt PUTBITS(tmp, db, w, P1(dp));
705 1.11.2.2 yamt GETBITS(P2(sp), sb, w, tmp);
706 1.11.2.2 yamt PUTBITS(tmp, db, w, P2(dp));
707 1.11.2.2 yamt GETBITS(P3(sp), sb, w, tmp);
708 1.11.2.2 yamt PUTBITS(tmp, db, w, P3(dp));
709 1.11.2.2 yamt dp += scanspan;
710 1.11.2.2 yamt sp += scanspan;
711 1.11.2.2 yamt height--;
712 1.11.2.2 yamt }
713 1.11.2.2 yamt return;
714 1.11.2.2 yamt }
715 1.11.2.2 yamt
716 1.11.2.2 yamt lmask = (db == 0) ? 0 : ALL1BITS >> db;
717 1.11.2.2 yamt eb = (db + w) & ALIGNMASK;
718 1.11.2.2 yamt rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb);
719 1.11.2.2 yamt lnum = (32 - db) & ALIGNMASK;
720 1.11.2.2 yamt rnum = (dstx + w) & ALIGNMASK;
721 1.11.2.2 yamt
722 1.11.2.2 yamt if (lmask != 0)
723 1.11.2.2 yamt full = (w - (32 - db)) / 32;
724 1.11.2.2 yamt else
725 1.11.2.2 yamt full = w / 32;
726 1.11.2.2 yamt
727 1.11.2.2 yamt sbover = (sb + lnum) >= 32;
728 1.1 nisimura
729 1.11.2.2 yamt if (dstcol < srccol || srccol + ncols < dstcol) {
730 1.11.2.2 yamt /* copy forward (left-to-right) */
731 1.11.2.2 yamt sp = basep + (srcx / 32) * 4;
732 1.11.2.2 yamt dp = basep + (dstx / 32) * 4;
733 1.11.2.2 yamt
734 1.11.2.2 yamt if (lmask != 0) {
735 1.11.2.2 yamt sboff = sb + lnum;
736 1.11.2.2 yamt if (sboff >= 32)
737 1.11.2.2 yamt sboff -= 32;
738 1.11.2.2 yamt } else
739 1.11.2.2 yamt sboff = sb;
740 1.11.2.2 yamt
741 1.11.2.2 yamt sq = sp;
742 1.11.2.2 yamt dq = dp;
743 1.11.2.2 yamt while (height > 0) {
744 1.11.2.2 yamt if (lmask != 0) {
745 1.11.2.2 yamt GETBITS(P0(sp), sb, lnum, tmp);
746 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P0(dp));
747 1.11.2.2 yamt GETBITS(P1(sp), sb, lnum, tmp);
748 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P1(dp));
749 1.11.2.2 yamt GETBITS(P2(sp), sb, lnum, tmp);
750 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P2(dp));
751 1.11.2.2 yamt GETBITS(P3(sp), sb, lnum, tmp);
752 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P3(dp));
753 1.11.2.2 yamt dp += BYTESDONE;
754 1.11.2.2 yamt if (sbover)
755 1.11.2.2 yamt sp += BYTESDONE;
756 1.11.2.2 yamt }
757 1.11.2.2 yamt
758 1.11.2.2 yamt for (cnt = full; cnt; cnt--) {
759 1.11.2.2 yamt GETBITS(P0(sp), sboff, 32, tmp);
760 1.11.2.2 yamt P0(dp) = tmp;
761 1.11.2.2 yamt GETBITS(P1(sp), sboff, 32, tmp);
762 1.11.2.2 yamt P1(dp) = tmp;
763 1.11.2.2 yamt GETBITS(P2(sp), sboff, 32, tmp);
764 1.11.2.2 yamt P2(dp) = tmp;
765 1.11.2.2 yamt GETBITS(P3(sp), sboff, 32, tmp);
766 1.11.2.2 yamt P3(dp) = tmp;
767 1.11.2.2 yamt sp += BYTESDONE;
768 1.11.2.2 yamt dp += BYTESDONE;
769 1.11.2.2 yamt }
770 1.11.2.2 yamt
771 1.11.2.2 yamt if (rmask != 0) {
772 1.11.2.2 yamt GETBITS(P0(sp), sboff, rnum, tmp);
773 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P0(dp));
774 1.11.2.2 yamt GETBITS(P1(sp), sboff, rnum, tmp);
775 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P1(dp));
776 1.11.2.2 yamt GETBITS(P2(sp), sboff, rnum, tmp);
777 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P2(dp));
778 1.11.2.2 yamt GETBITS(P3(sp), sboff, rnum, tmp);
779 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P3(dp));
780 1.11.2.2 yamt }
781 1.11.2.2 yamt
782 1.11.2.2 yamt sp = (sq += scanspan);
783 1.11.2.2 yamt dp = (dq += scanspan);
784 1.11.2.2 yamt height--;
785 1.11.2.2 yamt }
786 1.11.2.2 yamt } else {
787 1.11.2.2 yamt /* copy backward (right-to-left) */
788 1.11.2.2 yamt sp = basep + ((srcx + w) / 32) * 4;
789 1.11.2.2 yamt dp = basep + ((dstx + w) / 32) * 4;
790 1.11.2.2 yamt
791 1.11.2.2 yamt sboff = (srcx + w) & ALIGNMASK;
792 1.11.2.2 yamt sboff -= rnum;
793 1.11.2.2 yamt if (sboff < 0) {
794 1.11.2.2 yamt sp -= BYTESDONE;
795 1.11.2.2 yamt sboff += 32;
796 1.11.2.2 yamt }
797 1.11.2.2 yamt
798 1.11.2.2 yamt sq = sp;
799 1.11.2.2 yamt dq = dp;
800 1.11.2.2 yamt while (height > 0) {
801 1.11.2.2 yamt if (rnum != 0) {
802 1.11.2.2 yamt GETBITS(P0(sp), sboff, rnum, tmp);
803 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P0(dp));
804 1.11.2.2 yamt GETBITS(P1(sp), sboff, rnum, tmp);
805 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P1(dp));
806 1.11.2.2 yamt GETBITS(P2(sp), sboff, rnum, tmp);
807 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P2(dp));
808 1.11.2.2 yamt GETBITS(P3(sp), sboff, rnum, tmp);
809 1.11.2.2 yamt PUTBITS(tmp, 0, rnum, P3(dp));
810 1.11.2.2 yamt }
811 1.11.2.2 yamt
812 1.11.2.2 yamt for (cnt = full; cnt; cnt--) {
813 1.11.2.2 yamt sp -= BYTESDONE;
814 1.11.2.2 yamt dp -= BYTESDONE;
815 1.11.2.2 yamt GETBITS(P0(sp), sboff, 32, tmp);
816 1.11.2.2 yamt P0(dp) = tmp;
817 1.11.2.2 yamt GETBITS(P1(sp), sboff, 32, tmp);
818 1.11.2.2 yamt P1(dp) = tmp;
819 1.11.2.2 yamt GETBITS(P2(sp), sboff, 32, tmp);
820 1.11.2.2 yamt P2(dp) = tmp;
821 1.11.2.2 yamt GETBITS(P3(sp), sboff, 32, tmp);
822 1.11.2.2 yamt P3(dp) = tmp;
823 1.11.2.2 yamt }
824 1.11.2.2 yamt
825 1.11.2.2 yamt if (lmask != 0) {
826 1.11.2.2 yamt if (sbover)
827 1.11.2.2 yamt sp -= BYTESDONE;
828 1.11.2.2 yamt dp -= BYTESDONE;
829 1.11.2.2 yamt GETBITS(P0(sp), sb, lnum, tmp);
830 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P0(dp));
831 1.11.2.2 yamt GETBITS(P1(sp), sb, lnum, tmp);
832 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P1(dp));
833 1.11.2.2 yamt GETBITS(P2(sp), sb, lnum, tmp);
834 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P2(dp));
835 1.11.2.2 yamt GETBITS(P3(sp), sb, lnum, tmp);
836 1.11.2.2 yamt PUTBITS(tmp, db, lnum, P3(dp));
837 1.11.2.2 yamt }
838 1.11.2.2 yamt
839 1.11.2.2 yamt sp = (sq += scanspan);
840 1.11.2.2 yamt dp = (dq += scanspan);
841 1.11.2.2 yamt height--;
842 1.11.2.2 yamt }
843 1.11.2.2 yamt }
844 1.1 nisimura }
845 1.1 nisimura
846 1.1 nisimura /*
847 1.1 nisimura * Map a character.
848 1.1 nisimura */
849 1.1 nisimura static int
850 1.8 dsl om_mapchar(void *cookie, int c, u_int *cp)
851 1.1 nisimura {
852 1.11.2.1 yamt struct rasops_info *ri = cookie;
853 1.11.2.1 yamt struct wsdisplay_font *wf = ri->ri_font;
854 1.11 tsutsui
855 1.11.2.1 yamt if (wf->encoding != WSDISPLAY_FONTENC_ISO) {
856 1.11.2.1 yamt c = wsfont_map_unichar(wf, c);
857 1.11.2.1 yamt
858 1.11.2.1 yamt if (c < 0)
859 1.11.2.1 yamt goto fail;
860 1.1 nisimura }
861 1.11.2.1 yamt if (c < wf->firstchar || c >= (wf->firstchar + wf->numchars))
862 1.11.2.1 yamt goto fail;
863 1.11.2.1 yamt
864 1.11.2.1 yamt *cp = c;
865 1.11.2.1 yamt return 5;
866 1.11.2.1 yamt
867 1.11.2.1 yamt fail:
868 1.1 nisimura *cp = ' ';
869 1.11 tsutsui return 0;
870 1.1 nisimura }
871 1.1 nisimura
872 1.1 nisimura /*
873 1.1 nisimura * Position|{enable|disable} the cursor at the specified location.
874 1.1 nisimura */
875 1.1 nisimura static void
876 1.11.2.2 yamt om1_cursor(void *cookie, int on, int row, int col)
877 1.1 nisimura {
878 1.11.2.1 yamt struct rasops_info *ri = cookie;
879 1.5 tsutsui uint8_t *p;
880 1.1 nisimura int scanspan, startx, height, width, align, y;
881 1.11 tsutsui uint32_t lmask, rmask, image;
882 1.1 nisimura
883 1.1 nisimura if (!on) {
884 1.1 nisimura /* make sure it's on */
885 1.11.2.1 yamt if ((ri->ri_flg & RI_CURSOR) == 0)
886 1.1 nisimura return;
887 1.1 nisimura
888 1.11.2.1 yamt row = ri->ri_crow;
889 1.11.2.1 yamt col = ri->ri_ccol;
890 1.1 nisimura } else {
891 1.1 nisimura /* unpaint the old copy. */
892 1.11.2.1 yamt ri->ri_crow = row;
893 1.11.2.1 yamt ri->ri_ccol = col;
894 1.1 nisimura }
895 1.1 nisimura
896 1.11.2.1 yamt scanspan = ri->ri_stride;
897 1.11.2.1 yamt y = ri->ri_font->fontheight * row;
898 1.11.2.1 yamt startx = ri->ri_font->fontwidth * col;
899 1.11.2.1 yamt height = ri->ri_font->fontheight;
900 1.1 nisimura
901 1.11.2.1 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
902 1.1 nisimura align = startx & ALIGNMASK;
903 1.11.2.1 yamt width = ri->ri_font->fontwidth + align;
904 1.1 nisimura lmask = ALL1BITS >> align;
905 1.1 nisimura rmask = ALL1BITS << (-width & ALIGNMASK);
906 1.1 nisimura if (width <= BLITWIDTH) {
907 1.1 nisimura lmask &= rmask;
908 1.1 nisimura while (height > 0) {
909 1.11.2.2 yamt image = P0(p);
910 1.11.2.2 yamt P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
911 1.1 nisimura p += scanspan;
912 1.1 nisimura height--;
913 1.1 nisimura }
914 1.11 tsutsui } else {
915 1.5 tsutsui uint8_t *q = p;
916 1.1 nisimura
917 1.1 nisimura while (height > 0) {
918 1.11.2.2 yamt image = P0(p);
919 1.11.2.2 yamt P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
920 1.1 nisimura p += BYTESDONE;
921 1.11.2.2 yamt image = P0(p);
922 1.11.2.2 yamt P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
923 1.11.2.2 yamt
924 1.11.2.2 yamt p = (q += scanspan);
925 1.11.2.2 yamt height--;
926 1.11.2.2 yamt }
927 1.11.2.2 yamt }
928 1.11.2.2 yamt ri->ri_flg ^= RI_CURSOR;
929 1.11.2.2 yamt }
930 1.11.2.2 yamt
931 1.11.2.2 yamt static void
932 1.11.2.2 yamt om4_cursor(void *cookie, int on, int row, int col)
933 1.11.2.2 yamt {
934 1.11.2.2 yamt struct rasops_info *ri = cookie;
935 1.11.2.2 yamt uint8_t *p;
936 1.11.2.2 yamt int scanspan, startx, height, width, align, y;
937 1.11.2.2 yamt uint32_t lmask, rmask, image;
938 1.11.2.2 yamt
939 1.11.2.2 yamt if (!on) {
940 1.11.2.2 yamt /* make sure it's on */
941 1.11.2.2 yamt if ((ri->ri_flg & RI_CURSOR) == 0)
942 1.11.2.2 yamt return;
943 1.11.2.2 yamt
944 1.11.2.2 yamt row = ri->ri_crow;
945 1.11.2.2 yamt col = ri->ri_ccol;
946 1.11.2.2 yamt } else {
947 1.11.2.2 yamt /* unpaint the old copy. */
948 1.11.2.2 yamt ri->ri_crow = row;
949 1.11.2.2 yamt ri->ri_ccol = col;
950 1.11.2.2 yamt }
951 1.11.2.2 yamt
952 1.11.2.2 yamt scanspan = ri->ri_stride;
953 1.11.2.2 yamt y = ri->ri_font->fontheight * row;
954 1.11.2.2 yamt startx = ri->ri_font->fontwidth * col;
955 1.11.2.2 yamt height = ri->ri_font->fontheight;
956 1.11.2.2 yamt
957 1.11.2.2 yamt p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
958 1.11.2.2 yamt align = startx & ALIGNMASK;
959 1.11.2.2 yamt width = ri->ri_font->fontwidth + align;
960 1.11.2.2 yamt lmask = ALL1BITS >> align;
961 1.11.2.2 yamt rmask = ALL1BITS << (-width & ALIGNMASK);
962 1.11.2.2 yamt if (width <= BLITWIDTH) {
963 1.11.2.2 yamt lmask &= rmask;
964 1.11.2.2 yamt while (height > 0) {
965 1.11.2.2 yamt image = P0(p);
966 1.11.2.2 yamt P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
967 1.11.2.2 yamt image = P1(p);
968 1.11.2.2 yamt P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
969 1.11.2.2 yamt image = P2(p);
970 1.11.2.2 yamt P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
971 1.11.2.2 yamt image = P3(p);
972 1.11.2.2 yamt P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
973 1.11.2.2 yamt p += scanspan;
974 1.11.2.2 yamt height--;
975 1.11.2.2 yamt }
976 1.11.2.2 yamt } else {
977 1.11.2.2 yamt uint8_t *q = p;
978 1.11.2.2 yamt
979 1.11.2.2 yamt while (height > 0) {
980 1.11.2.2 yamt image = P0(p);
981 1.11.2.2 yamt P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
982 1.11.2.2 yamt image = P1(p);
983 1.11.2.2 yamt P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
984 1.11.2.2 yamt image = P2(p);
985 1.11.2.2 yamt P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
986 1.11.2.2 yamt image = P3(p);
987 1.11.2.2 yamt P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
988 1.11.2.2 yamt p += BYTESDONE;
989 1.11.2.2 yamt image = P0(p);
990 1.11.2.2 yamt P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
991 1.11.2.2 yamt image = P1(p);
992 1.11.2.2 yamt P1(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
993 1.11.2.2 yamt image = P2(p);
994 1.11.2.2 yamt P2(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
995 1.11.2.2 yamt image = P3(p);
996 1.11.2.2 yamt P3(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
997 1.1 nisimura
998 1.1 nisimura p = (q += scanspan);
999 1.1 nisimura height--;
1000 1.1 nisimura }
1001 1.1 nisimura }
1002 1.11.2.1 yamt ri->ri_flg ^= RI_CURSOR;
1003 1.1 nisimura }
1004 1.1 nisimura
1005 1.1 nisimura /*
1006 1.1 nisimura * Allocate attribute. We just pack these into an integer.
1007 1.1 nisimura */
1008 1.1 nisimura static int
1009 1.11.2.2 yamt om1_allocattr(void *id, int fg, int bg, int flags, long *attrp)
1010 1.1 nisimura {
1011 1.11 tsutsui
1012 1.11.2.2 yamt if ((flags & (WSATTR_HILIT | WSATTR_BLINK |
1013 1.11.2.2 yamt WSATTR_UNDERLINE | WSATTR_WSCOLORS)) != 0)
1014 1.11 tsutsui return EINVAL;
1015 1.11.2.2 yamt if ((flags & WSATTR_REVERSE) != 0)
1016 1.1 nisimura *attrp = 1;
1017 1.1 nisimura else
1018 1.1 nisimura *attrp = 0;
1019 1.11 tsutsui return 0;
1020 1.1 nisimura }
1021 1.1 nisimura
1022 1.11.2.2 yamt static int
1023 1.11.2.2 yamt om4_allocattr(void *id, int fg, int bg, int flags, long *attrp)
1024 1.11.2.2 yamt {
1025 1.11.2.2 yamt
1026 1.11.2.2 yamt if ((flags & (WSATTR_BLINK | WSATTR_UNDERLINE)) != 0)
1027 1.11.2.2 yamt return EINVAL;
1028 1.11.2.2 yamt if ((flags & WSATTR_WSCOLORS) == 0) {
1029 1.11.2.2 yamt fg = WSCOL_WHITE;
1030 1.11.2.2 yamt bg = WSCOL_BLACK;
1031 1.11.2.2 yamt }
1032 1.11.2.2 yamt
1033 1.11.2.2 yamt if ((flags & WSATTR_REVERSE) != 0) {
1034 1.11.2.2 yamt int swap;
1035 1.11.2.2 yamt swap = fg;
1036 1.11.2.2 yamt fg = bg;
1037 1.11.2.2 yamt bg = swap;
1038 1.11.2.2 yamt }
1039 1.11.2.2 yamt
1040 1.11.2.2 yamt if ((flags & WSATTR_HILIT) != 0)
1041 1.11.2.2 yamt fg += 8;
1042 1.11.2.2 yamt
1043 1.11.2.2 yamt *attrp = (fg << 24) | (bg << 16);
1044 1.11.2.2 yamt return 0;
1045 1.11.2.2 yamt }
1046 1.11.2.2 yamt
1047 1.11.2.1 yamt /*
1048 1.11.2.1 yamt * Init subset of rasops(9) for omrasops.
1049 1.11.2.1 yamt */
1050 1.11.2.1 yamt int
1051 1.11.2.2 yamt omrasops1_init(struct rasops_info *ri, int wantrows, int wantcols)
1052 1.11.2.2 yamt {
1053 1.11.2.2 yamt
1054 1.11.2.2 yamt omrasops_init(ri, wantrows, wantcols);
1055 1.11.2.2 yamt
1056 1.11.2.2 yamt /* fill our own emulops */
1057 1.11.2.2 yamt ri->ri_ops.cursor = om1_cursor;
1058 1.11.2.2 yamt ri->ri_ops.mapchar = om_mapchar;
1059 1.11.2.2 yamt ri->ri_ops.putchar = om1_putchar;
1060 1.11.2.2 yamt ri->ri_ops.copycols = om1_copycols;
1061 1.11.2.2 yamt ri->ri_ops.erasecols = om1_erasecols;
1062 1.11.2.2 yamt ri->ri_ops.copyrows = om1_copyrows;
1063 1.11.2.2 yamt ri->ri_ops.eraserows = om1_eraserows;
1064 1.11.2.2 yamt ri->ri_ops.allocattr = om1_allocattr;
1065 1.11.2.2 yamt ri->ri_caps = WSSCREEN_REVERSE;
1066 1.11.2.2 yamt
1067 1.11.2.2 yamt ri->ri_flg |= RI_CFGDONE;
1068 1.11.2.2 yamt
1069 1.11.2.2 yamt return 0;
1070 1.11.2.2 yamt }
1071 1.11.2.2 yamt
1072 1.11.2.2 yamt int
1073 1.11.2.2 yamt omrasops4_init(struct rasops_info *ri, int wantrows, int wantcols)
1074 1.11.2.2 yamt {
1075 1.11.2.2 yamt
1076 1.11.2.2 yamt omrasops_init(ri, wantrows, wantcols);
1077 1.11.2.2 yamt
1078 1.11.2.2 yamt /* fill our own emulops */
1079 1.11.2.2 yamt ri->ri_ops.cursor = om4_cursor;
1080 1.11.2.2 yamt ri->ri_ops.mapchar = om_mapchar;
1081 1.11.2.2 yamt ri->ri_ops.putchar = om4_putchar;
1082 1.11.2.2 yamt ri->ri_ops.copycols = om4_copycols;
1083 1.11.2.2 yamt ri->ri_ops.erasecols = om4_erasecols;
1084 1.11.2.2 yamt ri->ri_ops.copyrows = om4_copyrows;
1085 1.11.2.2 yamt ri->ri_ops.eraserows = om4_eraserows;
1086 1.11.2.2 yamt ri->ri_ops.allocattr = om4_allocattr;
1087 1.11.2.2 yamt ri->ri_caps = WSSCREEN_HILIT | WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
1088 1.11.2.2 yamt
1089 1.11.2.2 yamt ri->ri_flg |= RI_CFGDONE;
1090 1.11.2.2 yamt
1091 1.11.2.2 yamt return 0;
1092 1.11.2.2 yamt }
1093 1.11.2.2 yamt
1094 1.11.2.2 yamt static int
1095 1.11.2.1 yamt omrasops_init(struct rasops_info *ri, int wantrows, int wantcols)
1096 1.1 nisimura {
1097 1.11.2.1 yamt int wsfcookie, bpp;
1098 1.1 nisimura
1099 1.11.2.1 yamt if (wantrows == 0)
1100 1.11.2.1 yamt wantrows = 34;
1101 1.11.2.1 yamt if (wantrows < 10)
1102 1.11.2.1 yamt wantrows = 10;
1103 1.11.2.1 yamt if (wantcols == 0)
1104 1.11.2.1 yamt wantcols = 80;
1105 1.11.2.1 yamt if (wantcols < 20)
1106 1.11.2.1 yamt wantcols = 20;
1107 1.11.2.1 yamt
1108 1.11.2.1 yamt /* Use default font */
1109 1.11.2.1 yamt wsfont_init();
1110 1.11.2.1 yamt wsfcookie = wsfont_find(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_L2R,
1111 1.11.2.1 yamt WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
1112 1.11.2.1 yamt if (wsfcookie < 0)
1113 1.11.2.1 yamt panic("%s: no font available", __func__);
1114 1.11.2.1 yamt if (wsfont_lock(wsfcookie, &ri->ri_font))
1115 1.11.2.1 yamt panic("%s: unable to lock font", __func__);
1116 1.11.2.1 yamt ri->ri_wsfcookie = wsfcookie;
1117 1.11.2.1 yamt
1118 1.11.2.1 yamt KASSERT(ri->ri_font->fontwidth > 4 && ri->ri_font->fontwidth <= 32);
1119 1.11.2.1 yamt
1120 1.11.2.2 yamt /* all planes are independently addressed */
1121 1.11.2.2 yamt bpp = 1;
1122 1.11.2.1 yamt
1123 1.11.2.1 yamt /* Now constrain what they get */
1124 1.11.2.1 yamt ri->ri_emuwidth = ri->ri_font->fontwidth * wantcols;
1125 1.11.2.1 yamt ri->ri_emuheight = ri->ri_font->fontheight * wantrows;
1126 1.11.2.1 yamt if (ri->ri_emuwidth > ri->ri_width)
1127 1.11.2.1 yamt ri->ri_emuwidth = ri->ri_width;
1128 1.11.2.1 yamt if (ri->ri_emuheight > ri->ri_height)
1129 1.11.2.1 yamt ri->ri_emuheight = ri->ri_height;
1130 1.11.2.1 yamt
1131 1.11.2.1 yamt /* Reduce width until aligned on a 32-bit boundary */
1132 1.11.2.1 yamt while ((ri->ri_emuwidth * bpp & 31) != 0)
1133 1.11.2.1 yamt ri->ri_emuwidth--;
1134 1.11.2.1 yamt
1135 1.11.2.1 yamt ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth;
1136 1.11.2.1 yamt ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight;
1137 1.11.2.1 yamt ri->ri_emustride = ri->ri_emuwidth * bpp >> 3;
1138 1.11.2.1 yamt ri->ri_delta = ri->ri_stride - ri->ri_emustride;
1139 1.11.2.1 yamt ri->ri_ccol = 0;
1140 1.11.2.1 yamt ri->ri_crow = 0;
1141 1.11.2.1 yamt ri->ri_pelbytes = bpp >> 3;
1142 1.11.2.1 yamt
1143 1.11.2.1 yamt ri->ri_xscale = (ri->ri_font->fontwidth * bpp) >> 3;
1144 1.11.2.1 yamt ri->ri_yscale = ri->ri_font->fontheight * ri->ri_stride;
1145 1.11.2.1 yamt ri->ri_fontscale = ri->ri_font->fontheight * ri->ri_font->stride;
1146 1.11.2.1 yamt
1147 1.11.2.1 yamt /* Clear the entire display */
1148 1.11.2.1 yamt if ((ri->ri_flg & RI_CLEAR) != 0)
1149 1.11.2.1 yamt memset(ri->ri_bits, 0, ri->ri_stride * ri->ri_height);
1150 1.11.2.1 yamt
1151 1.11.2.1 yamt /* Now centre our window if needs be */
1152 1.11.2.1 yamt ri->ri_origbits = ri->ri_bits;
1153 1.11.2.1 yamt
1154 1.11.2.1 yamt if ((ri->ri_flg & RI_CENTER) != 0) {
1155 1.11.2.1 yamt ri->ri_bits += (((ri->ri_width * bpp >> 3) -
1156 1.11.2.1 yamt ri->ri_emustride) >> 1) & ~3;
1157 1.11.2.1 yamt ri->ri_bits += ((ri->ri_height - ri->ri_emuheight) >> 1) *
1158 1.11.2.1 yamt ri->ri_stride;
1159 1.11.2.1 yamt ri->ri_yorigin = (int)(ri->ri_bits - ri->ri_origbits)
1160 1.11.2.1 yamt / ri->ri_stride;
1161 1.11.2.1 yamt ri->ri_xorigin = (((int)(ri->ri_bits - ri->ri_origbits)
1162 1.11.2.1 yamt % ri->ri_stride) * 8 / bpp);
1163 1.11.2.1 yamt } else
1164 1.11.2.1 yamt ri->ri_xorigin = ri->ri_yorigin = 0;
1165 1.11.2.1 yamt
1166 1.11.2.1 yamt return 0;
1167 1.1 nisimura }
1168