Home | History | Annotate | Line # | Download | only in rasops
rasops1.c revision 1.3
      1  1.3  ad /* $NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $ */
      2  1.1  ad 
      3  1.2  ad /*
      4  1.2  ad  * Copyright (c) 1999 Andy Doran <ad (at) NetBSD.org>
      5  1.1  ad  * All rights reserved.
      6  1.1  ad  *
      7  1.1  ad  * Redistribution and use in source and binary forms, with or without
      8  1.1  ad  * modification, are permitted provided that the following conditions
      9  1.1  ad  * are met:
     10  1.1  ad  * 1. Redistributions of source code must retain the above copyright
     11  1.1  ad  *    notice, this list of conditions and the following disclaimer.
     12  1.1  ad  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  ad  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  ad  *    documentation and/or other materials provided with the distribution.
     15  1.1  ad  *
     16  1.2  ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.2  ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.2  ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.2  ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.2  ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.2  ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.2  ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.2  ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.2  ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.2  ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.2  ad  * SUCH DAMAGE.
     27  1.2  ad  *
     28  1.1  ad  */
     29  1.2  ad 
     30  1.1  ad #include "opt_rasops.h"
     31  1.1  ad #ifdef RASOPS1
     32  1.1  ad 
     33  1.1  ad #include <sys/cdefs.h>
     34  1.3  ad __KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
     35  1.1  ad 
     36  1.1  ad #include <sys/types.h>
     37  1.1  ad #include <sys/param.h>
     38  1.1  ad #include <sys/systm.h>
     39  1.1  ad #include <sys/time.h>
     40  1.1  ad #include <machine/endian.h>
     41  1.1  ad 
     42  1.1  ad #include <dev/wscons/wsdisplayvar.h>
     43  1.3  ad #include <dev/wscons/wsconsio.h>
     44  1.1  ad #include <dev/rasops/rasops.h>
     45  1.1  ad 
     46  1.1  ad static void	rasops1_putchar __P((void *, int, int col, u_int, long));
     47  1.1  ad static void	rasops1_putchar8 __P((void *, int, int col, u_int, long));
     48  1.1  ad static void	rasops1_putchar16 __P((void *, int, int col, u_int, long));
     49  1.1  ad static void	rasops1_copycols __P((void *, int, int, int, int));
     50  1.3  ad static void	rasops1_erasecols __P((void *, int, int, int, long));
     51  1.3  ad static void	rasops1_erasecols8 __P((void *, int, int, int, long));
     52  1.3  ad static void	rasops1_eraserows __P((void *, int, int, long));
     53  1.1  ad static int32_t	rasops1_fg_color __P((long));
     54  1.1  ad static int32_t	rasops1_bg_color __P((long));
     55  1.1  ad static void	rasops1_do_cursor __P((struct rasops_info *));
     56  1.1  ad static void	rasops1_do_cursor8 __P((struct rasops_info *));
     57  1.1  ad 
     58  1.1  ad void	rasops1_init __P((struct rasops_info *ri));
     59  1.1  ad 
     60  1.1  ad #if BYTE_ORDER == LITTLE_ENDIAN
     61  1.1  ad static u_int32_t rightmask[32] = {
     62  1.1  ad #else
     63  1.1  ad static u_int32_t leftmask[32] = {
     64  1.1  ad #endif
     65  1.1  ad     0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
     66  1.1  ad     0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000,
     67  1.1  ad     0xff000000, 0xff800000, 0xffc00000, 0xffe00000,
     68  1.1  ad     0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000,
     69  1.1  ad     0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
     70  1.1  ad     0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
     71  1.1  ad     0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
     72  1.1  ad     0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe,
     73  1.1  ad };
     74  1.1  ad 
     75  1.1  ad #if BYTE_ORDER == LITTLE_ENDIAN
     76  1.1  ad static u_int32_t leftmask[32] = {
     77  1.1  ad #else
     78  1.1  ad static u_int32_t rightmask[32] = {
     79  1.1  ad #endif
     80  1.1  ad     0x00000000, 0x00000001, 0x00000003, 0x00000007,
     81  1.1  ad     0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
     82  1.1  ad     0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
     83  1.1  ad     0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
     84  1.1  ad     0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
     85  1.1  ad     0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
     86  1.1  ad     0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
     87  1.1  ad     0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
     88  1.1  ad };
     89  1.1  ad 
     90  1.1  ad 
     91  1.1  ad /*
     92  1.1  ad  * Initalize rasops_info struct for this colordepth.
     93  1.1  ad  */
     94  1.1  ad void
     95  1.1  ad rasops1_init(ri)
     96  1.1  ad 	struct rasops_info *ri;
     97  1.1  ad {
     98  1.1  ad 
     99  1.1  ad 	switch (ri->ri_font->fontwidth) {
    100  1.1  ad 	case 8:
    101  1.1  ad 		ri->ri_ops.putchar = rasops1_putchar8;
    102  1.1  ad 		break;
    103  1.1  ad 	case 16:
    104  1.1  ad 		ri->ri_ops.putchar = rasops1_putchar16;
    105  1.1  ad 		break;
    106  1.1  ad 	default:
    107  1.1  ad 		/*
    108  1.1  ad 		 * XXX we don't support anything other than 8 and 16 pel
    109  1.1  ad 		 * wide fonts yet. rasops1_copycols needs to be finished, the
    110  1.1  ad 		 * other routines will need to be checked.
    111  1.1  ad 		 */
    112  1.1  ad 		panic("rasops1_init: not completed - see this location in src for details");
    113  1.1  ad 		ri->ri_ops.putchar = rasops1_putchar;
    114  1.1  ad 		break;
    115  1.1  ad 	}
    116  1.1  ad 
    117  1.1  ad 	if (ri->ri_font->fontwidth & 7) {
    118  1.1  ad 		ri->ri_ops.erasecols = rasops1_erasecols;
    119  1.1  ad 		ri->ri_ops.copycols = rasops1_copycols;
    120  1.1  ad 		ri->ri_do_cursor = rasops1_do_cursor;
    121  1.1  ad 	} else {
    122  1.1  ad 		ri->ri_ops.erasecols = rasops1_erasecols8;
    123  1.1  ad 		/* use default copycols */
    124  1.1  ad 		ri->ri_do_cursor = rasops1_do_cursor8;
    125  1.1  ad 	}
    126  1.1  ad 
    127  1.1  ad 	ri->ri_ops.eraserows = rasops1_eraserows;
    128  1.1  ad }
    129  1.1  ad 
    130  1.1  ad 
    131  1.1  ad /*
    132  1.1  ad  * Get foreground color from attribute and copy across all 4 bytes
    133  1.1  ad  * in a int32_t.
    134  1.1  ad  */
    135  1.1  ad static __inline__ int32_t
    136  1.1  ad rasops1_fg_color(long attr)
    137  1.1  ad {
    138  1.1  ad 
    139  1.1  ad 	return (attr & 0x0f000000) ? 0xffffffff : 0;
    140  1.1  ad }
    141  1.1  ad 
    142  1.1  ad 
    143  1.1  ad /*
    144  1.1  ad  * Get background color from attribute and copy across all 4 bytes
    145  1.1  ad  * in a int32_t.
    146  1.1  ad  */
    147  1.1  ad static __inline__ int32_t
    148  1.1  ad rasops1_bg_color(long attr)
    149  1.1  ad {
    150  1.1  ad 
    151  1.1  ad 	return (attr & 0x000f0000) ? 0xffffffff : 0;
    152  1.1  ad }
    153  1.1  ad 
    154  1.1  ad 
    155  1.1  ad /*
    156  1.1  ad  * Paint a single character. This is the generic version.
    157  1.1  ad  */
    158  1.1  ad static void
    159  1.1  ad rasops1_putchar(cookie, row, col, uc, attr)
    160  1.1  ad 	void *cookie;
    161  1.1  ad 	int row, col;
    162  1.1  ad 	u_int uc;
    163  1.1  ad 	long attr;
    164  1.1  ad {
    165  1.1  ad 
    166  1.3  ad 	panic("rasops1_putchar: i need implemention");
    167  1.1  ad }
    168  1.1  ad 
    169  1.1  ad 
    170  1.1  ad /*
    171  1.1  ad  * Paint a single character. This is for 8-pixel wide fonts.
    172  1.1  ad  */
    173  1.1  ad static void
    174  1.1  ad rasops1_putchar8(cookie, row, col, uc, attr)
    175  1.1  ad 	void *cookie;
    176  1.1  ad 	int row, col;
    177  1.1  ad 	u_int uc;
    178  1.1  ad 	long attr;
    179  1.1  ad {
    180  1.1  ad 	int height, fs, rs, bg, fg;
    181  1.1  ad 	struct rasops_info *ri;
    182  1.1  ad 	u_char *fr, *rp;
    183  1.1  ad 
    184  1.1  ad 	ri = (struct rasops_info *)cookie;
    185  1.1  ad 
    186  1.1  ad #ifdef RASOPS_CLIPPING
    187  1.3  ad 	/* Catches 'row < 0' case too */
    188  1.3  ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    189  1.1  ad 		return;
    190  1.1  ad 
    191  1.3  ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    192  1.1  ad 		return;
    193  1.1  ad #endif
    194  1.1  ad 
    195  1.3  ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    196  1.1  ad 	height = ri->ri_font->fontheight;
    197  1.1  ad 	rs = ri->ri_stride;
    198  1.1  ad 
    199  1.1  ad 	bg = (attr & 0x000f0000) ? 0xff : 0;
    200  1.1  ad 	fg = (attr & 0x0f000000) ? 0xff : 0;
    201  1.1  ad 
    202  1.1  ad 	/* If fg and bg match this becomes a space character */
    203  1.1  ad 	if (fg == bg || uc == ' ') {
    204  1.1  ad 		while (height--) {
    205  1.1  ad 			*rp = bg;
    206  1.1  ad 			rp += rs;
    207  1.1  ad 		}
    208  1.1  ad 	} else {
    209  1.1  ad 		uc -= ri->ri_font->firstchar;
    210  1.1  ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    211  1.1  ad 		fs = ri->ri_font->stride;
    212  1.1  ad 
    213  1.1  ad 		/* NOT fontbits if bg is white */
    214  1.1  ad 		if (bg) {
    215  1.1  ad 			while (height--) {
    216  1.1  ad 				*rp = ~*fr;
    217  1.1  ad 				fr += fs;
    218  1.1  ad 				rp += rs;
    219  1.1  ad 			}
    220  1.1  ad 		} else {
    221  1.1  ad 			while (height--) {
    222  1.1  ad 				*rp = *fr;
    223  1.1  ad 				fr += fs;
    224  1.1  ad 				rp += rs;
    225  1.1  ad 			}
    226  1.1  ad 		}
    227  1.1  ad 	}
    228  1.1  ad 
    229  1.1  ad 	/* Do underline */
    230  1.1  ad 	if (attr & 1)
    231  1.1  ad 		rp[-(ri->ri_stride << 1)] = fg;
    232  1.1  ad }
    233  1.1  ad 
    234  1.1  ad 
    235  1.1  ad /*
    236  1.1  ad  * Paint a single character. This is for 16-pixel wide fonts.
    237  1.1  ad  */
    238  1.1  ad static void
    239  1.1  ad rasops1_putchar16(cookie, row, col, uc, attr)
    240  1.1  ad 	void *cookie;
    241  1.1  ad 	int row, col;
    242  1.1  ad 	u_int uc;
    243  1.1  ad 	long attr;
    244  1.1  ad {
    245  1.1  ad 	int height, fs, rs, bg, fg;
    246  1.1  ad 	struct rasops_info *ri;
    247  1.1  ad 	u_char *fr, *rp;
    248  1.1  ad 
    249  1.1  ad 	ri = (struct rasops_info *)cookie;
    250  1.1  ad 
    251  1.1  ad #ifdef RASOPS_CLIPPING
    252  1.3  ad 	/* Catches 'row < 0' case too */
    253  1.3  ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    254  1.1  ad 		return;
    255  1.1  ad 
    256  1.3  ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    257  1.1  ad 		return;
    258  1.1  ad #endif
    259  1.1  ad 
    260  1.3  ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    261  1.1  ad 	height = ri->ri_font->fontheight;
    262  1.1  ad 	rs = ri->ri_stride;
    263  1.1  ad 
    264  1.1  ad 	bg = (attr & 0x000f0000) ? 0xffff : 0;
    265  1.1  ad 	fg = (attr & 0x0f000000) ? 0xffff : 0;
    266  1.1  ad 
    267  1.1  ad 	/* If fg and bg match this becomes a space character */
    268  1.1  ad 	if (fg == bg || uc == ' ') {
    269  1.1  ad 		while (height--) {
    270  1.1  ad 			*(int16_t *)rp = bg;
    271  1.1  ad 			rp += rs;
    272  1.1  ad 		}
    273  1.1  ad 	} else {
    274  1.1  ad 		uc -= ri->ri_font->firstchar;
    275  1.1  ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    276  1.1  ad 		fs = ri->ri_font->stride;
    277  1.1  ad 
    278  1.1  ad 		/* NOT fontbits if bg is white */
    279  1.1  ad 		if (bg) {
    280  1.1  ad 			while (height--) {
    281  1.1  ad 				rp[0] = ~fr[0];
    282  1.1  ad 				rp[1] = ~fr[1];
    283  1.1  ad 				fr += fs;
    284  1.1  ad 				rp += rs;
    285  1.1  ad 			}
    286  1.1  ad 		} else {
    287  1.1  ad 			while (height--) {
    288  1.1  ad 				rp[0] = fr[0];
    289  1.1  ad 				rp[1] = fr[1];
    290  1.1  ad 				fr += fs;
    291  1.1  ad 				rp += rs;
    292  1.1  ad 			}
    293  1.1  ad 		}
    294  1.1  ad 	}
    295  1.1  ad 
    296  1.1  ad 	/* Do underline */
    297  1.1  ad 	if (attr & 1)
    298  1.1  ad 		*(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
    299  1.1  ad }
    300  1.1  ad 
    301  1.1  ad 
    302  1.1  ad /*
    303  1.1  ad  * Erase columns.
    304  1.1  ad  */
    305  1.1  ad static void
    306  1.1  ad rasops1_erasecols(cookie, row, col, num, attr)
    307  1.1  ad 	void *cookie;
    308  1.1  ad 	int row, num;
    309  1.1  ad 	long attr;
    310  1.1  ad {
    311  1.1  ad 	int32_t *dp, *rp, lmask, rmask, lclr, rclr, clr;
    312  1.1  ad 	struct rasops_info *ri;
    313  1.1  ad 	int nint, height, cnt;
    314  1.1  ad 
    315  1.1  ad 	ri = (struct rasops_info *)cookie;
    316  1.1  ad 
    317  1.1  ad #ifdef RASOPS_CLIPPING
    318  1.3  ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    319  1.1  ad 		return;
    320  1.1  ad 
    321  1.1  ad 	if (col < 0) {
    322  1.1  ad 		num += col;
    323  1.1  ad 		col = 0;
    324  1.1  ad 	}
    325  1.1  ad 
    326  1.1  ad 	if ((col + num) > ri->ri_cols)
    327  1.1  ad 		num = ri->ri_cols - col;
    328  1.1  ad 
    329  1.1  ad 	if (num <= 0)
    330  1.1  ad 		return;
    331  1.1  ad #endif
    332  1.3  ad 	col *= ri->ri_font->fontwidth;
    333  1.3  ad 	num *= ri->ri_font->fontwidth;
    334  1.1  ad 
    335  1.1  ad 	/*
    336  1.1  ad 	 * lmask: mask for leftmost int32
    337  1.1  ad 	 * rmask: mask for rightmost int32
    338  1.1  ad 	 * nint: number of full int32s
    339  1.1  ad 	 */
    340  1.1  ad 	lmask = leftmask[col & 31];
    341  1.1  ad 	rmask = rightmask[(col + num) & 31];
    342  1.3  ad 	nint = (((col + num) & ~31) - ((col + 31) & ~31)) >> 5;
    343  1.1  ad 
    344  1.1  ad 	/* Merge both masks if the span is encapsulated within one int32 */
    345  1.3  ad 	if ((col & ~31) == ((col + num) & ~31)) {
    346  1.1  ad 		lmask &= rmask;
    347  1.1  ad 		rmask = 0;
    348  1.1  ad 	}
    349  1.1  ad 
    350  1.1  ad 	clr = rasops1_bg_color(attr);
    351  1.1  ad 	lclr = clr & lmask;
    352  1.1  ad 	rclr = clr & rmask;
    353  1.1  ad 	lmask = ~lmask;
    354  1.1  ad 	rmask = ~rmask;
    355  1.3  ad 	height = ri->ri_font->fontheight;
    356  1.3  ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
    357  1.1  ad 
    358  1.1  ad 	while (height--) {
    359  1.1  ad 		dp = rp;
    360  1.1  ad 		DELTA(rp, ri->ri_stride, int32_t *);
    361  1.1  ad 
    362  1.1  ad 		if (lmask != 0xffffffffU)
    363  1.1  ad 			*dp++ = (*dp & lmask) | lclr;
    364  1.1  ad 
    365  1.1  ad 		for (cnt = nint; cnt; cnt--)
    366  1.1  ad 			*dp++ = clr;
    367  1.1  ad 
    368  1.1  ad 		if (rmask != 0xffffffffU)
    369  1.1  ad 			*dp = (*dp & rmask) | rclr;
    370  1.1  ad 	}
    371  1.1  ad }
    372  1.1  ad 
    373  1.1  ad 
    374  1.1  ad /*
    375  1.1  ad  * Erase columns for fonts that are a multiple of 8 pels in width.
    376  1.1  ad  */
    377  1.1  ad static void
    378  1.1  ad rasops1_erasecols8(cookie, row, col, num, attr)
    379  1.1  ad 	void *cookie;
    380  1.1  ad 	int row, col, num;
    381  1.1  ad 	long attr;
    382  1.1  ad {
    383  1.1  ad 	struct rasops_info *ri;
    384  1.1  ad 	int32_t *dst;
    385  1.1  ad 	u_char *dstb, *rp;
    386  1.1  ad 	int clr, height, cnt, slop1, slop2;
    387  1.1  ad 
    388  1.1  ad 	ri = (struct rasops_info *)cookie;
    389  1.1  ad 
    390  1.1  ad #ifdef RASOPS_CLIPPING
    391  1.3  ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    392  1.1  ad 		return;
    393  1.1  ad 
    394  1.1  ad 	if (col < 0) {
    395  1.1  ad 		num += col;
    396  1.1  ad 		col = 0;
    397  1.1  ad 	}
    398  1.1  ad 
    399  1.1  ad 	if ((col + num) > ri->ri_cols)
    400  1.1  ad 		num = ri->ri_cols - col;
    401  1.1  ad 
    402  1.1  ad 	if (num <= 0)
    403  1.1  ad 		return;
    404  1.1  ad #endif
    405  1.1  ad 
    406  1.1  ad 	num = num * ri->ri_xscale;
    407  1.1  ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    408  1.1  ad 	clr = rasops1_bg_color(attr);
    409  1.1  ad 	height = ri->ri_font->fontheight;
    410  1.1  ad 
    411  1.1  ad 	slop1 = (int)rp & 3;
    412  1.1  ad 	slop2 = (num - slop1) & 3;
    413  1.1  ad 	num = (num - slop1 - slop2) >> 2;
    414  1.1  ad 
    415  1.1  ad 	while (height--) {
    416  1.1  ad 		dstb = rp;
    417  1.1  ad 		rp += ri->ri_stride;
    418  1.1  ad 
    419  1.1  ad 		/* Align span to 4 bytes */
    420  1.1  ad 		for (cnt = slop1; cnt; cnt--)
    421  1.1  ad 			*dstb++ = (u_char)clr;
    422  1.1  ad 
    423  1.1  ad 		dst = (int32_t *)dstb;
    424  1.1  ad 
    425  1.1  ad 		/* Write 4 bytes per loop */
    426  1.1  ad 		for (cnt = num; cnt; cnt--)
    427  1.1  ad 			*dst++ = clr;
    428  1.1  ad 
    429  1.1  ad 		/* Write unaligned trailing slop */
    430  1.1  ad 		if (slop2 == 0)
    431  1.1  ad 			continue;
    432  1.1  ad 
    433  1.1  ad 		dstb = (u_char *)dst;
    434  1.1  ad 
    435  1.1  ad 		for (cnt = slop2; cnt; cnt--)
    436  1.1  ad 			*dstb++ = (u_char)clr;
    437  1.1  ad 	}
    438  1.1  ad }
    439  1.1  ad 
    440  1.1  ad 
    441  1.1  ad /*
    442  1.1  ad  * Actually paint the cursor.
    443  1.1  ad  */
    444  1.1  ad static void
    445  1.1  ad rasops1_do_cursor(ri)
    446  1.1  ad 	struct rasops_info *ri;
    447  1.1  ad {
    448  1.1  ad 	int32_t *dp, *rp, lmask, rmask;
    449  1.1  ad 	int height, row, col;
    450  1.1  ad 
    451  1.1  ad 	row = ri->ri_crow;
    452  1.3  ad 	col = ri->ri_ccol * ri->ri_font->fontwidth;
    453  1.1  ad 
    454  1.1  ad 	/*
    455  1.1  ad 	 * lmask: mask for leftmost int32
    456  1.1  ad 	 * rmask: mask for rightmost int32
    457  1.1  ad 	 */
    458  1.1  ad 	lmask = leftmask[col & 31];
    459  1.3  ad 	rmask = rightmask[(col + ri->ri_font->fontwidth) & 31];
    460  1.1  ad 
    461  1.1  ad 	/* Merge both masks if the span is encapsulated within one int32 */
    462  1.3  ad 	if ((col & ~31) == ((col + ri->ri_font->fontwidth) & ~31)) {
    463  1.1  ad 		lmask &= rmask;
    464  1.1  ad 		rmask = 0;
    465  1.1  ad 	}
    466  1.1  ad 
    467  1.1  ad 	lmask = ~lmask;
    468  1.1  ad 	rmask = ~rmask;
    469  1.3  ad 	height = ri->ri_font->fontheight;
    470  1.3  ad 	rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
    471  1.1  ad 
    472  1.1  ad 	while (height--) {
    473  1.1  ad 		dp = rp;
    474  1.1  ad 		DELTA(rp, ri->ri_stride, int32_t *);
    475  1.1  ad 
    476  1.1  ad 		*dp++ = ((*dp & lmask) ^ lmask) | (*dp & ~lmask);
    477  1.1  ad 
    478  1.1  ad 		if (rmask != 0xffffffffU)
    479  1.1  ad 			*dp = ((*dp & rmask) ^ rmask) | (*dp & ~rmask);
    480  1.1  ad 	}
    481  1.1  ad }
    482  1.1  ad 
    483  1.1  ad 
    484  1.1  ad /*
    485  1.1  ad  * Paint cursors that are a multiple of 8 pels in size.
    486  1.1  ad  */
    487  1.1  ad static void
    488  1.1  ad rasops1_do_cursor8(ri)
    489  1.1  ad 	struct rasops_info *ri;
    490  1.1  ad {
    491  1.1  ad 	int width, height, cnt;
    492  1.1  ad 	u_char *dp, *rp;
    493  1.1  ad 
    494  1.3  ad 	height = ri->ri_font->fontheight;
    495  1.3  ad 	width = ri->ri_font->fontwidth >> 3;
    496  1.1  ad 	rp = ri->ri_bits + ri->ri_crow * ri->ri_yscale +
    497  1.1  ad 	    ri->ri_ccol * ri->ri_xscale;
    498  1.1  ad 
    499  1.1  ad 	while (height--) {
    500  1.1  ad 		dp = rp;
    501  1.1  ad 		rp += ri->ri_stride;
    502  1.1  ad 
    503  1.1  ad 		for (cnt = width; cnt; cnt--)
    504  1.1  ad 			*dp++ ^= 0xff;
    505  1.1  ad 	}
    506  1.1  ad }
    507  1.1  ad 
    508  1.1  ad 
    509  1.1  ad /*
    510  1.3  ad  * Erase rows. This is easy.
    511  1.1  ad  */
    512  1.1  ad static void
    513  1.1  ad rasops1_eraserows(cookie, row, num, attr)
    514  1.1  ad 	void *cookie;
    515  1.1  ad 	int row, num;
    516  1.1  ad 	long attr;
    517  1.1  ad {
    518  1.1  ad 	struct rasops_info *ri;
    519  1.1  ad 	int32_t *dp, clr;
    520  1.1  ad 	int n8, n1, cnt;
    521  1.1  ad 
    522  1.1  ad 	ri = (struct rasops_info *)cookie;
    523  1.1  ad 
    524  1.1  ad #ifdef RASOPS_CLIPPING
    525  1.1  ad 	if (row < 0) {
    526  1.1  ad 		num += row;
    527  1.1  ad 		row = 0;
    528  1.1  ad 	}
    529  1.1  ad 
    530  1.1  ad 	if ((row + num) > ri->ri_rows)
    531  1.1  ad 		num = ri->ri_rows - row;
    532  1.1  ad 
    533  1.1  ad 	if (num <= 0)
    534  1.1  ad 		return;
    535  1.1  ad #endif
    536  1.1  ad 
    537  1.1  ad 	num *= ri->ri_font->fontheight;
    538  1.1  ad 	dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
    539  1.1  ad 	clr = rasops1_bg_color(attr);
    540  1.1  ad 
    541  1.1  ad 	n8 = ri->ri_emustride >> 5;
    542  1.1  ad 	n1 = (ri->ri_emustride >> 2) & 7;
    543  1.1  ad 
    544  1.1  ad 	while (num--) {
    545  1.1  ad 		for (cnt = n8; cnt; cnt--) {
    546  1.1  ad 			dp[0] = clr;
    547  1.1  ad 			dp[1] = clr;
    548  1.1  ad 			dp[2] = clr;
    549  1.1  ad 			dp[3] = clr;
    550  1.1  ad 			dp[4] = clr;
    551  1.1  ad 			dp[5] = clr;
    552  1.1  ad 			dp[6] = clr;
    553  1.1  ad 			dp[7] = clr;
    554  1.1  ad 			dp += 8;
    555  1.1  ad 		}
    556  1.1  ad 
    557  1.1  ad 		for (cnt = n1; cnt; cnt--)
    558  1.1  ad 			*dp++ = clr;
    559  1.1  ad 
    560  1.1  ad 		DELTA(dp, ri->ri_delta, int32_t *);
    561  1.1  ad 	}
    562  1.1  ad }
    563  1.1  ad 
    564  1.1  ad 
    565  1.1  ad /*
    566  1.1  ad  * Copy columns. This is slow. Ick! You'd better use a font with
    567  1.1  ad  * a width that's a multiple of 8 pels, otherwise this is used...
    568  1.1  ad  */
    569  1.1  ad static void
    570  1.3  ad rasops1_copycols(cookie, row, src, dst, num)
    571  1.1  ad 	void *cookie;
    572  1.3  ad 	int row, src, dst, num;
    573  1.1  ad {
    574  1.1  ad 
    575  1.3  ad 	panic("rasops1_copycols: i need implemention");
    576  1.1  ad }
    577  1.1  ad 
    578  1.1  ad #endif /* RASOPS1 */
    579