Home | History | Annotate | Line # | Download | only in rasops
rasops8.c revision 1.20.6.1
      1  1.20.6.1  simonb /* 	$NetBSD: rasops8.c,v 1.20.6.1 2006/04/22 11:39:28 simonb Exp $	*/
      2       1.1      ad 
      3       1.4      ad /*-
      4       1.4      ad  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5       1.1      ad  * All rights reserved.
      6       1.1      ad  *
      7       1.4      ad  * This code is derived from software contributed to The NetBSD Foundation
      8       1.9      ad  * by Andrew Doran.
      9       1.4      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.4      ad  * 3. All advertising materials mentioning features or use of this software
     19       1.4      ad  *    must display the following acknowledgement:
     20       1.4      ad  *	This product includes software developed by the NetBSD
     21       1.4      ad  *	Foundation, Inc. and its contributors.
     22       1.4      ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.4      ad  *    contributors may be used to endorse or promote products derived
     24       1.4      ad  *    from this software without specific prior written permission.
     25       1.1      ad  *
     26       1.4      ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.4      ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.4      ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.4      ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.4      ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.4      ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.4      ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.4      ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.4      ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.4      ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.4      ad  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1      ad  */
     38       1.2      ad 
     39      1.12   lukem #include <sys/cdefs.h>
     40  1.20.6.1  simonb __KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.20.6.1 2006/04/22 11:39:28 simonb Exp $");
     41      1.12   lukem 
     42       1.1      ad #include "opt_rasops.h"
     43       1.1      ad 
     44       1.1      ad #include <sys/param.h>
     45       1.1      ad #include <sys/systm.h>
     46       1.1      ad #include <sys/time.h>
     47       1.1      ad 
     48       1.1      ad #include <dev/wscons/wsdisplayvar.h>
     49       1.1      ad #include <dev/wscons/wsconsio.h>
     50       1.1      ad #include <dev/rasops/rasops.h>
     51       1.1      ad 
     52      1.18   perry static void 	rasops8_putchar(void *, int, int, u_int, long attr);
     53       1.7      ad #ifndef RASOPS_SMALL
     54      1.18   perry static void 	rasops8_putchar8(void *, int, int, u_int, long attr);
     55      1.18   perry static void 	rasops8_putchar12(void *, int, int, u_int, long attr);
     56      1.18   perry static void 	rasops8_putchar16(void *, int, int, u_int, long attr);
     57      1.18   perry static void	rasops8_makestamp(struct rasops_info *ri, long);
     58       1.1      ad 
     59       1.8      pk /*
     60       1.8      pk  * 4x1 stamp for optimized character blitting
     61       1.1      ad  */
     62       1.1      ad static int32_t	stamp[16];
     63       1.1      ad static long	stamp_attr;
     64       1.1      ad static int	stamp_mutex;	/* XXX see note in README */
     65      1.10   bjh21 #endif
     66       1.1      ad 
     67       1.1      ad /*
     68       1.1      ad  * XXX this confuses the hell out of gcc2 (not egcs) which always insists
     69       1.1      ad  * that the shift count is negative.
     70       1.1      ad  *
     71       1.1      ad  * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
     72       1.1      ad  * destination = STAMP_READ(offset)
     73       1.1      ad  */
     74       1.1      ad #define STAMP_SHIFT(fb,n)	((n*4-2) >= 0 ? (fb)>>(n*4-2):(fb)<<-(n*4-2))
     75       1.8      pk #define STAMP_MASK		(0xf << 2)
     76       1.1      ad #define STAMP_READ(o)		(*(int32_t *)((caddr_t)stamp + (o)))
     77       1.1      ad 
     78       1.1      ad /*
     79      1.11     wiz  * Initialize a 'rasops_info' descriptor for this depth.
     80       1.1      ad  */
     81       1.1      ad void
     82       1.1      ad rasops8_init(ri)
     83       1.1      ad 	struct rasops_info *ri;
     84       1.1      ad {
     85       1.8      pk 
     86       1.1      ad 	switch (ri->ri_font->fontwidth) {
     87       1.7      ad #ifndef RASOPS_SMALL
     88       1.1      ad 	case 8:
     89       1.1      ad 		ri->ri_ops.putchar = rasops8_putchar8;
     90       1.1      ad 		break;
     91       1.1      ad 	case 12:
     92       1.1      ad 		ri->ri_ops.putchar = rasops8_putchar12;
     93       1.1      ad 		break;
     94       1.1      ad 	case 16:
     95       1.1      ad 		ri->ri_ops.putchar = rasops8_putchar16;
     96       1.1      ad 		break;
     97       1.7      ad #endif /* !RASOPS_SMALL */
     98       1.1      ad 	default:
     99       1.1      ad 		ri->ri_ops.putchar = rasops8_putchar;
    100       1.1      ad 		break;
    101       1.1      ad 	}
    102       1.1      ad }
    103       1.1      ad 
    104       1.1      ad /*
    105       1.3      ad  * Put a single character.
    106       1.1      ad  */
    107       1.1      ad static void
    108       1.1      ad rasops8_putchar(cookie, row, col, uc, attr)
    109       1.1      ad 	void *cookie;
    110       1.1      ad 	int row, col;
    111       1.1      ad 	u_int uc;
    112       1.1      ad 	long attr;
    113       1.1      ad {
    114       1.7      ad 	int width, height, cnt, fs, fb;
    115  1.20.6.1  simonb 	u_char *dp, *rp, *hp, *hrp, *fr, clr[2];
    116       1.1      ad 	struct rasops_info *ri;
    117       1.8      pk 
    118       1.1      ad 	ri = (struct rasops_info *)cookie;
    119  1.20.6.1  simonb 	hp = hrp = NULL;
    120       1.1      ad 
    121      1.17  petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    122      1.17  petrov 		return;
    123      1.17  petrov 
    124       1.8      pk #ifdef RASOPS_CLIPPING
    125       1.8      pk 	/* Catches 'row < 0' case too */
    126       1.1      ad 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    127       1.1      ad 		return;
    128       1.1      ad 
    129       1.1      ad 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    130       1.1      ad 		return;
    131       1.1      ad #endif
    132       1.1      ad 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    133  1.20.6.1  simonb 	if (ri->ri_hwbits)
    134  1.20.6.1  simonb 		hrp = ri->ri_hwbits + row * ri->ri_yscale + col *
    135  1.20.6.1  simonb 		    ri->ri_xscale;
    136       1.1      ad 
    137       1.1      ad 	height = ri->ri_font->fontheight;
    138       1.1      ad 	width = ri->ri_font->fontwidth;
    139       1.8      pk 	clr[0] = (u_char)ri->ri_devcmap[(attr >> 16) & 0xf];
    140       1.8      pk 	clr[1] = (u_char)ri->ri_devcmap[(attr >> 24) & 0xf];
    141       1.8      pk 
    142       1.1      ad 	if (uc == ' ') {
    143       1.8      pk 		u_char c = clr[0];
    144       1.8      pk 
    145       1.1      ad 		while (height--) {
    146       1.1      ad 			dp = rp;
    147       1.1      ad 			rp += ri->ri_stride;
    148  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    149  1.20.6.1  simonb 				hp = hrp;
    150  1.20.6.1  simonb 				hrp += ri->ri_stride;
    151  1.20.6.1  simonb 			}
    152       1.8      pk 
    153  1.20.6.1  simonb 			for (cnt = width; cnt; cnt--) {
    154       1.8      pk 				*dp++ = c;
    155  1.20.6.1  simonb 				if (ri->ri_hwbits)
    156  1.20.6.1  simonb 					*hp++ = c;
    157  1.20.6.1  simonb 			}
    158       1.1      ad 		}
    159       1.1      ad 	} else {
    160       1.1      ad 		uc -= ri->ri_font->firstchar;
    161       1.1      ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    162       1.1      ad 		fs = ri->ri_font->stride;
    163       1.1      ad 
    164       1.1      ad 		while (height--) {
    165       1.1      ad 			dp = rp;
    166  1.20.6.1  simonb 			if (ri->ri_hwbits)
    167  1.20.6.1  simonb 				hp = hrp;
    168       1.1      ad 			fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) | (fr[0] << 24);
    169       1.1      ad 			fr += fs;
    170       1.1      ad 			rp += ri->ri_stride;
    171  1.20.6.1  simonb 			if (ri->ri_hwbits)
    172  1.20.6.1  simonb 				hrp += ri->ri_stride;
    173       1.8      pk 
    174       1.1      ad 			for (cnt = width; cnt; cnt--) {
    175       1.1      ad 				*dp++ = clr[(fb >> 31) & 1];
    176  1.20.6.1  simonb 				if (ri->ri_hwbits)
    177  1.20.6.1  simonb 					*hp++ = clr[(fb >> 31) & 1];
    178       1.1      ad 				fb <<= 1;
    179       1.1      ad 			}
    180       1.1      ad 		}
    181       1.8      pk 	}
    182       1.1      ad 
    183       1.1      ad 	/* Do underline */
    184       1.7      ad 	if ((attr & 1) != 0) {
    185       1.8      pk 		u_char c = clr[1];
    186       1.8      pk 
    187       1.1      ad 		rp -= (ri->ri_stride << 1);
    188  1.20.6.1  simonb 		if (ri->ri_hwbits)
    189  1.20.6.1  simonb 			hrp -= (ri->ri_stride << 1);
    190       1.1      ad 
    191  1.20.6.1  simonb 		while (width--) {
    192       1.8      pk 			*rp++ = c;
    193  1.20.6.1  simonb 			if (ri->ri_hwbits)
    194  1.20.6.1  simonb 				*hrp++ = c;
    195  1.20.6.1  simonb 		}
    196       1.8      pk 	}
    197       1.1      ad }
    198       1.1      ad 
    199       1.7      ad #ifndef RASOPS_SMALL
    200       1.1      ad /*
    201       1.1      ad  * Recompute the 4x1 blitting stamp.
    202       1.1      ad  */
    203       1.1      ad static void
    204       1.6      ad rasops8_makestamp(ri, attr)
    205       1.6      ad 	struct rasops_info *ri;
    206       1.3      ad 	long attr;
    207       1.1      ad {
    208       1.7      ad 	int32_t fg, bg;
    209       1.1      ad 	int i;
    210       1.5      ad 
    211       1.8      pk 	fg = ri->ri_devcmap[(attr >> 24) & 0xf] & 0xff;
    212       1.8      pk 	bg = ri->ri_devcmap[(attr >> 16) & 0xf] & 0xff;
    213       1.1      ad 	stamp_attr = attr;
    214       1.8      pk 
    215       1.1      ad 	for (i = 0; i < 16; i++) {
    216      1.16     uwe #if BYTE_ORDER == BIG_ENDIAN
    217      1.16     uwe #define NEED_LITTLE_ENDIAN_STAMP RI_BSWAP
    218       1.1      ad #else
    219      1.16     uwe #define NEED_LITTLE_ENDIAN_STAMP 0
    220       1.1      ad #endif
    221      1.16     uwe 		if ((ri->ri_flg & RI_BSWAP) == NEED_LITTLE_ENDIAN_STAMP) {
    222      1.16     uwe 			/* little endian */
    223      1.16     uwe 			stamp[i] = (i & 8 ? fg : bg);
    224      1.16     uwe 			stamp[i] |= ((i & 4 ? fg : bg) << 8);
    225      1.16     uwe 			stamp[i] |= ((i & 2 ? fg : bg) << 16);
    226      1.16     uwe 			stamp[i] |= ((i & 1 ? fg : bg) << 24);
    227      1.16     uwe 		} else {
    228      1.16     uwe 			/* big endian */
    229      1.16     uwe 			stamp[i] = (i & 1 ? fg : bg);
    230      1.16     uwe 			stamp[i] |= ((i & 2 ? fg : bg) << 8);
    231      1.16     uwe 			stamp[i] |= ((i & 4 ? fg : bg) << 16);
    232      1.16     uwe 			stamp[i] |= ((i & 8 ? fg : bg) << 24);
    233      1.16     uwe 		}
    234       1.1      ad 	}
    235       1.1      ad }
    236       1.1      ad 
    237       1.1      ad /*
    238       1.3      ad  * Put a single character. This is for 8-pixel wide fonts.
    239       1.1      ad  */
    240       1.1      ad static void
    241       1.1      ad rasops8_putchar8(cookie, row, col, uc, attr)
    242       1.1      ad 	void *cookie;
    243       1.1      ad 	int row, col;
    244       1.1      ad 	u_int uc;
    245       1.1      ad 	long attr;
    246       1.1      ad {
    247       1.1      ad 	struct rasops_info *ri;
    248       1.1      ad 	int height, fs;
    249  1.20.6.1  simonb 	int32_t *rp, *hp;
    250       1.1      ad 	u_char *fr;
    251       1.8      pk 
    252       1.1      ad 	/* Can't risk remaking the stamp if it's already in use */
    253       1.1      ad 	if (stamp_mutex++) {
    254       1.1      ad 		stamp_mutex--;
    255       1.1      ad 		rasops8_putchar(cookie, row, col, uc, attr);
    256       1.1      ad 		return;
    257       1.1      ad 	}
    258       1.1      ad 
    259       1.1      ad 	ri = (struct rasops_info *)cookie;
    260  1.20.6.1  simonb 	hp = NULL;
    261       1.1      ad 
    262      1.17  petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    263      1.17  petrov 		return;
    264      1.17  petrov 
    265       1.8      pk #ifdef RASOPS_CLIPPING
    266       1.1      ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    267       1.1      ad 		stamp_mutex--;
    268       1.1      ad 		return;
    269       1.1      ad 	}
    270       1.1      ad 
    271       1.1      ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    272       1.1      ad 		stamp_mutex--;
    273       1.1      ad 		return;
    274       1.1      ad 	}
    275       1.1      ad #endif
    276       1.1      ad 
    277       1.1      ad 	/* Recompute stamp? */
    278       1.1      ad 	if (attr != stamp_attr)
    279       1.6      ad 		rasops8_makestamp(ri, attr);
    280       1.8      pk 
    281       1.1      ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    282  1.20.6.1  simonb 	if (ri->ri_hwbits)
    283  1.20.6.1  simonb 		hp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    284  1.20.6.1  simonb 		    col*ri->ri_xscale);
    285       1.1      ad 	height = ri->ri_font->fontheight;
    286       1.8      pk 
    287       1.1      ad 	if (uc == ' ') {
    288       1.1      ad 		while (height--) {
    289       1.8      pk 			rp[0] = rp[1] = stamp[0];
    290       1.1      ad 			DELTA(rp, ri->ri_stride, int32_t *);
    291  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    292  1.20.6.1  simonb 				hp[0] = hp[1] = stamp[0];
    293  1.20.6.1  simonb 				DELTA(hp, ri->ri_stride, int32_t *);
    294  1.20.6.1  simonb 			}
    295       1.8      pk 		}
    296       1.1      ad 	} else {
    297       1.1      ad 		uc -= ri->ri_font->firstchar;
    298       1.1      ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    299       1.1      ad 		fs = ri->ri_font->stride;
    300       1.8      pk 
    301       1.1      ad 		while (height--) {
    302       1.1      ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    303       1.1      ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    304  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    305  1.20.6.1  simonb 				hp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) &
    306  1.20.6.1  simonb 				    STAMP_MASK);
    307  1.20.6.1  simonb 				hp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) &
    308  1.20.6.1  simonb 				    STAMP_MASK);
    309  1.20.6.1  simonb 			}
    310       1.1      ad 
    311       1.1      ad 			fr += fs;
    312       1.8      pk 			DELTA(rp, ri->ri_stride, int32_t *);
    313  1.20.6.1  simonb 			if (ri->ri_hwbits)
    314  1.20.6.1  simonb 				DELTA(hp, ri->ri_stride, int32_t *);
    315       1.1      ad 		}
    316       1.1      ad 	}
    317       1.1      ad 
    318       1.1      ad 	/* Do underline */
    319       1.7      ad 	if ((attr & 1) != 0) {
    320       1.8      pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    321       1.8      pk 		rp[0] = rp[1] = stamp[15];
    322  1.20.6.1  simonb 		if (ri->ri_hwbits) {
    323  1.20.6.1  simonb 			DELTA(hp, -(ri->ri_stride << 1), int32_t *);
    324  1.20.6.1  simonb 			hp[0] = hp[1] = stamp[15];
    325  1.20.6.1  simonb 		}
    326       1.8      pk 	}
    327       1.8      pk 
    328       1.8      pk 	stamp_mutex--;
    329       1.1      ad }
    330       1.1      ad 
    331       1.1      ad /*
    332       1.3      ad  * Put a single character. This is for 12-pixel wide fonts.
    333       1.1      ad  */
    334       1.1      ad static void
    335       1.1      ad rasops8_putchar12(cookie, row, col, uc, attr)
    336       1.1      ad 	void *cookie;
    337       1.1      ad 	int row, col;
    338       1.1      ad 	u_int uc;
    339       1.1      ad 	long attr;
    340       1.1      ad {
    341       1.1      ad 	struct rasops_info *ri;
    342       1.1      ad 	int height, fs;
    343  1.20.6.1  simonb 	int32_t *rp,  *hrp;
    344       1.1      ad 	u_char *fr;
    345       1.8      pk 
    346       1.1      ad 	/* Can't risk remaking the stamp if it's already in use */
    347       1.1      ad 	if (stamp_mutex++) {
    348       1.1      ad 		stamp_mutex--;
    349       1.1      ad 		rasops8_putchar(cookie, row, col, uc, attr);
    350       1.1      ad 		return;
    351       1.1      ad 	}
    352       1.1      ad 
    353       1.1      ad 	ri = (struct rasops_info *)cookie;
    354  1.20.6.1  simonb 	hrp = NULL;
    355       1.1      ad 
    356      1.17  petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    357      1.17  petrov 	    return;
    358      1.17  petrov 
    359       1.8      pk #ifdef RASOPS_CLIPPING
    360       1.1      ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    361       1.1      ad 		stamp_mutex--;
    362       1.1      ad 		return;
    363       1.1      ad 	}
    364       1.1      ad 
    365       1.1      ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    366       1.1      ad 		stamp_mutex--;
    367       1.1      ad 		return;
    368       1.1      ad 	}
    369       1.1      ad #endif
    370       1.1      ad 
    371       1.1      ad 	/* Recompute stamp? */
    372       1.1      ad 	if (attr != stamp_attr)
    373       1.6      ad 		rasops8_makestamp(ri, attr);
    374       1.8      pk 
    375       1.1      ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    376  1.20.6.1  simonb 	if (ri->ri_hwbits)
    377  1.20.6.1  simonb 		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    378  1.20.6.1  simonb 		    col*ri->ri_xscale);
    379       1.1      ad 	height = ri->ri_font->fontheight;
    380       1.8      pk 
    381       1.1      ad 	if (uc == ' ') {
    382       1.1      ad 		while (height--) {
    383       1.8      pk 			int32_t c = stamp[0];
    384       1.8      pk 
    385       1.8      pk 			rp[0] = rp[1] = rp[2] = c;
    386       1.8      pk 			DELTA(rp, ri->ri_stride, int32_t *);
    387  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    388  1.20.6.1  simonb 				hrp[0] = hrp[1] = hrp[2] = c;
    389  1.20.6.1  simonb 				DELTA(hrp, ri->ri_stride, int32_t *);
    390  1.20.6.1  simonb 			}
    391       1.8      pk 		}
    392       1.1      ad 	} else {
    393       1.1      ad 		uc -= ri->ri_font->firstchar;
    394       1.1      ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    395       1.1      ad 		fs = ri->ri_font->stride;
    396       1.8      pk 
    397       1.1      ad 		while (height--) {
    398       1.1      ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    399       1.1      ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    400       1.1      ad 			rp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    401  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    402  1.20.6.1  simonb 				hrp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    403  1.20.6.1  simonb 				hrp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    404  1.20.6.1  simonb 				hrp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    405  1.20.6.1  simonb 			}
    406       1.8      pk 
    407       1.1      ad 			fr += fs;
    408       1.8      pk 			DELTA(rp, ri->ri_stride, int32_t *);
    409  1.20.6.1  simonb 			if (ri->ri_hwbits)
    410  1.20.6.1  simonb 				DELTA(hrp, ri->ri_stride, int32_t *);
    411       1.1      ad 		}
    412       1.8      pk 	}
    413       1.1      ad 
    414       1.1      ad 	/* Do underline */
    415       1.7      ad 	if ((attr & 1) != 0) {
    416       1.8      pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    417       1.8      pk 		rp[0] = rp[1] = rp[2] = stamp[15];
    418  1.20.6.1  simonb 		if (ri->ri_hwbits) {
    419  1.20.6.1  simonb 			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    420  1.20.6.1  simonb 			hrp[0] = hrp[1] = hrp[2] = stamp[15];
    421  1.20.6.1  simonb 		}
    422       1.8      pk 	}
    423       1.8      pk 
    424       1.1      ad 	stamp_mutex--;
    425       1.1      ad }
    426       1.1      ad 
    427       1.1      ad /*
    428       1.3      ad  * Put a single character. This is for 16-pixel wide fonts.
    429       1.1      ad  */
    430       1.1      ad static void
    431       1.1      ad rasops8_putchar16(cookie, row, col, uc, attr)
    432       1.1      ad 	void *cookie;
    433       1.1      ad 	int row, col;
    434       1.1      ad 	u_int uc;
    435       1.1      ad 	long attr;
    436       1.1      ad {
    437       1.1      ad 	struct rasops_info *ri;
    438       1.1      ad 	int height, fs;
    439  1.20.6.1  simonb 	int32_t *rp, *hrp;
    440       1.1      ad 	u_char *fr;
    441       1.1      ad 
    442       1.1      ad 	/* Can't risk remaking the stamp if it's already in use */
    443       1.1      ad 	if (stamp_mutex++) {
    444       1.1      ad 		stamp_mutex--;
    445       1.1      ad 		rasops8_putchar(cookie, row, col, uc, attr);
    446       1.1      ad 		return;
    447       1.1      ad 	}
    448       1.1      ad 
    449       1.1      ad 	ri = (struct rasops_info *)cookie;
    450  1.20.6.1  simonb 	hrp = NULL;
    451       1.1      ad 
    452      1.17  petrov 	if (!CHAR_IN_FONT(uc, ri->ri_font))
    453      1.17  petrov 		return;
    454      1.17  petrov 
    455       1.8      pk #ifdef RASOPS_CLIPPING
    456       1.1      ad 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    457       1.1      ad 		stamp_mutex--;
    458       1.1      ad 		return;
    459       1.1      ad 	}
    460       1.1      ad 
    461       1.1      ad 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    462       1.1      ad 		stamp_mutex--;
    463       1.1      ad 		return;
    464       1.1      ad 	}
    465       1.1      ad #endif
    466       1.1      ad 
    467       1.1      ad 	/* Recompute stamp? */
    468       1.1      ad 	if (attr != stamp_attr)
    469       1.6      ad 		rasops8_makestamp(ri, attr);
    470       1.8      pk 
    471       1.1      ad 	rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    472  1.20.6.1  simonb 	if (ri->ri_hwbits)
    473  1.20.6.1  simonb 		hrp = (int32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    474  1.20.6.1  simonb 		    col*ri->ri_xscale);
    475  1.20.6.1  simonb 
    476       1.1      ad 	height = ri->ri_font->fontheight;
    477       1.8      pk 
    478       1.1      ad 	if (uc == ' ') {
    479  1.20.6.1  simonb 		while (height--) {
    480       1.8      pk 			rp[0] = rp[1] = rp[2] = rp[3] = stamp[0];
    481  1.20.6.1  simonb 			if (ri->ri_hwbits)
    482  1.20.6.1  simonb 				hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[0];
    483  1.20.6.1  simonb 		}
    484       1.1      ad 	} else {
    485       1.1      ad 		uc -= ri->ri_font->firstchar;
    486       1.1      ad 		fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
    487       1.1      ad 		fs = ri->ri_font->stride;
    488       1.8      pk 
    489       1.1      ad 		while (height--) {
    490       1.1      ad 			rp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    491       1.1      ad 			rp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    492       1.1      ad 			rp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    493       1.1      ad 			rp[3] = STAMP_READ(STAMP_SHIFT(fr[1], 0) & STAMP_MASK);
    494  1.20.6.1  simonb 			if (ri->ri_hwbits) {
    495  1.20.6.1  simonb 				hrp[0] = STAMP_READ(STAMP_SHIFT(fr[0], 1) & STAMP_MASK);
    496  1.20.6.1  simonb 				hrp[1] = STAMP_READ(STAMP_SHIFT(fr[0], 0) & STAMP_MASK);
    497  1.20.6.1  simonb 				hrp[2] = STAMP_READ(STAMP_SHIFT(fr[1], 1) & STAMP_MASK);
    498  1.20.6.1  simonb 				hrp[3] = STAMP_READ(STAMP_SHIFT(fr[1], 0) & STAMP_MASK);
    499  1.20.6.1  simonb 			}
    500       1.1      ad 
    501       1.1      ad 			fr += fs;
    502       1.8      pk 			DELTA(rp, ri->ri_stride, int32_t *);
    503  1.20.6.1  simonb 			if (ri->ri_hwbits)
    504  1.20.6.1  simonb 				DELTA(hrp, ri->ri_stride, int32_t *);
    505       1.1      ad 		}
    506       1.8      pk 	}
    507       1.1      ad 
    508       1.1      ad 	/* Do underline */
    509       1.7      ad 	if ((attr & 1) != 0) {
    510       1.8      pk 		DELTA(rp, -(ri->ri_stride << 1), int32_t *);
    511       1.8      pk 		rp[0] = rp[1] = rp[2] = rp[3] = stamp[15];
    512  1.20.6.1  simonb 		if (ri->ri_hwbits) {
    513  1.20.6.1  simonb 			DELTA(hrp, -(ri->ri_stride << 1), int32_t *);
    514  1.20.6.1  simonb 			hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[15];
    515  1.20.6.1  simonb 		}
    516       1.8      pk 	}
    517       1.8      pk 
    518       1.1      ad 	stamp_mutex--;
    519       1.1      ad }
    520       1.7      ad #endif /* !RASOPS_SMALL */
    521