Home | History | Annotate | Line # | Download | only in rasops
rasops15.c revision 1.26
      1 /* 	$NetBSD: rasops15.c,v 1.26 2019/07/25 02:26:32 rin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Andrew Doran.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include <sys/cdefs.h>
     33 __KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.26 2019/07/25 02:26:32 rin Exp $");
     34 
     35 #include "opt_rasops.h"
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/time.h>
     40 
     41 #include <dev/wscons/wsdisplayvar.h>
     42 #include <dev/wscons/wsconsio.h>
     43 #include <dev/rasops/rasops.h>
     44 
     45 static void 	rasops15_putchar(void *, int, int, u_int, long attr);
     46 static void 	rasops15_putchar_aa(void *, int, int, u_int, long attr);
     47 #ifndef RASOPS_SMALL
     48 static void 	rasops15_putchar8(void *, int, int, u_int, long attr);
     49 static void 	rasops15_putchar12(void *, int, int, u_int, long attr);
     50 static void 	rasops15_putchar16(void *, int, int, u_int, long attr);
     51 static void	rasops15_makestamp(struct rasops_info *, long);
     52 #endif
     53 
     54 #ifndef RASOPS_SMALL
     55 /*
     56  * (2x2)x1 stamp for optimized character blitting
     57  */
     58 static uint32_t	stamp[32];
     59 static long	stamp_attr;
     60 static int	stamp_mutex;	/* XXX see note in readme */
     61 
     62 /*
     63  * XXX this confuses the hell out of gcc2 (not egcs) which always insists
     64  * that the shift count is negative.
     65  *
     66  * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
     67  * destination uint32_t[0] = STAMP_READ(offset)
     68  * destination uint32_t[1] = STAMP_READ(offset + 4)
     69  */
     70 #define STAMP_SHIFT(fb,n)	((n*4-3) >= 0 ? (fb)>>(n*4-3):(fb)<<-(n*4-3))
     71 #define STAMP_MASK		(15 << 3)
     72 #define STAMP_READ(o)		(*(uint32_t *)((char *)stamp + (o)))
     73 #endif
     74 
     75 /*
     76  * Initialize rasops_info struct for this colordepth.
     77  */
     78 void
     79 rasops15_init(struct rasops_info *ri)
     80 {
     81 
     82 	if (FONT_IS_ALPHA(ri->ri_font)) {
     83 		ri->ri_ops.putchar = rasops15_putchar_aa;
     84 	} else {
     85 		switch (ri->ri_font->fontwidth) {
     86 #ifndef RASOPS_SMALL
     87 		case 8:
     88 			ri->ri_ops.putchar = rasops15_putchar8;
     89 			break;
     90 
     91 		case 12:
     92 			ri->ri_ops.putchar = rasops15_putchar12;
     93 			break;
     94 
     95 		case 16:
     96 			ri->ri_ops.putchar = rasops15_putchar16;
     97 			break;
     98 #endif	/* !RASOPS_SMALL */
     99 		default:
    100 			ri->ri_ops.putchar = rasops15_putchar;
    101 			break;
    102 		}
    103 	}
    104 
    105 	if (ri->ri_rnum == 0) {
    106 		ri->ri_rnum = 5;
    107 		ri->ri_rpos = 10 + (ri->ri_depth == 16);
    108 		ri->ri_gnum = 5 + (ri->ri_depth == 16);
    109 		ri->ri_gpos = 5;
    110 		ri->ri_bnum = 5;
    111 		ri->ri_bpos = 0;
    112 	}
    113 }
    114 
    115 /*
    116  * Paint a single character.
    117  */
    118 static void
    119 rasops15_putchar(void *cookie, int row, int col, u_int uc, long attr)
    120 {
    121 	int fb, width, height, cnt, clr[2];
    122 	struct rasops_info *ri = (struct rasops_info *)cookie;
    123 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    124 	uint8_t *dp, *rp, *hp, *hrp, *fr;
    125 
    126 	hp = hrp = NULL;
    127 
    128 #ifdef RASOPS_CLIPPING
    129 	/* Catches 'row < 0' case too */
    130 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    131 		return;
    132 
    133 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    134 		return;
    135 #endif
    136 
    137 	rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
    138 	if (ri->ri_hwbits)
    139 		hrp = ri->ri_hwbits + row * ri->ri_yscale +
    140 		    col * ri->ri_xscale;
    141 	height = font->fontheight;
    142 	width = font->fontwidth;
    143 
    144 	clr[1] = ri->ri_devcmap[((u_int)attr >> 24) & 0xf];
    145 	clr[0] = ri->ri_devcmap[((u_int)attr >> 16) & 0xf];
    146 
    147 	if (uc == ' ') {
    148 		uint16_t c = (uint16_t)clr[0];
    149 		while (height--) {
    150 			dp = rp;
    151 			rp += ri->ri_stride;
    152 			if (ri->ri_hwbits) {
    153 				hp = hrp;
    154 				hrp += ri->ri_stride;
    155 			}
    156 
    157 			for (cnt = width; cnt; cnt--) {
    158 				*(uint16_t *)dp = c;
    159 				dp += 2;
    160 				if (ri->ri_hwbits) {
    161 					*(uint16_t *)hp = c;
    162 					hp += 2;
    163 				}
    164 			}
    165 		}
    166 	} else {
    167 		uc -= font->firstchar;
    168 		fr = (uint8_t *)font->data + uc * ri->ri_fontscale;
    169 
    170 		while (height--) {
    171 			dp = rp;
    172 			fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
    173 			    (fr[0] << 24);
    174 			fr += font->stride;
    175 			rp += ri->ri_stride;
    176 			if (ri->ri_hwbits) {
    177 				hp = hrp;
    178 				hrp += ri->ri_stride;
    179 			}
    180 
    181 			for (cnt = width; cnt; cnt--) {
    182 				*(uint16_t *)dp = (uint16_t)clr[(fb >> 31) & 1];
    183 				if (ri->ri_hwbits)
    184 					*(uint16_t *)hp =
    185 					    (uint16_t)clr[(fb >> 31) & 1];
    186 				fb <<= 1;
    187 				dp += 2;
    188 				if (ri->ri_hwbits)
    189 					hp += 2;
    190 			}
    191 		}
    192 	}
    193 
    194 	/* Do underline */
    195 	if ((attr & WSATTR_UNDERLINE) != 0) {
    196 		uint16_t c = (uint16_t)clr[1];
    197 		rp -= ri->ri_stride << 1;
    198 		if (ri->ri_hwbits)
    199 			hrp -= ri->ri_stride << 1;
    200 
    201 		while (width--) {
    202 			*(uint16_t *)rp = c;
    203 			rp += 2;
    204 			if (ri->ri_hwbits) {
    205 				*(uint16_t *)hrp = c;
    206 				hrp += 2;
    207 			}
    208 		}
    209 	}
    210 }
    211 
    212 static void
    213 rasops15_putchar_aa(void *cookie, int row, int col, u_int uc, long attr)
    214 {
    215 	int width, height, cnt, clr[2];
    216 	struct rasops_info *ri = (struct rasops_info *)cookie;
    217 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    218 	uint16_t *dp, *rp;
    219 	uint8_t *rrp;
    220 	uint8_t *fr;
    221 	uint16_t buffer[64]; /* XXX */
    222 	int x, y, r, g, b, aval;
    223 	int r1, g1, b1, r0, g0, b0, fgo, bgo;
    224 
    225 
    226 #ifdef RASOPS_CLIPPING
    227 	/* Catches 'row < 0' case too */
    228 	if ((unsigned)row >= (unsigned)ri->ri_rows)
    229 		return;
    230 
    231 	if ((unsigned)col >= (unsigned)ri->ri_cols)
    232 		return;
    233 #endif
    234 
    235 	/* check if character fits into font limits */
    236 	if (!CHAR_IN_FONT(uc, font))
    237 		return;
    238 
    239 	rrp = (ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    240 	rp = (uint16_t *)rrp;
    241 
    242 	height = font->fontheight;
    243 	width = font->fontwidth;
    244 
    245 	clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
    246 	clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
    247 
    248 	if (uc == ' ') {
    249 	        for (cnt = 0; cnt < width; cnt++)
    250 	                buffer[cnt] = clr[0];
    251 		while (height--) {
    252 			dp = rp;
    253 			DELTA(rp, ri->ri_stride, uint16_t *);
    254 			memcpy(dp, buffer, width << 1);
    255 		}
    256 	} else {
    257 		fr = WSFONT_GLYPH(uc, font);
    258 
    259 		fgo = ((attr >> 24) & 0xf) * 3;
    260 		bgo = ((attr >> 16) & 0xf) * 3;
    261 
    262 		r0 = rasops_cmap[bgo];
    263 		r1 = rasops_cmap[fgo];
    264 		g0 = rasops_cmap[bgo + 1];
    265 		g1 = rasops_cmap[fgo + 1];
    266 		b0 = rasops_cmap[bgo + 2];
    267 		b1 = rasops_cmap[fgo + 2];
    268 
    269 		for (y = 0; y < height; y++) {
    270 			dp = (uint16_t *)(rrp + ri->ri_stride * y);
    271 			for (x = 0; x < width; x++) {
    272 				aval = *fr;
    273 				if (aval == 0) {
    274 					buffer[x] = clr[0];
    275 				} else if (aval == 255) {
    276 					buffer[x] = clr[1];
    277 				} else {
    278 					r = aval * r1 + (255 - aval) * r0;
    279 					g = aval * g1 + (255 - aval) * g0;
    280 					b = aval * b1 + (255 - aval) * b0;
    281 					buffer[x] =
    282 					    ((r >> (16 - ri->ri_rnum)) <<
    283 						ri->ri_rpos) |
    284 					    ((g >> (16 - ri->ri_gnum)) <<
    285 					        ri->ri_gpos) |
    286 					    ((b >> (16 - ri->ri_bnum)) <<
    287 						ri->ri_bpos);
    288 				}
    289 				fr++;
    290 			}
    291 			memcpy(dp, buffer, width << 1);
    292 		}
    293 	}
    294 
    295 	/* Do underline */
    296 	if ((attr & WSATTR_UNDERLINE) != 0) {
    297 	        rp = (uint16_t *)rrp;
    298 		DELTA(rp, (ri->ri_stride * (height - 2)), uint16_t *);
    299 		while (width--)
    300 			*rp++ = clr[1];
    301 	}
    302 }
    303 
    304 #ifndef RASOPS_SMALL
    305 /*
    306  * Recompute the (2x2)x1 blitting stamp.
    307  */
    308 static void
    309 rasops15_makestamp(struct rasops_info *ri, long attr)
    310 {
    311 	uint32_t fg, bg;
    312 	int i;
    313 
    314 	fg = ri->ri_devcmap[((u_int)attr >> 24) & 0xf] & 0xffff;
    315 	bg = ri->ri_devcmap[((u_int)attr >> 16) & 0xf] & 0xffff;
    316 	stamp_attr = attr;
    317 
    318 	for (i = 0; i < 32; i += 2) {
    319 #if BYTE_ORDER == LITTLE_ENDIAN
    320 		stamp[i] = (i & 16 ? fg : bg);
    321 		stamp[i] |= ((i & 8 ? fg : bg) << 16);
    322 		stamp[i + 1] = (i & 4 ? fg : bg);
    323 		stamp[i + 1] |= ((i & 2 ? fg : bg) << 16);
    324 #else
    325 		stamp[i] = (i & 8 ? fg : bg);
    326 		stamp[i] |= ((i & 16 ? fg : bg) << 16);
    327 		stamp[i + 1] = (i & 2 ? fg : bg);
    328 		stamp[i + 1] |= ((i & 4 ? fg : bg) << 16);
    329 #endif
    330 	}
    331 }
    332 
    333 /*
    334  * Paint a single character. This is for 8-pixel wide fonts.
    335  */
    336 static void
    337 rasops15_putchar8(void *cookie, int row, int col, u_int uc, long attr)
    338 {
    339 	struct rasops_info *ri = (struct rasops_info *)cookie;
    340 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    341 	int height, so, fs;
    342 	uint32_t *rp, *hrp;
    343 	uint8_t *fr;
    344 
    345 	/* Can't risk remaking the stamp if it's already in use */
    346 	if (stamp_mutex++) {
    347 		stamp_mutex--;
    348 		rasops15_putchar(cookie, row, col, uc, attr);
    349 		return;
    350 	}
    351 
    352 	hrp = NULL;
    353 
    354 #ifdef RASOPS_CLIPPING
    355 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    356 		stamp_mutex--;
    357 		return;
    358 	}
    359 
    360 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    361 		stamp_mutex--;
    362 		return;
    363 	}
    364 #endif
    365 
    366 	/* Recompute stamp? */
    367 	if (attr != stamp_attr)
    368 		rasops15_makestamp(ri, attr);
    369 
    370 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    371 	if (ri->ri_hwbits)
    372 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    373 		    col*ri->ri_xscale);
    374 	height = font->fontheight;
    375 
    376 	if (uc == (u_int)-1) {
    377 		while (height--) {
    378 			rp[0] = rp[1] = rp[2] = rp[3] = stamp[0];
    379 			DELTA(rp, ri->ri_stride, uint32_t *);
    380 			if (ri->ri_hwbits) {
    381 				hrp[0] = hrp[1] = hrp[2] = hrp[3] = stamp[0];
    382 				DELTA(hrp, ri->ri_stride, uint32_t *);
    383 			}
    384 		}
    385 	} else {
    386 		uc -= font->firstchar;
    387 		fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
    388 		fs = font->stride;
    389 
    390 		while (height--) {
    391 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    392 			rp[0] = STAMP_READ(so);
    393 			rp[1] = STAMP_READ(so + 4);
    394 			if (ri->ri_hwbits) {
    395 				hrp[0] = STAMP_READ(so);
    396 				hrp[1] = STAMP_READ(so + 4);
    397 			}
    398 
    399 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    400 			rp[2] = STAMP_READ(so);
    401 			rp[3] = STAMP_READ(so + 4);
    402 			if (ri->ri_hwbits) {
    403 				hrp[2] = STAMP_READ(so);
    404 				hrp[3] = STAMP_READ(so + 4);
    405 			}
    406 
    407 			fr += fs;
    408 			DELTA(rp, ri->ri_stride, uint32_t *);
    409 			if (ri->ri_hwbits)
    410 				DELTA(hrp, ri->ri_stride, uint32_t *);
    411 		}
    412 	}
    413 
    414 	/* Do underline */
    415 	if ((attr & WSATTR_UNDERLINE) != 0) {
    416 		uint32_t c = STAMP_READ(28);
    417 
    418 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    419 		rp[0] = rp[1] = rp[2] = rp[3] = c;
    420 		if (ri->ri_hwbits) {
    421 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    422 			hrp[0] = hrp[1] = hrp[2] = hrp[3] = c;
    423 		}
    424 	}
    425 
    426 	stamp_mutex--;
    427 }
    428 
    429 /*
    430  * Paint a single character. This is for 12-pixel wide fonts.
    431  */
    432 static void
    433 rasops15_putchar12(void *cookie, int row, int col, u_int uc, long attr)
    434 {
    435 	struct rasops_info *ri = (struct rasops_info *)cookie;
    436 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    437 	int height, so, fs;
    438 	uint32_t *rp, *hrp;
    439 	uint8_t *fr;
    440 
    441 	/* Can't risk remaking the stamp if it's already in use */
    442 	if (stamp_mutex++) {
    443 		stamp_mutex--;
    444 		rasops15_putchar(cookie, row, col, uc, attr);
    445 		return;
    446 	}
    447 
    448 	hrp = NULL;
    449 
    450 #ifdef RASOPS_CLIPPING
    451 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    452 		stamp_mutex--;
    453 		return;
    454 	}
    455 
    456 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    457 		stamp_mutex--;
    458 		return;
    459 	}
    460 #endif
    461 
    462 	/* Recompute stamp? */
    463 	if (attr != stamp_attr)
    464 		rasops15_makestamp(ri, attr);
    465 
    466 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    467 	if (ri->ri_hwbits)
    468 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    469 		    col*ri->ri_xscale);
    470 	height = font->fontheight;
    471 
    472 	if (uc == (u_int)-1) {
    473 		while (height--) {
    474 			rp[0] = rp[1] = rp[2] = rp[3] = rp[4] = rp[5] =
    475 			    stamp[0];
    476 			DELTA(rp, ri->ri_stride, uint32_t *);
    477 			if (ri->ri_hwbits) {
    478 				hrp[0] = hrp[1] = hrp[2] = hrp[3] = hrp[4] =
    479 				    hrp[5] = stamp[0];
    480 				DELTA(hrp, ri->ri_stride, uint32_t *);
    481 			}
    482 		}
    483 	} else {
    484 		uc -= font->firstchar;
    485 		fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
    486 		fs = font->stride;
    487 
    488 		while (height--) {
    489 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    490 			rp[0] = STAMP_READ(so);
    491 			rp[1] = STAMP_READ(so + 4);
    492 			if (ri->ri_hwbits) {
    493 				hrp[0] = STAMP_READ(so);
    494 				hrp[1] = STAMP_READ(so + 4);
    495 			}
    496 
    497 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    498 			rp[2] = STAMP_READ(so);
    499 			rp[3] = STAMP_READ(so + 4);
    500 			if (ri->ri_hwbits) {
    501 				hrp[2] = STAMP_READ(so);
    502 				hrp[3] = STAMP_READ(so + 4);
    503 			}
    504 
    505 			so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
    506 			rp[4] = STAMP_READ(so);
    507 			rp[5] = STAMP_READ(so + 4);
    508 			if (ri->ri_hwbits) {
    509 				hrp[4] = STAMP_READ(so);
    510 				hrp[5] = STAMP_READ(so + 4);
    511 			}
    512 
    513 			fr += fs;
    514 			DELTA(rp, ri->ri_stride, uint32_t *);
    515 			if (ri->ri_hwbits)
    516 				DELTA(hrp, ri->ri_stride, uint32_t *);
    517 		}
    518 	}
    519 
    520 	/* Do underline */
    521 	if (attr & WSATTR_UNDERLINE) {
    522 		uint32_t c = STAMP_READ(28);
    523 
    524 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    525 		rp[0] = rp[1] = rp[2] = rp[3] = rp[4] = rp[5] = c;
    526 		if (ri->ri_hwbits) {
    527 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    528 			hrp[0] = hrp[1] = hrp[2] = hrp[3] = hrp[4] = hrp[5] = c;
    529 		}
    530 	}
    531 
    532 	stamp_mutex--;
    533 }
    534 
    535 /*
    536  * Paint a single character. This is for 16-pixel wide fonts.
    537  */
    538 static void
    539 rasops15_putchar16(void *cookie, int row, int col, u_int uc, long attr)
    540 {
    541 	struct rasops_info *ri = (struct rasops_info *)cookie;
    542 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
    543 	int height, so, fs;
    544 	uint32_t *rp, *hrp;
    545 	uint8_t *fr;
    546 
    547 	/* Can't risk remaking the stamp if it's already in use */
    548 	if (stamp_mutex++) {
    549 		stamp_mutex--;
    550 		rasops15_putchar(cookie, row, col, uc, attr);
    551 		return;
    552 	}
    553 
    554 	hrp = NULL;
    555 
    556 #ifdef RASOPS_CLIPPING
    557 	if ((unsigned)row >= (unsigned)ri->ri_rows) {
    558 		stamp_mutex--;
    559 		return;
    560 	}
    561 
    562 	if ((unsigned)col >= (unsigned)ri->ri_cols) {
    563 		stamp_mutex--;
    564 		return;
    565 	}
    566 #endif
    567 
    568 	/* Recompute stamp? */
    569 	if (attr != stamp_attr)
    570 		rasops15_makestamp(ri, attr);
    571 
    572 	rp = (uint32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
    573 	if (ri->ri_hwbits)
    574 		hrp = (uint32_t *)(ri->ri_hwbits + row*ri->ri_yscale +
    575 		    col*ri->ri_xscale);
    576 	height = font->fontheight;
    577 
    578 	if (uc == (u_int)-1) {
    579 		while (height--) {
    580 			rp[0] = rp[1] = rp[2] = rp[3] =
    581 			rp[4] = rp[5] = rp[6] = rp[7] = stamp[0];
    582 			DELTA(rp, ri->ri_stride, uint32_t *);
    583 			if (ri->ri_hwbits) {
    584 				hrp[0] = hrp[1] = hrp[2] = hrp[3] =
    585 				hrp[4] = hrp[5] = hrp[6] = hrp[7] = stamp[0];
    586 				DELTA(hrp, ri->ri_stride, uint32_t *);
    587 			}
    588 		}
    589 	} else {
    590 		uc -= font->firstchar;
    591 		fr = (uint8_t *)font->data + uc*ri->ri_fontscale;
    592 		fs = font->stride;
    593 
    594 		while (height--) {
    595 			so = STAMP_SHIFT(fr[0], 1) & STAMP_MASK;
    596 			rp[0] = STAMP_READ(so);
    597 			rp[1] = STAMP_READ(so + 4);
    598 			if (ri->ri_hwbits) {
    599 				hrp[0] = STAMP_READ(so);
    600 				hrp[1] = STAMP_READ(so + 4);
    601 			}
    602 
    603 			so = STAMP_SHIFT(fr[0], 0) & STAMP_MASK;
    604 			rp[2] = STAMP_READ(so);
    605 			rp[3] = STAMP_READ(so + 4);
    606 			if (ri->ri_hwbits) {
    607 				hrp[2] = STAMP_READ(so);
    608 				hrp[3] = STAMP_READ(so + 4);
    609 			}
    610 
    611 			so = STAMP_SHIFT(fr[1], 1) & STAMP_MASK;
    612 			rp[4] = STAMP_READ(so);
    613 			rp[5] = STAMP_READ(so + 4);
    614 			if (ri->ri_hwbits) {
    615 				hrp[4] = STAMP_READ(so);
    616 				hrp[5] = STAMP_READ(so + 4);
    617 			}
    618 
    619 			so = STAMP_SHIFT(fr[1], 0) & STAMP_MASK;
    620 			rp[6] = STAMP_READ(so);
    621 			rp[7] = STAMP_READ(so + 4);
    622 			if (ri->ri_hwbits) {
    623 				hrp[6] = STAMP_READ(so);
    624 				hrp[7] = STAMP_READ(so + 4);
    625 			}
    626 
    627 			DELTA(rp, ri->ri_stride, uint32_t *);
    628 			if (ri->ri_hwbits)
    629 				DELTA(hrp, ri->ri_stride, uint32_t *);
    630 			fr += fs;
    631 		}
    632 	}
    633 
    634 	/* Do underline */
    635 	if (attr & WSATTR_UNDERLINE) {
    636 		uint32_t c = STAMP_READ(28);
    637 
    638 		DELTA(rp, -(ri->ri_stride << 1), uint32_t *);
    639 		rp[0] = rp[1] = rp[2] = rp[3] =
    640 		rp[4] = rp[5] = rp[6] = rp[7] = c;
    641 		if (ri->ri_hwbits) {
    642 			DELTA(hrp, -(ri->ri_stride << 1), uint32_t *);
    643 			hrp[0] = hrp[1] = hrp[2] = hrp[3] =
    644 			hrp[4] = hrp[5] = hrp[6] = hrp[7] = c;
    645 		}
    646 	}
    647 
    648 	stamp_mutex--;
    649 }
    650 #endif	/* !RASOPS_SMALL */
    651