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

📄 lcd_fil.c

📁 与Nucleus Plus配套的图形库
💻 C
📖 第 1 页 / 共 2 页
字号:
		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 = &SolidFillRect;
				if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
				continue;
			}
		}
		
		SolidFillRect(fillRec);	/* blit the rectangle */
	}

	nuResume(dstBmap);
	return;
}


/* Function MultiColorFillRect fills a multicolored rectangle on
the screen */
void MultiColorFillRect(blitRcd *blitRec)
{
	int lclByteCnt, lclLineCnt;
	int ptrnX, ptrnY;
	byte *dstPtrSave;

	lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
	dstBgnByte = ((dRect.Xmin & 0xfffe) << 1) + (dRect.Xmin & 1);
	byteCntM1 = dRect.Xmax - dRect.Xmin - 1;

/* BobB 5/15/98 - corrected for first pixel addressing
	dstNextRow = dstBmap->pixBytes - byteCntM1 - byteCntM1 - 2;*/
	dstNextRow = dstBmap->pixBytes;

	ptrnY = dRect.Ymin % patHeight;	/* start of pattern allignment */
	ptrnY *= patWidthInBytes;
	dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
				+ dstBgnByte;
	while (lclLineCnt-- >= 0)
	{	/* for each row */

/* BobB 5/15/98 - added for first pixel addressing */
		dstPtrSave = dstPtr;

		ptrnX = dRect.Xmin % patWidthInBytes;
		lclByteCnt = byteCntM1;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			*dstPtr = savePat->imData[ptrnX + ptrnY];
			if (((long) dstPtr) & 1)
			{	/* advance 3 bytes */
				dstPtr += 3;
			}
			else
			{	/* advance only 1 byte */
				dstPtr++;
			}
			ptrnX++;
			if (ptrnX == patWidthInBytes) ptrnX = 0;
		}

/* BobB 5/15/98 - corrected for first pixel addressing
		dstPtr += dstNextRow;*/	/* advance to next row */
		dstPtr = dstPtrSave + dstNextRow;	/* advance to next row */

		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}


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

	lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
	dstBgnByte = ((dRect.Xmin & 0xfffe) << 1) + (dRect.Xmin & 1);
	byteCntM1 = dRect.Xmax - dRect.Xmin - 1;

/* BobB 5/15/98 - corrected for first pixel addressing
	dstNextRow = dstBmap->pixBytes - byteCntM1 - byteCntM1 - 2;*/
	dstNextRow = dstBmap->pixBytes;


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

	return;
}


/* Function NotDestFillLCD handles LCD "not dst" by inverting the
destination first. */
void NotDestFillLCD(void)
{
	void InvertDestLCD(void);
	void FillOXADestLCD(void);

	InvertDestLCD();

	FillOXADestLCD();	/* fill this rectangle */

	return;
}


/* Function NotDestMonoFillLCD handles LCD "not dst" by inverting
the destination first. */
void NotDestMonoFillLCD(void)
{
	void InvertDestLCD(void);
	void MonoFillOXADestLCD(void);

	InvertDestLCD();

	MonoFillOXADestLCD();	/* fill this rectangle */

	return;
}


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

/* BobB 5/18/98 - added for first pixel addressing */
	byte * dstPtrSave;

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclLineCnt = lineCntM1;
	ptrnY = dRect.Ymin % patHeight;	/* start of pattern alignment */
	ptrnY *= patWidthInBytes;
	while (lclLineCnt-- >= 0)
	{	/* for each row */

/* BobB 5/18/98 - added for first pixel addressing */
		dstPtrSave = lclDstPtr;

		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;
			}

			if (((long) lclDstPtr) & 1)
			{	/* advance 3 bytes */
				lclDstPtr += 3;
			}
			else
			{	/* advance only 1 byte */
				lclDstPtr++;
			}

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

/* BobB 5/18/98 - corrected for first pixel addressing
		lclDstPtr += dstNextRow;*/	/* advance to next row */
		lclDstPtr = dstPtrSave + dstNextRow;
		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}


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

/* BobB 5/18/98 - added for first pixel addressing */
	byte * dstPtrSave;

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

	while (lclLineCnt-- >= 0)
	{	/* for each row */

/* BobB 5/18/98 - added for first pixel addressing */
		dstPtrSave = lclDstPtr;

		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;
			}

			if (((long) lclDstPtr) & 1)
			{	/* advance 3 bytes */
				lclDstPtr += 3;
			}
			else
			{	/* advance only 1 byte */
				lclDstPtr++;
			}
		}

/* BobB 5/18/98 - corrected for first pixel addressing
		lclDstPtr += dstNextRow;*/	/* advance to next row */
		lclDstPtr = dstPtrSave + dstNextRow;
	}

	return;
}


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

/* BobB 5/18/98 - added for first pixel addressing */
	byte * dstPtrSave;

	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 */

/* BobB 5/18/98 - added for first pixel addressing */
		dstPtrSave = lclDstPtr;

		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;
			}

			if (((long) lclDstPtr) & 1)
			{	/* advance 3 bytes */
				lclDstPtr += 3;
			}
			else
			{	/* advance only 1 byte */
				lclDstPtr++;
			}
			ptrnBt = ptrnBt >> 1;
			if (ptrnBt == 0)
			{
				ptrnBt = 128;
				ptrnX++;
				if (ptrnX == patWidthInBytes) ptrnX = 0;
				ptrnByte = savePat->imData[ptrnX + ptrnY];
			}
		}

/* BobB 5/18/98 - corrected for first pixel addressing
		lclDstPtr += dstNextRow;*/	/* advance to next row */
		lclDstPtr = dstPtrSave + dstNextRow;
		ptrnY += patWidthInBytes;
		if (ptrnY == patLength) ptrnY = 0;
	}

	return;
}


void mwFLM4(blitRcd *fillRec)
{
	return;
}

⌨️ 快捷键说明

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