Home | History | Annotate | Line # | Download | only in rasops
rasops1.c revision 1.20.2.1
      1  1.20.2.1  uebayasi /* 	$NetBSD: rasops1.c,v 1.20.2.1 2010/04/30 14:43:47 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.1 2010/04/30 14:43:47 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.4        ad 	struct rasops_info *ri;
     93  1.20.2.1  uebayasi 	int32_t *rp, *hrp = NULL, tmp, tmp2;
     94       1.4        ad 	u_char *fr;
     95      1.11        pk 
     96       1.4        ad 	ri = (struct rasops_info *)cookie;
     97       1.4        ad 
     98      1.11        pk #ifdef RASOPS_CLIPPING
     99      1.11        pk 	/* Catches 'row < 0' case too */
    100       1.4        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    101       1.4        ad 		return;
    102       1.4        ad 
    103       1.4        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    104       1.4        ad 		return;
    105       1.4        ad #endif
    106       1.4        ad 
    107       1.4        ad 	col *= ri->ri_font->fontwidth;
    108       1.4        ad 	rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
    109  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    110  1.20.2.1  uebayasi 		hrp = (int32_t *)(ri->ri_hwbits + row * ri->ri_yscale +
    111  1.20.2.1  uebayasi 		    ((col >> 3) & ~3));
    112       1.4        ad 	height = ri->ri_font->fontheight;
    113       1.4        ad 	width = ri->ri_font->fontwidth;
    114       1.4        ad 	col = col & 31;
    115       1.4        ad 	rs = ri->ri_stride;
    116      1.11        pk 
    117       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    118       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    119       1.4        ad 
    120       1.4        ad 	/* If fg and bg match this becomes a space character */
    121       1.4        ad 	if (fg == bg || uc == ' ') {
    122       1.4        ad 		uc = (u_int)-1;
    123       1.4        ad 		fr = 0;		/* shutup gcc */
    124       1.4        ad 		fs = 0;		/* shutup gcc */
    125       1.4        ad 	} else {
    126       1.4        ad 		uc -= ri->ri_font->firstchar;
    127       1.4        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    128       1.4        ad 		fs = ri->ri_font->stride;
    129       1.4        ad 	}
    130      1.11        pk 
    131       1.4        ad 	/* Single word, one mask */
    132       1.4        ad 	if ((col + width) <= 32) {
    133       1.4        ad 		rmask = rasops_pmask[col][width];
    134       1.4        ad 		lmask = ~rmask;
    135      1.11        pk 
    136       1.4        ad 		if (uc == (u_int)-1) {
    137       1.4        ad 			bg &= rmask;
    138      1.11        pk 
    139       1.4        ad 			while (height--) {
    140  1.20.2.1  uebayasi 				tmp = (*rp & lmask) | bg;
    141  1.20.2.1  uebayasi 				*rp = tmp;
    142       1.4        ad 				DELTA(rp, rs, int32_t *);
    143  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    144  1.20.2.1  uebayasi 					*hrp = tmp;
    145  1.20.2.1  uebayasi 					DELTA(hrp, rs, int32_t *);
    146  1.20.2.1  uebayasi 				}
    147       1.4        ad 			}
    148       1.4        ad 		} else {
    149       1.4        ad 			/* NOT fontbits if bg is white */
    150       1.4        ad 			if (bg) {
    151       1.4        ad 				while (height--) {
    152      1.11        pk 					fb = ~(fr[3] | (fr[2] << 8) |
    153       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    154  1.20.2.1  uebayasi 					tmp = (*rp & lmask)
    155       1.4        ad 					    | (MBE(fb >> col) & rmask);
    156  1.20.2.1  uebayasi 					*rp = tmp;
    157       1.4        ad 
    158       1.4        ad 					fr += fs;
    159       1.4        ad 					DELTA(rp, rs, int32_t *);
    160  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    161  1.20.2.1  uebayasi 						*hrp = tmp;
    162  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    163  1.20.2.1  uebayasi 					}
    164       1.4        ad 				}
    165       1.4        ad 			} else {
    166       1.4        ad 				while (height--) {
    167      1.11        pk 					fb = (fr[3] | (fr[2] << 8) |
    168       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    169  1.20.2.1  uebayasi 					tmp = (*rp & lmask)
    170       1.4        ad 					    | (MBE(fb >> col) & rmask);
    171  1.20.2.1  uebayasi 					*rp = tmp;
    172      1.11        pk 
    173       1.4        ad 					fr += fs;
    174       1.4        ad 					DELTA(rp, rs, int32_t *);
    175  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    176  1.20.2.1  uebayasi 						*hrp = tmp;
    177  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    178  1.20.2.1  uebayasi 					}
    179       1.4        ad 				}
    180       1.4        ad 			}
    181       1.4        ad 		}
    182      1.11        pk 
    183       1.4        ad 		/* Do underline */
    184      1.10        ad 		if ((attr & 1) != 0) {
    185       1.4        ad 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    186  1.20.2.1  uebayasi 			tmp = (*rp & lmask) | (fg & rmask);
    187  1.20.2.1  uebayasi 			*rp = tmp;
    188  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    189  1.20.2.1  uebayasi 				DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    190  1.20.2.1  uebayasi 				*hrp = tmp;
    191  1.20.2.1  uebayasi 			}
    192       1.4        ad 		}
    193       1.4        ad 	} else {
    194       1.4        ad 		lmask = ~rasops_lmask[col];
    195       1.4        ad 		rmask = ~rasops_rmask[(col + width) & 31];
    196      1.11        pk 
    197       1.4        ad 		if (uc == (u_int)-1) {
    198       1.8     mouse 			width = bg & ~rmask;
    199       1.4        ad 			bg = bg & ~lmask;
    200      1.11        pk 
    201       1.4        ad 			while (height--) {
    202  1.20.2.1  uebayasi 				tmp = (rp[0] & lmask) | bg;
    203  1.20.2.1  uebayasi 				tmp2 = (rp[1] & rmask) | width;
    204  1.20.2.1  uebayasi 				rp[0] = tmp;
    205  1.20.2.1  uebayasi 				rp[1] = tmp2;
    206       1.4        ad 				DELTA(rp, rs, int32_t *);
    207  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    208  1.20.2.1  uebayasi 					hrp[0] = tmp;
    209  1.20.2.1  uebayasi 					hrp[1] = tmp2;
    210  1.20.2.1  uebayasi 					DELTA(hrp, rs, int32_t *);
    211  1.20.2.1  uebayasi 				}
    212       1.4        ad 			}
    213       1.4        ad 		} else {
    214       1.4        ad 			width = 32 - col;
    215      1.11        pk 
    216       1.4        ad 			/* NOT fontbits if bg is white */
    217       1.4        ad 			if (bg) {
    218       1.4        ad 				while (height--) {
    219      1.11        pk 					fb = ~(fr[3] | (fr[2] << 8) |
    220       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    221      1.11        pk 
    222  1.20.2.1  uebayasi 					tmp = (rp[0] & lmask)
    223       1.4        ad 					    | MBE((u_int)fb >> col);
    224       1.4        ad 
    225  1.20.2.1  uebayasi 					tmp2 = (rp[1] & rmask)
    226       1.4        ad 					    | (MBE((u_int)fb << width) & ~rmask);
    227  1.20.2.1  uebayasi 					rp[0] = tmp;
    228  1.20.2.1  uebayasi 					rp[1] = tmp2;
    229       1.4        ad 					fr += fs;
    230       1.4        ad 					DELTA(rp, rs, int32_t *);
    231  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    232  1.20.2.1  uebayasi 						hrp[0] = tmp;
    233  1.20.2.1  uebayasi 						hrp[1] = tmp2;
    234  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    235  1.20.2.1  uebayasi 					}
    236       1.4        ad 				}
    237       1.4        ad 			} else {
    238       1.4        ad 				while (height--) {
    239      1.11        pk 					fb = (fr[3] | (fr[2] << 8) |
    240       1.4        ad 					    (fr[1] << 16) | (fr[0] << 24));
    241       1.4        ad 
    242  1.20.2.1  uebayasi 					tmp = (rp[0] & lmask)
    243       1.4        ad 					    | MBE(fb >> col);
    244       1.4        ad 
    245  1.20.2.1  uebayasi 					tmp2 = (rp[1] & rmask)
    246       1.4        ad 					    | (MBE(fb << width) & ~rmask);
    247  1.20.2.1  uebayasi 					rp[0] = tmp;
    248  1.20.2.1  uebayasi 					rp[1] = tmp2;
    249       1.4        ad 					fr += fs;
    250       1.4        ad 					DELTA(rp, rs, int32_t *);
    251  1.20.2.1  uebayasi 					if (ri->ri_hwbits) {
    252  1.20.2.1  uebayasi 						hrp[0] = tmp;
    253  1.20.2.1  uebayasi 						hrp[1] = tmp2;
    254  1.20.2.1  uebayasi 						DELTA(hrp, rs, int32_t *);
    255  1.20.2.1  uebayasi 					}
    256       1.4        ad 				}
    257       1.4        ad 			}
    258       1.4        ad 		}
    259       1.1        ad 
    260       1.4        ad 		/* Do underline */
    261      1.10        ad 		if ((attr & 1) != 0) {
    262       1.4        ad 			DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    263  1.20.2.1  uebayasi 			tmp = (rp[0] & lmask) | (fg & ~lmask);
    264  1.20.2.1  uebayasi 			tmp2 = (rp[1] & rmask) | (fg & ~rmask);
    265  1.20.2.1  uebayasi 			rp[0] = tmp;
    266  1.20.2.1  uebayasi 			rp[1] = tmp2;
    267  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    268  1.20.2.1  uebayasi 				DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    269  1.20.2.1  uebayasi 				hrp[0] = tmp;
    270  1.20.2.1  uebayasi 				hrp[1] = tmp2;
    271  1.20.2.1  uebayasi 			}
    272       1.4        ad 		}
    273       1.4        ad 	}
    274       1.1        ad }
    275       1.1        ad 
    276      1.10        ad #ifndef RASOPS_SMALL
    277       1.1        ad /*
    278       1.1        ad  * Paint a single character. This is for 8-pixel wide fonts.
    279       1.1        ad  */
    280       1.1        ad static void
    281      1.20       dsl rasops1_putchar8(void *cookie, int row, int col, u_int uc, long attr)
    282       1.1        ad {
    283       1.1        ad 	int height, fs, rs, bg, fg;
    284       1.1        ad 	struct rasops_info *ri;
    285  1.20.2.1  uebayasi 	u_char *fr, *rp, *hrp = NULL;
    286      1.11        pk 
    287       1.1        ad 	ri = (struct rasops_info *)cookie;
    288       1.1        ad 
    289      1.11        pk #ifdef RASOPS_CLIPPING
    290      1.11        pk 	/* Catches 'row < 0' case too */
    291       1.3        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    292       1.1        ad 		return;
    293       1.1        ad 
    294       1.3        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    295       1.1        ad 		return;
    296       1.1        ad #endif
    297       1.1        ad 
    298       1.3        ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    299  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    300  1.20.2.1  uebayasi 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
    301       1.1        ad 	height = ri->ri_font->fontheight;
    302       1.1        ad 	rs = ri->ri_stride;
    303      1.11        pk 
    304       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    305       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    306      1.11        pk 
    307       1.1        ad 	/* If fg and bg match this becomes a space character */
    308       1.1        ad 	if (fg == bg || uc == ' ') {
    309       1.1        ad 		while (height--) {
    310       1.1        ad 			*rp = bg;
    311       1.1        ad 			rp += rs;
    312  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    313  1.20.2.1  uebayasi 				*hrp = bg;
    314  1.20.2.1  uebayasi 				hrp += rs;
    315  1.20.2.1  uebayasi 			}
    316       1.1        ad 		}
    317       1.1        ad 	} else {
    318       1.1        ad 		uc -= ri->ri_font->firstchar;
    319       1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    320       1.1        ad 		fs = ri->ri_font->stride;
    321      1.11        pk 
    322       1.1        ad 		/* NOT fontbits if bg is white */
    323       1.1        ad 		if (bg) {
    324       1.1        ad 			while (height--) {
    325       1.1        ad 				*rp = ~*fr;
    326       1.1        ad 				rp += rs;
    327  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    328  1.20.2.1  uebayasi 					*hrp = ~*fr;
    329  1.20.2.1  uebayasi 					hrp += rs;
    330  1.20.2.1  uebayasi 				}
    331  1.20.2.1  uebayasi 				fr += fs;
    332  1.20.2.1  uebayasi 
    333       1.1        ad 			}
    334       1.1        ad 		} else {
    335       1.1        ad 			while (height--) {
    336       1.1        ad 				*rp = *fr;
    337       1.1        ad 				rp += rs;
    338  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    339  1.20.2.1  uebayasi 					*hrp = *fr;
    340  1.20.2.1  uebayasi 					hrp += rs;
    341  1.20.2.1  uebayasi 				}
    342  1.20.2.1  uebayasi 				fr += fs;
    343       1.1        ad 			}
    344       1.1        ad 		}
    345       1.4        ad 
    346       1.1        ad 	}
    347       1.1        ad 
    348       1.1        ad 	/* Do underline */
    349  1.20.2.1  uebayasi 	if ((attr & 1) != 0) {
    350       1.1        ad 		rp[-(ri->ri_stride << 1)] = fg;
    351  1.20.2.1  uebayasi 		if (ri->ri_hwbits) {
    352  1.20.2.1  uebayasi 			hrp[-(ri->ri_stride << 1)] = fg;
    353  1.20.2.1  uebayasi 		}
    354  1.20.2.1  uebayasi 	}
    355       1.1        ad }
    356       1.1        ad 
    357       1.1        ad /*
    358       1.1        ad  * Paint a single character. This is for 16-pixel wide fonts.
    359       1.1        ad  */
    360       1.1        ad static void
    361      1.20       dsl rasops1_putchar16(void *cookie, int row, int col, u_int uc, long attr)
    362       1.1        ad {
    363       1.1        ad 	int height, fs, rs, bg, fg;
    364       1.1        ad 	struct rasops_info *ri;
    365  1.20.2.1  uebayasi 	u_char *fr, *rp, *hrp = NULL;
    366      1.11        pk 
    367       1.1        ad 	ri = (struct rasops_info *)cookie;
    368       1.1        ad 
    369      1.11        pk #ifdef RASOPS_CLIPPING
    370      1.11        pk 	/* Catches 'row < 0' case too */
    371       1.3        ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    372       1.1        ad 		return;
    373       1.1        ad 
    374       1.3        ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    375       1.1        ad 		return;
    376       1.1        ad #endif
    377       1.1        ad 
    378       1.3        ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    379  1.20.2.1  uebayasi 	if (ri->ri_hwbits)
    380  1.20.2.1  uebayasi 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col * ri->ri_xscale;
    381       1.1        ad 	height = ri->ri_font->fontheight;
    382       1.1        ad 	rs = ri->ri_stride;
    383      1.11        pk 
    384       1.9        ad 	bg = (attr & 0x000f0000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    385       1.9        ad 	fg = (attr & 0x0f000000) ? ri->ri_devcmap[1] : ri->ri_devcmap[0];
    386       1.9        ad 
    387       1.1        ad 	/* If fg and bg match this becomes a space character */
    388       1.1        ad 	if (fg == bg || uc == ' ') {
    389       1.1        ad 		while (height--) {
    390  1.20.2.1  uebayasi 			/* XXX alignment?! */
    391       1.1        ad 			*(int16_t *)rp = bg;
    392       1.1        ad 			rp += rs;
    393  1.20.2.1  uebayasi 			if (ri->ri_hwbits) {
    394  1.20.2.1  uebayasi 				*(int16_t *)hrp = bg;
    395  1.20.2.1  uebayasi 				hrp += rs;
    396  1.20.2.1  uebayasi 			}
    397       1.1        ad 		}
    398       1.1        ad 	} else {
    399       1.1        ad 		uc -= ri->ri_font->firstchar;
    400       1.1        ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    401       1.1        ad 		fs = ri->ri_font->stride;
    402      1.11        pk 
    403       1.1        ad 		/* NOT fontbits if bg is white */
    404       1.1        ad 		if (bg) {
    405       1.1        ad 			while (height--) {
    406       1.1        ad 				rp[0] = ~fr[0];
    407       1.1        ad 				rp[1] = ~fr[1];
    408       1.1        ad 				rp += rs;
    409  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    410  1.20.2.1  uebayasi 					hrp[0] = ~fr[0];
    411  1.20.2.1  uebayasi 					hrp[1] = ~fr[1];
    412  1.20.2.1  uebayasi 					hrp += rs;
    413  1.20.2.1  uebayasi 				}
    414  1.20.2.1  uebayasi 				fr += fs;
    415       1.1        ad 			}
    416       1.1        ad 		} else {
    417       1.1        ad 			while (height--) {
    418       1.1        ad 				rp[0] = fr[0];
    419       1.1        ad 				rp[1] = fr[1];
    420       1.1        ad 				rp += rs;
    421  1.20.2.1  uebayasi 				if (ri->ri_hwbits) {
    422  1.20.2.1  uebayasi 					hrp[0] = fr[0];
    423  1.20.2.1  uebayasi 					hrp[1] = fr[1];
    424  1.20.2.1  uebayasi 					hrp += rs;
    425  1.20.2.1  uebayasi 				}
    426  1.20.2.1  uebayasi 				fr += fs;
    427       1.1        ad 			}
    428       1.1        ad 		}
    429       1.1        ad 	}
    430       1.1        ad 
    431       1.1        ad 	/* Do underline */
    432      1.10        ad 	if ((attr & 1) != 0)
    433  1.20.2.1  uebayasi 		/* XXX alignment?! */
    434       1.1        ad 		*(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
    435  1.20.2.1  uebayasi 		if (ri->ri_hwbits)
    436  1.20.2.1  uebayasi 			*(int16_t *)(hrp - (ri->ri_stride << 1)) = fg;
    437       1.1        ad }
    438      1.10        ad #endif	/* !RASOPS_SMALL */
    439       1.1        ad 
    440       1.1        ad /*
    441       1.4        ad  * Grab routines common to depths where (bpp < 8)
    442       1.1        ad  */
    443       1.4        ad #define NAME(ident)	rasops1_##ident
    444       1.4        ad #define PIXEL_SHIFT	0
    445       1.1        ad 
    446       1.4        ad #include <dev/rasops/rasops_bitops.h>
    447