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

📄 s3im.c

📁 基于组件方式开发操作系统的OSKIT源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
#endif{   int   j;   char *pline;   int   ypix, xpix0, offset0;   int   cxpix;   char *videobuffer;   char  bank;   if (alu == MIX_DST)      return;   if ((alu != MIX_SRC) || ((planemask & s3BppPMask) != s3BppPMask)) {      s3ImageFillNoMem(x, y, w, h, psrc, pwidth,                     pw, ph, pox, poy, alu, planemask);      return;   }   videobuffer = (char *) s3VideoMem;   if (w == 0 || h == 0)      return;         BLOCK_CURSOR;#if 0   WaitQueue16_32(2,3);   outw (FRGD_MIX, FSS_PCDATA | alu);   outw32(WRT_MASK, planemask);   WaitQueue(8);#endif   pw *= s3Bpp;   modulus ((x - pox) * s3Bpp, pw, xpix0);   cxpix = pw - xpix0;   modulus (y - poy, ph, ypix);   pline = psrc + pwidth * ypix;   offset0 = (y * s3BppDisplayWidth) + x * s3Bpp;   bank = offset0 / s3BankSize;   offset0 %= s3BankSize;   w *= s3Bpp;   WaitIdleEmpty();   s3EnableLinear();   if (bank != old_bank) {      s3BankSelect(bank);   }   for (j = 0; j < h; j++, offset0 += s3BppDisplayWidth) {      int   offset, width, xpix;      width = (w <= cxpix) ? w : cxpix;      xpix = xpix0;      offset = offset0;      if (offset + width >= s3BankSize) {	 int   partwidth;	 partwidth = s3BankSize - offset;	 offset0 -= s3BankSize;	 if (partwidth > 0) {	    MemToBusBase (videobuffer, offset, pline + xpix, partwidth);	    width -= partwidth;	    xpix += partwidth;	    offset = 0;	 } else	    offset = offset0;	 bank++;         s3BankSelect(bank);            }      MemToBusBase (videobuffer, offset, pline + xpix, width);      offset += width;      for (width = w - cxpix; width >= pw; width -= pw, offset += pw) {       /* identical to ImageWrite() */	 if (offset + pw > s3BankSize) {	    int   partwidth;	    partwidth = s3BankSize - offset;	    if (partwidth > 0)	       MemToBusBase (videobuffer, offset, pline, partwidth);	    bank++;	    s3BankSelect(bank);     	    offset -= s3BankSize;	    offset0 -= s3BankSize;	     	    if (partwidth > 0) {	       MemToBusBase (videobuffer, 0, pline + partwidth, pw - partwidth);	       continue;	    }	 }	 MemToBusBase (videobuffer, offset, pline, pw);      }    /* at this point: 0 <= width < pw */      xpix = 0;          if (width > 0) {	 if (offset + width > s3BankSize) {	    int   partwidth;	    partwidth = s3BankSize - offset;	    if (partwidth > 0) {	       MemToBusBase (videobuffer, offset, pline, partwidth);	       width -= partwidth;	       xpix = partwidth;	       offset = 0;	    } else {	       offset -= s3BankSize;	    }	    offset0 -= s3BankSize;	    bank++;	    s3BankSelect(bank);	 }	 MemToBusBase (videobuffer, offset, pline + xpix, width);      }      if ((++ypix) == ph) {	 ypix = 0;	 pline = psrc;      } else	 pline += pwidth;   }   old_bank = bank;   s3DisableLinear();   WaitQueue(1);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);   UNBLOCK_CURSOR;}/* BL */#ifdef S3_NEWMMIO#undef s3EnableLinear#undef s3DisableLinear#undef s3BankSelect#define s3EnableLinear()#define s3DisableLinear()#define s3BankSelect(X)#undef  SET_MULT_MISC#define SET_MULT_MISC(val) outw(MULTIFUNC_CNTL, MULT_MISC) /* for WaitQueue16_32 */#endif/* end BL */static void#if NeedFunctionPrototypess3ImageWrite (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   px,     int   py,     short alu,     unsigned long planemask)#elses3ImageWrite (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   j, offset;   char  bank;   char *videobuffer;   if (alu == MIX_DST)      return;   if ((alu != MIX_SRC) || ((planemask & s3BppPMask) != s3BppPMask)) {      s3ImageWriteNoMem(x, y, w, h, psrc, pwidth, px, py, alu, planemask);      return;   }   videobuffer = (char *) s3VideoMem;   if (w == 0 || h == 0)      return;         BLOCK_CURSOR;#if 0   WaitQueue16_32(2,3);   outw (FRGD_MIX, FSS_PCDATA | alu);   outw32(WRT_MASK, planemask);#endif   psrc += pwidth * py + px * s3Bpp;   offset = (y * s3BppDisplayWidth) + x *s3Bpp;   bank = offset / s3BankSize;   offset %= s3BankSize;   w *= s3Bpp;   WaitIdleEmpty();   s3EnableLinear();    /*  * if we do a bank switch here, is _not_ possible to do one in the loop  * before some data has been copied; for that situation to occur it would be  * necessary that offset == s3BankSize; and by the above initialisation of  * offset, we know offset < s3BankSize  */   if (old_bank != bank) {      s3BankSelect(bank);   }      for (j = 0; j < h; j++, psrc += pwidth, offset += s3BppDisplayWidth) {      if (offset >= s3BankSize) {       /* bank switch to the next bank */	 bank++;	 s3BankSelect(bank);       /* adjust the offset by 1 banks worth */	 offset -= s3BankSize;      }      MemToBusBase (videobuffer, offset, psrc, w);   }   old_bank = bank;   s3DisableLinear();#if 0   WaitQueue(1);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);#endif   UNBLOCK_CURSOR;}static void#if NeedFunctionPrototypess3ImageRead (     int   x,     int   y,     int   w,     int   h,     char *psrc,     int   pwidth,     int   px,     int   py,     unsigned long planemask)#elses3ImageRead (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,w0;   int   offset;   int   bank;   char *videobuffer;   unsigned long l_planemask = 0;   if (w == 0 || h == 0)      return;   if ((planemask & s3BppPMask) != s3BppPMask && !S3_x64_SERIES(s3ChipId)) {      s3ImageReadNoMem(x, y, w, h, psrc, pwidth, px, py, planemask);      return;   }   videobuffer = (char *) s3VideoMem;      #if 0   outw (FRGD_MIX, FSS_PCDATA | MIX_SRC);#endif    psrc += pwidth * py + px * s3Bpp;   offset = (y * s3BppDisplayWidth) + x * s3Bpp;   bank = offset / s3BankSize;   offset %= s3BankSize;   if ((planemask & s3BppPMask) != s3BppPMask) {      w0 = w;      l_planemask = planemask &= s3BppPMask;      for (i=s3Bpp; i<sizeof(long); i+=s3Bpp)	 l_planemask = (l_planemask << (s3Bpp<<3)) | planemask;#ifdef __alpha__      if (s3Bpp == 3)	 l_planemask |= (1<<(24*(sizeof(long)/3))) - 1;#endif      planemask |= ~s3BppPMask;   }   else       w0 = 0;   w *= s3Bpp;   BLOCK_CURSOR;   WaitIdleEmpty ();   s3EnableLinear();   if (old_bank != bank) {      s3BankSelect(bank);   }   for (j = 0; j < h; j++, psrc += pwidth, offset += s3BppDisplayWidth) {      if (offset >= s3BankSize) {       /* bank switch to the next bank */	 bank++;	 s3BankSelect(bank);       /* adjust the offset by 1 banks worth */	 offset -= s3BankSize;      }      BusToMemBase (psrc, videobuffer, offset, w);      if (w0) {	 char *p = psrc;	 switch (s3Bpp) {	 case 1: 	    for (i=w0; i>=sizeof(long); i-=sizeof(long),p+=sizeof(long))	       *((long*)p) &= l_planemask;	    for (; i; i--)	       *p++ &= planemask;	    break;	 case 2: 	    for (i=w0; i>=sizeof(long); i-=sizeof(long),p+=sizeof(long))	       *((long*)p) &= l_planemask;	    for (; i; i--,p+=sizeof(short))	       *((short*)p) &= planemask;	    break;	 case 3:  /* XXX depends on byte sex! __BYTE_ORDER == 1234 assumed */	    i=w0;#ifdef __alpha__	    for (; i>=1; i-=2,p+=6)	       *((long*)p) &= l_planemask ;#endif	    for (; i; i--,p+=3) 	       *((int*)p) &= planemask;	    break;	 case 4:	    for (i=w0; i>=sizeof(long); i-=sizeof(long),p+=sizeof(long))	       *((long*)p) &= l_planemask;	    for (; i; i--,p+=sizeof(int))	       *((int*)p) &= planemask;	    break;	 }      }   }   old_bank = bank;   s3DisableLinear();#if 0   WaitQueue(1);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);#endif   UNBLOCK_CURSOR;}static void#if NeedFunctionPrototypess3ImageFill (     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)#elses3ImageFill (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   j;   char *pline;   int   ypix, xpix, offset0;   int   cxpix;   char *videobuffer;   char  bank;   if (alu == MIX_DST)      return;   if ((alu != MIX_SRC) || ((planemask & s3BppPMask) != s3BppPMask)) {     s3ImageFillNoMem(x, y, w, h, psrc, pwidth,                    pw, ph, pox, poy, alu, planemask);     return;   }   videobuffer = (char *) s3VideoMem;   if (w == 0 || h == 0)      return;       #if 0   WaitQueue16_32(2,3);   outw (FRGD_MIX, FSS_PCDATA | alu);   outw32(WRT_MASK, planemask);#endif   w  *= s3Bpp;   pw *= s3Bpp;   modulus ((x - pox) * s3Bpp, pw, xpix);   cxpix = pw - xpix ;   modulus (y - poy, ph, ypix);   pline = psrc + pwidth * ypix;   offset0 = (y * s3BppDisplayWidth) + x * s3Bpp;   bank = offset0 / s3BankSize;   offset0 %= s3BankSize;   BLOCK_CURSOR;   WaitIdleEmpty();   s3EnableLinear();   if (bank != old_bank) {      s3BankSelect(bank);   }   for (j = 0; j < h; j++, offset0 += s3BppDisplayWidth) {      if (offset0 >= s3BankSize) {	 bank++;	 s3BankSelect(bank);	 offset0 -= s3BankSize;      }      if (w <= cxpix) {	 MemToBusBase (videobuffer, offset0, pline + xpix, w);      } else {	 int   width, offset;	 MemToBusBase (videobuffer, offset0, pline + xpix, cxpix);	 offset = offset0 + cxpix;	 for (width = w - cxpix; width >= pw; width -= pw, offset += pw)	    MemToBusBase (videobuffer, offset, pline, pw);       /* at this point: 0 <= width < pw */	 if (width > 0)	    MemToBusBase (videobuffer, offset, pline, width);      }      if ((++ypix) == ph) {	 ypix = 0;	 pline = psrc;      } else	 pline += pwidth;   }   old_bank = bank;   s3DisableLinear();#if 0   WaitQueue(1);   outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);#endif

⌨️ 快捷键说明

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