Innumerable fixes and improvements. README contains list of remaining bugs

that need to be squashed.
This commit is contained in:
ad 1999-04-26 04:27:47 +00:00
parent 613a381d71
commit f9510a4f4b
13 changed files with 2504 additions and 1375 deletions

View File

@ -1,21 +1,13 @@
$NetBSD: README,v 1.1 1999/04/13 00:17:57 ad Exp $
$NetBSD: README,v 1.2 1999/04/26 04:27:47 ad Exp $
This directory contains 'rasops', a set of raster operations intended to
replace the dev/rcons/raster stuff for both wscons and rcons. It yields
significantly improved performance, supports multiple depths and color.
The stamp_mutex used by some of the colordepths is not fully atomic. It's
designed to stop stamp corruption in the event that text is printed at
interrupt time. Even if it fails, >99% of the time text will be white on
black, so it doesn't really matter. Going to splhigh for each character is
a Bad Thing.
Status of the various depths. Feel free to complete/test:
8 tested, complete
15/16 untested, complete (endainness issues exist?)
32 untested, complete (endainness issues exist?)
1 untested, incomplete for non 8,16 pel fonts
24 untested, incomplete, assumes RGB order
- Andy Doran <ad@NetBSD.org>, April 1999
TODO o There is no generic `putchar' function for 2bpp.
o Color handling for 2bpp is broken.
o copycols() from rasops_bitops.h is broken in right->left case.
o The stamp mutex is not particularly safe.
o rasops_pmask[][] is too big (4kB).
o 64-bit types are not used on machines that are 64-bit.
o We should never be doing reads/writes of less than 32-bits.

View File

@ -1,11 +1,22 @@
# $NetBSD: files.rasops,v 1.1 1999/04/13 00:17:58 ad Exp $
# $NetBSD: files.rasops,v 1.2 1999/04/26 04:27:47 ad Exp $
file dev/rasops/rasops.c rasterconsole
file dev/rasops/rasops1.c rasterconsole
file dev/rasops/rasops8.c rasterconsole
file dev/rasops/rasops15.c rasterconsole
file dev/rasops/rasops24.c rasterconsole
file dev/rasops/rasops32.c rasterconsole
define rasops1
define rasops2
define rasops8
define rasops15
define rasops16
define rasops24
define rasops32
defopt opt_rasops.h RASOPS1 RASOPS8 RASOPS15 RASOPS16 RASOPS24 RASOPS32
RASOPS_CLIPPING
file dev/rasops/rasops.c rasops_glue | rasops1 | rasops2 | rasops8 |
rasops15 | rasops16 | rasops24 | rasops32 needs-flag
file dev/rasops/rasops_masks.c rasops1 | rasops2
file dev/rasops/rasops1.c rasops1
file dev/rasops/rasops2.c rasops2
file dev/rasops/rasops8.c rasops8
file dev/rasops/rasops15.c rasops15 | rasops16
file dev/rasops/rasops24.c rasops24
file dev/rasops/rasops32.c rasops32
defopt opt_rasops.h RASOPS_CLIPPING

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops.c,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/* $NetBSD: rasops.c,v 1.4 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -28,9 +28,9 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.4 1999/04/26 04:27:47 ad Exp $");
#include "opt_rasops.h"
#include "rasops_glue.h"
#include <sys/types.h>
#include <sys/param.h>
@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
#include <sys/time.h>
#include <machine/bswap.h>
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
@ -73,16 +74,18 @@ u_char rasops_isgray[16] = {
0, 0, 0, 1
};
/* Common functions */
static void rasops_copycols __P((void *, int, int, int, int));
/* Generic functions */
static void rasops_copyrows __P((void *, int, int, int));
static int rasops_mapchar __P((void *, int, u_int *));
static void rasops_cursor __P((void *, int, int, int));
static int rasops_alloc_cattr __P((void *, int, int, int, long *));
static int rasops_alloc_mattr __P((void *, int, int, int, long *));
static void rasops_do_cursor __P((struct rasops_info *));
static void rasops_init_devcmap __P((struct rasops_info *));
/* Per-depth initalization functions */
void rasops1_init __P((struct rasops_info *));
void rasops2_init __P((struct rasops_info *));
void rasops8_init __P((struct rasops_info *));
void rasops15_init __P((struct rasops_info *));
void rasops24_init __P((struct rasops_info *));
@ -96,7 +99,7 @@ rasops_init(ri, wantrows, wantcols, clear, center)
struct rasops_info *ri;
int wantrows, wantcols, clear, center;
{
#ifdef _KERNEL
/* Select a font if the caller doesn't care */
if (ri->ri_font == NULL) {
int cookie;
@ -113,11 +116,12 @@ rasops_init(ri, wantrows, wantcols, clear, center)
}
if (wsfont_lock(cookie, &ri->ri_font,
WSFONT_LITTLE, WSFONT_LITTLE) < 0) {
WSFONT_L2R, WSFONT_L2R) < 0) {
printf("rasops_init: couldn't lock font\n");
return (-1);
}
}
#endif
/* This should never happen in reality... */
#ifdef DEBUG
@ -130,18 +134,42 @@ rasops_init(ri, wantrows, wantcols, clear, center)
printf("rasops_init: stride not aligned on 32-bit boundary\n");
return (-1);
}
if (ri->ri_font->fontwidth > 32) {
printf("rasops_init: fontwidth > 32\n");
return (-1);
}
#endif
/* Fix color palette. We need this for the cursor to work. */
rasops_cmap[255*3+0] = 0xff;
rasops_cmap[255*3+1] = 0xff;
rasops_cmap[255*3+2] = 0xff;
/* setfont does most of the work */
if (rasops_setfont(ri, wantrows, wantcols, clear, center))
return (-1);
rasops_init_devcmap(ri);
ri->ri_flg = RASOPS_INITTED;
return (0);
}
/*
* Choose a different font. The new font will already be set in ri_font.
*/
int
rasops_setfont(ri, wantrows, wantcols, clear, center)
struct rasops_info *ri;
int wantrows, wantcols, clear, center;
{
int bpp;
if (ri->ri_font->fontwidth > 32 || ri->ri_font->fontwidth < 4)
panic("rasops_init: fontwidth assumptions botched!\n");
/* Need this to frob the setup below */
bpp = (ri->ri_depth == 15 ? 16 : ri->ri_depth);
if (ri->ri_flg & RASOPS_INITTED)
ri->ri_bits = ri->ri_origbits;
/* Don't care if the caller wants a hideously small console */
if (wantrows < 10)
wantrows = 5000;
@ -160,18 +188,18 @@ rasops_init(ri, wantrows, wantcols, clear, center)
ri->ri_emuheight = ri->ri_height;
/* Reduce width until aligned on a 32-bit boundary */
while ((ri->ri_emuwidth*ri->ri_depth & 31) != 0)
while ((ri->ri_emuwidth*bpp & 31) != 0)
ri->ri_emuwidth--;
ri->ri_cols = ri->ri_emuwidth / ri->ri_font->fontwidth;
ri->ri_rows = ri->ri_emuheight / ri->ri_font->fontheight;
ri->ri_emustride = ri->ri_emuwidth * ri->ri_depth >> 3;
ri->ri_emustride = ri->ri_emuwidth * bpp >> 3;
ri->ri_delta = ri->ri_stride - ri->ri_emustride;
ri->ri_ccol = 0;
ri->ri_crow = 0;
ri->ri_pelbytes = ri->ri_depth >> 3;
ri->ri_pelbytes = bpp >> 3;
ri->ri_xscale = (ri->ri_font->fontwidth * ri->ri_depth) >> 3;
ri->ri_xscale = (ri->ri_font->fontwidth * bpp) >> 3;
ri->ri_yscale = ri->ri_font->fontheight * ri->ri_stride;
ri->ri_fontscale = ri->ri_font->fontheight * ri->ri_font->stride;
@ -191,45 +219,61 @@ rasops_init(ri, wantrows, wantcols, clear, center)
ri->ri_bits += ((ri->ri_height - ri->ri_emuheight) >> 1) *
ri->ri_stride;
}
/* Fill in defaults for operations set */
/*
* Fill in defaults for operations set. XXX this nukes private
* routines used by accelerated fb drivers.
*/
ri->ri_ops.mapchar = rasops_mapchar;
ri->ri_ops.copyrows = rasops_copyrows;
ri->ri_ops.copycols = rasops_copycols;
ri->ri_ops.erasecols = rasops_erasecols;
ri->ri_ops.eraserows = rasops_eraserows;
ri->ri_ops.cursor = rasops_cursor;
ri->ri_do_cursor = rasops_do_cursor;
if (ri->ri_depth == 1 || ri->ri_forcemono)
if (ri->ri_depth < 8 || ri->ri_forcemono) {
ri->ri_ops.alloc_attr = rasops_alloc_mattr;
else
ri->ri_caps = WSATTR_UNDERLINE;
} else {
ri->ri_ops.alloc_attr = rasops_alloc_cattr;
ri->ri_caps = WSATTR_UNDERLINE | WSATTR_HILIT |
WSATTR_WSCOLORS;
}
switch (ri->ri_depth) {
#ifdef RASOPS1
#if NRASOPS1
case 1:
rasops1_init(ri);
break;
#endif
#ifdef RASOPS8
#if NRASOPS2
case 2:
rasops2_init(ri);
break;
#endif
#if NRASOPS8
case 8:
rasops8_init(ri);
break;
#endif
#if defined(RASOPS15) || defined(RASOPS16)
#if NRASOPS15 || NRASOPS16
case 15:
case 16:
rasops15_init(ri);
break;
#endif
#ifdef RASOPS24
#if NRASOPS24
case 24:
rasops24_init(ri);
break;
#endif
#ifdef RASOPS24
#if NRASOPS32
case 32:
rasops32_init(ri);
break;
@ -239,7 +283,6 @@ rasops_init(ri, wantrows, wantcols, clear, center)
return (-1);
}
ri->ri_flg = RASOPS_INITTED;
return (0);
}
@ -449,7 +492,7 @@ rasops_copyrows(cookie, src, dst, num)
* We simply cop-out here and use bcopy(), since it handles all of
* these cases anyway.
*/
static void
void
rasops_copycols(cookie, row, src, dst, num)
void *cookie;
int row, src, dst, num;
@ -545,17 +588,38 @@ rasops_cursor(cookie, on, row, col)
}
#if (RASOPS15 + RASOPS16 + RASOPS32)
/*
* Make the device colormap
*/
void
static void
rasops_init_devcmap(ri)
struct rasops_info *ri;
{
int i, c;
u_char *p;
int i, c;
switch (ri->ri_depth) {
case 1:
ri->ri_devcmap[0] = 0;
for (i = 1; i < 16; i++)
ri->ri_devcmap[i] = -1;
return;
case 2:
for (i = 1; i < 15; i++)
ri->ri_devcmap[i] = 0xaaaaaaaa;
ri->ri_devcmap[0] = 0;
ri->ri_devcmap[8] = 0x55555555;
ri->ri_devcmap[15] = -1;
return;
case 8:
for (i = 0; i < 16; i++)
ri->ri_devcmap[i] = i | (i<<8) | (i<<16) | (i<<24);
return;
}
p = rasops_cmap;
for (i = 0; i < 16; i++) {
@ -565,24 +629,32 @@ rasops_init_devcmap(ri)
c = (*p++ << (ri->ri_rnum - 8)) << ri->ri_rpos;
if (ri->ri_gnum <= 8)
c = (*p++ >> (8 - ri->ri_gnum)) << ri->ri_gpos;
c |= (*p++ >> (8 - ri->ri_gnum)) << ri->ri_gpos;
else
c = (*p++ << (ri->ri_gnum - 8)) << ri->ri_gpos;
c |= (*p++ << (ri->ri_gnum - 8)) << ri->ri_gpos;
if (ri->ri_bnum <= 8)
c = (*p++ >> (8 - ri->ri_bnum)) << ri->ri_bpos;
c |= (*p++ >> (8 - ri->ri_bnum)) << ri->ri_bpos;
else
c = (*p++ << (ri->ri_bnum - 8)) << ri->ri_bpos;
c |= (*p++ << (ri->ri_bnum - 8)) << ri->ri_bpos;
/* Fill the word for generic routines, which want this */
if (ri->ri_depth == 24)
c = c | ((c & 0xff) << 24);
else if (ri->ri_depth <= 16)
c = c | (c << 16);
/* 24bpp does bswap on the fly. {32,16,15}bpp do it here. */
if (!ri->ri_swab)
ri->ri_devcmap[i] = c;
else if (ri->ri_depth <= 32)
else if (ri->ri_depth == 32)
ri->ri_devcmap[i] = bswap32(c);
else /* if (ri->ri_depth <= 16) */
else if (ri->ri_depth == 16 || ri->ri_depth == 15)
ri->ri_devcmap[i] = bswap16(c);
else
ri->ri_devcmap[i] = c;
}
}
#endif
/*
@ -598,3 +670,257 @@ rasops_unpack_attr(attr, fg, bg, underline)
*bg = ((u_int)attr >> 16) & 15;
*underline = (u_int)attr & 1;
}
/*
* Erase rows. This isn't static, since 24-bpp uses it in special cases.
*/
void
rasops_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
long attr;
{
struct rasops_info *ri;
int np, nw, cnt;
int32_t *dp, clr;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if ((row + num) > ri->ri_rows)
num = ri->ri_rows - row;
if (num <= 0)
return;
#endif
clr = ri->ri_devcmap[(attr >> 16) & 15];
num *= ri->ri_font->fontheight;
dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
np = ri->ri_emustride >> 5;
nw = (ri->ri_emustride >> 2) & 7;
while (num--) {
for (cnt = np; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
for (cnt = nw; cnt; cnt--) {
*(int32_t *)dp = clr;
DELTA(dp, 4, int32_t *);
}
DELTA(dp, ri->ri_delta, int32_t *);
}
}
/*
* Actually turn the cursor on or off. This does the dirty work for
* rasops_cursor().
*/
static void
rasops_do_cursor(ri)
struct rasops_info *ri;
{
int full1, height, cnt, slop1, slop2, row, col, mask;
u_char *dp, *rp;
row = ri->ri_crow;
col = ri->ri_ccol;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
mask = ri->ri_devcmap[15];
slop1 = (int)rp & 3;
if (slop1 > ri->ri_xscale)
slop1 = ri->ri_xscale;
slop2 = (ri->ri_xscale - slop1) & 3;
full1 = (ri->ri_xscale - slop1 - slop2) >> 2;
if ((slop1 | slop2) == 0) {
/* A common case */
while (height--) {
dp = rp;
rp += ri->ri_stride;
for (cnt = full1; cnt; cnt--) {
*(int32_t *)dp ^= mask;
dp += 4;
}
}
} else {
/* XXX this is stupid.. use masks instead */
while (height--) {
dp = rp;
rp += ri->ri_stride;
if (slop1 & 1)
*dp++ ^= mask;
if (slop1 & 2) {
*(int16_t *)dp ^= mask;
dp += 2;
}
for (cnt = full1; cnt; cnt--) {
*(int32_t *)dp ^= mask;
dp += 4;
}
if (slop2 & 1)
*dp++ ^= mask;
if (slop2 & 2)
*(int16_t *)dp ^= mask;
}
}
}
/*
* Erase columns.
*/
void
rasops_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
long attr;
{
int n8, height, cnt, slop1, slop2, clr;
struct rasops_info *ri;
int32_t *rp, *dp;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
num = num * ri->ri_xscale;
rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + col*ri->ri_xscale);
height = ri->ri_font->fontheight;
clr = ri->ri_devcmap[(attr >> 16) & 15];
/* Don't bother using the full loop for <= 32 pels */
if (num <= 32) {
if (((num | ri->ri_xscale) & 1) == 0) {
/*
* Halfword aligned blt. This is needed so the
* 15/16 bit ops can use this function.
*/
num >>= 1;
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
for (cnt = num; cnt; cnt--) {
*(int16_t *)dp = clr;
DELTA(dp, 2, int32_t *);
}
}
} else if (((num | ri->ri_xscale) & 3) == 0) {
/* Word aligned blt */
num >>= 2;
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
for (cnt = num; cnt; cnt--)
*dp++ = clr;
}
} else {
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
for (cnt = num; cnt; cnt--) {
*(u_char *)dp = clr;
DELTA(dp, 1, int32_t *);
}
}
}
return;
}
slop1 = (int)rp & 3;
slop2 = (num - slop1) & 3;
num -= slop1 + slop2;
n8 = num >> 5;
num = (num >> 2) & 7;
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
/* Align span to 4 bytes */
if (slop1 & 1) {
*(u_char *)dp = clr;
DELTA(dp, 1, int32_t *);
}
if (slop1 & 2) {
*(int16_t *)dp = clr;
DELTA(dp, 2, int32_t *);
}
/* Write 32 bytes per loop */
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
/* Write 4 bytes per loop */
for (cnt = num; cnt; cnt--)
*dp++ = clr;
/* Write unaligned trailing slop */
if (slop2 & 1) {
*(u_char *)dp = clr;
DELTA(dp, 1, int32_t *);
}
if (slop2 & 2)
*(int16_t *)dp = clr;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops.h,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/* $NetBSD: rasops.h,v 1.4 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -69,7 +69,7 @@ struct rasops_info {
int ri_flg; /* flags */
int ri_crow; /* cursor row */
int ri_ccol; /* cursor column */
int ri_pelbytes; /* bytes per pel */
int ri_pelbytes; /* bytes per pel (may be zero) */
int ri_fontscale; /* fontheight * fontstride */
int ri_xscale; /* fontwidth * pelbytes */
int ri_yscale; /* fontheight * stride */
@ -78,11 +78,12 @@ struct rasops_info {
/* For 15, 16, 24, 32 bits */
int32_t ri_devcmap[16]; /* device colormap (WSCOL_*) */
/* The emulops you need to use */
/* The emulops you need to use, and the screen caps for wscons */
struct wsdisplay_emulops ri_ops;
int ri_caps;
/* Callbacks so we can share some code */
void (*ri_do_cursor)(struct rasops_info *);
void (*ri_do_cursor) __P((struct rasops_info *));
};
#define RASOPS_CURSOR (0x01) /* cursor is on */
@ -100,16 +101,24 @@ struct rasops_info {
*
* In terms of optimization, fonts that are a multiple of 8 pixels wide
* work the best: this is important, and will cost you if you don't use 'em.
*
* rasops_init() takes care of rasops_setfont(). You only need to use this
* when you want to switch fonts later on. The integer parameters to both
* are the same. Before calling rasops_setfont(), set ri.ri_font. This
* should happen at _splhigh_.
*/
/* rasops.c */
int rasops_init __P((struct rasops_info *, int, int, int, int));
int rasops_setfont __P((struct rasops_info *, int, int, int, int));
void rasops_unpack_attr __P((long, int *, int *, int *));
/* This should not be called outside rasops */
void rasops_init_devcmap __P((struct rasops_info *));
/* These should _not_ be called outside rasops */
void rasops_eraserows __P((void *, int, int, long));
void rasops_erasecols __P((void *, int, int, int, long));
void rasops_copycols __P((void *, int, int, int, int));
extern u_char rasops_isgray[16];
extern u_char rasops_cmap[256*3];
extern u_char rasops_isgray[16];
extern u_char rasops_cmap[256*3];
#endif /* _RASOPS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $ */
/* $NetBSD: rasops1.c,v 1.4 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -28,10 +28,8 @@
*/
#include "opt_rasops.h"
#ifdef RASOPS1
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.4 1999/04/26 04:27:47 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -42,52 +40,17 @@ __KERNEL_RCSID(0, "$NetBSD: rasops1.c,v 1.3 1999/04/13 03:02:40 ad Exp $");
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
#include <dev/rasops/rasops.h>
#include <dev/rasops/rasops_masks.h>
static void rasops1_putchar __P((void *, int, int col, u_int, long));
static void rasops1_putchar8 __P((void *, int, int col, u_int, long));
static void rasops1_putchar16 __P((void *, int, int col, u_int, long));
static void rasops1_copycols __P((void *, int, int, int, int));
static void rasops1_erasecols __P((void *, int, int, int, long));
static void rasops1_erasecols8 __P((void *, int, int, int, long));
static void rasops1_eraserows __P((void *, int, int, long));
static int32_t rasops1_fg_color __P((long));
static int32_t rasops1_bg_color __P((long));
static void rasops1_do_cursor __P((struct rasops_info *));
static void rasops1_do_cursor8 __P((struct rasops_info *));
void rasops1_init __P((struct rasops_info *ri));
#if BYTE_ORDER == LITTLE_ENDIAN
static u_int32_t rightmask[32] = {
#else
static u_int32_t leftmask[32] = {
#endif
0x00000000, 0x80000000, 0xc0000000, 0xe0000000,
0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000,
0xff000000, 0xff800000, 0xffc00000, 0xffe00000,
0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000,
0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000,
0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00,
0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0,
0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe,
};
#if BYTE_ORDER == LITTLE_ENDIAN
static u_int32_t leftmask[32] = {
#else
static u_int32_t rightmask[32] = {
#endif
0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
};
/*
* Initalize rasops_info struct for this colordepth.
*/
@ -104,12 +67,6 @@ rasops1_init(ri)
ri->ri_ops.putchar = rasops1_putchar16;
break;
default:
/*
* XXX we don't support anything other than 8 and 16 pel
* wide fonts yet. rasops1_copycols needs to be finished, the
* other routines will need to be checked.
*/
panic("rasops1_init: not completed - see this location in src for details");
ri->ri_ops.putchar = rasops1_putchar;
break;
}
@ -118,42 +75,12 @@ rasops1_init(ri)
ri->ri_ops.erasecols = rasops1_erasecols;
ri->ri_ops.copycols = rasops1_copycols;
ri->ri_do_cursor = rasops1_do_cursor;
} else {
ri->ri_ops.erasecols = rasops1_erasecols8;
/* use default copycols */
ri->ri_do_cursor = rasops1_do_cursor8;
}
ri->ri_ops.eraserows = rasops1_eraserows;
}
/*
* Get foreground color from attribute and copy across all 4 bytes
* in a int32_t.
*/
static __inline__ int32_t
rasops1_fg_color(long attr)
{
return (attr & 0x0f000000) ? 0xffffffff : 0;
}
/*
* Get background color from attribute and copy across all 4 bytes
* in a int32_t.
*/
static __inline__ int32_t
rasops1_bg_color(long attr)
{
return (attr & 0x000f0000) ? 0xffffffff : 0;
}
/*
* Paint a single character. This is the generic version.
* Paint a single character. This is the generic version, this is ugly.
*/
static void
rasops1_putchar(cookie, row, col, uc, attr)
@ -162,8 +89,140 @@ rasops1_putchar(cookie, row, col, uc, attr)
u_int uc;
long attr;
{
int height, width, fs, rs, fb, bg, fg, lmask, rmask;
struct rasops_info *ri;
int32_t *rp;
u_char *fr;
ri = (struct rasops_info *)cookie;
panic("rasops1_putchar: i need implemention");
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if ((unsigned)col >= (unsigned)ri->ri_cols)
return;
#endif
col *= ri->ri_font->fontwidth;
rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
height = ri->ri_font->fontheight;
width = ri->ri_font->fontwidth;
col = col & 31;
rs = ri->ri_stride;
bg = (attr & 0x000f0000) ? 0xffffffff : 0;
fg = (attr & 0x0f000000) ? 0xffffffff : 0;
/* If fg and bg match this becomes a space character */
if (fg == bg || uc == ' ') {
uc = (u_int)-1;
fr = 0; /* shutup gcc */
fs = 0; /* shutup gcc */
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
fs = ri->ri_font->stride;
}
/* Single word, one mask */
if ((col + width) <= 32) {
rmask = rasops_pmask[col][width];
lmask = ~rmask;
if (uc == (u_int)-1) {
bg &= rmask;
while (height--) {
*rp = (*rp & lmask) | bg;
DELTA(rp, rs, int32_t *);
}
} else {
/* NOT fontbits if bg is white */
if (bg) {
while (height--) {
fb = ~(fr[3] | (fr[2] << 8) |
(fr[1] << 16) | (fr[0] << 24));
*rp = (*rp & lmask)
| (MBE(fb >> col) & rmask);
fr += fs;
DELTA(rp, rs, int32_t *);
}
} else {
while (height--) {
fb = (fr[3] | (fr[2] << 8) |
(fr[1] << 16) | (fr[0] << 24));
*rp = (*rp & lmask)
| (MBE(fb >> col) & rmask);
fr += fs;
DELTA(rp, rs, int32_t *);
}
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
*rp = (*rp & lmask) | (fg & rmask);
}
} else {
lmask = ~rasops_lmask[col];
rmask = ~rasops_rmask[(col + width) & 31];
if (uc == (u_int)-1) {
bg = bg & ~lmask;
width = bg & ~rmask;
while (height--) {
rp[0] = (rp[0] & lmask) | bg;
rp[1] = (rp[1] & rmask) | width;
DELTA(rp, rs, int32_t *);
}
} else {
width = 32 - col;
/* NOT fontbits if bg is white */
if (bg) {
while (height--) {
fb = ~(fr[3] | (fr[2] << 8) |
(fr[1] << 16) | (fr[0] << 24));
rp[0] = (rp[0] & lmask)
| MBE((u_int)fb >> col);
rp[1] = (rp[1] & rmask)
| (MBE((u_int)fb << width) & ~rmask);
fr += fs;
DELTA(rp, rs, int32_t *);
}
} else {
while (height--) {
fb = (fr[3] | (fr[2] << 8) |
(fr[1] << 16) | (fr[0] << 24));
rp[0] = (rp[0] & lmask)
| MBE(fb >> col);
rp[1] = (rp[1] & rmask)
| (MBE(fb << width) & ~rmask);
fr += fs;
DELTA(rp, rs, int32_t *);
}
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
rp[0] = (rp[0] & lmask) | (fg & ~lmask);
rp[1] = (rp[1] & rmask) | (fg & ~rmask);
}
}
}
@ -224,6 +283,7 @@ rasops1_putchar8(cookie, row, col, uc, attr)
rp += rs;
}
}
}
/* Do underline */
@ -298,281 +358,10 @@ rasops1_putchar16(cookie, row, col, uc, attr)
*(int16_t *)(rp - (ri->ri_stride << 1)) = fg;
}
/*
* Erase columns.
* Grab routines common to depths where (bpp < 8)
*/
static void
rasops1_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, num;
long attr;
{
int32_t *dp, *rp, lmask, rmask, lclr, rclr, clr;
struct rasops_info *ri;
int nint, height, cnt;
ri = (struct rasops_info *)cookie;
#define NAME(ident) rasops1_##ident
#define PIXEL_SHIFT 0
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
col *= ri->ri_font->fontwidth;
num *= ri->ri_font->fontwidth;
/*
* lmask: mask for leftmost int32
* rmask: mask for rightmost int32
* nint: number of full int32s
*/
lmask = leftmask[col & 31];
rmask = rightmask[(col + num) & 31];
nint = (((col + num) & ~31) - ((col + 31) & ~31)) >> 5;
/* Merge both masks if the span is encapsulated within one int32 */
if ((col & ~31) == ((col + num) & ~31)) {
lmask &= rmask;
rmask = 0;
}
clr = rasops1_bg_color(attr);
lclr = clr & lmask;
rclr = clr & rmask;
lmask = ~lmask;
rmask = ~rmask;
height = ri->ri_font->fontheight;
rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
if (lmask != 0xffffffffU)
*dp++ = (*dp & lmask) | lclr;
for (cnt = nint; cnt; cnt--)
*dp++ = clr;
if (rmask != 0xffffffffU)
*dp = (*dp & rmask) | rclr;
}
}
/*
* Erase columns for fonts that are a multiple of 8 pels in width.
*/
static void
rasops1_erasecols8(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
long attr;
{
struct rasops_info *ri;
int32_t *dst;
u_char *dstb, *rp;
int clr, height, cnt, slop1, slop2;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
num = num * ri->ri_xscale;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
clr = rasops1_bg_color(attr);
height = ri->ri_font->fontheight;
slop1 = (int)rp & 3;
slop2 = (num - slop1) & 3;
num = (num - slop1 - slop2) >> 2;
while (height--) {
dstb = rp;
rp += ri->ri_stride;
/* Align span to 4 bytes */
for (cnt = slop1; cnt; cnt--)
*dstb++ = (u_char)clr;
dst = (int32_t *)dstb;
/* Write 4 bytes per loop */
for (cnt = num; cnt; cnt--)
*dst++ = clr;
/* Write unaligned trailing slop */
if (slop2 == 0)
continue;
dstb = (u_char *)dst;
for (cnt = slop2; cnt; cnt--)
*dstb++ = (u_char)clr;
}
}
/*
* Actually paint the cursor.
*/
static void
rasops1_do_cursor(ri)
struct rasops_info *ri;
{
int32_t *dp, *rp, lmask, rmask;
int height, row, col;
row = ri->ri_crow;
col = ri->ri_ccol * ri->ri_font->fontwidth;
/*
* lmask: mask for leftmost int32
* rmask: mask for rightmost int32
*/
lmask = leftmask[col & 31];
rmask = rightmask[(col + ri->ri_font->fontwidth) & 31];
/* Merge both masks if the span is encapsulated within one int32 */
if ((col & ~31) == ((col + ri->ri_font->fontwidth) & ~31)) {
lmask &= rmask;
rmask = 0;
}
lmask = ~lmask;
rmask = ~rmask;
height = ri->ri_font->fontheight;
rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
*dp++ = ((*dp & lmask) ^ lmask) | (*dp & ~lmask);
if (rmask != 0xffffffffU)
*dp = ((*dp & rmask) ^ rmask) | (*dp & ~rmask);
}
}
/*
* Paint cursors that are a multiple of 8 pels in size.
*/
static void
rasops1_do_cursor8(ri)
struct rasops_info *ri;
{
int width, height, cnt;
u_char *dp, *rp;
height = ri->ri_font->fontheight;
width = ri->ri_font->fontwidth >> 3;
rp = ri->ri_bits + ri->ri_crow * ri->ri_yscale +
ri->ri_ccol * ri->ri_xscale;
while (height--) {
dp = rp;
rp += ri->ri_stride;
for (cnt = width; cnt; cnt--)
*dp++ ^= 0xff;
}
}
/*
* Erase rows. This is easy.
*/
static void
rasops1_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
long attr;
{
struct rasops_info *ri;
int32_t *dp, clr;
int n8, n1, cnt;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if ((row + num) > ri->ri_rows)
num = ri->ri_rows - row;
if (num <= 0)
return;
#endif
num *= ri->ri_font->fontheight;
dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
clr = rasops1_bg_color(attr);
n8 = ri->ri_emustride >> 5;
n1 = (ri->ri_emustride >> 2) & 7;
while (num--) {
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
for (cnt = n1; cnt; cnt--)
*dp++ = clr;
DELTA(dp, ri->ri_delta, int32_t *);
}
}
/*
* Copy columns. This is slow. Ick! You'd better use a font with
* a width that's a multiple of 8 pels, otherwise this is used...
*/
static void
rasops1_copycols(cookie, row, src, dst, num)
void *cookie;
int row, src, dst, num;
{
panic("rasops1_copycols: i need implemention");
}
#endif /* RASOPS1 */
#include <dev/rasops/rasops_bitops.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops15.c,v 1.2 1999/04/13 00:40:09 ad Exp $ */
/* $NetBSD: rasops15.c,v 1.3 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -28,10 +28,8 @@
*/
#include "opt_rasops.h"
#ifdef RASOPS15
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.2 1999/04/13 00:40:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.3 1999/04/26 04:27:47 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -46,11 +44,7 @@ static void rasops15_putchar __P((void *, int, int, u_int, long attr));
static void rasops15_putchar8 __P((void *, int, int, u_int, long attr));
static void rasops15_putchar12 __P((void *, int, int, u_int, long attr));
static void rasops15_putchar16 __P((void *, int, int, u_int, long attr));
static void rasops15_erasecols __P((void *, int, int, int, long));
static void rasops15_eraserows __P((void *, int, int, long));
static void rasops15_makestamp __P((struct rasops_info *, long));
static int32_t rasops15_bg_color __P((struct rasops_info *, long));
static void rasops15_do_cursor __P((struct rasops_info *));
void rasops15_init __P((struct rasops_info *ri));
@ -94,13 +88,12 @@ rasops15_init(ri)
case 16:
ri->ri_ops.putchar = rasops15_putchar16;
break;
default:
ri->ri_ops.putchar = rasops15_putchar;
break;
}
/* Select defaults for color masks if none selected */
if (ri->ri_rnum == 0) {
ri->ri_rnum = 5;
ri->ri_rpos = 0;
@ -109,148 +102,6 @@ rasops15_init(ri)
ri->ri_bnum = 5;
ri->ri_bpos = 10 + (ri->ri_depth == 16);
}
ri->ri_ops.erasecols = rasops15_erasecols;
ri->ri_ops.eraserows = rasops15_eraserows;
ri->ri_do_cursor = rasops15_do_cursor;
rasops_init_devcmap(ri);
}
/*
* Get background color from attribute and copy across all 4 bytes
* in a int32_t.
*/
static __inline__ int32_t
rasops15_bg_color(ri, attr)
struct rasops_info *ri;
long attr;
{
int32_t bg;
bg = ri->ri_devcmap[((u_int)attr >> 16) & 15];
return bg | (bg << 16);
}
/*
* Actually turn the cursor on or off. This does the dirty work for
* rasops_cursor().
*/
static void
rasops15_do_cursor(ri)
struct rasops_info *ri;
{
u_char *rp, *dp;
int full1, height, cnt, slop1, slop2, row, col;
int32_t planemask;
row = ri->ri_crow;
col = ri->ri_ccol;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
slop1 = (int)rp & 2;
slop2 = (ri->ri_xscale - slop1) & 2;
full1 = (ri->ri_xscale - slop1 - slop2) >> 2;
planemask = ri->ri_devcmap[15] | (ri->ri_devcmap[15] << 16);
while (height--) {
dp = rp;
rp += ri->ri_stride;
if (slop1) {
*(int16_t *)dp ^= (int16_t)planemask;
dp += 2;
}
for (cnt = full1; cnt; cnt--) {
*(int32_t *)dp ^= planemask;
dp += 4;
}
if (slop2)
*(int16_t *)dp ^= (int16_t)planemask;
}
}
/*
* Erase columns.
*/
static void
rasops15_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, num;
long attr;
{
int n8, clr, height, cnt, slop1, slop2;
struct rasops_info *ri;
int32_t *dp;
u_char *rp;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
num *= ri->ri_xscale;
clr = rasops15_bg_color(ri, attr);
height = ri->ri_font->fontheight;
slop1 = (int)rp & 2;
slop2 = (num - slop1) & 2;
num = num - slop1 - slop2;
n8 = num >> 5;
num = (num >> 2) & 7;
while (height--) {
dp = (u_int32_t *)rp;
rp += ri->ri_stride;
/* Align span to 4 bytes */
if (slop1) {
*(int16_t *)dp = (int16_t)clr;
DELTA(dp, 2, int32_t *);
}
/* Write 32 bytes per loop */
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
/* Write 4 bytes per loop */
for (cnt = num; cnt; cnt--)
*dp++ = clr;
/* Write unaligned trailing slop */
if (slop2)
*(int16_t *)dp = (int16_t)clr;
}
}
@ -268,11 +119,6 @@ rasops15_putchar(cookie, row, col, uc, attr)
int fb, width, height, cnt, clr[2];
u_char *dp, *rp, *fr;
if (uc == (u_int)-1) {
rasops15_erasecols(cookie, row, col, 1, attr);
return;
}
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
@ -284,26 +130,48 @@ rasops15_putchar(cookie, row, col, uc, attr)
return;
#endif
uc -= ri->ri_font->firstchar;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
height = ri->ri_font->fontheight;
width = ri->ri_font->fontwidth;
clr[1] = ri->ri_devcmap[((u_int)attr >> 24) & 15];
clr[0] = ri->ri_devcmap[((u_int)attr >> 16) & 15];
while (height--) {
dp = rp;
fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) | (fr[0] << 24);
fr += ri->ri_font->stride;
rp += ri->ri_stride;
if (uc == ' ') {
while (height--) {
dp = rp;
rp += ri->ri_stride;
for (cnt = width; cnt; cnt--) {
*(int16_t *)dp = (int16_t)clr[(fb >> 31) & 1];
fb <<= 1;
dp += 2;
for (cnt = width; cnt; cnt--) {
*(int16_t *)dp = (int16_t)clr[0];
dp += 2;
}
}
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
while (height--) {
dp = rp;
fb = fr[3] | (fr[2] << 8) | (fr[1] << 16) | (fr[0] << 24);
fr += ri->ri_font->stride;
rp += ri->ri_stride;
for (cnt = width; cnt; cnt--) {
*(int16_t *)dp = (int16_t)clr[(fb >> 31) & 1];
fb <<= 1;
dp += 2;
}
}
}
/* Do underline */
if (attr & 1) {
rp -= ri->ri_stride << 1;
while (width--) {
*(int16_t *)rp = clr[1];
rp += 2;
}
}
}
@ -320,21 +188,21 @@ rasops15_makestamp(ri, attr)
int32_t fg, bg;
int i;
fg = ri->ri_devcmap[((u_int)attr >> 24) & 15];
bg = ri->ri_devcmap[((u_int)attr >> 16) & 15];
fg = ri->ri_devcmap[((u_int)attr >> 24) & 15] & 0xffff;
bg = ri->ri_devcmap[((u_int)attr >> 16) & 15] & 0xffff;
stamp_attr = attr;
for (i = 0; i < 16; i++) {
for (i = 0; i < 32; i += 2) {
#if BYTE_ORDER == LITTLE_ENDIAN
stamp[i << 1] = (i & 8 ? fg : bg);
stamp[i << 1] |= ((i & 4 ? fg : bg) << 16);
stamp[(i << 1) + 1] = (i & 2 ? fg : bg);
stamp[(i << 1) + 1] |= ((i & 1 ? fg : bg) << 16);
stamp[i] = (i & 16 ? fg : bg);
stamp[i] |= ((i & 8 ? fg : bg) << 16);
stamp[i + 1] = (i & 4 ? fg : bg);
stamp[i + 1] |= ((i & 2 ? fg : bg) << 16);
#else
stamp[i << 1] = (i & 1 ? fg : bg);
stamp[i << 1] |= ((i & 2 ? fg : bg) << 16);
stamp[(i << 1) + 1] = (i & 4 ? fg : bg);
stamp[(i << 1) + 1] |= ((i & 8 ? fg : bg) << 16);
stamp[i] = (i & 2 ? fg : bg);
stamp[i] |= ((i & 4 ? fg : bg) << 16);
stamp[i + 1] = (i & 8 ? fg : bg);
stamp[i + 1] |= ((i & 16 ? fg : bg) << 16);
#endif
}
}
@ -409,6 +277,15 @@ rasops15_putchar8(cookie, row, col, uc, attr)
DELTA(rp, ri->ri_stride, int32_t *);
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
rp[0] = STAMP_READ(30);
rp[1] = STAMP_READ(30);
rp[2] = STAMP_READ(30);
rp[3] = STAMP_READ(30);
}
stamp_mutex--;
}
@ -489,6 +366,17 @@ rasops15_putchar12(cookie, row, col, uc, attr)
DELTA(rp, ri->ri_stride, int32_t *);
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
rp[0] = STAMP_READ(30);
rp[1] = STAMP_READ(30);
rp[2] = STAMP_READ(30);
rp[3] = STAMP_READ(30);
rp[4] = STAMP_READ(30);
rp[5] = STAMP_READ(30);
}
stamp_mutex--;
}
@ -575,64 +463,19 @@ rasops15_putchar16(cookie, row, col, uc, attr)
fr += fs;
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
rp[0] = STAMP_READ(30);
rp[1] = STAMP_READ(30);
rp[2] = STAMP_READ(30);
rp[3] = STAMP_READ(30);
rp[4] = STAMP_READ(30);
rp[5] = STAMP_READ(30);
rp[6] = STAMP_READ(30);
rp[7] = STAMP_READ(30);
}
stamp_mutex--;
}
/*
* Erase rows.
*/
static void
rasops15_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
long attr;
{
struct rasops_info *ri;
int32_t *dp, clr;
int n8, n1, cnt;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if ((row + num) > ri->ri_rows)
num = ri->ri_rows - row;
if (num <= 0)
return;
#endif
num *= ri->ri_font->fontheight;
dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
clr = rasops15_bg_color(ri, attr);
n8 = ri->ri_emustride >> 5;
n1 = (ri->ri_emustride >> 2) & 7;
while (num--) {
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
for (cnt = n1; cnt; cnt--)
*dp++ = clr;
DELTA(dp, ri->ri_delta, int32_t *);
}
}
#endif /* RASOPS15 */

473
sys/dev/rasops/rasops2.c Normal file
View File

@ -0,0 +1,473 @@
/* $NetBSD: rasops2.c,v 1.1 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "opt_rasops.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.1 1999/04/26 04:27:47 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <machine/endian.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsconsio.h>
#include <dev/rasops/rasops.h>
#include <dev/rasops/rasops_masks.h>
static void rasops2_putchar __P((void *, int, int col, u_int, long));
static void rasops2_putchar8 __P((void *, int, int col, u_int, long));
static void rasops2_putchar12 __P((void *, int, int col, u_int, long));
static void rasops2_putchar16 __P((void *, int, int col, u_int, long));
static void rasops2_copycols __P((void *, int, int, int, int));
static void rasops2_erasecols __P((void *, int, int, int, long));
static void rasops2_do_cursor __P((struct rasops_info *));
static void rasops2_makestamp __P((struct rasops_info *, long));
void rasops2_init __P((struct rasops_info *ri));
/*
* 4x1 stamp for optimized character blitting
*/
static int8_t stamp[16];
static long stamp_attr;
static int stamp_mutex; /* XXX see note in README */
/*
* Initialize rasops_info struct for this colordepth.
*/
void
rasops2_init(ri)
struct rasops_info *ri;
{
switch (ri->ri_font->fontwidth) {
case 8:
ri->ri_ops.putchar = rasops2_putchar8;
break;
case 12:
ri->ri_ops.putchar = rasops2_putchar12;
break;
case 16:
ri->ri_ops.putchar = rasops2_putchar16;
break;
default:
panic("fontwidth not 8/12/16 - fixme!");
ri->ri_ops.putchar = rasops2_putchar;
break;
}
if (ri->ri_font->fontwidth & 3) {
ri->ri_ops.erasecols = rasops2_erasecols;
ri->ri_ops.copycols = rasops2_copycols;
ri->ri_do_cursor = rasops2_do_cursor;
}
}
/*
* Recompute the blitting stamp.
*/
static void
rasops2_makestamp(ri, attr)
struct rasops_info *ri;
long attr;
{
int i;
int32_t fg, bg;
fg = ri->ri_devcmap[(attr >> 24) & 15] & 3;
bg = ri->ri_devcmap[(attr >> 16) & 15] & 3;
stamp_attr = attr;
for (i = 0; i < 16; i++) {
stamp[i] = (i & 1 ? fg : bg);
stamp[i] |= (i & 2 ? fg : bg) << 2;
stamp[i] |= (i & 4 ? fg : bg) << 4;
stamp[i] |= (i & 8 ? fg : bg) << 6;
}
}
#if 0
/*
* Paint a single character. This is the generic version, this is ugly.
*/
static void
rasops2_putchar(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
int height, width, fs, rs, fb, bg, fg, lmask, rmask;
struct rasops_info *ri;
int32_t *rp;
u_char *fr;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if ((unsigned)col >= (unsigned)ri->ri_cols)
return;
#endif
width = ri->ri_font->fontwidth << 1;
height = ri->ri_font->fontheight;
col *= width;
rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
col = col & 31;
rs = ri->ri_stride;
bg = ri->ri_devcmap[(attr >> 16) & 15];
fg = ri->ri_devcmap[(attr >> 24) & 15];
/* If fg and bg match this becomes a space character */
if (fg == bg || uc == ' ') {
uc = (u_int)-1;
fr = 0; /* shutup gcc */
fs = 0; /* shutup gcc */
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
fs = ri->ri_font->stride;
}
/* Single word, one mask */
if ((col + width) <= 32) {
rmask = rasops_pmask[col][width];
lmask = ~rmask;
if (uc == (u_int)-1) {
bg &= rmask;
while (height--) {
*rp = (*rp & lmask) | bg;
DELTA(rp, rs, int32_t *);
}
} else {
while (height--) {
/* get bits, mask */
/* compose sl */
/* mask sl */
/* put word */
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
*rp = (*rp & lmask) | (fg & rmask);
}
} else {
lmask = ~rasops_lmask[col];
rmask = ~rasops_rmask[(col + width) & 31];
if (uc == (u_int)-1) {
bg = bg & ~lmask;
width = bg & ~rmask;
while (height--) {
rp[0] = (rp[0] & lmask) | bg;
rp[1] = (rp[1] & rmask) | width;
DELTA(rp, rs, int32_t *);
}
} else {
width = 32 - col;
/* NOT fontbits if bg is white */
while (height--) {
fb = ~(fr[3] | (fr[2] << 8) |
(fr[1] << 16) | (fr[0] << 24));
rp[0] = (rp[0] & lmask)
| MBE((u_int)fb >> col);
rp[1] = (rp[1] & rmask)
| (MBE((u_int)fb << width) & ~rmask);
fr += fs;
DELTA(rp, rs, int32_t *);
}
}
/* Do underline */
if (attr & 1) {
DELTA(rp, -(ri->ri_stride << 1), int32_t *);
rp[0] = (rp[0] & lmask) | (fg & ~lmask);
rp[1] = (rp[1] & rmask) | (fg & ~rmask);
}
}
}
#endif
/*
* Put a single character. This is the generic version.
*/
static void
rasops2_putchar(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
/* XXX punt */
}
/*
* Put a single character. This is for 8-pixel wide fonts.
*/
static void
rasops2_putchar8(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
struct rasops_info *ri;
int height, fs, rs;
u_char *fr, *rp;
/* Can't risk remaking the stamp if it's already in use */
if (stamp_mutex++) {
stamp_mutex--;
rasops2_putchar(cookie, row, col, uc, attr);
return;
}
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows) {
stamp_mutex--;
return;
}
if ((unsigned)col >= (unsigned)ri->ri_cols) {
stamp_mutex--;
return;
}
#endif
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
/* Recompute stamp? */
if (attr != stamp_attr)
rasops2_makestamp(ri, attr);
if (uc == ' ') {
while (height--) {
*(int16_t *)rp = stamp[0];
rp += rs;
}
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
fs = ri->ri_font->stride;
while (height--) {
rp[0] = stamp[(*fr >> 4) & 15];
rp[1] = stamp[*fr & 15];
fr += fs;
rp += rs;
}
}
/* Do underline */
if (attr & 1)
*(int16_t *)(rp - (ri->ri_stride << 1)) = stamp[15];
stamp_mutex--;
}
/*
* Put a single character. This is for 12-pixel wide fonts.
*/
static void
rasops2_putchar12(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
struct rasops_info *ri;
int height, fs, rs;
u_char *fr, *rp;
/* Can't risk remaking the stamp if it's already in use */
if (stamp_mutex++) {
stamp_mutex--;
rasops2_putchar(cookie, row, col, uc, attr);
return;
}
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows) {
stamp_mutex--;
return;
}
if ((unsigned)col >= (unsigned)ri->ri_cols) {
stamp_mutex--;
return;
}
#endif
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
/* Recompute stamp? */
if (attr != stamp_attr)
rasops2_makestamp(ri, attr);
if (uc == ' ') {
while (height--) {
rp[0] = stamp[0];
rp[1] = stamp[0];
rp[2] = stamp[0];
rp += rs;
}
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
fs = ri->ri_font->stride;
while (height--) {
rp[0] = stamp[(fr[0] >> 4) & 15];
rp[1] = stamp[fr[0] & 15];
rp[2] = stamp[(fr[1] >> 4) & 15];
fr += fs;
rp += rs;
}
}
/* Do underline */
if (attr & 1) {
rp -= ri->ri_stride << 1;
rp[0] = stamp[15];
rp[1] = stamp[15];
rp[2] = stamp[15];
}
stamp_mutex--;
}
/*
* Put a single character. This is for 16-pixel wide fonts.
*/
static void
rasops2_putchar16(cookie, row, col, uc, attr)
void *cookie;
int row, col;
u_int uc;
long attr;
{
struct rasops_info *ri;
int height, fs, rs;
u_char *fr, *rp;
/* Can't risk remaking the stamp if it's already in use */
if (stamp_mutex++) {
stamp_mutex--;
rasops2_putchar(cookie, row, col, uc, attr);
return;
}
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
/* Catches 'row < 0' case too */
if ((unsigned)row >= (unsigned)ri->ri_rows) {
stamp_mutex--;
return;
}
if ((unsigned)col >= (unsigned)ri->ri_cols) {
stamp_mutex--;
return;
}
#endif
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
rs = ri->ri_stride;
/* Recompute stamp? */
if (attr != stamp_attr)
rasops2_makestamp(ri, attr);
if (uc == ' ') {
while (height--) {
*(int32_t *)rp = stamp[0];
rp += rs;
}
} else {
uc -= ri->ri_font->firstchar;
fr = (u_char *)ri->ri_font->data + uc * ri->ri_fontscale;
fs = ri->ri_font->stride;
while (height--) {
rp[0] = stamp[(fr[0] >> 4) & 15];
rp[1] = stamp[fr[0] & 15];
rp[2] = stamp[(fr[1] >> 4) & 15];
rp[3] = stamp[fr[1] & 15];
fr += fs;
rp += rs;
}
}
/* Do underline */
if (attr & 1)
*(int32_t *)(rp - (ri->ri_stride << 1)) = stamp[15];
stamp_mutex--;
}
/*
* Grab routines common to depths where (bpp < 8)
*/
#define NAME(ident) rasops2_##ident
#define PIXEL_SHIFT 1
#include <dev/rasops/rasops_bitops.h>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops32.c,v 1.2 1999/04/13 00:40:09 ad Exp $ */
/* $NetBSD: rasops32.c,v 1.3 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -28,10 +28,8 @@
*/
#include "opt_rasops.h"
#ifdef RASOPS32
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.2 1999/04/13 00:40:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.3 1999/04/26 04:27:47 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -43,13 +41,9 @@ __KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.2 1999/04/13 00:40:09 ad Exp $");
#include <dev/rasops/rasops.h>
static void rasops32_putchar __P((void *, int, int, u_int, long attr));
static void rasops32_erasecols __P((void *, int, int, int, long));
static void rasops32_eraserows __P((void *, int, int, long));
static int32_t rasops32_fg_color __P((struct rasops_info *, long));
static int32_t rasops32_bg_color __P((struct rasops_info *, long));
static void rasops32_do_cursor __P((struct rasops_info *));
void rasops32_init __P((struct rasops_info *ri));
/*
* Initalize a 'rasops_info' descriptor for this depth.
*/
@ -57,74 +51,17 @@ void
rasops32_init(ri)
struct rasops_info *ri;
{
/*
* This sucks. There is little optimization you can do with this
* colordepth on 32-bit machines.
*
* XXX c'mon sparc, alpha ppl?
*/
ri->ri_ops.putchar = rasops32_putchar;
ri->ri_ops.erasecols = rasops32_erasecols;
ri->ri_ops.eraserows = rasops32_eraserows;
ri->ri_do_cursor = rasops32_do_cursor;
rasops_init_devcmap(ri);
}
/*
* Get background color from attribute.
*/
static __inline__ int32_t
rasops32_bg_color(ri, attr)
struct rasops_info *ri;
long attr;
{
return ri->ri_devcmap[((int32_t)attr >> 24) & 15];
}
/*
* Get foreground color from attribute.
*/
static __inline__ int32_t
rasops32_fg_color(ri, attr)
struct rasops_info *ri;
long attr;
{
return ri->ri_devcmap[((int32_t)attr >> 16) & 15];
}
/*
* Actually turn the cursor on or off. This does the dirty work for
* rasops_cursor().
*/
static void
rasops32_do_cursor(ri)
struct rasops_info *ri;
{
u_char *rp;
int32_t *dp, planemask;
int num, height, cnt, row, col;
row = ri->ri_crow;
col = ri->ri_ccol;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
num = ri->ri_xscale >> 2;
planemask = ri->ri_devcmap[15];
while (height--) {
dp = (int32_t *)rp;
rp += ri->ri_stride;
for (cnt = num; cnt; cnt--)
*dp++ ^= planemask;
if (ri->ri_rnum == 0) {
ri->ri_rnum = 8;
ri->ri_rpos = 0;
ri->ri_gnum = 8;
ri->ri_gpos = 8;
ri->ri_bnum = 8;
ri->ri_bpos = 16;
}
ri->ri_ops.putchar = rasops32_putchar;
}
@ -158,8 +95,9 @@ rasops32_putchar(cookie, row, col, uc, attr)
height = ri->ri_font->fontheight;
width = ri->ri_font->fontwidth;
clr[0] = rasops32_bg_color(ri, attr);
clr[1] = rasops32_fg_color(ri, attr);
clr[0] = ri->ri_devcmap[(attr >> 16) & 15];
clr[1] = ri->ri_devcmap[(attr >> 24) & 15];
if (uc == ' ') {
while (height--) {
@ -195,122 +133,3 @@ rasops32_putchar(cookie, row, col, uc, attr)
*rp++ = clr[1];
}
}
/*
* Erase rows.
*/
static void
rasops32_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
long attr;
{
struct rasops_info *ri;
int32_t *dp, clr;
int n8, n1, cnt;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if ((row + num) > ri->ri_rows)
num = ri->ri_rows - row;
if (num <= 0)
return;
#endif
num *= ri->ri_font->fontheight;
dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
clr = rasops32_bg_color(ri, attr);
n8 = ri->ri_emustride >> 5;
n1 = (ri->ri_emustride >> 2) & 7;
while (num--) {
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
for (cnt = n1; cnt; cnt--)
*dp++ = clr;
DELTA(dp, ri->ri_delta, int32_t *);
}
}
/*
* Erase columns.
*/
static void
rasops32_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
long attr;
{
int n8, clr, height, cnt;
struct rasops_info *ri;
int32_t *dst;
u_char *rp;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
num = num * ri->ri_xscale;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
clr = rasops32_bg_color(ri, attr);
height = ri->ri_font->fontheight;
n8 = num >> 5;
num = (num >> 2) & 7;
while (height--) {
dst = (int32_t *)rp;
rp += ri->ri_stride;
for (cnt = n8; cnt; cnt--) {
dst[0] = clr;
dst[1] = clr;
dst[2] = clr;
dst[3] = clr;
dst[4] = clr;
dst[5] = clr;
dst[6] = clr;
dst[7] = clr;
dst += 8;
}
for (cnt = num; cnt; cnt--)
*dst++ = clr;
}
}
#endif /* RASOPS32 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rasops8.c,v 1.2 1999/04/13 00:40:09 ad Exp $ */
/* $NetBSD: rasops8.c,v 1.3 1999/04/26 04:27:47 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
@ -28,10 +28,8 @@
*/
#include "opt_rasops.h"
#ifdef RASOPS8
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.2 1999/04/13 00:40:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.3 1999/04/26 04:27:47 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -46,11 +44,7 @@ static void rasops8_putchar __P((void *, int, int, u_int, long attr));
static void rasops8_putchar8 __P((void *, int, int, u_int, long attr));
static void rasops8_putchar12 __P((void *, int, int, u_int, long attr));
static void rasops8_putchar16 __P((void *, int, int, u_int, long attr));
static void rasops8_erasecols __P((void *, int, int, int, long));
static void rasops8_eraserows __P((void *, int, int, long));
static void rasops8_makestamp __P((long));
static int32_t rasops8_bg_color __P((long));
static void rasops8_do_cursor __P((struct rasops_info *));
void rasops8_init __P((struct rasops_info *ri));
/*
@ -92,74 +86,16 @@ rasops8_init(ri)
case 16:
ri->ri_ops.putchar = rasops8_putchar16;
break;
default:
ri->ri_ops.putchar = rasops8_putchar;
break;
}
ri->ri_ops.erasecols = rasops8_erasecols;
ri->ri_ops.eraserows = rasops8_eraserows;
ri->ri_do_cursor = rasops8_do_cursor;
}
/*
* Get background color from attribute and copy across all 4 bytes
* of an int32_t.
*/
static __inline__ int32_t
rasops8_bg_color(attr)
long attr;
{
int32_t bg;
bg = ((int32_t)attr >> 16) & 15;
return bg | (bg << 8) | (bg << 16) | (bg << 24);
}
/*
* Actually turn the cursor on or off. This does the dirty work for
* rasops_cursor().
*/
static void
rasops8_do_cursor(ri)
struct rasops_info *ri;
{
u_char *dp, *rp;
int full1, height, cnt, slop1, slop2, row, col;
row = ri->ri_crow;
col = ri->ri_ccol;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
height = ri->ri_font->fontheight;
slop1 = (int)rp & 3;
slop2 = (ri->ri_xscale - slop1) & 3;
full1 = (ri->ri_xscale - slop1 - slop2) >> 2;
while (height--) {
dp = rp;
rp += ri->ri_stride;
for (cnt = slop1; cnt; cnt--)
*dp++ ^= 0xff;
for (cnt = full1; cnt; cnt--) {
*(int32_t *)dp ^= 0xffffffff;
dp += 4;
}
for (cnt = slop2; cnt; cnt--)
*dp++ ^= 0xff;
}
}
/*
* Paint a single character.
* Put a single character.
*/
static void
rasops8_putchar(cookie, row, col, uc, attr)
@ -222,7 +158,6 @@ rasops8_putchar(cookie, row, col, uc, attr)
while (width--)
*rp++ = clr[1];
}
}
@ -230,7 +165,8 @@ rasops8_putchar(cookie, row, col, uc, attr)
* Recompute the 4x1 blitting stamp.
*/
static void
rasops8_makestamp(long attr)
rasops8_makestamp(attr)
long attr;
{
int i;
int32_t fg, bg;
@ -256,7 +192,7 @@ rasops8_makestamp(long attr)
/*
* Paint a single character. This is for 8-pixel wide fonts.
* Put a single character. This is for 8-pixel wide fonts.
*/
static void
rasops8_putchar8(cookie, row, col, uc, attr)
@ -330,7 +266,7 @@ rasops8_putchar8(cookie, row, col, uc, attr)
/*
* Paint a single character. This is for 12-pixel wide fonts.
* Put a single character. This is for 12-pixel wide fonts.
*/
static void
rasops8_putchar12(cookie, row, col, uc, attr)
@ -407,7 +343,7 @@ rasops8_putchar12(cookie, row, col, uc, attr)
/*
* Paint a single character. This is for 16-pixel wide fonts.
* Put a single character. This is for 16-pixel wide fonts.
*/
static void
rasops8_putchar16(cookie, row, col, uc, attr)
@ -484,143 +420,3 @@ rasops8_putchar16(cookie, row, col, uc, attr)
stamp_mutex--;
}
/*
* Erase rows.
*/
static void
rasops8_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
long attr;
{
struct rasops_info *ri;
int32_t *dp, clr;
int n8, n1, cnt;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (row < 0) {
num += row;
row = 0;
}
if ((row + num) > ri->ri_rows)
num = ri->ri_rows - row;
if (num <= 0)
return;
#endif
num *= ri->ri_font->fontheight;
dp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale);
clr = rasops8_bg_color(attr);
n8 = ri->ri_emustride >> 5;
n1 = (ri->ri_emustride >> 2) & 7;
while (num--) {
for (cnt = n8; cnt; cnt--) {
dp[0] = clr;
dp[1] = clr;
dp[2] = clr;
dp[3] = clr;
dp[4] = clr;
dp[5] = clr;
dp[6] = clr;
dp[7] = clr;
dp += 8;
}
for (cnt = n1; cnt; cnt--)
*dp++ = clr;
DELTA(dp, ri->ri_delta, int32_t *);
}
}
/*
* Erase columns.
*/
static void
rasops8_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
long attr;
{
int n8, clr, height, cnt, slop1, slop2;
struct rasops_info *ri;
int32_t *dst;
u_char *dstb, *rp;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
num = num * ri->ri_xscale;
rp = ri->ri_bits + row * ri->ri_yscale + col * ri->ri_xscale;
clr = rasops8_bg_color(attr);
height = ri->ri_font->fontheight;
slop1 = (int)rp & 3;
slop2 = (num - slop1) & 3;
num -= slop1 + slop2;
n8 = num >> 5;
num = (num >> 2) & 7;
while (height--) {
dstb = rp;
rp += ri->ri_stride;
/* Align span to 4 bytes */
for (cnt = slop1; cnt; cnt--)
*dstb++ = (u_char)clr;
dst = (int32_t *)dstb;
/* Write 32 bytes per loop */
for (cnt = n8; cnt; cnt--) {
dst[0] = clr;
dst[1] = clr;
dst[2] = clr;
dst[3] = clr;
dst[4] = clr;
dst[5] = clr;
dst[6] = clr;
dst[7] = clr;
dst += 8;
}
/* Write 4 bytes per loop */
for (cnt = num; cnt; cnt--)
*dst++ = clr;
/* Write unaligned trailing slop */
if (slop2 == 0)
continue;
dstb = (u_char *)dst;
for (cnt = slop2; cnt; cnt--)
*dstb++ = (u_char)clr;
}
}
#endif /* RASOPS8 */

View File

@ -0,0 +1,304 @@
/* $NetBSD: rasops_bitops.h,v 1.1 1999/04/26 04:27:48 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _RASOPS_BITOPS_H_
#define _RASOPS_BITOPS_H_ 1
/*
* Erase columns.
*/
static void
NAME(erasecols)(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
long attr;
{
int32_t *dp, *rp, lmask, rmask, lclr, rclr, clr;
struct rasops_info *ri;
int height, cnt;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (col < 0) {
num += col;
col = 0;
}
if ((col + num) > ri->ri_cols)
num = ri->ri_cols - col;
if (num <= 0)
return;
#endif
col *= ri->ri_font->fontwidth << PIXEL_SHIFT;
num *= ri->ri_font->fontwidth << PIXEL_SHIFT;
height = ri->ri_font->fontheight;
clr = ri->ri_devcmap[(attr >> 16) & 15];
rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
if ((col & 31) + num <= 32) {
lmask = ~rasops_pmask[col & 31][num];
lclr = clr & ~lmask;
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
*dp = (*dp & lmask) | lclr;
}
} else {
lmask = rasops_rmask[col & 31];
rmask = rasops_lmask[(col + num) & 31];
if (lmask)
num = (num - (32 - (col & 31))) >> 5;
else
num = num >> 5;
lclr = clr & ~lmask;
rclr = clr & ~rmask;
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
if (lmask)
*dp++ = (*dp & lmask) | lclr;
for (cnt = num; cnt > 0; cnt--)
*dp++ = clr;
if (rmask)
*dp = (*dp & rmask) | rclr;
}
}
}
/*
* Actually paint the cursor.
*/
static void
NAME(do_cursor)(ri)
struct rasops_info *ri;
{
int32_t *dp, *rp, lmask, rmask;
int height, row, col, num;
row = ri->ri_crow;
col = ri->ri_ccol * ri->ri_font->fontwidth << PIXEL_SHIFT;
height = ri->ri_font->fontheight;
num = ri->ri_font->fontwidth << PIXEL_SHIFT;
rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
if ((col & 31) + num <= 32) {
lmask = rasops_pmask[col & 31][num];
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
*dp ^= lmask;
}
} else {
lmask = ~rasops_rmask[col & 31];
rmask = ~rasops_lmask[(col + num) & 31];
while (height--) {
dp = rp;
DELTA(rp, ri->ri_stride, int32_t *);
if (lmask != -1)
*dp++ ^= lmask;
if (rmask != -1)
*dp ^= rmask;
}
}
}
/*
* Copy columns. This is slow. Ick!
*/
static void
NAME(copycols)(cookie, row, src, dst, num)
void *cookie;
int row, src, dst, num;
{
int32_t *sp, *dp, *srp, *drp, tmp, lmask, rmask;
int height, lnum, rnum, sb, db, cnt, full;
struct rasops_info *ri;
ri = (struct rasops_info *)cookie;
#ifdef RASOPS_CLIPPING
if (dst == src)
return;
/* Catches < 0 case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
return;
if (src < 0) {
num += src;
src = 0;
}
if ((src + num) > ri->ri_cols)
num = ri->ri_cols - src;
if (dst < 0) {
num += dst;
dst = 0;
}
if ((dst + num) > ri->ri_cols)
num = ri->ri_cols - dst;
if (num <= 0)
return;
#endif
cnt = ri->ri_font->fontwidth << PIXEL_SHIFT;
src *= cnt;
dst *= cnt;
num *= cnt;
row *= ri->ri_yscale;
height = ri->ri_font->fontheight;
if (db + num <= 32) {
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
sb = src & 31;
db = dst & 31;
while (height--) {
GETBITS(srp, sb, num, tmp);
PUTBITS(tmp, db, num, drp);
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
}
return;
}
lmask = rasops_rmask[dst & 31];
rmask = rasops_lmask[(dst + num) & 31];
lnum = (lmask ? 32 - db : 0);
rnum = (rmask ? (dst + num) & 31 : 0);
sb = src < dst && src + num > dst;
if (lmask)
full = (num - (32 - (dst & 31))) >> 5;
else
full = num >> 5;
if (sb) {
/* Go backwards */
/* XXX this is broken! */
src = src + num;
dst = dst + num;
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
src = src & 31;
db = dst & 31;
while (height--) {
sb = src;
sp = srp;
dp = drp;
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
if (db) {
GETBITS(sp, sb, db, tmp);
PUTBITS(tmp, db, db, dp);
dp--;
if ((sb -= rnum) < 0) {
sp--;
sb += 32;
}
}
/* Now we're aligned to 32-bits with dp :) */
for (cnt = full; cnt; cnt--, sp--) {
GETBITS(sp, sb, 32, tmp);
*dp-- = tmp;
}
if (lmask) {
GETBITS(sp, sb, rnum, tmp);
PUTBITS(tmp, 0, rnum, dp);
}
}
} else {
srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
db = dst & 31;
while (height--) {
sb = src & 31;
sp = srp;
dp = drp;
DELTA(srp, ri->ri_stride, int32_t *);
DELTA(drp, ri->ri_stride, int32_t *);
if (lmask) {
GETBITS(sp, sb, lnum, tmp);
PUTBITS(tmp, db, lnum, dp);
dp++;
if ((sb += lnum) > 31) {
sp++;
sb -= 32;
}
}
/* Now we're aligned to 32-bits with dp :) */
for (cnt = full; cnt; cnt--) {
GETBITS(sp, sb, 32, tmp);
*dp++ = tmp;
sp++;
}
if (rmask) {
GETBITS(sp, sb, rnum, tmp);
PUTBITS(tmp, 0, rnum, dp);
}
}
}
}
#endif /* _RASOPS_BITOPS_H_ */

View File

@ -0,0 +1,358 @@
/* $NetBSD: rasops_masks.c,v 1.1 1999/04/26 04:27:48 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include "rasops_masks.h"
/* `ragged edge' bitmasks */
int32_t rasops_lmask[32+1] = {
MBE(0x00000000), MBE(0x7fffffff), MBE(0x3fffffff), MBE(0x1fffffff),
MBE(0x0fffffff), MBE(0x07ffffff), MBE(0x03ffffff), MBE(0x01ffffff),
MBE(0x00ffffff), MBE(0x007fffff), MBE(0x003fffff), MBE(0x001fffff),
MBE(0x000fffff), MBE(0x0007ffff), MBE(0x0003ffff), MBE(0x0001ffff),
MBE(0x0000ffff), MBE(0x00007fff), MBE(0x00003fff), MBE(0x00001fff),
MBE(0x00000fff), MBE(0x000007ff), MBE(0x000003ff), MBE(0x000001ff),
MBE(0x000000ff), MBE(0x0000007f), MBE(0x0000003f), MBE(0x0000001f),
MBE(0x0000000f), MBE(0x00000007), MBE(0x00000003), MBE(0x00000001),
MBE(0x00000000)
};
int32_t rasops_rmask[32+1] = {
MBE(0x00000000), MBE(0x80000000), MBE(0xc0000000), MBE(0xe0000000),
MBE(0xf0000000), MBE(0xf8000000), MBE(0xfc000000), MBE(0xfe000000),
MBE(0xff000000), MBE(0xff800000), MBE(0xffc00000), MBE(0xffe00000),
MBE(0xfff00000), MBE(0xfff80000), MBE(0xfffc0000), MBE(0xfffe0000),
MBE(0xffff0000), MBE(0xffff8000), MBE(0xffffc000), MBE(0xffffe000),
MBE(0xfffff000), MBE(0xfffff800), MBE(0xfffffc00), MBE(0xfffffe00),
MBE(0xffffff00), MBE(0xffffff80), MBE(0xffffffc0), MBE(0xffffffe0),
MBE(0xfffffff0), MBE(0xfffffff8), MBE(0xfffffffc), MBE(0xfffffffe),
MBE(0xffffffff)
};
#ifdef notyet
/* `ragged edge' bytemasks */
int32_t rasops_lbmask[4+1] = {
MBE(0x00000000), MBE(0x00ffffff), MBE(0x0000ffff), MBE(0x000000ff),
MBE(0x00000000)
};
int32_t rasops_rbmask[4+1] = {
MBE(0x00000000), MBE(0xff000000), MBE(0xffff0000), MBE(0xffffff00),
MBE(0xffffffff)
};
#endif
/* Part bitmasks */
int32_t rasops_pmask[32][32] = {
{ MBE(0xffffffff), MBE(0x80000000), MBE(0xc0000000), MBE(0xe0000000),
MBE(0xf0000000), MBE(0xf8000000), MBE(0xfc000000), MBE(0xfe000000),
MBE(0xff000000), MBE(0xff800000), MBE(0xffc00000), MBE(0xffe00000),
MBE(0xfff00000), MBE(0xfff80000), MBE(0xfffc0000), MBE(0xfffe0000),
MBE(0xffff0000), MBE(0xffff8000), MBE(0xffffc000), MBE(0xffffe000),
MBE(0xfffff000), MBE(0xfffff800), MBE(0xfffffc00), MBE(0xfffffe00),
MBE(0xffffff00), MBE(0xffffff80), MBE(0xffffffc0), MBE(0xffffffe0),
MBE(0xfffffff0), MBE(0xfffffff8), MBE(0xfffffffc), MBE(0xfffffffe), },
{ MBE(0x00000000), MBE(0x40000000), MBE(0x60000000), MBE(0x70000000),
MBE(0x78000000), MBE(0x7c000000), MBE(0x7e000000), MBE(0x7f000000),
MBE(0x7f800000), MBE(0x7fc00000), MBE(0x7fe00000), MBE(0x7ff00000),
MBE(0x7ff80000), MBE(0x7ffc0000), MBE(0x7ffe0000), MBE(0x7fff0000),
MBE(0x7fff8000), MBE(0x7fffc000), MBE(0x7fffe000), MBE(0x7ffff000),
MBE(0x7ffff800), MBE(0x7ffffc00), MBE(0x7ffffe00), MBE(0x7fffff00),
MBE(0x7fffff80), MBE(0x7fffffc0), MBE(0x7fffffe0), MBE(0x7ffffff0),
MBE(0x7ffffff8), MBE(0x7ffffffc), MBE(0x7ffffffe), MBE(0x7fffffff), },
{ MBE(0x00000000), MBE(0x20000000), MBE(0x30000000), MBE(0x38000000),
MBE(0x3c000000), MBE(0x3e000000), MBE(0x3f000000), MBE(0x3f800000),
MBE(0x3fc00000), MBE(0x3fe00000), MBE(0x3ff00000), MBE(0x3ff80000),
MBE(0x3ffc0000), MBE(0x3ffe0000), MBE(0x3fff0000), MBE(0x3fff8000),
MBE(0x3fffc000), MBE(0x3fffe000), MBE(0x3ffff000), MBE(0x3ffff800),
MBE(0x3ffffc00), MBE(0x3ffffe00), MBE(0x3fffff00), MBE(0x3fffff80),
MBE(0x3fffffc0), MBE(0x3fffffe0), MBE(0x3ffffff0), MBE(0x3ffffff8),
MBE(0x3ffffffc), MBE(0x3ffffffe), MBE(0x3fffffff), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x10000000), MBE(0x18000000), MBE(0x1c000000),
MBE(0x1e000000), MBE(0x1f000000), MBE(0x1f800000), MBE(0x1fc00000),
MBE(0x1fe00000), MBE(0x1ff00000), MBE(0x1ff80000), MBE(0x1ffc0000),
MBE(0x1ffe0000), MBE(0x1fff0000), MBE(0x1fff8000), MBE(0x1fffc000),
MBE(0x1fffe000), MBE(0x1ffff000), MBE(0x1ffff800), MBE(0x1ffffc00),
MBE(0x1ffffe00), MBE(0x1fffff00), MBE(0x1fffff80), MBE(0x1fffffc0),
MBE(0x1fffffe0), MBE(0x1ffffff0), MBE(0x1ffffff8), MBE(0x1ffffffc),
MBE(0x1ffffffe), MBE(0x1fffffff), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x08000000), MBE(0x0c000000), MBE(0x0e000000),
MBE(0x0f000000), MBE(0x0f800000), MBE(0x0fc00000), MBE(0x0fe00000),
MBE(0x0ff00000), MBE(0x0ff80000), MBE(0x0ffc0000), MBE(0x0ffe0000),
MBE(0x0fff0000), MBE(0x0fff8000), MBE(0x0fffc000), MBE(0x0fffe000),
MBE(0x0ffff000), MBE(0x0ffff800), MBE(0x0ffffc00), MBE(0x0ffffe00),
MBE(0x0fffff00), MBE(0x0fffff80), MBE(0x0fffffc0), MBE(0x0fffffe0),
MBE(0x0ffffff0), MBE(0x0ffffff8), MBE(0x0ffffffc), MBE(0x0ffffffe),
MBE(0x0fffffff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x04000000), MBE(0x06000000), MBE(0x07000000),
MBE(0x07800000), MBE(0x07c00000), MBE(0x07e00000), MBE(0x07f00000),
MBE(0x07f80000), MBE(0x07fc0000), MBE(0x07fe0000), MBE(0x07ff0000),
MBE(0x07ff8000), MBE(0x07ffc000), MBE(0x07ffe000), MBE(0x07fff000),
MBE(0x07fff800), MBE(0x07fffc00), MBE(0x07fffe00), MBE(0x07ffff00),
MBE(0x07ffff80), MBE(0x07ffffc0), MBE(0x07ffffe0), MBE(0x07fffff0),
MBE(0x07fffff8), MBE(0x07fffffc), MBE(0x07fffffe), MBE(0x07ffffff),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x02000000), MBE(0x03000000), MBE(0x03800000),
MBE(0x03c00000), MBE(0x03e00000), MBE(0x03f00000), MBE(0x03f80000),
MBE(0x03fc0000), MBE(0x03fe0000), MBE(0x03ff0000), MBE(0x03ff8000),
MBE(0x03ffc000), MBE(0x03ffe000), MBE(0x03fff000), MBE(0x03fff800),
MBE(0x03fffc00), MBE(0x03fffe00), MBE(0x03ffff00), MBE(0x03ffff80),
MBE(0x03ffffc0), MBE(0x03ffffe0), MBE(0x03fffff0), MBE(0x03fffff8),
MBE(0x03fffffc), MBE(0x03fffffe), MBE(0x03ffffff), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x01000000), MBE(0x01800000), MBE(0x01c00000),
MBE(0x01e00000), MBE(0x01f00000), MBE(0x01f80000), MBE(0x01fc0000),
MBE(0x01fe0000), MBE(0x01ff0000), MBE(0x01ff8000), MBE(0x01ffc000),
MBE(0x01ffe000), MBE(0x01fff000), MBE(0x01fff800), MBE(0x01fffc00),
MBE(0x01fffe00), MBE(0x01ffff00), MBE(0x01ffff80), MBE(0x01ffffc0),
MBE(0x01ffffe0), MBE(0x01fffff0), MBE(0x01fffff8), MBE(0x01fffffc),
MBE(0x01fffffe), MBE(0x01ffffff), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00800000), MBE(0x00c00000), MBE(0x00e00000),
MBE(0x00f00000), MBE(0x00f80000), MBE(0x00fc0000), MBE(0x00fe0000),
MBE(0x00ff0000), MBE(0x00ff8000), MBE(0x00ffc000), MBE(0x00ffe000),
MBE(0x00fff000), MBE(0x00fff800), MBE(0x00fffc00), MBE(0x00fffe00),
MBE(0x00ffff00), MBE(0x00ffff80), MBE(0x00ffffc0), MBE(0x00ffffe0),
MBE(0x00fffff0), MBE(0x00fffff8), MBE(0x00fffffc), MBE(0x00fffffe),
MBE(0x00ffffff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00400000), MBE(0x00600000), MBE(0x00700000),
MBE(0x00780000), MBE(0x007c0000), MBE(0x007e0000), MBE(0x007f0000),
MBE(0x007f8000), MBE(0x007fc000), MBE(0x007fe000), MBE(0x007ff000),
MBE(0x007ff800), MBE(0x007ffc00), MBE(0x007ffe00), MBE(0x007fff00),
MBE(0x007fff80), MBE(0x007fffc0), MBE(0x007fffe0), MBE(0x007ffff0),
MBE(0x007ffff8), MBE(0x007ffffc), MBE(0x007ffffe), MBE(0x007fffff),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00200000), MBE(0x00300000), MBE(0x00380000),
MBE(0x003c0000), MBE(0x003e0000), MBE(0x003f0000), MBE(0x003f8000),
MBE(0x003fc000), MBE(0x003fe000), MBE(0x003ff000), MBE(0x003ff800),
MBE(0x003ffc00), MBE(0x003ffe00), MBE(0x003fff00), MBE(0x003fff80),
MBE(0x003fffc0), MBE(0x003fffe0), MBE(0x003ffff0), MBE(0x003ffff8),
MBE(0x003ffffc), MBE(0x003ffffe), MBE(0x003fffff), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00100000), MBE(0x00180000), MBE(0x001c0000),
MBE(0x001e0000), MBE(0x001f0000), MBE(0x001f8000), MBE(0x001fc000),
MBE(0x001fe000), MBE(0x001ff000), MBE(0x001ff800), MBE(0x001ffc00),
MBE(0x001ffe00), MBE(0x001fff00), MBE(0x001fff80), MBE(0x001fffc0),
MBE(0x001fffe0), MBE(0x001ffff0), MBE(0x001ffff8), MBE(0x001ffffc),
MBE(0x001ffffe), MBE(0x001fffff), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00080000), MBE(0x000c0000), MBE(0x000e0000),
MBE(0x000f0000), MBE(0x000f8000), MBE(0x000fc000), MBE(0x000fe000),
MBE(0x000ff000), MBE(0x000ff800), MBE(0x000ffc00), MBE(0x000ffe00),
MBE(0x000fff00), MBE(0x000fff80), MBE(0x000fffc0), MBE(0x000fffe0),
MBE(0x000ffff0), MBE(0x000ffff8), MBE(0x000ffffc), MBE(0x000ffffe),
MBE(0x000fffff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00040000), MBE(0x00060000), MBE(0x00070000),
MBE(0x00078000), MBE(0x0007c000), MBE(0x0007e000), MBE(0x0007f000),
MBE(0x0007f800), MBE(0x0007fc00), MBE(0x0007fe00), MBE(0x0007ff00),
MBE(0x0007ff80), MBE(0x0007ffc0), MBE(0x0007ffe0), MBE(0x0007fff0),
MBE(0x0007fff8), MBE(0x0007fffc), MBE(0x0007fffe), MBE(0x0007ffff),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00020000), MBE(0x00030000), MBE(0x00038000),
MBE(0x0003c000), MBE(0x0003e000), MBE(0x0003f000), MBE(0x0003f800),
MBE(0x0003fc00), MBE(0x0003fe00), MBE(0x0003ff00), MBE(0x0003ff80),
MBE(0x0003ffc0), MBE(0x0003ffe0), MBE(0x0003fff0), MBE(0x0003fff8),
MBE(0x0003fffc), MBE(0x0003fffe), MBE(0x0003ffff), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00010000), MBE(0x00018000), MBE(0x0001c000),
MBE(0x0001e000), MBE(0x0001f000), MBE(0x0001f800), MBE(0x0001fc00),
MBE(0x0001fe00), MBE(0x0001ff00), MBE(0x0001ff80), MBE(0x0001ffc0),
MBE(0x0001ffe0), MBE(0x0001fff0), MBE(0x0001fff8), MBE(0x0001fffc),
MBE(0x0001fffe), MBE(0x0001ffff), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00008000), MBE(0x0000c000), MBE(0x0000e000),
MBE(0x0000f000), MBE(0x0000f800), MBE(0x0000fc00), MBE(0x0000fe00),
MBE(0x0000ff00), MBE(0x0000ff80), MBE(0x0000ffc0), MBE(0x0000ffe0),
MBE(0x0000fff0), MBE(0x0000fff8), MBE(0x0000fffc), MBE(0x0000fffe),
MBE(0x0000ffff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00004000), MBE(0x00006000), MBE(0x00007000),
MBE(0x00007800), MBE(0x00007c00), MBE(0x00007e00), MBE(0x00007f00),
MBE(0x00007f80), MBE(0x00007fc0), MBE(0x00007fe0), MBE(0x00007ff0),
MBE(0x00007ff8), MBE(0x00007ffc), MBE(0x00007ffe), MBE(0x00007fff),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00002000), MBE(0x00003000), MBE(0x00003800),
MBE(0x00003c00), MBE(0x00003e00), MBE(0x00003f00), MBE(0x00003f80),
MBE(0x00003fc0), MBE(0x00003fe0), MBE(0x00003ff0), MBE(0x00003ff8),
MBE(0x00003ffc), MBE(0x00003ffe), MBE(0x00003fff), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00001000), MBE(0x00001800), MBE(0x00001c00),
MBE(0x00001e00), MBE(0x00001f00), MBE(0x00001f80), MBE(0x00001fc0),
MBE(0x00001fe0), MBE(0x00001ff0), MBE(0x00001ff8), MBE(0x00001ffc),
MBE(0x00001ffe), MBE(0x00001fff), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000800), MBE(0x00000c00), MBE(0x00000e00),
MBE(0x00000f00), MBE(0x00000f80), MBE(0x00000fc0), MBE(0x00000fe0),
MBE(0x00000ff0), MBE(0x00000ff8), MBE(0x00000ffc), MBE(0x00000ffe),
MBE(0x00000fff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000400), MBE(0x00000600), MBE(0x00000700),
MBE(0x00000780), MBE(0x000007c0), MBE(0x000007e0), MBE(0x000007f0),
MBE(0x000007f8), MBE(0x000007fc), MBE(0x000007fe), MBE(0x000007ff),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000200), MBE(0x00000300), MBE(0x00000380),
MBE(0x000003c0), MBE(0x000003e0), MBE(0x000003f0), MBE(0x000003f8),
MBE(0x000003fc), MBE(0x000003fe), MBE(0x000003ff), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000100), MBE(0x00000180), MBE(0x000001c0),
MBE(0x000001e0), MBE(0x000001f0), MBE(0x000001f8), MBE(0x000001fc),
MBE(0x000001fe), MBE(0x000001ff), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000080), MBE(0x000000c0), MBE(0x000000e0),
MBE(0x000000f0), MBE(0x000000f8), MBE(0x000000fc), MBE(0x000000fe),
MBE(0x000000ff), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000040), MBE(0x00000060), MBE(0x00000070),
MBE(0x00000078), MBE(0x0000007c), MBE(0x0000007e), MBE(0x0000007f),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000020), MBE(0x00000030), MBE(0x00000038),
MBE(0x0000003c), MBE(0x0000003e), MBE(0x0000003f), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000010), MBE(0x00000018), MBE(0x0000001c),
MBE(0x0000001e), MBE(0x0000001f), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000008), MBE(0x0000000c), MBE(0x0000000e),
MBE(0x0000000f), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000004), MBE(0x00000006), MBE(0x00000007),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000002), MBE(0x00000003), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
{ MBE(0x00000000), MBE(0x00000001), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000),
MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), MBE(0x00000000), },
};

View File

@ -0,0 +1,97 @@
/* $NetBSD: rasops_masks.h,v 1.1 1999/04/26 04:27:48 ad Exp $ */
/*
* Copyright (c) 1999 Andy Doran <ad@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef _RASOPS_MASKS_H_
#define _RASOPS_MASKS_H_ 1
#include <sys/types.h>
#include <machine/endian.h>
/*
* Convenience macros. To get around the problem of dealing with properly
* ordered bits on little-endian machines, we just convert everything to
* big-endian and back again when we're done.
*
* MBL: move bits left
* MBR: move bits right
* MBE: make big-endian
*/
#if BYTE_ORDER == BIG_ENDIAN
#define MBL(x,y) ((y) > 31 ? 0 : (x) >> (y))
#define MBR(x,y) ((y) > 31 ? 0 : (x) << (y))
#define MBE(x) (x)
#else
#define MBL(x,y) ((y) > 31 ? 0 : MBE(MBE(x) << (y)))
#define MBR(x,y) ((y) > 31 ? 0 : MBE(MBE(x) >> (y)))
#define MBE(x) ( (((x) & 0x000000FFU) << 24) \
| (((x) & 0x0000FF00U) << 8) \
| (((x) & 0x00FF0000U) >> 8) \
| (((x) & 0xFF000000U) >> 24) )
#endif
/*
* Using GETBITS() and PUTBITS() inside a loop mightn't be such a good idea.
* There's probably some CSE and strength-reduction that the compiler won't
* even think about - really should have a few assumptions/separate cases.
*/
/* Get a number of bits ( <= 32 ) from *sp and store in dw */
#define GETBITS(sp, x, w, dw) do { \
dw = MBL(*(sp), (x)); \
if (((x) + (w)) > 32) \
dw |= (MBR((sp)[1], 32 - (x))); \
} while(0);
/* Put a number of bits ( <= 32 ) from sw to *dp */
#define PUTBITS(sw, x, w, dp) do { \
int n = (x) + (w) - 32; \
\
if (n <= 0) { \
n = rasops_pmask[x & 31][w & 31]; \
*(dp) = (*(dp) & ~n) | (MBR(sw, x) & n); \
} else { \
*(dp) = (*(dp) & rasops_rmask[x]) | (MBR((sw), x)); \
(dp)[1] = ((dp)[1] & rasops_rmask[n]) | \
(MBL(sw, 32-(x)) & rasops_lmask[n]); \
} \
} while(0);
/* rasops_masks.c */
extern int32_t rasops_lmask[32+1];
extern int32_t rasops_rmask[32+1];
extern int32_t rasops_pmask[32][32];
#ifdef notyet
extern int32_t rasops_lbmask[4+1];
extern int32_t rasops_rbmask[4+1];
#endif
#endif /* _RASOPS_MASKS_H_ */