OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [fblin1rev.c] - Diff between revs 674 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 674 Rev 1765
/*
/*
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
*
*
* 1bpp Packed Linear Video Driver (reversed bit order)
* 1bpp Packed Linear Video Driver (reversed bit order)
* For Psion S5
* For Psion S5
*
*
*       In this driver, psd->linelen is line byte length, not line pixel length
*       In this driver, psd->linelen is line byte length, not line pixel length
*/
*/
/*#define NDEBUG*/
/*#define NDEBUG*/
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include "device.h"
#include "device.h"
#include "fb.h"
#include "fb.h"
 
 
static unsigned char notmask[8] = {
static unsigned char notmask[8] = {
        0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe};
        0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe};
 
 
/* Calc linelen and mmap size, return 0 on fail*/
/* Calc linelen and mmap size, return 0 on fail*/
static int
static int
linear1_init(PSD psd)
linear1_init(PSD psd)
{
{
        if (!psd->size)
        if (!psd->size)
                psd->size = psd->yres * psd->linelen;
                psd->size = psd->yres * psd->linelen;
        /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
        /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
        return 1;
        return 1;
}
}
 
 
/* Set pixel at x, y, to pixelval c*/
/* Set pixel at x, y, to pixelval c*/
static void
static void
linear1_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
linear1_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
{
{
        ADDR8   addr = psd->addr;
        ADDR8   addr = psd->addr;
 
 
        assert (addr != 0);
        assert (addr != 0);
        assert (x >= 0 && x < psd->xres);
        assert (x >= 0 && x < psd->xres);
        assert (y >= 0 && y < psd->yres);
        assert (y >= 0 && y < psd->yres);
        assert (c < psd->ncolors);
        assert (c < psd->ncolors);
 
 
        DRAWON;
        DRAWON;
        addr += (x>>3) + y * psd->linelen;
        addr += (x>>3) + y * psd->linelen;
        if(gr_mode == MWMODE_XOR)
        if(gr_mode == MWMODE_XOR)
                *addr ^= c << (x&7);
                *addr ^= c << (x&7);
        else
        else
                *addr = (*addr & notmask[x&7]) | (c << (x&7));
                *addr = (*addr & notmask[x&7]) | (c << (x&7));
        DRAWOFF;
        DRAWOFF;
}
}
 
 
/* Read pixel at x, y*/
/* Read pixel at x, y*/
static MWPIXELVAL
static MWPIXELVAL
linear1_readpixel(PSD psd, MWCOORD x, MWCOORD y)
linear1_readpixel(PSD psd, MWCOORD x, MWCOORD y)
{
{
        ADDR8   addr = psd->addr;
        ADDR8   addr = psd->addr;
 
 
        assert (addr != 0);
        assert (addr != 0);
        assert (x >= 0 && x < psd->xres);
        assert (x >= 0 && x < psd->xres);
        assert (y >= 0 && y < psd->yres);
        assert (y >= 0 && y < psd->yres);
 
 
        return (addr[(x>>3) + y * psd->linelen] >> (x&7) ) & 0x01;
        return (addr[(x>>3) + y * psd->linelen] >> (x&7) ) & 0x01;
}
}
 
 
/* Draw horizontal line from x1,y to x2,y including final point*/
/* Draw horizontal line from x1,y to x2,y including final point*/
static void
static void
linear1_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
linear1_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
{
{
        ADDR8   addr = psd->addr;
        ADDR8   addr = psd->addr;
 
 
        assert (addr != 0);
        assert (addr != 0);
        assert (x1 >= 0 && x1 < psd->xres);
        assert (x1 >= 0 && x1 < psd->xres);
        assert (x2 >= 0 && x2 < psd->xres);
        assert (x2 >= 0 && x2 < psd->xres);
        assert (x2 >= x1);
        assert (x2 >= x1);
        assert (y >= 0 && y < psd->yres);
        assert (y >= 0 && y < psd->yres);
        assert (c < psd->ncolors);
        assert (c < psd->ncolors);
 
 
        DRAWON;
        DRAWON;
        addr += (x1>>3) + y * psd->linelen;
        addr += (x1>>3) + y * psd->linelen;
        if(gr_mode == MWMODE_XOR) {
        if(gr_mode == MWMODE_XOR) {
                while(x1 <= x2) {
                while(x1 <= x2) {
                        *addr ^= c << (x1&7);
                        *addr ^= c << (x1&7);
                        if((++x1 & 7) == 0)
                        if((++x1 & 7) == 0)
                                ++addr;
                                ++addr;
                }
                }
        } else {
        } else {
                while(x1 <= x2) {
                while(x1 <= x2) {
                        *addr = (*addr & notmask[x1&7]) | (c << (x1&7));
                        *addr = (*addr & notmask[x1&7]) | (c << (x1&7));
                        if((++x1 & 7) == 0)
                        if((++x1 & 7) == 0)
                                ++addr;
                                ++addr;
                }
                }
        }
        }
        DRAWOFF;
        DRAWOFF;
}
}
 
 
/* Draw a vertical line from x,y1 to x,y2 including final point*/
/* Draw a vertical line from x,y1 to x,y2 including final point*/
static void
static void
linear1_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
linear1_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
{
{
        ADDR8   addr = psd->addr;
        ADDR8   addr = psd->addr;
        int     linelen = psd->linelen;
        int     linelen = psd->linelen;
 
 
        assert (addr != 0);
        assert (addr != 0);
        assert (x >= 0 && x < psd->xres);
        assert (x >= 0 && x < psd->xres);
        assert (y1 >= 0 && y1 < psd->yres);
        assert (y1 >= 0 && y1 < psd->yres);
        assert (y2 >= 0 && y2 < psd->yres);
        assert (y2 >= 0 && y2 < psd->yres);
        assert (y2 >= y1);
        assert (y2 >= y1);
        assert (c < psd->ncolors);
        assert (c < psd->ncolors);
 
 
        DRAWON;
        DRAWON;
        addr += (x>>3) + y1 * linelen;
        addr += (x>>3) + y1 * linelen;
        if(gr_mode == MWMODE_XOR)
        if(gr_mode == MWMODE_XOR)
                while(y1++ <= y2) {
                while(y1++ <= y2) {
                        *addr ^= c << (x&7);
                        *addr ^= c << (x&7);
                        addr += linelen;
                        addr += linelen;
                }
                }
        else
        else
                while(y1++ <= y2) {
                while(y1++ <= y2) {
                        *addr = (*addr & notmask[x&7]) | (c << (x&7));
                        *addr = (*addr & notmask[x&7]) | (c << (x&7));
                        addr += linelen;
                        addr += linelen;
                }
                }
        DRAWOFF;
        DRAWOFF;
}
}
 
 
/* srccopy bitblt, opcode is currently ignored*/
/* srccopy bitblt, opcode is currently ignored*/
static void
static void
linear1_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
linear1_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
        PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
        PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
{
{
        ADDR8   dst;
        ADDR8   dst;
        ADDR8   src;
        ADDR8   src;
        int     i;
        int     i;
        int     dlinelen = dstpsd->linelen;
        int     dlinelen = dstpsd->linelen;
        int     slinelen = srcpsd->linelen;
        int     slinelen = srcpsd->linelen;
 
 
        assert (dstpsd->addr != 0);
        assert (dstpsd->addr != 0);
        assert (dstx >= 0 && dstx < dstpsd->xres);
        assert (dstx >= 0 && dstx < dstpsd->xres);
        assert (dsty >= 0 && dsty < dstpsd->yres);
        assert (dsty >= 0 && dsty < dstpsd->yres);
        assert (w > 0);
        assert (w > 0);
        assert (h > 0);
        assert (h > 0);
        assert (srcpsd->addr != 0);
        assert (srcpsd->addr != 0);
        assert (srcx >= 0 && srcx < srcpsd->xres);
        assert (srcx >= 0 && srcx < srcpsd->xres);
        assert (srcy >= 0 && srcy < srcpsd->yres);
        assert (srcy >= 0 && srcy < srcpsd->yres);
        assert (dstx+w <= dstpsd->xres);
        assert (dstx+w <= dstpsd->xres);
        assert (dsty+h <= dstpsd->yres);
        assert (dsty+h <= dstpsd->yres);
        assert (srcx+w <= srcpsd->xres);
        assert (srcx+w <= srcpsd->xres);
        assert (srcy+h <= srcpsd->yres);
        assert (srcy+h <= srcpsd->yres);
 
 
        DRAWON;
        DRAWON;
        dst = dstpsd->addr + (dstx>>3) + dsty * dlinelen;
        dst = dstpsd->addr + (dstx>>3) + dsty * dlinelen;
        src = srcpsd->addr + (srcx>>3) + srcy * slinelen;
        src = srcpsd->addr + (srcx>>3) + srcy * slinelen;
        while(--h >= 0) {
        while(--h >= 0) {
                ADDR8   d = dst;
                ADDR8   d = dst;
                ADDR8   s = src;
                ADDR8   s = src;
                MWCOORD dx = dstx;
                MWCOORD dx = dstx;
                MWCOORD sx = srcx;
                MWCOORD sx = srcx;
                for(i=0; i<w; ++i) {
                for(i=0; i<w; ++i) {
                        *d = (*d & notmask[dx&7]) |
                        *d = (*d & notmask[dx&7]) |
                           ((*s >> (sx&7) & 0x01) << (dx&7));
                           ((*s >> (sx&7) & 0x01) << (dx&7));
                        if((++dx & 7) == 0)
                        if((++dx & 7) == 0)
                                ++d;
                                ++d;
                        if((++sx & 7) == 0)
                        if((++sx & 7) == 0)
                                ++s;
                                ++s;
                }
                }
                dst += dlinelen;
                dst += dlinelen;
                src += slinelen;
                src += slinelen;
        }
        }
        DRAWOFF;
        DRAWOFF;
}
}
 
 
SUBDRIVER fblinear1 = {
SUBDRIVER fblinear1 = {
        linear1_init,
        linear1_init,
        linear1_drawpixel,
        linear1_drawpixel,
        linear1_readpixel,
        linear1_readpixel,
        linear1_drawhorzline,
        linear1_drawhorzline,
        linear1_drawvertline,
        linear1_drawvertline,
        gen_fillrect,
        gen_fillrect,
        linear1_blit
        linear1_blit
};
};
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.