Home | History | Annotate | Line # | Download | only in rasops
rasops1.c revision 1.20.2.2
      1  1.20.2.1  uebayasi /* 	$NetBSD: rasops1.c,v 1.20.2.2 2010/08/17 06:46:37 uebayasi Exp $	*/
      2       1.1        ad 
      3       1.5        ad /*-
      4       1.5        ad  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5       1.1        ad  * All rights reserved.
      6       1.1        ad  *
      7       1.5        ad  * This code is derived from software contributed to The NetBSD Foundation
      8      1.12        ad  * by Andrew Doran.
      9       1.5        ad  *
     10       1.1        ad  * Redistribution and use in source and binary forms, with or without
     11       1.1        ad  * modification, are permitted provided that the following conditions
     12       1.1        ad  * are met:
     13       1.1        ad  * 1. Redistributions of source code must retain the above copyright
     14       1.1        ad  *    notice, this list of conditions and the following disclaimer.
     15       1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     17       1.1        ad  *    documentation and/or other materials provided with the distribution.
     18       1.1        ad  *
     19       1.5        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.5        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.5        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.5        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.5        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.5        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.5        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.5        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.5        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.5        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.5        ad  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1        ad  */
     31       1.2        ad 
     32      1.14     lukem #include <sys/cdefs.h>
     33  1.20.2.1  uebayasi __KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.20.2.2 2010/08/17 06:46:37 uebayasi Exp $");
     34      1.14     lukem 
     35       1.1        ad #include "opt_rasops.h"
     36       1.1        ad 
     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.4        ad #include <dev/rasops/rasops_masks.h>
     46       1.1        ad 
     47      1.16     perry static void	rasops1_copycols(void *, int, int, int, int);
     48      1.16     perry static void	rasops1_erasecols(void *, int, int, int, long);
     49      1.16     perry static void	rasops1_do_cursor(struct rasops_info *);
     50      1.16     perry static void	rasops1_putchar(void *, int, int col, u_int, long);
     51      1.10        ad #ifndef RASOPS_SMALL
     52      1.16     perry static void	rasops1_putchar8(void *, int, int col, u_int, long);
     53      1.16     perry static void	rasops1_putchar16(void *, int, int col, u_int, long);
     54      1.10        ad #endif
     55       1.1        ad 
     56       1.1        ad /*
     57      1.13       wiz  * Initialize rasops_info struct for this colordepth.
     58       1.1        ad  */
     59       1.1        ad void
     60      1.19       dsl rasops1_init(struct rasops_info *ri)
     61       1.1        ad {
     62       1.1        ad 
     63       1.1        ad 	switch (ri->ri_font->fontwidth) {
     64      1.10        ad #ifndef RASOPS_SMALL
     65       1.1        ad 	case 8:
     66       1.1        ad 		ri->ri_ops.putchar = rasops1_putchar8;
     67       1.1        ad 		break;
     68       1.1        ad 	case 16:
     69       1.1        ad 		ri->ri_ops.putchar = rasops1_putchar16;
     70       1.1        ad 		break;
     71      1.10        ad #endif
     72       1.1        ad 	default:
     73       1.1        ad 		ri->ri_ops.putchar = rasops1_putchar;
     74       1.1        ad 		break;
     75       1.1        ad 	}
     76      1.11        pk 
     77       1.6        ad 	if ((ri->ri_font->fontwidth & 7) != 0) {
     78       1.1        ad 		ri->ri_ops.erasecols = rasops1_erasecols;
     79       1.1        ad 		ri->ri_ops.copycols = rasops1_copycols;
     80       1.1        ad 		ri->ri_do_cursor = rasops1_do_cursor;
     81       1.1        ad 	}
     82       1.1        ad }
     83       1.1        ad 
     84       1.1        ad /*
     85       1.4        ad  * Paint a single character. This is the generic version, this is ugly.
     86       1.1        ad  */
     87       1.1        ad static void
     88      1.20       dsl rasops1_putchar(void *cookie, int row, int col, u_int uc, long attr)
     89       1.1        ad {
     90      1.10        ad 	u_int fs, rs, fb, bg, fg, lmask, rmask;
     91      1.10        ad 	u_int32_t height, width;
     92  1.20.2.2  uebayasi 	struct rasops_info *ri = (struct rasops_info *)cookie;
     93  1.20.2.2  uebayasi 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
     94  1.20.2.1  uebayasi 	int32_t *rp, *hrp = NULL, tmp, tmp2;
     95       1.4        ad 	u_char *fr;
     96      1.11        pk 
     97      1.11        pk #ifdef RASOPS_CLIPPING
     98      1.11        pk 	/* Catches 'row < 0' case too */
     99       1.4        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    100       1.4        ad 		return;
    101       1.4        ad 
    102       1.4        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    103       1.4        ad 		return;
    104       1.4        ad #endif
    105       1.4        ad 
    106       1.4        ad 	col *= ri->ri_font->fontwidth;
    107       1.4        ad 	rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
    108  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    109  1.20.2.1  uebayasi 		hrp = (int32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
    110  1.20.2.1  uebayasi 		    ((col >> 3) & ~3));
    111  1.20.2.2  uebayasi 	height = font->fontheight;
    112  1.20.2.2  uebayasi 	width = font->fontwidth;
    113       1.4        ad 	col = col & 31;
    114       1.4        ad 	rs = ri->ri_stride;
    115      1.11        pk 
    116       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    117       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    118       1.4        ad 
    119       1.4        ad 	/* If fg and bg match this becomes a space character */
    120       1.4        ad 	if (fg == bg || uc == ' ') {
    121       1.4        ad 		uc = (u_int)-1;
    122       1.4        ad 		fr = 0;		/* shutup gcc */
    123       1.4        ad 		fs = 0;		/* shutup gcc */
    124       1.4        ad 	} else {
    125  1.20.2.2  uebayasi 		uc -= font->firstchar;
    126  1.20.2.2  uebayasi 		fr = (u_char *)font->data + uc * ri->ri_fontscale;
    127  1.20.2.2  uebayasi 		fs = font->stride;
    128       1.4        ad 	}
    129      1.11        pk 
    130       1.4        ad 	/* Single word, one mask */
    131       1.4        ad 	if ((col + width) <= 32) {
    132       1.4        ad 		rmask = rasops_pmask[col][width];
    133       1.4        ad 		lmask = ~rmask;
    134      1.11        pk 
    135       1.4        ad 		if (uc == (u_int)-1) {
    136       1.4        ad 			bg &= rmask;
    137      1.11        pk 
    138       1.4        ad 			while (height--) {
    139  1.20.2.1  uebayasi 				tmp = (*rp & lmask) | bg;
    140  1.20.2.1  uebayasi 				*rp = tmp;
    141       1.4        ad 				DELTA(rp, rs, int32_t *);
    142  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    143  1.20.2.1  uebayasi 					*hrp = tmp;
    144  1.20.2.1  uebayasi 					DELTA(hrp, rs, int32_t *);
    145  1.20.2.1  uebayasi 				}
    146       1.4        ad 			}
    147       1.4        ad 		} else {
    148       1.4        ad 			/* NOT fontbits if bg is white */
    149       1.4        ad 			if (bg) {
    150       1.4        ad 				while (height--) {
    151      1.11        pk 					fb = ~(fr[3] | (fr[2] << 8) |
    152       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    153  1.20.2.1  uebayasi 					tmp = (*rp & lmask)
    154       1.4        ad 					    | (MBE(fb >> col) & rmask);
    155  1.20.2.1  uebayasi 					*rp = tmp;
    156       1.4        ad 
    157       1.4        ad 					fr += fs;
    158       1.4        ad 					DELTA(rp, rs, int32_t *);
    159  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    160  1.20.2.1  uebayasi 						*hrp = tmp;
    161  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    162  1.20.2.1  uebayasi 					}
    163       1.4        ad 				}
    164       1.4        ad 			} else {
    165       1.4        ad 				while (height--) {
    166      1.11        pk 					fb = (fr[3] | (fr[2] << 8) |
    167       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    168  1.20.2.1  uebayasi 					tmp = (*rp & lmask)
    169       1.4        ad 					    | (MBE(fb >> col) & rmask);
    170  1.20.2.1  uebayasi 					*rp = tmp;
    171      1.11        pk 
    172       1.4        ad 					fr += fs;
    173       1.4        ad 					DELTA(rp, rs, int32_t *);
    174  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    175  1.20.2.1  uebayasi 						*hrp = tmp;
    176  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    177  1.20.2.1  uebayasi 					}
    178       1.4        ad 				}
    179       1.4        ad 			}
    180       1.4        ad 		}
    181      1.11        pk 
    182       1.4        ad 		/* Do underline */
    183      1.10        ad 		if ((attr & 1) != 0) {
    184       1.4        ad 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    185  1.20.2.1  uebayasi 			tmp = (*rp & lmask) | (fg & rmask);
    186  1.20.2.1  uebayasi 			*rp = tmp;
    187  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    188  1.20.2.1  uebayasi 				DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    189  1.20.2.1  uebayasi 				*hrp = tmp;
    190  1.20.2.1  uebayasi 			}
    191       1.4        ad 		}
    192       1.4        ad 	} else {
    193       1.4        ad 		lmask = ~rasops_lmask[col];
    194       1.4        ad 		rmask = ~rasops_rmask[(col + width) & 31];
    195      1.11        pk 
    196       1.4        ad 		if (uc == (u_int)-1) {
    197       1.8     mouse 			width = bg & ~rmask;
    198       1.4        ad 			bg = bg & ~lmask;
    199      1.11        pk 
    200       1.4        ad 			while (height--) {
    201  1.20.2.1  uebayasi 				tmp = (rp[0] & lmask) | bg;
    202  1.20.2.1  uebayasi 				tmp2 = (rp[1] & rmask) | width;
    203  1.20.2.1  uebayasi 				rp[0] = tmp;
    204  1.20.2.1  uebayasi 				rp[1] = tmp2;
    205       1.4        ad 				DELTA(rp, rs, int32_t *);
    206  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    207  1.20.2.1  uebayasi 					hrp[0] = tmp;
    208  1.20.2.1  uebayasi 					hrp[1] = tmp2;
    209  1.20.2.1  uebayasi 					DELTA(hrp, rs, int32_t *);
    210  1.20.2.1  uebayasi 				}
    211       1.4        ad 			}
    212       1.4        ad 		} else {
    213       1.4        ad 			width = 32 - col;
    214      1.11        pk 
    215       1.4        ad 			/* NOT fontbits if bg is white */
    216       1.4        ad 			if (bg) {
    217       1.4        ad 				while (height--) {
    218      1.11        pk 					fb = ~(fr[3] | (fr[2] << 8) |
    219       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    220      1.11        pk 
    221  1.20.2.1  uebayasi 					tmp = (rp[0] & lmask)
    222       1.4        ad 					    | MBE((u_int)fb >> col);
    223       1.4        ad 
    224  1.20.2.1  uebayasi 					tmp2 = (rp[1] & rmask)
    225       1.4        ad 					    | (MBE((u_int)fb << width) & ~rmask);
    226  1.20.2.1  uebayasi 					rp[0] = tmp;
    227  1.20.2.1  uebayasi 					rp[1] = tmp2;
    228       1.4        ad 					fr += fs;
    229       1.4        ad 					DELTA(rp, rs, int32_t *);
    230  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    231  1.20.2.1  uebayasi 						hrp[0] = tmp;
    232  1.20.2.1  uebayasi 						hrp[1] = tmp2;
    233  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    234  1.20.2.1  uebayasi 					}
    235       1.4        ad 				}
    236       1.4        ad 			} else {
    237       1.4        ad 				while (height--) {
    238      1.11        pk 					fb = (fr[3] | (fr[2] << 8) |
    239       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    240       1.4        ad 
    241  1.20.2.1  uebayasi 					tmp = (rp[0] & lmask)
    242       1.4        ad 					    | MBE(fb >> col);
    243       1.4        ad 
    244  1.20.2.1  uebayasi 					tmp2 = (rp[1] & rmask)
    245       1.4        ad 					    | (MBE(fb << width) & ~rmask);
    246  1.20.2.1  uebayasi 					rp[0] = tmp;
    247  1.20.2.1  uebayasi 					rp[1] = tmp2;
    248       1.4        ad 					fr += fs;
    249       1.4        ad 					DELTA(rp, rs, int32_t *);
    250  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    251  1.20.2.1  uebayasi 						hrp[0] = tmp;
    252  1.20.2.1  uebayasi 						hrp[1] = tmp2;
    253  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    254  1.20.2.1  uebayasi 					}
    255       1.4        ad 				}
    256       1.4        ad 			}
    257       1.4        ad 		}
    258       1.1        ad 
    259       1.4        ad 		/* Do underline */
    260      1.10        ad 		if ((attr & 1) != 0) {
    261       1.4        ad 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    262  1.20.2.1  uebayasi 			tmp = (rp[0] & lmask) | (fg & ~lmask);
    263  1.20.2.1  uebayasi 			tmp2 = (rp[1] & rmask) | (fg & ~rmask);
    264  1.20.2.1  uebayasi 			rp[0] = tmp;
    265  1.20.2.1  uebayasi 			rp[1] = tmp2;
    266  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    267  1.20.2.1  uebayasi 				DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    268  1.20.2.1  uebayasi 				hrp[0] = tmp;
    269  1.20.2.1  uebayasi 				hrp[1] = tmp2;
    270  1.20.2.1  uebayasi 			}
    271       1.4        ad 		}
    272       1.4        ad 	}
    273       1.1        ad }
    274       1.1        ad 
    275      1.10        ad #ifndef RASOPS_SMALL
    276       1.1        ad /*
    277       1.1        ad  * Paint a single character. This is for 8-pixel wide fonts.
    278       1.1        ad  */
    279       1.1        ad static void
    280      1.20       dsl rasops1_putchar8(void *cookie, int row, int col, u_int uc, long attr)
    281       1.1        ad {
    282       1.1        ad 	int height, fs, rs, bg, fg;
    283  1.20.2.2  uebayasi 	struct rasops_info *ri = (struct rasops_info *)cookie;
    284  1.20.2.2  uebayasi 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    285  1.20.2.1  uebayasi 	u_char *fr, *rp, *hrp = NULL;
    286      1.11        pk 
    287      1.11        pk #ifdef RASOPS_CLIPPING
    288      1.11        pk 	/* Catches 'row < 0' case too */
    289       1.3        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    290       1.1        ad 		return;
    291       1.1        ad 
    292       1.3        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    293       1.1        ad 		return;
    294       1.1        ad #endif
    295       1.1        ad 
    296       1.3        ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    297  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    298  1.20.2.1  uebayasi 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
    299  1.20.2.2  uebayasi 	height = font->fontheight;
    300       1.1        ad 	rs = ri->ri_stride;
    301      1.11        pk 
    302       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    303       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    304      1.11        pk 
    305       1.1        ad 	/* If fg and bg match this becomes a space character */
    306       1.1        ad 	if (fg == bg || uc == ' ') {
    307       1.1        ad 		while (height--) {
    308       1.1        ad 			*rp = bg;
    309       1.1        ad 			rp += rs;
    310  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    311  1.20.2.1  uebayasi 				*hrp = bg;
    312  1.20.2.1  uebayasi 				hrp += rs;
    313  1.20.2.1  uebayasi 			}
    314       1.1        ad 		}
    315       1.1        ad 	} else {
    316  1.20.2.2  uebayasi 		uc -= font->firstchar;
    317  1.20.2.2  uebayasi 		fr = (u_char *)font->data + uc * ri->ri_fontscale;
    318  1.20.2.2  uebayasi 		fs = font->stride;
    319      1.11        pk 
    320       1.1        ad 		/* NOT fontbits if bg is white */
    321       1.1        ad 		if (bg) {
    322       1.1        ad 			while (height--) {
    323       1.1        ad 				*rp = ~*fr;
    324       1.1        ad 				rp += rs;
    325  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    326  1.20.2.1  uebayasi 					*hrp = ~*fr;
    327  1.20.2.1  uebayasi 					hrp += rs;
    328  1.20.2.1  uebayasi 				}
    329  1.20.2.1  uebayasi 				fr += fs;
    330  1.20.2.1  uebayasi 
    331       1.1        ad 			}
    332       1.1        ad 		} else {
    333       1.1        ad 			while (height--) {
    334       1.1        ad 				*rp = *fr;
    335       1.1        ad 				rp += rs;
    336  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    337  1.20.2.1  uebayasi 					*hrp = *fr;
    338  1.20.2.1  uebayasi 					hrp += rs;
    339  1.20.2.1  uebayasi 				}
    340  1.20.2.1  uebayasi 				fr += fs;
    341       1.1        ad 			}
    342       1.1        ad 		}
    343       1.4        ad 
    344       1.1        ad 	}
    345       1.1        ad 
    346       1.1        ad 	/* Do underline */
    347  1.20.2.1  uebayasi 	if ((attr & 1) != 0) {
    348       1.1        ad 		rp[-(ri->ri_stride << 1)] = fg;
    349  1.20.2.1  uebayasi 		if (ri->ri_hwbits) {
    350  1.20.2.1  uebayasi 			hrp[-(ri->ri_stride << 1)] = fg;
    351  1.20.2.1  uebayasi 		}
    352  1.20.2.1  uebayasi 	}
    353       1.1        ad }
    354       1.1        ad 
    355       1.1        ad /*
    356       1.1        ad  * Paint a single character. This is for 16-pixel wide fonts.
    357       1.1        ad  */
    358       1.1        ad static void
    359      1.20       dsl rasops1_putchar16(void *cookie, int row, int col, u_int uc, long attr)
    360       1.1        ad {
    361       1.1        ad 	int height, fs, rs, bg, fg;
    362  1.20.2.2  uebayasi 	struct rasops_info *ri = (struct rasops_info *)cookie;
    363  1.20.2.2  uebayasi 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    364  1.20.2.1  uebayasi 	u_char *fr, *rp, *hrp = NULL;
    365      1.11        pk 
    366      1.11        pk #ifdef RASOPS_CLIPPING
    367      1.11        pk 	/* Catches 'row < 0' case too */
    368       1.3        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    369       1.1        ad 		return;
    370       1.1        ad 
    371       1.3        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    372       1.1        ad 		return;
    373       1.1        ad #endif
    374       1.1        ad 
    375       1.3        ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    376  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    377  1.20.2.1  uebayasi 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
    378  1.20.2.2  uebayasi 	height = font->fontheight;
    379       1.1        ad 	rs = ri->ri_stride;
    380      1.11        pk 
    381       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    382       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    383       1.9        ad 
    384       1.1        ad 	/* If fg and bg match this becomes a space character */
    385       1.1        ad 	if (fg == bg || uc == ' ') {
    386       1.1        ad 		while (height--) {
    387  1.20.2.1  uebayasi 			/* XXX alignment?! */
    388       1.1        ad 			*(int16_t *)rp = bg;
    389       1.1        ad 			rp += rs;
    390  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    391  1.20.2.1  uebayasi 				*(int16_t *)hrp = bg;
    392  1.20.2.1  uebayasi 				hrp += rs;
    393  1.20.2.1  uebayasi 			}
    394       1.1        ad 		}
    395       1.1        ad 	} else {
    396  1.20.2.2  uebayasi 		uc -= font->firstchar;
    397  1.20.2.2  uebayasi 		fr = (u_char *)font->data + uc * ri->ri_fontscale;
    398  1.20.2.2  uebayasi 		fs = font->stride;
    399      1.11        pk 
    400       1.1        ad 		/* NOT fontbits if bg is white */
    401       1.1        ad 		if (bg) {
    402       1.1        ad 			while (height--) {
    403       1.1        ad 				rp[0] = ~fr[0];
    404       1.1        ad 				rp[1] = ~fr[1];
    405       1.1        ad 				rp += rs;
    406  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    407  1.20.2.1  uebayasi 					hrp[0] = ~fr[0];
    408  1.20.2.1  uebayasi 					hrp[1] = ~fr[1];
    409  1.20.2.1  uebayasi 					hrp += rs;
    410  1.20.2.1  uebayasi 				}
    411  1.20.2.1  uebayasi 				fr += fs;
    412       1.1        ad 			}
    413       1.1        ad 		} else {
    414       1.1        ad 			while (height--) {
    415       1.1        ad 				rp[0] = fr[0];
    416       1.1        ad 				rp[1] = fr[1];
    417       1.1        ad 				rp += rs;
    418  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    419  1.20.2.1  uebayasi 					hrp[0] = fr[0];
    420  1.20.2.1  uebayasi 					hrp[1] = fr[1];
    421  1.20.2.1  uebayasi 					hrp += rs;
    422  1.20.2.1  uebayasi 				}
    423  1.20.2.1  uebayasi 				fr += fs;
    424       1.1        ad 			}
    425       1.1        ad 		}
    426       1.1        ad 	}
    427       1.1        ad 
    428       1.1        ad 	/* Do underline */
    429  1.20.2.2  uebayasi 	if ((attr & 1) != 0) {
    430  1.20.2.1  uebayasi 		/* XXX alignment?! */
    431       1.1        ad 		*(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
    432  1.20.2.2  uebayasi 		if (ri->ri_hwbits) {
    433  1.20.2.1  uebayasi 			*(int16_t *)(hrp - (ri->ri_stride << 1)) = fg;
    434  1.20.2.2  uebayasi 		}
    435  1.20.2.2  uebayasi 	}
    436       1.1        ad }
    437      1.10        ad #endif	/* !RASOPS_SMALL */
    438       1.1        ad 
    439       1.1        ad /*
    440       1.4        ad  * Grab routines common to depths where (bpp < 8)
    441       1.1        ad  */
    442       1.4        ad #define NAME(ident)	rasops1_##ident
    443       1.4        ad #define PIXEL_SHIFT	0
    444       1.1        ad 
    445       1.4        ad #include <dev/rasops/rasops_bitops.h>
    446