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

📄 m8b_fil.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
		optPtr = &InvertDestMem;
		break;
	}

		/* modify the pen color as necessary */
	switch (dstClass)
	{
	case 3:	/* zNANDz */
	case 4:	/* zNREPz */
	case 5:	/* zNORz */
	case 6:	/* zNXORz */
	case 13:	/* zNORNz */
	case 15:	/* zNANDNz */
		bkColr = ~bkColr;	/* this has the effect of notting the
					pen color for all operations during this call */
		pnColr = ~pnColr;
	case 0:	/* zREPz */
	case 1:	/* zORz */
	case 2:	/* zXORz */
	case 7:	/* zANDz */
	case 9:	/* zORNz */
	case 10:	/* zNOPz */
	case 11:	/* zANDNz */
		break;
	case 8:	/* zCLEARz */
		bkColr = 0;	/* sets all source bits to 0 */
		pnColr = 0;
		break;
	case 12:	/* zSETz */
	case 14:	/* zINVERTz */
		bkColr = (char)-1;	/* sets all source bits to 1 */
		pnColr = (char)-1;
	}

/* set up clipping */
	if (Set_Up_Clip(fillRec, &clipR, blitMayOverlap, isLine))
	{
		nuResume(dstBmap);
		return;
	}

	while (--rectCnt >= 0 )
	{
		dRect = *rListPtr++;
		if (clipToRectFlag != 0)	/* do we need to worry about clipping */
		{	/* yes, do trivial reject */
			if (dRect.Xmin < clipR.Xmin) dRect.Xmin  = clipR.Xmin;
			if (dRect.Ymin < clipR.Ymin) dRect.Ymin  = clipR.Ymin;
			if (dRect.Xmax > clipR.Xmax) dRect.Xmax  = clipR.Xmax;
			if (dRect.Ymax > clipR.Ymax) dRect.Ymax  = clipR.Ymax;
			
			if (dRect.Ymin >= dRect.Ymax)
			{	/* Check to see whether the rectangle was trivially
				clipped because it was fully below the clip rect,
				in which case we can discard the rest of a YX banded
				blitList, or because it was fully above the clip
				rect, in which case we can whiz ahead through a YX
				banded blitList until we run out of rects or find a
				rect that isn't fully above the clip rect. */
				if (Check_YX_Band(&dRect, rListPtr, &clipR,
					   &rectCnt)) break;
				continue;
			}
			
			if (dRect.Xmin >= dRect.Xmax) continue;

			/* do we need to worry about region clipping? */
			if (clipToRegionFlag != 0)
			{	/* yes, decide whether to copy top->bottom
				or bottom->top */
				FillDrawer = &SolidFillRectM;
				if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
				continue;
			}
		}
		
		SolidFillRectM(fillRec);	/* blit the rectangle */
	}

	nuResume(dstBmap);
	return;
}


/* Function MultiColorFillRectM fills a multicolored rectangle in
the memory */
void MultiColorFillRectM(blitRcd *blitRec)
{
	int lclByteCnt, lclLineCnt;
	int ptrnX, ptrnY;

	lclLineCnt = dRect.Ymax - dRect.Ymin - 1;
	dstBgnByte = dRect.Xmin;
	byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
	dstNextRow = dstBmap->pixBytes - byteCntM1 - 1;
	ptrnY = dRect.Ymin % patHeight;	/* start of pattern allignment */
	ptrnY *= patWidthInBytes;
	dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
				+ dstBgnByte;
	while (lclLineCnt-- >= 0)
	{	/* for each row */
		ptrnX = dRect.Xmin % patWidthInBytes;
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			*dstPtr = savePat->imData[ptrnX + ptrnY];
			dstPtr++;
			ptrnX++;
			if (ptrnX == patWidthInBytes) ptrnX = 0;
		}

		dstPtr += dstNextRow;	/* advance to next row */
		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}


/* Function SolidFillRect fills the rectangle on the screen */
void SolidFillRectM(blitRcd *blitRec)
{

	lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
	dstBgnByte = dRect.Xmin;
	byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
	dstNextRow = dstBmap->pixBytes - byteCntM1 - 1;

	dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
				+ dstBgnByte;
	optPtr();	/* blit the rectangle */

	return;
}


/* Function InvertDestMem inverts the destination pixel data. */
void InvertDestMem(void)
{
	byte *lclDstPtr;
	int lclLineCnt, lclByteCnt;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;

	while (lclLineCnt-- >= 0)
	{	/* for each row */
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			*lclDstPtr = ~(*lclDstPtr);
			lclDstPtr++;
		}

		lclDstPtr += dstNextRow;	/* advance to next row */
	}

	return;
}


/* Function SetDestMem sets the destination pixel data. */
void SetDestMem(void)
{
	byte *lclDstPtr;
	int lclLineCnt, lclByteCnt;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;

	while (lclLineCnt-- >= 0)
	{	/* for each row */
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			*lclDstPtr = pnColr;
				lclDstPtr++;
		}

		lclDstPtr += dstNextRow;	/* advance to next row */
	}

	return;
}


/* Function NotDestFillMem handles memory "not dst" by inverting the
destination first. */
void NotDestFillMem(void)
{
	void InvertDestMem(void);
	void FillOXADestMem(void);

	InvertDestMem();

	FillOXADestMem();	/* fill this rectangle */

	return;
}


/* Function NotDestMonoFillMem handles memory "not dst" by inverting
the destination first. */
void NotDestMonoFillMem(void)
{
	void InvertDestMem(void);
	void MonoFillOXADestMem(void);

	InvertDestMem();

	MonoFillOXADestMem();	/* fill this rectangle */

	return;
}


/* Function MonoFillDestMem sets the destination pixel data to pnColr
if the source is 1 else bkColr. */
void MonoFillDestMem(void)
{
	byte *lclDstPtr;
	int lclLineCnt, lclByteCnt;
	int ptrnX, ptrnY, ptrnByte, ptrnBt;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;
	ptrnY = dRect.Ymin % patHeight;	/* start of pattern allignment */
	ptrnY *= patWidthInBytes;
	while (lclLineCnt-- >= 0)
	{	/* for each row */
		ptrnX = dRect.Xmin % patWidthInBytes;
		ptrnBt = (128 >> (dRect.Xmin & 7));
		ptrnByte = savePat->imData[ptrnX + ptrnY];
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (ptrnByte & ptrnBt)
			{	/* source is 1 */
				*lclDstPtr = pnColr;
			}
			else
			{	/* source is 0 */
				*lclDstPtr = bkColr;
			}

			lclDstPtr++;
			ptrnBt = ptrnBt >> 1;
			if (ptrnBt == 0)
			{
				ptrnBt = 128;
				ptrnX++;
				if (ptrnX == patWidthInBytes) ptrnX = 0;
				ptrnByte = savePat->imData[ptrnX + ptrnY];
			}
		}

		lclDstPtr += dstNextRow;	/* advance to next row */
		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}


/* Function FillOXADestMem sets the destination pixel data based on
the logical function "OR", "XOR" or "AND". */
void FillOXADestMem(void)
{
	byte *lclDstPtr;
	int lclLineCnt, lclByteCnt;
	int logFnc;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;
	logFnc = (dstClass & 3);	/* only two lower bits needed */

	while (lclLineCnt-- >= 0)
	{	/* for each row */
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			switch (logFnc)
			{
			case 0:	/* handled elsewhere */
			case 1:	/* "OR" */
				*lclDstPtr = *lclDstPtr | pnColr;
				break;
			case 2:	/* "XOR" */
				*lclDstPtr = *lclDstPtr ^ pnColr;
				break;
			case 3:	/* "AND" */
				*lclDstPtr = *lclDstPtr & pnColr;
			}

			lclDstPtr++;
		}

		lclDstPtr += dstNextRow;	/* advance to next row */
	}

	return;
}


/* Function MonoFillOXADestMem sets the destination pixel data based on
the logical function "OR", "XOR" or "AND" and the pattern bit. */
void MonoFillOXADestMem(void)
{
	byte *lclDstPtr;
	int lclLineCnt, lclByteCnt;
	int logFnc;
	int ptrnX, ptrnY, ptrnByte, ptrnBt, ptrnColr;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;
	logFnc = (dstClass & 3);	/* only two lower bits needed */
	ptrnY = dRect.Ymin % patHeight;	/* start of pattern allignment */
	ptrnY *= patWidthInBytes;

	while (lclLineCnt-- >= 0)
	{	/* for each row */
		ptrnX = dRect.Xmin % patWidthInBytes;
		ptrnBt = (128 >> (dRect.Xmin & 7));
		ptrnByte = savePat->imData[ptrnX + ptrnY];
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (ptrnByte & ptrnBt)
			{
				ptrnColr = pnColr;
			}
			else
			{
				ptrnColr = bkColr;
			}

			switch (logFnc)
			{
			case 0:	/* handled elsewhere */
			case 1:	/* "OR" */
				*lclDstPtr = *lclDstPtr | ptrnColr;
				break;
			case 2:	/* "XOR" */
				*lclDstPtr = *lclDstPtr ^ ptrnColr;
				break;
			case 3:	/* "AND" */
				*lclDstPtr = *lclDstPtr & ptrnColr;
			}

			lclDstPtr++;
			ptrnBt = ptrnBt >> 1;
			if (ptrnBt == 0)
			{
				ptrnBt = 128;
				ptrnX++;
				if (ptrnX == patWidthInBytes) ptrnX = 0;
				ptrnByte = savePat->imData[ptrnX + ptrnY];
			}
		}

		lclDstPtr += dstNextRow;	/* advance to next row */
		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}

⌨️ 快捷键说明

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