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