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

📄 lcd_drv.c

📁 与Nucleus Plus配套的图形库
💻 C
📖 第 1 页 / 共 5 页
字号:
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
	case 15:	/* zNANDNz : (NOT src) AND (NOT dst) */
		optPtr = &NotDestSolid1LCD;
		break;
	case 10:	/* zNOPz   :           dst <NOP>	 */
		optPtr = &QuickEnd;
		break;
	case 14:	/* zINVERTz:        (NOT dst)		 */
		optPtr = &InvertDestLCD;
		break;

/* BobB 5/6/98 - added the following cases */
	  			    /* LCD transparent */
	case 16:	/* xREPx   :           !0src		 */
	case 17:	/* xORx    :       !0src OR  dst	 */
	case 25:	/* xORNx   :     !0src OR  (NOT dst) */
	case 28:	/* xSETx   :           1's			 */
		optPtr = &SetTrans1LCD;
		break;
	case 18:	/* xXORx   :       !0src XOR dst	 */
	case 27:	/* xANDNx  :     !0src AND (NOT dst) */
	case 30:	/* xINVERTx:        (NOT dst)		 */
		optPtr = &InvertTrans1LCD;
		break;
	case 19:	/* xNANDx  :    (NOT !0src) AND dst	 */
	case 20:	/* xNREPx  :        (NOT !0src)		 */
	case 21:	/* xNORx   :    (NOT !0src) OR  dst	 */
	case 22:	/* xNXORx  :    (NOT !0src) XOR dst	 */
	case 23:	/* xANDx   :       !0src AND dst	 */
	case 24:	/* xCLEARx :           0's			 */
	case 26:	/* xNOPx   :           dst <NOP>	 */
	case 29:	/* xNORNx  : (NOT !0src) OR  (NOT dst) */
	case 31:	/* xNANDNx : (NOT !0src) AND (NOT dst) */
		optPtr = &QuickEnd;
	}

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

/* BobB 5/6/98 - added the following for the transparent raster ops */
		break;
	default:	/* all transparent cases */
		break;
	}

	/* set up clipping */
	if (Set_Up_Clip(blitRec, &clipR, blitMayOverlap, isLine))
		goto PB_RTN;

	while (--rectCnt >= 0 )
	{
		sRect = *rListPtr++;
		dRect = *rListPtr++;
		if (clipToRectFlag != 0)	/* do we need to worry about clipping */
		{	/* yes, do trivial reject */
			if (dRect.Xmin < clipR.Xmin)
			{	/* Reset src & dst Xmin clip limit */
				sRect.Xmin -= (dRect.Xmin - clipR.Xmin);
				dRect.Xmin  = clipR.Xmin;
			}
			if (dRect.Ymin < clipR.Ymin)
			{	/* Reset src & dst Ymin clip limit */
				sRect.Ymin -= (dRect.Ymin - clipR.Ymin);
				dRect.Ymin  = clipR.Ymin;
			}
			if (dRect.Xmax > clipR.Xmax)
			{	/* Reset src & dst Xmax clip limit */
				sRect.Xmax -= (dRect.Xmax - clipR.Xmax);
				dRect.Xmax  = clipR.Xmax;
			}
			if (dRect.Ymax > clipR.Ymax)
			{	/* Reset src & dst Ymax clip limit */
				sRect.Ymax -= (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_Blit(&dRect, rListPtr, &clipR,
					   &rectCnt)) break;
				continue;
			}
			
			if (dRect.Xmin >= dRect.Xmax) continue;

			/* do we need to worry about region clipping? */
			if (clipToRegionFlag != 0)
			{	/* yes */
				FillDrawer = &DrawRectEntryBlit1L;
				if (Blit_Clip_Region(blitRec, &dRect, &sRect)
					== 0) break;
				continue;
			}
		}
		
		DrawRectEntryBlit1L(blitRec);	/* blit the rectangle */
	}

PB_RTN:
	nuResume(srcBmap);
	nuResume(dstBmap);
	return;
}


/* Function DrawRectEntryBlit1L blits the image to the screen */
void DrawRectEntryBlit1L(blitRcd *blitRec)
{

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

/* BobB 5/6/98 - changed the following line to correct pixel addressing
	srcNextRow = srcPixBytes - ((byteCntM1 + 1) >> 3); */
	srcNextRow = srcPixBytes - (sRect.Xmax >> 3) + srcBgnByte;

/* 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;
	srcPtr = (byte *) (*(srcBmap->mapTable[0] + sRect.Ymin))
				+ srcBgnByte;
	optPtr();	/* blit the rectangle */

	return;
}


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

	InvertDestLCD();

	OXADest1LCD();	/* fill this rectangle */

	return;
}


/* Function RepDest1LCD sets the destination pixel data to pnColr
if the source is 1 else bkColr. */
void RepDest1LCD(void)
{
	byte *lclDstPtr, *lclSrcPtr;
	int lclLineCnt, lclByteCnt;
	int pxBit;

/* BobB 5/6/98 - added another variable to allow pxBit to be set inside
   the first while loop. */
	int pxBitVal;

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

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

/* BobB 5/6/98 - changed the following line
	pxBit = 128 >> (sRect.Xmin & 7); */
	pxBitVal = 128 >> (sRect.Xmin & 7);

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

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

		lclByteCnt = byteCntM1;
/* BobB 5/6/98 - added the following line: */
		pxBit = pxBitVal;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (*lclSrcPtr & pxBit)
			{	/* 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++;
			}

			pxBit = pxBit >> 1;
			if (pxBit == 0)
			{
				pxBit = 128;
				lclSrcPtr++;
			}
		}

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

		lclSrcPtr += srcNextRow;
	}

	return;
}


/* BobB 5/6/98 */
/* Function SetTrans1LCD sets the destination pixel data to pnColr
if the source is 1 else it does nothing. */
void SetTrans1LCD(void)
{
	byte *lclDstPtr, *lclSrcPtr;
	int lclLineCnt, lclByteCnt;
	int pxBit;

/* BobB 5/6/98 - added another variable to allow pxBit to be set inside
   the first while loop. */
	int pxBitVal;

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

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

/* BobB 5/6/98 - changed the following line
	pxBit = 128 >> (sRect.Xmin & 7); */
	pxBitVal = 128 >> (sRect.Xmin & 7);

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

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

		lclByteCnt = byteCntM1;
/* BobB 5/6/98 - added the following line: */
		pxBit = pxBitVal;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (*lclSrcPtr & pxBit)
			{	/* source is 1 */
				*lclDstPtr = pnColr;
			}

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

			pxBit = pxBit >> 1;
			if (pxBit == 0)
			{
				pxBit = 128;
				lclSrcPtr++;
			}
		}

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

		lclSrcPtr += srcNextRow;
	}

	return;
}


/* BobB 5/6/98 */
/* Function InvertTrans1LCD inverts the destination pixel data
if the source is 1 else it does nothing. */
void InvertTrans1LCD(void)
{
	byte *lclDstPtr, *lclSrcPtr;
	int lclLineCnt, lclByteCnt;
	int pxBit;
	int pxBitVal;
	byte pixlVal;

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

	lclDstPtr = dstPtr;	/* set up local pointers */
	lclSrcPtr = srcPtr;
	lclLineCnt = lineCntM1;
	pxBitVal = 128 >> (sRect.Xmin & 7);

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

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

		lclByteCnt = byteCntM1;
		pxBit = pxBitVal;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (*lclSrcPtr & pxBit)
			{	/* source is 1 */
				pixlVal = *lclDstPtr;
				*lclDstPtr = !pixlVal;
			}

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

			pxBit = pxBit >> 1;
			if (pxBit == 0)
			{
				pxBit = 128;
				lclSrcPtr++;
			}
		}

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

		lclSrcPtr += srcNextRow;
	}

	return;
}


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

/* BobB 5/6/98 - added another variable to allow pxBit to be set inside
   the first while loop. */
	int pxBitVal;

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

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

/* BobB 5/6/98 - changed the following line
	pxBit = 128 >> (sRect.Xmin & 7); */
	pxBitVal = 128 >> (sRect.Xmin & 7);

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

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

		lclByteCnt = byteCntM1;
/* BobB 5/6/98 - added the following line: */
		pxBit = pxBitVal;
		while (lclByteCnt-- >= 0)
		{	/* for each byte in the row */
			if (!(*lclSrcPtr & pxBit))
			{	/* source is 0 */
				if ((logFnc == 3) || (*lclDstPtr == 0))
				{	/* "AND" or 0,0 */
					*lclDstPtr = bkColr;
				}
				else
				{	/* "OR","XOR" with 0,1 */
					*lclDstPtr = pnColr;
				}
			}
			else
			{	/* source is 1 */
				if (logFnc == 1)
				{	/* "OR" with 1,X */
					*lclDstPtr = pnColr;
				}
				else
				{
					if (logFnc == 3)
					{	/* "AND" */
						if (*lclDstPtr)
						{	/* "AND", with 1,1 */
							*lclDstPtr = pnColr;
						}
						else
						{	/* "AND", with 1,0 */
							*lclDstPtr = bkColr;
						}
					}
					else
					{	/* "XOR" */
						if (*lclDstPtr)
						{	/* "XOR", with 1,1 */
							*lclDstPtr = bkColr;
						}
						else
						{	/* "XOR", with 1,0 */
							*lclDstPtr = pnColr;
						}
					}
				}
			}

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

⌨️ 快捷键说明

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