summaryrefslogtreecommitdiff
path: root/sys/arch/luna88k/dev/omrasops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/luna88k/dev/omrasops.c')
-rw-r--r--sys/arch/luna88k/dev/omrasops.c268
1 files changed, 57 insertions, 211 deletions
diff --git a/sys/arch/luna88k/dev/omrasops.c b/sys/arch/luna88k/dev/omrasops.c
index 5f3c2c56f3d..43f7ad56bbf 100644
--- a/sys/arch/luna88k/dev/omrasops.c
+++ b/sys/arch/luna88k/dev/omrasops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: omrasops.c,v 1.9 2013/05/17 23:25:16 aoyama Exp $ */
+/* $OpenBSD: omrasops.c,v 1.10 2013/11/16 22:45:37 aoyama Exp $ */
/* $NetBSD: omrasops.c,v 1.1 2000/01/05 08:48:56 nisimura Exp $ */
/*-
@@ -47,6 +47,8 @@
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
+#include <luna88k/dev/omrasops.h>
+
/* wscons emulator operations */
int om_cursor(void *, int, int, int);
int om_putchar(void *, int, int, u_int, long);
@@ -55,24 +57,22 @@ int om_copyrows(void *, int, int, int num);
int om_erasecols(void *, int, int, int, long);
int om_eraserows(void *, int, int, long);
+/* internal functions (for 1bpp, in omrasops1.c) */
+int om_windowmove1(struct rasops_info *, u_int16_t, u_int16_t,
+ u_int16_t, u_int16_t, u_int16_t, u_int16_t, int16_t,
+ int16_t /* ignored */);
+
#define ALL1BITS (~0U)
#define ALL0BITS (0U)
#define BLITWIDTH (32)
#define ALIGNMASK (0x1f)
#define BYTESDONE (4)
-#define W(p) (*(u_int32_t *)(p))
-#define R(p) (*(u_int32_t *)((u_int8_t *)(p) + 0x40000))
-
/*
* Blit a character at the specified co-ordinates.
*/
int
-om_putchar(cookie, row, startcol, uc, attr)
- void *cookie;
- int row, startcol;
- u_int uc;
- long attr;
+om_putchar(void *cookie, int row, int startcol, u_int uc, long attr)
{
struct rasops_info *ri = cookie;
u_int8_t *p;
@@ -132,236 +132,84 @@ om_putchar(cookie, row, startcol, uc, attr)
}
int
-om_erasecols(cookie, row, startcol, ncols, attr)
- void *cookie;
- int row, startcol, ncols;
- long attr;
+om_erasecols(void *cookie, int row, int col, int num, long attr)
{
- struct rasops_info *ri = cookie;
- u_int8_t *p;
- int scanspan, startx, height, width, align, w, y, fg, bg;
- u_int32_t lmask, rmask, fill;
-
- scanspan = ri->ri_stride;
- y = ri->ri_font->fontheight * row;
- startx = ri->ri_font->fontwidth * startcol;
- height = ri->ri_font->fontheight;
- w = ri->ri_font->fontwidth * ncols;
+ struct rasops_info *ri = cookie;
+ int fg, bg;
+ int snum, scol, srow;
+
ri->ri_ops.unpack_attr(cookie, attr, &fg, &bg, NULL);
- fill = (bg != 0) ? ALL1BITS : ALL0BITS;
- p = (u_int8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
- align = startx & ALIGNMASK;
- width = w + align;
- lmask = ALL1BITS >> align;
- rmask = ALL1BITS << (-width & ALIGNMASK);
- if (width <= BLITWIDTH) {
- lmask &= rmask;
- fill &= lmask;
- while (height > 0) {
- W(p) = (R(p) & ~lmask) | fill;
- p += scanspan;
- height--;
- }
- }
- else {
- u_int8_t *q = p;
- while (height > 0) {
- W(p) = (R(p) & ~lmask) | (fill & lmask);
- width -= 2 * BLITWIDTH;
- while (width > 0) {
- p += BYTESDONE;
- W(p) = fill;
- width -= BLITWIDTH;
- }
- p += BYTESDONE;
- W(p) = (fill & rmask) | (R(p) & ~rmask);
+ snum = num * ri->ri_font->fontwidth;
+ scol = col * ri->ri_font->fontwidth + ri->ri_xorigin;
+ srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
- p = (q += scanspan);
- width = w + align;
- height--;
- }
- }
+ /*
+ * If this is too tricky for the simple raster ops engine,
+ * pass the fun to rasops.
+ */
+ if (om_windowmove1(ri, scol, srow, scol, srow, snum,
+ ri->ri_font->fontheight, RR_CLEAR, 0xff ^ bg) != 0)
+ rasops_erasecols(cookie, row, col, num, attr);
return 0;
}
int
-om_eraserows(cookie, startrow, nrows, attr)
- void *cookie;
- int startrow, nrows;
- long attr;
+om_eraserows(void *cookie, int row, int num, long attr)
{
struct rasops_info *ri = cookie;
- u_int8_t *p, *q;
- int scanspan, starty, height, width, w, fg, bg;
- u_int32_t rmask, fill;
+ int fg, bg;
+ int srow, snum;
+ int rc;
- scanspan = ri->ri_stride;
- starty = ri->ri_font->fontheight * startrow;
- height = ri->ri_font->fontheight * nrows;
- w = ri->ri_emuwidth;
ri->ri_ops.unpack_attr(cookie, attr, &fg, &bg, NULL);
- fill = (bg != 0) ? ALL1BITS : ALL0BITS;
-
- p = (u_int8_t *)ri->ri_bits + starty * scanspan;
- width = w;
- rmask = ALL1BITS << (-width & ALIGNMASK);
- q = p;
- while (height > 0) {
- W(p) = fill; /* always aligned */
- width -= 2 * BLITWIDTH;
- while (width > 0) {
- p += BYTESDONE;
- W(p) = fill;
- width -= BLITWIDTH;
- }
- p += BYTESDONE;
- W(p) = (fill & rmask) | (R(p) & ~rmask);
- p = (q += scanspan);
- width = w;
- height--;
+ bg ^= 0xff;
+
+ if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR)) {
+ rc = om_windowmove1(ri, 0, 0, 0, 0, ri->ri_width, ri->ri_height,
+ RR_CLEAR, bg);
+ } else {
+ srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
+ snum = num * ri->ri_font->fontheight;
+ rc = om_windowmove1(ri, ri->ri_xorigin, srow, ri->ri_xorigin,
+ srow, ri->ri_emuwidth, snum, RR_CLEAR, bg);
}
+ if (rc != 0)
+ rasops_eraserows(cookie, row, num, attr);
return 0;
}
int
-om_copyrows(cookie, srcrow, dstrow, nrows)
- void *cookie;
- int srcrow, dstrow, nrows;
+om_copyrows(void *cookie, int src, int dst, int n)
{
- struct rasops_info *ri = cookie;
- u_int8_t *p, *q;
- int scanspan, offset, srcy, height, width, w;
- u_int32_t rmask;
-
- scanspan = ri->ri_stride;
- height = ri->ri_font->fontheight * nrows;
- offset = (dstrow - srcrow) * scanspan * ri->ri_font->fontheight;
- srcy = ri->ri_font->fontheight * srcrow;
- if (srcrow < dstrow && srcrow + nrows > dstrow) {
- scanspan = -scanspan;
- srcy += height;
- }
+ struct rasops_info *ri = cookie;
- p = (u_int8_t *)ri->ri_bits + srcy * ri->ri_stride;
- w = ri->ri_emuwidth;
- width = w;
- rmask = ALL1BITS << (-width & ALIGNMASK);
- q = p;
- while (height > 0) {
- W(p + offset) = R(p); /* always aligned */
- width -= 2 * BLITWIDTH;
- while (width > 0) {
- p += BYTESDONE;
- W(p + offset) = R(p);
- width -= BLITWIDTH;
- }
- p += BYTESDONE;
- W(p + offset) = (R(p) & rmask) | (R(p + offset) & ~rmask);
+ n *= ri->ri_font->fontheight;
+ src *= ri->ri_font->fontheight;
+ dst *= ri->ri_font->fontheight;
- p = (q += scanspan);
- width = w;
- height--;
- }
+ om_windowmove1(ri, ri->ri_xorigin, ri->ri_yorigin + src,
+ ri->ri_xorigin, ri->ri_yorigin + dst,
+ ri->ri_emuwidth, n, RR_COPY, 0xff);
return 0;
}
int
-om_copycols(cookie, startrow, srccol, dstcol, ncols)
- void *cookie;
- int startrow, srccol, dstcol, ncols;
+om_copycols(void *cookie, int row, int src, int dst, int n)
{
struct rasops_info *ri = cookie;
- u_int8_t *sp, *dp, *basep;
- int scanspan, height, width, align, shift, w, y, srcx, dstx;
- u_int32_t lmask, rmask;
-
- scanspan = ri->ri_stride;
- y = ri->ri_font->fontheight * startrow;
- srcx = ri->ri_font->fontwidth * srccol;
- dstx = ri->ri_font->fontwidth * dstcol;
- height = ri->ri_font->fontheight;
- w = ri->ri_font->fontwidth * ncols;
- basep = (u_int8_t *)ri->ri_bits + y * scanspan;
-
- align = shift = srcx & ALIGNMASK;
- width = w + align;
- align = dstx & ALIGNMASK;
- lmask = ALL1BITS >> align;
- rmask = ALL1BITS << (-(w + align) & ALIGNMASK);
- shift = align - shift;
- sp = basep + (srcx / 32) * 4;
- dp = basep + (dstx / 32) * 4;
-
- if (shift != 0)
- goto hardluckalignment;
-
- /* alignments comfortably match */
- if (width <= BLITWIDTH) {
- lmask &= rmask;
- while (height > 0) {
- W(dp) = (R(dp) & ~lmask) | (R(sp) & lmask);
- dp += scanspan;
- sp += scanspan;
- height--;
- }
- }
- /* copy forward (left-to-right) */
- else if (dstcol < srccol || srccol + ncols < dstcol) {
- u_int8_t *sq = sp, *dq = dp;
- w = width;
- while (height > 0) {
- W(dp) = (R(dp) & ~lmask) | (R(sp) & lmask);
- width -= 2 * BLITWIDTH;
- while (width > 0) {
- sp += BYTESDONE;
- dp += BYTESDONE;
- W(dp) = R(sp);
- width -= BLITWIDTH;
- }
- sp += BYTESDONE;
- dp += BYTESDONE;
- W(dp) = (R(sp) & rmask) | (R(dp) & ~rmask);
- sp = (sq += scanspan);
- dp = (dq += scanspan);
- width = w;
- height--;
- }
- }
- /* copy backward (right-to-left) */
- else {
- u_int8_t *sq, *dq;
-
- sq = (sp += width / 32 * 4);
- dq = (dp += width / 32 * 4);
- w = width;
- while (height > 0) {
- W(dp) = (R(sp) & rmask) | (R(dp) & ~rmask);
- width -= 2 * BLITWIDTH;
- while (width > 0) {
- sp -= BYTESDONE;
- dp -= BYTESDONE;
- W(dp) = R(sp);
- width -= BLITWIDTH;
- }
- sp -= BYTESDONE;
- dp -= BYTESDONE;
- W(dp) = (R(dp) & ~lmask) | (R(sp) & lmask);
-
- sp = (sq += scanspan);
- dp = (dq += scanspan);
- width = w;
- height--;
- }
- }
- return 0;
+ n *= ri->ri_font->fontwidth;
+ src *= ri->ri_font->fontwidth;
+ dst *= ri->ri_font->fontwidth;
+ row *= ri->ri_font->fontheight;
- hardluckalignment:
- /* alignments painfully disagree */
+ om_windowmove1(ri, ri->ri_xorigin + src, ri->ri_yorigin + row,
+ ri->ri_xorigin + dst, ri->ri_yorigin + row,
+ n, ri->ri_font->fontheight, RR_COPY, 0xff);
return 0;
}
@@ -370,9 +218,7 @@ om_copycols(cookie, startrow, srccol, dstcol, ncols)
* Position|{enable|disable} the cursor at the specified location.
*/
int
-om_cursor(cookie, on, row, col)
- void *cookie;
- int on, row, col;
+om_cursor(void *cookie, int on, int row, int col)
{
struct rasops_info *ri = cookie;
u_int8_t *p;