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

📄 str20.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
			sfPixBytes = gpGrafMap->pixBytes;

/* BobB 9/8/98 - Corrected the folloing line for correct pointer
			rowTable = *gpGrafMap->mapTable[0]; */
			rowTable = gpGrafMap->mapTable[0];
				
			#ifdef FIXUP386
			rowTable -= dllFixup;
/* BobB 9/10/98 - corrected the following two lines to get saved pointer
			sfBitmap = (byte *) *rowTable;    						  	
			sfBitmap -= dllFixup; */
			svBitmap = (byte *) *rowTable;    						  	
			svBitmap -= dllFixup;
			#else
/* BobB 9/10/98 - corrected the following line to get saved pointer
			sfBitmap = (byte *) *rowTable;  */   						  	
			svBitmap = (byte *) *rowTable;    						  	
			#endif
				
		/* set Ys of source (same for all rects) */
			grafBlist.Ymin = StrPtr[0].sYmin;
			grafBlist.Ymax = StrPtr[0].sYmax;
				
		/* for each rectangle in the list move the font pixels to
			the workspace*/
			do{
				sfByteCnt = -(StrPtr[charCount].sXmin >> 3) ;
/* BobB 9/10/98 - corrected the following line to get saved pointer
				sfBitmap -= sfByteCnt ; */
				sfBitmap = svBitmap - sfByteCnt;
			/* Round sXmax up to next byte */
				sfByteCnt += ((StrPtr[charCount].sXmax + 7) >> 3);
			/* Compute deltas to next raster  */
				sfDst2Next = workGrafMap.pixBytes - sfByteCnt ;
				
				if(sfDst2Next < 0 )
				{	/* rect too big for workspace buffer  */
					ErrValue = c_DrawText + c_OutofMem ;
					nuGrafErr(ErrValue);
					continue;
				}
	
				sfSrc2Next = sfPixBytes - sfByteCnt;
				wsBitmap = mpWorkSpace;
				for (i = 0; i < StrPtr[charCount].sYmax; i++)
				{
					for (j = 0; j < sfByteCnt; j++)
					{
/* BobB 9/8/98 - Corrected the following line for incrementing
						*wsBitmap = *sfBitmap; */
						*wsBitmap++ = *sfBitmap++;
					}

					sfBitmap += sfSrc2Next; 
					wsBitmap += sfDst2Next;
				}

			/* set Xs of workspace rect  */
				grafBlist.Xmin = StrPtr[charCount].sXmin & 7;
/* BobB 9/9/98 - corrected the following line to get Xmax
				grafBlist.Xmax = StrPtr[charCount].sXmax + grafBlist.Xmin ;	*/
				grafBlist.Xmax = StrPtr[charCount].sXmax -
					StrPtr[charCount].sXmin + grafBlist.Xmin;
				
			/* Apply the facing  */
				if(gpTxFace & faceBold)
				{	/* or's the image over itself advancing in X by the
					ports txBold boldness factor  */
					sfShiftBytes = (grafPort.txBold >> 3) + sfByteCnt + 1;
					if(sfShiftBytes > workGrafMap.pixBytes)
					{
						ErrValue = c_DrawText + c_OutofMem;
						nuGrafErr(ErrValue);
					}
					else
					{
						MaskLeft = LfMask[StrPtr[charCount].sXmin & 0x07];
						MaskRight= RtMask[StrPtr[charCount].sXmax & 0x07];
						wsBitmap = mpWorkSpace;
						for (i = 0; i < StrPtr[charCount].sYmax; i++)
						{
							sfBitmap = wsBitmap;
							ws2Bitmap = wsBitmap + sfByteCnt - 1;
							*wsBitmap &= MaskLeft;
							*ws2Bitmap++ &= MaskRight;
							*ws2Bitmap++ = 0;
							*ws2Bitmap = 0;
							for (j = 0; j < grafPort.txBold; j++)
							{
/* BobB 9/9/98 - added the following line to zero the old LSB */
								tempData = 0;
								for (k = 0; k < sfShiftBytes; k++)
								{
/* BobB 9/9/98 - Corrected the following three lines to get or'd shifted data
									tempData = *wsBitmap & 1;
									*wsBitmap = (*wsBitmap >> 1);
									if (tempData) *wsBitmap |= 0x80; */
									boldData = (*wsBitmap >> 1);
									if (tempData) boldData |= 0x80;
									tempData = *wsBitmap & 1;
									*wsBitmap |= boldData;	/* or in shifted data */
									wsBitmap++;
								}

								wsBitmap = sfBitmap;
							}
							wsBitmap = sfBitmap + workGrafMap.pixBytes;
						}

						StrPtr[charCount].dXmax	+= grafPort.txBold;
						grafBlist.Xmax += grafPort.txBold;
					}
				}	/* End Bold Face  */

				if(gpTxFace & faceHalftone)
				{	/* sets bits to background using a 50% pattern  */
					wsBitmap = mpWorkSpace;
					MaskRight = 0x55;	/* clear half the bits */
					for (i = 0; i < StrPtr[charCount].sYmax; i++)
					{
						for (j = 0; j < sfByteCnt; j++)							
						{
							*wsBitmap++ &= MaskRight;
						}
						wsBitmap += sfDst2Next;
						MaskLeft = MaskRight & 0x01;
						MaskRight = MaskRight >> 1;
						if (MaskLeft == 1) MaskRight |= 0x80;
					}
				}	/* END Halftone  */

				sfShiftInc = (3600 - grafPort.txSlant) / 50;
				if((gpTxFace & faceItalic) && (sfShiftInc < 18))
				{	/* only handle slant to right for now with 5 degree
					increments */
				/* compute amount of shift per raster necessary (times 256) */
					sfShiftInc = deltatbl[sfShiftInc];
				/* compute total amount of shift necessary in bytes  */
					sfCumShift = (sfShiftInc * StrPtr[charCount].sYmax) >> 8;
					StrPtr[charCount].dXmax += sfCumShift;
					grafBlist.Xmax += sfCumShift;
				/* compute bytes of entire shifted retangle  */
					sfShiftBytes = ((sfCumShift + 7) >> 3) + sfByteCnt;
				/* check will fit in buffer  */
					if(sfShiftBytes > workGrafMap.pixBytes )
					{
						ErrValue = c_DrawText + c_OutofMem;
						nuGrafErr(ErrValue);
					}
					else
					{	/* Mask and store */		
						sfCumShift = 0;
						MaskLeft = LfMask[StrPtr[charCount].sXmin & 0x07];
						MaskRight= RtMask[StrPtr[charCount].sXmax & 0x07];
						for (i = (StrPtr[charCount].sYmax -1); i >= 0; i--)
						{
							wsBitmap = mpWorkSpace + (i * workGrafMap.pixBytes);
							ws2Bitmap = wsBitmap + sfByteCnt - 1;
							*wsBitmap &= MaskLeft;
							*ws2Bitmap++ &= MaskRight;
							sfBitmap = wsBitmap;
							j = sfShiftBytes - sfByteCnt;
							while (j-- > 0)
							{
								*ws2Bitmap++ = 0;
							}

							j = sfCumShift >> 8;
							while (j-- > 0)
							{	/* shift raster right */
/* BobB 9/9/98 - added the following line to zero the old LSB */
								tempData = 0;
								for (k = 0; k < sfShiftBytes; k++)
								{
/* BobB 9/9/98 - Corrected the following three lines to get shifted data
									tempData = *wsBitmap & 1;
									*wsBitmap = (*wsBitmap >> 1);
									if (tempData) *wsBitmap |= 0x80; */
									boldData = (*wsBitmap >> 1);
									if (tempData) boldData |= 0x80;
									tempData = *wsBitmap & 1;
									*wsBitmap = boldData;	/* store shifted data */
									wsBitmap++;
								}

								wsBitmap = sfBitmap;
							}

						/* Compute pixels to shift next raster  */
							sfCumShift += sfShiftInc;
						}
					}
				}	/* END Italic   */

			/* Blit the rect from the work space to the destination  */
/* BobB 9/9/98 - corrected the following 4 lines for the dest rect
				grafBlist.Xmin = StrPtr[charCount].dXmin;
				grafBlist.Xmax = StrPtr[charCount].dXmax;
				grafBlist.Ymin = StrPtr[charCount].dYmin;
				grafBlist.Ymax = StrPtr[charCount].dYmax; */
				grafBlist.skipStat = StrPtr[charCount].dXmin;
				grafBlist.temp1 = StrPtr[charCount].dYmin;
				grafBlist.temp2 = StrPtr[charCount].dXmax;					
				grafBlist.temp3 = StrPtr[charCount].dYmax;				
						
				grafPort.portMap->prBlit1S(&grafBlit); 

/* BobB 9/9/98 - corrected the following line
			}while (charCount++ <= COUNT); */
			}while (++charCount < COUNT);
		}
		else
		{	/* no special processing */
			grafBlit.blitList = (long) &StrPtr[0]; 
			grafBlit.blitSmap = gpGrafMap;  
			grafPort.portMap->prBlit1S(&grafBlit);
		}

	/* Process intercharacter fills  */
		if(!(gpTxMode & 0x10))
		{
			dstPtr = (rect *) &StrPtr[0];
			charCount = 0;
			if(gpTxPath != pathRight) goto PathedFill;
			if(bgnX < StrPtr[0].dXmin )
			{
				dstPtr->Xmax = StrPtr[0].dXmin;
				dstPtr->Xmin = bgnX;
				dstPtr->Ymin = dstYmin;
				dstPtr->Ymax = dstYmax;
				dstPtr++;
			}

			while(++charCount < COUNT)
			{
				tempData = StrPtr[charCount - 1].dXmax;
				if (tempData < StrPtr[charCount].dXmin)
				{
					dstPtr->Xmax = StrPtr[charCount].dXmin;
					dstPtr->Xmin = tempData;
					dstPtr->Ymin = dstYmin;
					dstPtr->Ymax = dstYmax;
					dstPtr++;
				}
			}

			dstPtr->Xmin = StrPtr[charCount - 1].dXmax;
			dstPtr->Xmax = dstX;
			dstPtr->Ymin = dstYmin;
			dstPtr->Ymax = dstYmax;
			dstPtr++;

			grafBlit.blitCnt = ((int) dstPtr - (int) &StrPtr[0] - 8); 
			if(grafBlit.blitCnt > 0 )
			{
				grafBlit.blitList = (long) &StrPtr[0]; 
				grafBlit.blitCnt = grafBlit.blitCnt >> 3;
				grafBlit.blitPat = grafPort.bkPat;
				grafPort.portMap->prFill(&grafBlit);
			}
		}	/* End fills */
			
		if(gpTxFace & faceUnderline)
		{	/* port txUnder controls depth from baseline; port txScore
			controls distance around descenders */
			tempData = fntVertTbl[alignBaseline * 2] + 1 + grafPort.txUnder;
			penSize = grafPort.pnSize.Y;
			if(penSize == 0) penSize++;	/* must have pen => 1 */

			grafBlist.Ymin = tempData + dstYmin - (penSize >> 1);
			grafBlist.Ymax = grafBlist.Ymin + penSize;
			grafBlist.Xmin = LocX;
			grafBlist.Xmax = LocX;
			grafBlit.blitCnt = 1;
			grafBlit.blitPat = 1;
			grafBlit.blitList = (long) &grafBlist;

			/* advance along X looking for transitions in pen color */
			oldPen = -1;	/* set to unknown state */
			do{
				if (grafPort.portMap->prGetPx(grafBlist.Xmax, grafBlist.Ymin,
					grafPort.portMap) != grafPort.pnColor)
				{	/* not in pen */
					if(oldPen == -1)
					{	/* unknown state - first time through */
						oldPen = 1;
					}
					else
					{
						if (oldPen == 0)
						{	/* had a transition */
							oldPen++;
							grafBlist.Xmin = grafBlist.Xmax + grafPort.txScore;
						}
					}
				}
				else
				{	/* in pen */
					if(oldPen == -1)
					{	/* unknown state - first time through */
						oldPen = 0;
					}
					else
					{
						if (oldPen != 0)
						{	/* had a transition */
							oldPen = 0;
							tempData = grafBlist.Xmax - grafPort.txScore;
							if(tempData > grafBlist.Xmin)
							{
								grafBlist.Xmax = tempData;
								grafPort.portMap->prFill(&grafBlit);  
								grafBlist.Xmax += grafPort.txScore;
								grafBlist.Xmin = grafBlist.Xmax;
							}	
						}
					}
				}

				grafBlist.Xmax++;
			}while (grafBlist.Xmax < dstX );
					
			if (grafBlist.Xmax > grafBlist.Xmin) 
				grafPort.portMap->prFill(&grafBlit);
		}	/* End Underline  */

		if(gpTxFace & faceStrikeout)
		{	/* strikeout line halfway between char rect */
			penSize = grafPort.pnSize.Y;
			if(penSize == 0) penSize++;	/* must have pen => 1 */

			srcYmax = ((srcYmax + 1) - penSize) >> 1;

			grafBlist.Ymin = dstYmin + srcYmax;	/* setup rect */
			grafBlist.Ymax = grafBlist.Ymin + penSize;
			grafBlist.Xmin = LocX;
			grafBlist.Xmax = dstX;
			grafBlit.blitCnt = 1;
			grafBlit.blitPat = 1;

/* BobB 1/7/99 - Added the following line to correct blit list pointer */
			grafBlit.blitList = (long) &grafBlist;
			grafPort.portMap->prFill(&grafBlit); 
		}	/* End Strikeout */
					
PathedFill:
		grafBlit.blitCnt = 1;
		grafBlit.blitRop = grafPort.pnMode;
		grafBlit.blitPat = grafPort.pnPat;
		grafBlit.blitList = (long) &grafBlist;  
		grafBlit.blitSmap = grafPort.portMap;
	}	/* end pnLevel  */
	
	LocX = dstX;
	LocY = bgnY;
			
	if( globalLevel > 0)
	{
		G2UP(LocX, LocY, &grafPort.pnLoc.X, &grafPort.pnLoc.Y);
	}
	else
	{
		grafPort.pnLoc.X = LocX;
		grafPort.pnLoc.Y = LocY;
	}

	thePort->pnLoc.X = grafPort.pnLoc.X;
	thePort->pnLoc.Y = grafPort.pnLoc.Y;

	return;
}

⌨️ 快捷键说明

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