⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s3im.c

📁 基于组件方式开发操作系统的OSKIT源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
   UNBLOCK_CURSOR;}#endif /* !OSKIT */void#if NeedFunctionPrototypess3ImageWriteNoMem (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   px,     int   py,     short alu,     unsigned long planemask)#elses3ImageWriteNoMem (x, y, w, h, psrc, pwidth, px, py, alu, planemask)     int   x;     int   y;     int   w;     int   h;     char *psrc;     int   pwidth;     int   px;     int   py;     short alu;     unsigned long planemask;#endif{   int   i, j;   if (alu == MIX_DST)      return;   if (w == 0 || h == 0)      return;         BLOCK_CURSOR;   WaitQueue16_32(3,4);   outw (FRGD_MIX, FSS_PCDATA | alu);   outw32 (WRT_MASK, planemask);   outw (MULTIFUNC_CNTL, PIX_CNTL | 0);   WaitQueue(5);   outw (CUR_X, (short) x);   outw (CUR_Y, (short) y);   outw (MAJ_AXIS_PCNT, (short) w - 1);   outw (MULTIFUNC_CNTL, MIN_AXIS_PCNT | (h - 1));   WaitIdle();   outw (CMD, CMD_RECT | BYTSEQ | _16BIT | INC_Y | INC_X | DRAW | PCDATA	  | WRTDATA);   w *= s3Bpp;   psrc += pwidth * py;   for (j = 0; j < h; j++) {      /* This assumes we can cast odd addresses to short! NOT!! */      short *psrcs = (short *)&psrc[px*s3Bpp];      for (i = 0; i < (w & ~1); ) {	 if (s3InfoRec.bitsPerPixel == 32) {	    outl (PIX_TRANS, ldl_u((unsigned int *)psrcs));	    psrcs+=2;	    i += 4;	 }	 else {	    outw (PIX_TRANS, ldw_u(psrcs));	    psrcs++;	    i += 2;	 }      }      if (i < w)  /* can't happen for 32bpp */	 outw (PIX_TRANS, *((char*)psrcs));      psrc += pwidth;   }#if 0   WaitQueue16_32(2,3);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);   outw32(WRT_MASK, ~0);#endif   UNBLOCK_CURSOR;}static void#if NeedFunctionPrototypess3ImageReadNoMem (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   px,     int   py,     unsigned long planemask)#elses3ImageReadNoMem (x, y, w, h, psrc, pwidth, px, py, planemask)     int   x;     int   y;     int   w;     int   h;     char *psrc;     int   pwidth;     int   px;     int   py;     unsigned long planemask;#endif{   int   i, j;   if (w == 0 || h == 0)      return;         BLOCK_CURSOR;   WaitIdleEmpty ();   WaitQueue(7);   outw (MULTIFUNC_CNTL, PIX_CNTL);   outw (FRGD_MIX, FSS_PCDATA | MIX_SRC);   outw (CUR_X, (short) x);   outw (CUR_Y, (short) y);   outw (MAJ_AXIS_PCNT, (short) w - 1);   outw (MULTIFUNC_CNTL, MIN_AXIS_PCNT | (h - 1));   outw (CMD, CMD_RECT  | BYTSEQ | _16BIT | INC_Y | INC_X | DRAW |	  PCDATA);   WaitQueue16_32(1,2);   outw32(RD_MASK, planemask);   WaitQueue(8); /* wait for data to be ready */   if (!S3_x64_SERIES(s3ChipId)) {     while ((inw (GP_STAT) & 0x100) == 0) ;   }   else {     /* x64: GP_STAT bit 8 is reserved for 864/964 */   }   w *= s3Bpp;   psrc += pwidth * py;   for (j = 0; j < h; j++) {      short *psrcs = (short *)&psrc[px*s3Bpp];       for (i = 0; i < (w & ~1); ) {	 if (s3InfoRec.bitsPerPixel == 32) {	    *((long*)(psrcs)) = inl(PIX_TRANS);	    psrcs += 2;	    i += 4;	 } else {	    *psrcs++ = inw(PIX_TRANS);	    i += 2;	 }      }      if (i < w)  /* can't happen for 32bpp */	 *((char*)psrcs) = inw(PIX_TRANS);      psrc += pwidth;   }   WaitQueue16_32(2,3);   outw32(RD_MASK, ~0);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);   UNBLOCK_CURSOR;}static void#if NeedFunctionPrototypess3ImageFillNoMem (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   pw,     int   ph,     int   pox,     int   poy,     short alu,     unsigned long planemask)#elses3ImageFillNoMem (x, y, w, h, psrc, pwidth, pw, ph, pox, poy, alu, planemask)     int   x;     int   y;     int   w;     int   h;     char *psrc;     int   pwidth;     int   pw;      int   ph;      int   pox;     int   poy;     short alu;     unsigned long planemask;#endif{   int   i, j;   char *pline;   int   mod;   if (alu == MIX_DST)      return;   if (w == 0 || h == 0)      return;   BLOCK_CURSOR;     WaitQueue16_32(7,8);   outw (FRGD_MIX, FSS_PCDATA | alu);   outw32 (WRT_MASK, planemask);   outw (CUR_X, (short) x);   outw (CUR_Y, (short) y);   outw (MAJ_AXIS_PCNT, (short) w - 1);   outw (MULTIFUNC_CNTL, MIN_AXIS_PCNT | (h - 1));   WaitIdle();   outw (CMD, CMD_RECT | BYTSEQ|_16BIT | INC_Y | INC_X | DRAW |	 PCDATA | WRTDATA);   for (j = 0; j < h; j++) {      unsigned short wrapped;      unsigned short *pend;      unsigned short *plines;      modulus (y + j - poy, ph, mod);      pline = psrc + pwidth * mod;      pend = (unsigned short *)&pline[pw*s3Bpp];      wrapped = (pline[0] << 8) + (pline[pw-1] << 0); /* only for 8bpp */      modulus (x - pox, pw, mod);      plines = (unsigned short *) &pline[mod*s3Bpp];      for (i = 0; i < w * s3Bpp;)  {         /* arrg in 8BPP we need to check for wrap round */         if (plines + 1 > pend) {	    outw (PIX_TRANS, wrapped);            plines = (unsigned short *)&pline[1]; i += 2;	 } else {	    if (s3InfoRec.bitsPerPixel == 32) {	       outl (PIX_TRANS, ldl_u((unsigned int *)(plines)));	       plines += 2;	       i += 4;	    }	    else {	       outw (PIX_TRANS, ldw_u(plines++));	       i += 2;	    }	 }	 if (plines == pend)	    plines = (unsigned short *)pline;	       }   }   WaitQueue(1);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);      UNBLOCK_CURSOR;}#ifndef OSKITstatic int _internal_s3_mskbits[17] ={   0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff,   0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff};#define MSKBIT(n) (_internal_s3_mskbits[(n)])#ifdef S3_NEWMMIO#undef  SET_MULT_MISC#define SET_MULT_MISC(val)	((mmtr)s3MmioMem)->pk_enh_regs.regs.mult_misc = (val)#endifstatic voids3RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,		   fgPixel, bgPixel, alu, planemask, opaque)    int			x;    int			y;    int			w;    int			h;    unsigned char	*psrc;    int			pw, ph, pox, poy;    int			pwidth;    Pixel		fgPixel;    Pixel		bgPixel;    short		alu;    Pixel		planemask;    int			opaque;{    int			srcx, srch, dstw;    unsigned short	*ptmp;    if (alu == MIX_DST || w == 0 || h == 0)	return;    BLOCK_CURSOR;    WaitQueue16_32(5,8);    SET_WRT_MASK(planemask);    SET_FRGD_MIX(FSS_FRGDCOL | alu);    if( opaque ) {      SET_BKGD_MIX(BSS_BKGDCOL | alu);      SET_BKGD_COLOR(bgPixel);    }    else {       if (s3_968_DashBug) {	  SET_BKGD_COLOR(0);	  SET_BKGD_MIX(BSS_BKGDCOL | MIX_OR);       }       else {	  SET_BKGD_MIX(BSS_BKGDCOL | MIX_DST);       }    }    SET_FRGD_COLOR(fgPixel);    WaitQueue(6);    SET_PIX_CNTL(MIXSEL_EXPPC | COLCMPOP_F);    SET_AXIS_PCNT((short) (w - 1), (short)(h-1));    SET_CURPT((short) x, (short) y);    WaitIdle();    SET_CMD(CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |	     DRAW | PLANAR | WRTDATA | BYTSEQ);    modulus(x - pox, pw, x);    modulus(y - poy, ph, y);    /*     * When the source bitmap is properly aligned, max 16 pixels wide     * and nonrepeating, use this faster loop instead.     */    if( (x & 7) == 0 && w <= 16 && x+w <= pw && y+h <= ph ) {	unsigned short pix;	unsigned char *pnt;	pnt = (unsigned char *)(psrc + pwidth * y + (x >> 3));	while( h-- > 0 ) {	    pix = ldw_u(((unsigned short *)(pnt)));	    SET_PIX_TRANS_W(s3SwapBits[ pix & 0xff ] | 			       s3SwapBits[ ( pix >> 8 ) & 0xff ] << 8);	    pnt += pwidth;	}    }    else {	while( h > 0 ) {	    srch = ( y+h > ph ? ph - y : h );	    while( srch > 0 ) {		dstw = w;		srcx = x;		ptmp = (unsigned short *)(psrc + pwidth * y);		while( dstw > 0 ) {		    int np, x2;		    unsigned short *pnt, pix;		    /*		     * Assemble 16 bits and feed them to the draw engine.		     */		    np = pw - srcx;		/* No. pixels left in bitmap.*/		    pnt =(unsigned short *)				       ((unsigned char *)(ptmp) + (srcx >> 3));		    x2 = srcx & 7;		/* Offset within byte. */		    if( np >= 16 ) {		      pix = (unsigned short)(ldl_u((unsigned int *)(pnt)) >> x2);		    }		    else if( pw >= 16 ) {		      pix = (unsigned short)((ldl_u((unsigned int *)(pnt)) >> x2)					     & MSKBIT(np)) | (ldw_u(ptmp) << np);		    }		    else if( pw >= 8 ) {			pix = ((ldw_u(pnt) >> x2) & MSKBIT(np)) 			   | ((ldw_u(ptmp) & MSKBIT(pw)) << np) | (ldw_u(ptmp) << (np+pw));		    }		    else {			pix = (ldw_u(pnt) >> x2) & MSKBIT(np);			while( np < 16 && np < dstw ) {			    pix |= (ldw_u(ptmp) & MSKBIT(pw)) << np;			    np += pw;			}		    }		    SET_PIX_TRANS_W(s3SwapBits[ pix & 0xff ] | 				       s3SwapBits[ ( pix >> 8 ) & 0xff ] << 8);		    srcx += 16;		    while (srcx >= pw)			srcx -= pw;		    dstw -= 16;		}		y++;		h--;		srch--;	    }	    y = 0;	}    }    WaitQueue(4);    SET_MIX(FSS_FRGDCOL | MIX_SRC, BSS_BKGDCOL | MIX_SRC);    SET_PIX_CNTL(MIXSEL_FRGDMIX | COLCMPOP_F);    UNBLOCK_CURSOR;}void#if NeedFunctionPrototypess3ImageStipple (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   pw,     int   ph,     int   pox,     int   poy,     Pixel fgPixel,     short alu,     unsigned long planemask)#elses3ImageStipple (x, y, w, h, psrc, pwidth, pw, ph, pox, poy, fgPixel, alu, planemask)     int   x;     int   y;     int   w;     int   h;     char *psrc;     int   pwidth;     int   pw;     int   ph;     int   pox;     int   poy;     Pixel fgPixel;     short alu;     unsigned long planemask;#endif{    s3RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,		       fgPixel, 0, alu, planemask, 0);}#if NeedFunctionPrototypesvoids3ImageOpStipple (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   pw,     int   ph,     int   pox,     int   poy,     Pixel fgPixel,     Pixel bgPixel,      short alu,     unsigned long planemask)#elsevoids3ImageOpStipple (x, y, w, h, psrc, pwidth, pw,		  ph, pox, poy, fgPixel, bgPixel, alu, planemask)     int   x;     int   y;     int   w;     int   h;     char *psrc;     int   pwidth;     int   pw, ph, pox, poy;     Pixel fgPixel;     Pixel bgPixel;     short alu;     unsigned long planemask;#endif{    s3RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,		       fgPixel, bgPixel, alu, planemask, 1);}#endif /* !OSKIT */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -