Annotation of sys/dev/rasops/rasops32.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: rasops32.c,v 1.4 2002/07/27 22:17:49 miod Exp $ */
! 2: /* $NetBSD: rasops32.c,v 1.7 2000/04/12 14:22:29 pk Exp $ */
! 3:
! 4: /*-
! 5: * Copyright (c) 1999 The NetBSD Foundation, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * This code is derived from software contributed to The NetBSD Foundation
! 9: * by Andrew Doran.
! 10: *
! 11: * Redistribution and use in source and binary forms, with or without
! 12: * modification, are permitted provided that the following conditions
! 13: * are met:
! 14: * 1. Redistributions of source code must retain the above copyright
! 15: * notice, this list of conditions and the following disclaimer.
! 16: * 2. Redistributions in binary form must reproduce the above copyright
! 17: * notice, this list of conditions and the following disclaimer in the
! 18: * documentation and/or other materials provided with the distribution.
! 19: * 3. All advertising materials mentioning features or use of this software
! 20: * must display the following acknowledgement:
! 21: * This product includes software developed by the NetBSD
! 22: * Foundation, Inc. and its contributors.
! 23: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 24: * contributors may be used to endorse or promote products derived
! 25: * from this software without specific prior written permission.
! 26: *
! 27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 37: * POSSIBILITY OF SUCH DAMAGE.
! 38: */
! 39:
! 40: #include <sys/param.h>
! 41: #include <sys/systm.h>
! 42: #include <sys/time.h>
! 43:
! 44: #include <dev/wscons/wsdisplayvar.h>
! 45: #include <dev/wscons/wsconsio.h>
! 46: #include <dev/rasops/rasops.h>
! 47:
! 48: void rasops32_putchar(void *, int, int, u_int, long);
! 49:
! 50: /*
! 51: * Initialize a 'rasops_info' descriptor for this depth.
! 52: */
! 53: void
! 54: rasops32_init(ri)
! 55: struct rasops_info *ri;
! 56: {
! 57:
! 58: if (ri->ri_rnum == 0) {
! 59: ri->ri_rnum = 8;
! 60: ri->ri_rpos = 0;
! 61: ri->ri_gnum = 8;
! 62: ri->ri_gpos = 8;
! 63: ri->ri_bnum = 8;
! 64: ri->ri_bpos = 16;
! 65: }
! 66:
! 67: ri->ri_ops.putchar = rasops32_putchar;
! 68: }
! 69:
! 70: /*
! 71: * Paint a single character.
! 72: */
! 73: void
! 74: rasops32_putchar(cookie, row, col, uc, attr)
! 75: void *cookie;
! 76: int row, col;
! 77: u_int uc;
! 78: long attr;
! 79: {
! 80: int width, height, cnt, fs, fb, clr[2];
! 81: struct rasops_info *ri;
! 82: int32_t *dp, *rp;
! 83: u_char *fr;
! 84:
! 85: ri = (struct rasops_info *)cookie;
! 86:
! 87: #ifdef RASOPS_CLIPPING
! 88: /* Catches 'row < 0' case too */
! 89: if ((unsigned)row >= (unsigned)ri->ri_rows)
! 90: return;
! 91:
! 92: if ((unsigned)col >= (unsigned)ri->ri_cols)
! 93: return;
! 94: #endif
! 95:
! 96: rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
! 97:
! 98: height = ri->ri_font->fontheight;
! 99: width = ri->ri_font->fontwidth;
! 100:
! 101: clr[0] = ri->ri_devcmap[(attr >> 16) & 0xf];
! 102: clr[1] = ri->ri_devcmap[(attr >> 24) & 0xf];
! 103:
! 104: if (uc == ' ') {
! 105: while (height--) {
! 106: dp = rp;
! 107: DELTA(rp, ri->ri_stride, int32_t *);
! 108:
! 109: for (cnt = width; cnt; cnt--)
! 110: *dp++ = clr[0];
! 111: }
! 112: } else {
! 113: uc -= ri->ri_font->firstchar;
! 114: fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
! 115: fs = ri->ri_font->stride;
! 116:
! 117: while (height--) {
! 118: dp = rp;
! 119: fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) |
! 120: (fr[0] << 24);
! 121: fr += fs;
! 122: DELTA(rp, ri->ri_stride, int32_t *);
! 123:
! 124: for (cnt = width; cnt; cnt--) {
! 125: *dp++ = clr[(fb >> 31) & 1];
! 126: fb <<= 1;
! 127: }
! 128: }
! 129: }
! 130:
! 131: /* Do underline */
! 132: if ((attr & 1) != 0) {
! 133: DELTA(rp, -(ri->ri_stride << 1), int32_t *);
! 134:
! 135: while (width--)
! 136: *rp++ = clr[1];
! 137: }
! 138: }
CVSweb