Exemple #1
0
void GrPatternDrawString(void *text,int length,int x,int y,
			 const GrTextOption *opt,GrPattern *p)
{
    GRX_ENTER();
    _GrDrawString(text,length,x,y,opt,p,PatternFilledBmp);
    GRX_LEAVE();
}
Exemple #2
0
static INLINE
void drawpixel(int x,int y,GrxColor color)
{
        GR_int32u offs;
        char *p0,*p1,*p2;
        GRX_ENTER();
        offs = FOFS(x,y,CURC->gc_line_offset);
        p0 = &CURC->gc_base_address.plane0[offs];
        p1 = &CURC->gc_base_address.plane1[offs];
        p2 = &CURC->gc_base_address.plane2[offs];
        switch(C_OPER(color)) {
          case C_XOR: poke_b_xor(p0,RD24BYTE(color,0));
                      poke_b_xor(p1,RD24BYTE(color,1));
                      poke_b_xor(p2,RD24BYTE(color,2));
                      break;
          case C_OR:  poke_b_or(p0,RD24BYTE(color,0));
                      poke_b_or(p1,RD24BYTE(color,1));
                      poke_b_or(p2,RD24BYTE(color,2));
                      break;
          case C_AND: poke_b_and(p0,RD24BYTE(color,0));
                      poke_b_and(p1,RD24BYTE(color,1));
                      poke_b_and(p2,RD24BYTE(color,2));
                      break;
          default:    poke_b(p0,RD24BYTE(color,0));
                      poke_b(p1,RD24BYTE(color,1));
                      poke_b(p2,RD24BYTE(color,2));
                      break;
        }
        GRX_LEAVE();
}
Exemple #3
0
static int detect(void)
{
        int res;
        GRX_ENTER();
        res = SDL_WasInit(SDL_INIT_VIDEO) || SDL_Init(SDL_INIT_VIDEO) == 0;
        GRX_RETURN(res);
}
Exemple #4
0
void _GrFrDrvGenericBitBlt(GrxFrame *dst,int dx,int dy,GrxFrame *src,int x,int y,int w,int h,GrxColor op)
{
        GrxFrame csave;
        GrxColor (*readpix)(GrxFrame *,int,int);
        void (*drawpix)(int,int,GrxColor);
        GrxColor skipc;
        int  step;
        GRX_ENTER();
        readpix = src->driver->readpixel;
        drawpix = dst->driver->drawpixel;
        skipc = op ^ GRX_COLOR_MODE_IMAGE;
        step  = 1;
        op &= GRX_COLOR_MODE_MASK;
        sttcopy(&csave,&CURC->frame);
        sttcopy(&CURC->frame,dst);
        if((dy > y) || ((dy == y) && (dx > x))) {
            x += (w - 1); dx += (w - 1);
            y += (h - 1); dy += (h - 1);
            step = (-1);
        }
        do {
            int dxx = dx,xx = x,ww = w;
            do {
                GrxColor c = (*readpix)(src,xx,y);
                if(c != skipc) (*drawpix)(dxx,dy,(c | op));
                dxx += step; xx += step;
            } while(--ww > 0);
            dy += step; y += step;
        } while(--h > 0);
        sttcopy(&CURC->frame,&csave);
        GRX_LEAVE();
}
Exemple #5
0
GrVideoMode * _gr_selectmode(GrVideoDriver *drv,int w,int h,int bpp,
                             int txt,unsigned int *ep)
{
#       define ERROR(des,act)   ((des > act) ? ((des - act) + 20000) : (act - des))
    int  n;
    unsigned int cerr,serr,err[2];
    GrVideoMode *best,*mp;
    GRX_ENTER();
    best = NULL;
    mp = drv->modes;
    for(n = drv->nmodes; --n >= 0; mp++) {
        if(!mp->present) continue;
        if(!mp->extinfo) continue;
        if((mp->extinfo->mode != GR_frameText) ? txt : !txt) continue;
        cerr = ERROR(bpp,mp->bpp);
        serr = ERROR(w,mp->width) + ERROR(h,mp->height);
        if(((ep) ? FALSE : ((ep = err),TRUE)) ||
                ((cerr <  ep[0])) ||
                ((cerr == ep[0]) && (serr < ep[1]))) {
            best  = mp;
            if (!cerr && !serr) break;
            ep[0] = cerr;
            ep[1] = serr;
        }
    }
    if(drv->inherit) {
        mp = (drv->inherit->selectmode) (drv->inherit,w,h,bpp,txt,ep);
        if(mp) best = mp;
    }
    GRX_RETURN(best);
}
Exemple #6
0
void drawhline(int x,int y,int w,GrxColor c)
{
        GRX_ENTER();
        w += x;
        do { drawpixel(x,y,c); } while(++x != w);
        GRX_LEAVE();
}
Exemple #7
0
static void PatternFilledBmp(int x,int y,int w,int h,int ox, int oy,
				char *bmp,int pitch,int start,
				GrColor fg,GrColor bg,GrPattern *p)
{
    GRX_ENTER();
    _GrFillBitmapPattern(x,y,w,h,bmp,pitch,start,p,bg);
    GRX_LEAVE();
}
Exemple #8
0
void _GR_swap16(GR_int16 *w) {
  GR_int16 res;
  GRX_ENTER();
  res  = SWAPBYTE(GR_int16,*w,1,0);
  res |= SWAPBYTE(GR_int16,*w,0,1);
  *w = res;
  GRX_LEAVE();
}
Exemple #9
0
static void swapbytes(GR_int8 *b1, GR_int8 *b2) {
  GR_int8 b;
  GRX_ENTER();
  b = peek_b(b1);
  poke_b(b1, peek_b(b2));
  poke_b(b2, b);
  GRX_LEAVE();
}
Exemple #10
0
void _GR_swap64(GR_int64 *h) {
  GRX_ENTER();
  swapbytes(((GR_int8 *)h)  , ((GR_int8 *)h)+7);
  swapbytes(((GR_int8 *)h)+1, ((GR_int8 *)h)+6); 
  swapbytes(((GR_int8 *)h)+2, ((GR_int8 *)h)+5);
  swapbytes(((GR_int8 *)h)+3, ((GR_int8 *)h)+4); 
  GRX_LEAVE();
}
Exemple #11
0
void _GR_swap32(GR_int32 *l) {
  GR_int32 res;
  GRX_ENTER();
  res  = SWAPBYTE(GR_int32,*l,3,0);
  res |= SWAPBYTE(GR_int16,*l,0,3);
  res |= SWAPBYTE(GR_int16,*l,2,1);
  res |= SWAPBYTE(GR_int16,*l,1,2);
  *l = res;
  GRX_LEAVE();
}
Exemple #12
0
void drawpattern(int x,int y,int w,char patt,GrColor fg,GrColor bg)
{
	GR_int8u mask;
	GRX_ENTER();
	mask = 0x80;
	w += x;
	do {
	    drawpixel(x,y,(patt & mask) ? fg : bg);
	    if((mask >>= 1) == 0) mask = 0x80;
	} while(++x != w);
	GRX_LEAVE();
}
Exemple #13
0
static int buildframedriver(GrVideoMode *mp,GrFrameDriver *drv)
{
    GrFrameDriver *d1, *d2;
    int res = TRUE;
    GRX_ENTER();
    res = TRUE;
    d1 = _GrFindFrameDriver(mp->extinfo->mode);
    d2 = mp->extinfo->drv;
    if(d1) sttcopy(drv,d1);
    if(d2) {
        int compl = TRUE;
#           define MERGE(F) if(d2->F) drv->F = d2->F; else compl = FALSE;
        MERGE(readpixel);
        MERGE(drawpixel);
        MERGE(drawhline);
        MERGE(drawvline);
        MERGE(drawblock);
        MERGE(drawline);
        MERGE(drawbitmap);
        MERGE(drawpattern);
        MERGE(bitblt);
        MERGE(bltv2r);
        MERGE(bltr2v);
        MERGE(getindexedscanline);
        MERGE(putscanline);
        if(compl) {
            memcpy(drv,d2,offsetof(GrFrameDriver,readpixel));
            goto done; /* TRUE */
        }
        if(!d1) {
            res = FALSE;
            goto done;
        }
        if((d2->mode == d1->mode) &&
                (d2->rmode == d1->rmode) &&
                (d1->is_video ? d2->is_video : !d2->is_video) &&
                (d2->row_align <= d1->row_align) && !(d1->row_align % d2->row_align) &&
                (d2->num_planes == d1->num_planes) &&
                (d2->max_plane_size >= d1->max_plane_size) &&
                (d2->bits_per_pixel == d1->bits_per_pixel)) {
            drv->init = d2->init ? d2->init : d1->init;
            goto done; /* TRUE */
        }
    }
    if(!d1) {
        res = FALSE;
        goto done;
    }
    sttcopy(drv,d1);
done:
    GRX_RETURN(res);
}
Exemple #14
0
static INLINE
GrxColor readpixel(GrxFrame *c,int x,int y)
{
        GR_int32u offs;
        GrxColor pix;
        GRX_ENTER();
        offs = FOFS(x,y,c->line_offset);
        pix = 0;
        WR24BYTE(pix,0,peek_b(&c->base_address.plane0[offs]));
        WR24BYTE(pix,1,peek_b(&c->base_address.plane1[offs]));
        WR24BYTE(pix,2,peek_b(&c->base_address.plane2[offs]));
        GRX_RETURN(pix);
}
Exemple #15
0
static void bitblit(GrxFrame *dst,int dx,int dy,
                    GrxFrame *src,int sx,int sy,
                    int w,int h,GrxColor op)
{
    int pl;
    GRX_ENTER();
    if(grx_color_get_mode(op) == GRX_COLOR_MODE_IMAGE)
        bitblt(dst,dx,dy,src,sx,sy,w,h,op);
    else
        for (pl=0; pl < 3; ++pl)
            _GrFrDrvPackedBitBltR2Rpl(dst,dx,dy,src,sx,sy,w,h,op,pl);
    GRX_LEAVE();
}
Exemple #16
0
static void w32_drawblock(int x, int y, int w, int h, GrxColor color)
{
    RECT Rect;

    GRX_ENTER();
    drawblock(x, y, w, h, color);
    Rect.left = x;
    Rect.top = y;
    Rect.right = x + w;
    Rect.bottom = y + h;
    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #17
0
static void w32_bitblt(GrxFrame *dst, int dx, int dy, GrxFrame *src,
                       int sx, int sy, int w, int h, GrxColor op)
{
    RECT Rect;

    GRX_ENTER();
    bitblt(dst, dx, dy, src, sx, sy, w, h, op);
    Rect.left = dx;
    Rect.top = dy;
    Rect.right = dx + w;
    Rect.bottom = dy + h;
    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #18
0
static int init(GrVideoMode *mp)
{
    GRX_ENTER();
    /* set write mode 0 */
    outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_MODE_REG));
    /* don't care register to 0 */
    outport_w(VGA_GR_CTRL_PORT,((0 << 8) | VGA_COLOR_DONTC_REG));
    /* enable all 4 planes for writing */
    outport_w(VGA_SEQUENCER_PORT,((0x0f << 8) | VGA_WRT_PLANE_ENB_REG));
    /* enable all 4 planes for set/reset */
    outport_w(VGA_GR_CTRL_PORT,((0x0f << 8) | VGA_SET_RESET_ENB_REG));
    lastcolor = (-1L);
    GRX_RETURN(TRUE);
}
Exemple #19
0
static void w32_drawbitmap(int x, int y, int w, int h, unsigned char *bmp,
                           int pitch, int start, GrxColor fg, GrxColor bg)
{
    RECT Rect;

    GRX_ENTER();
    drawbitmap(x, y, w, h, bmp, pitch, start, fg, bg);
    Rect.left = x;
    Rect.top = y;
    Rect.right = x + w;
    Rect.bottom = y + h;
    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #20
0
static void w32_drawpattern(int x, int y, int w, unsigned char patt,
                            GrxColor fg, GrxColor bg)
{
    RECT Rect;

    GRX_ENTER();
    drawpattern(x, y, w, patt, fg, bg);
    Rect.left = x;
    Rect.top = y;
    Rect.right = x + w;
    Rect.bottom = y + 1;
    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #21
0
static void reset(void)
{
        GRX_ENTER();
#if defined(__WIN32__)
        _SGrActive = TRUE;
        if(_SGrBackup != NULL) free(_SGrBackup);
        _SGrBackup = NULL;
#endif
        if(_SGrScreen != NULL)
            if(SDL_MUSTLOCK(_SGrScreen)) SDL_UnlockSurface(_SGrScreen);
        if(SDL_WasInit(SDL_INIT_VIDEO)) SDL_Quit();
        _SGrScreen = NULL;
        GRX_LEAVE();
}
Exemple #22
0
void _GR_swap64(GR_int64 *h) {
  GR_int64 res;
  GRX_ENTER();
  res  = SWAPBYTE(GR_int64,*h,7,0);
  res |= SWAPBYTE(GR_int64,*h,0,7);
  res |= SWAPBYTE(GR_int64,*h,6,1);
  res |= SWAPBYTE(GR_int64,*h,1,6);
  res |= SWAPBYTE(GR_int64,*h,5,2);
  res |= SWAPBYTE(GR_int64,*h,2,5);
  res |= SWAPBYTE(GR_int64,*h,4,3);
  res |= SWAPBYTE(GR_int64,*h,3,4);
  *h = res;
  GRX_LEAVE();
}
Exemple #23
0
static void w32_drawpixel(int x, int y, GrxColor color)
{
    HDC hDC;
    COLORREF c;

    GRX_ENTER();
    drawpixel(x, y, color);

    c = GetPixel ( hDCMem, x, y );
    hDC = GetDC ( hGRXWnd );
    SetPixelV ( hDC, x, y, c );
    ReleaseDC ( hGRXWnd, hDC );

    GRX_LEAVE();
}
Exemple #24
0
static INLINE
void drawpixel(int x,int y,GrColor color)
{
    char *ptr;
    GRX_ENTER();
    ptr = &CURC->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)];
    setup_far_selector(CURC->gc_selector);
    if(lastcolor != color) {
        outport_w(VGA_GR_CTRL_PORT,writeops[C_OPER(color) & 3]);
        outport_w(VGA_GR_CTRL_PORT,((((int)color & 0x0f) << 8) | VGA_SET_RESET_REG));
        lastcolor = color;
    }
    outport_w(VGA_GR_CTRL_PORT,((0x8000U >> (x & 7)) | VGA_BIT_MASK_REG));
    poke_b_f_or(ptr,0);
    GRX_LEAVE();
}
Exemple #25
0
static INLINE
GrColor readpixel(GrFrame *c,int x,int y)
{
    char *ptr;
    unsigned mask, pixval;
    GRX_ENTER();
    ptr = &SCRN->gc_baseaddr[0][FOFS(x,y,SCRN->gc_lineoffset)];
    mask= 0x80U >> (x &= 7);
    setup_far_selector(SCRN->gc_selector);
    outport_w(VGA_GR_CTRL_PORT,((3 << 8) | VGA_RD_PLANE_SEL_REG));
    pixval = (peek_b_f(ptr) & mask);
    outport_b(VGA_GR_CTRL_DATA,2);
    pixval = (peek_b_f(ptr) & mask) | (pixval << 1);
    outport_b(VGA_GR_CTRL_DATA,1);
    pixval = (peek_b_f(ptr) & mask) | (pixval << 1);
    outport_b(VGA_GR_CTRL_DATA,0);
    pixval = (peek_b_f(ptr) & mask) | (pixval << 1);
    lastcolor = (-1L);
    GRX_RETURN((GrColor)(pixval >> (7 - x)));
}
Exemple #26
0
void GrPatternDrawChar(long chr,int x,int y,const GrTextOption *opt,GrPattern *p)
{
    char  cbuff[2];
    short sbuff[2];

    GRX_ENTER();
    switch(opt->txo_chrtype) {
      case GR_UTF8_TEXT:
	GrPatternDrawString((void *)&chr,1,x,y,opt,p);
	break;
      case GR_WORD_TEXT:
      case GR_ATTR_TEXT:
	sbuff[0] = chr;
	GrPatternDrawString(sbuff,1,x,y,opt,p);
	break;
      default:
	cbuff[0] = chr;
	GrPatternDrawString(cbuff,1,x,y,opt,p);
	break;
    }
    GRX_LEAVE();
}
Exemple #27
0
static void drawhline(int x,int y,int w,GrxColor color) {
    int copr, pl;
    GR_int32u offs;
    GRX_ENTER();
    copr = C_OPER(color);
    offs = FOFS(x,y,CURC->gc_line_offset);
    for (pl=0; pl < 3; ++pl) {
      if(DOCOLOR8(color,copr)) {
        GR_repl cval = freplicate_b(color);
        char *pp = &GRX_FRAME_MEMORY_PLANE(&CURC->gc_base_address,pl)[offs];
        int ww = w;
        switch(copr) {
            case C_XOR: repfill_b_xor(pp,cval,ww); break;
            case C_OR:  repfill_b_or( pp,cval,ww); break;
            case C_AND: repfill_b_and(pp,cval,ww); break;
            default:    repfill_b(    pp,cval,ww); break;
        }
      }
      color >>= 8;
    }
    GRX_LEAVE();
}
Exemple #28
0
void w32_putscanline(int x, int y, int w,
                     const GrxColor *scl, GrxColor op )
{
    GrxColor skipc;
    RECT Rect;

    GRX_ENTER();
    Rect.left = x;
    Rect.top = y;
    Rect.right = x + w;
    Rect.bottom = y + 1;

    skipc = op ^ GRX_COLOR_MODE_IMAGE;
    op &= GRX_COLOR_MODE_MASK;
    for ( w += x; x < w; ++x) {
        GrxColor c = *(scl++);
        if (c != skipc) drawpixel(x, y, (c|op));
    }

    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #29
0
static void w32_drawline(int x, int y, int dx, int dy, GrxColor color)
{
    RECT Rect;

    GRX_ENTER();
    drawline(x, y, dx, dy, color);
    if (dx > 0 ) {
        Rect.left = x;
        Rect.right = x + dx + 1;
    } else {
        Rect.left = x + dx;
        Rect.right = x + 1;
    }
    if (dy > 0 ) {
        Rect.top = y;
        Rect.bottom = y + dy + 1;
    } else {
        Rect.top = y + dy;
        Rect.bottom = y + 1;
    }
    InvalidateRect(hGRXWnd, &Rect, FALSE);
    GRX_LEAVE();
}
Exemple #30
0
static void drawvline(int x,int y,int h,GrxColor color)
{
    int copr, pl;
    GR_int32u offs;
    unsigned lwdt;
    GRX_ENTER();
    copr = C_OPER(color);
    lwdt = CURC->gc_line_offset;
    offs = FOFS(x,y,lwdt);
    for (pl=0; pl < 3; ++pl) {
      if(DOCOLOR8(color,copr)) {
        char *pp = &GRX_FRAME_MEMORY_PLANE(&CURC->gc_base_address,pl)[offs];
        int hh = h;
        switch(copr) {
            case C_XOR: colfill_b_xor(pp,lwdt,(GR_int8u)color,hh); break;
            case C_OR:  colfill_b_or( pp,lwdt,(GR_int8u)color,hh); break;
            case C_AND: colfill_b_and(pp,lwdt,(GR_int8u)color,hh); break;
            default:    colfill_b(    pp,lwdt,(GR_int8u)color,hh); break;
        }
      }
      color >>= 8;
    }
    GRX_LEAVE();
}