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

📄 m2b4_fil.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*                                                                       */
/*         Copyright (c) 1997 - 1999 Accelerated Technology, Inc.        */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FLLE NAME                                            VERSION          */
/*                                                                       */
/*      m2b4_fil.c                                       1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the mwFL2_4B function.                        */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Bob Burrill, Accelerated Technology, Inc.                        */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*                                                                       */
/*************************************************************************/

#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
#include "fill_5.h"

/* Function mwFL2_4B is a special case optimization for MultiFill, monochrome
to 2/4 bit memory, rectangular and/or region clipping with color translation.
mwFL2_4B forms the outer processing loop for this mode which internally
dispatches to one of several other optimizations based upon the specific
rasterOp transfer mode and memory destination. */
void mwFL2_4B(blitRcd *fillRec)
{
	void mwFLM4(blitRcd *fillRec);
	void SolidFillM2_4B(blitRcd *fillRec);
	void MonoPatternFillM2_4B(blitRcd *fillRec);
	void MultiColorFillM2_4B(blitRcd *fillRec);

/* Figure out whether this is a multicolor pattern, and, if so, whether the
   raster op is replace. All non-multicolor patterns are handled here, as are
   replace-op multicolor, but non-replace multicolor patterns are handled by
   the multiplane fill handler.  */

	lclPortMask = fillRec->blitMask;
	/* save the pattern header address here temporarily  */
	if (fillRec->blitPat > 1)
	{	/* it's a patterned fill */
		patStart = fillRec->blitPatl->patPtr[fillRec->blitPat];
		if (patStart->patBits > 1)
		{	/* it's a multicolor fill */
			if((fillRec->blitRop & 0x0f) > 0)
			{	/* non-replace multicolor, handle thru general plane filler  */
				fillRec->blitDmap->mapWinPlane = -1;
				mwFLM4(fillRec);
				return;
			}
			else
			{	/*  we'll do a replace multicolor fill locally  */	
				MultiColorFillM2_4B(fillRec);
				return;
			}
		}
		else
		{	/* we'll do a monocolor pattern fill locally  */
			MonoPatternFillM2_4B(fillRec);
			return;
		}
	}
	else
	{/* we'll do a solid fill locally  */
		SolidFillM2_4B(fillRec);
		return;
	}
}


/* Function MultiColorFill is a special case optimization for multicolor,
patterned fill to memory, rectangular clipping with color translation. */
void MultiColorFillM2_4B(blitRcd *fillRec)
{
	int Check_YX_Band(rect *bandRect, rect *blitRectPtr, rect *clipR,
					   int *rectCnt);
	void MultiColorFillRectM2_4B(blitRcd *fillRec);
	int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
				int isLine);
	int Fill_Clip_Region(blitRcd *fillRec, rect *fillRect);
	void nuResume(grafMap *dstBmap);

	rect clipR;	/* Clip rect */
	rect *rListPtr;	/* list pointer */
	int blitMayOverlap = 0;	/* Set false for region clipping*/
	int isLine = 0;	/* Set false */

	savePat = (image *) patStart;/* retrieve the pattern header address  */
	rectCnt = fillRec->blitCnt;
	rListPtr = (rect *) fillRec->blitList;
	dstBmap = fillRec->blitDmap;
	patHeight = savePat->imHeight;/* height in rows  */
	patWidthInBytes = savePat->imWidth;
	patLength = patWidthInBytes * patHeight;
	patPlaneOffset = patLength;/* distance from one plane to the next */

	M_PAUSE(dstBmap);

	/* 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 = &MultiColorFillRectM2_4B;
				if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
				continue;
			}
		}
		
		MultiColorFillRectM2_4B(fillRec);	/* blit the rectangle */
	}

	nuResume(dstBmap);
	return;
}


void SolidFillM2_4B(blitRcd *fillRec )
{	 	    	
	int Check_YX_Band(rect *bandRect, rect *blitRectPtr, rect *clipR,
					   int *rectCnt);
	void SolidFillRectM2_4B(blitRcd *fillRec);
	int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
				int isLine);
	int Fill_Clip_Region(blitRcd *fillRec, rect *fillRect);
	void SetDestM2_4B(void);
	void FillOXADestM2_4B(void);
	void NotDestFillM2_4B(void);
	void InvertDestM2_4B(void);
	void QuickEnd(void);
	void nuResume(grafMap *dstBmap);

	rect clipR;	/* Clip rect */
	rect *rListPtr;	/* list pointer */
	int blitMayOverlap = 0;	/* Set false for region clipping*/
	int isLine = 0;	/* Set false */

	rectCnt = fillRec->blitCnt;
	rListPtr = (rect *) fillRec->blitList;
	dstBmap = fillRec->blitDmap;

	if(fillRec->blitPat == 0)
	{
		if((fillRec->blitRop & 0x10)  != 0)
		{	/* transparent with background color is a NOP */
			nuResume(dstBmap);
			return;
		}

		pnColr = (char) fillRec->blitBack;
	}
	else
	{
		pnColr = (char) fillRec->blitFore;
	}

	M_PAUSE(dstBmap);

	dstWidth = dstBmap->pixBytes;
	shfCnt = dstBmap->pixBits;	/* determine number of bits per pixel */
	if (shfCnt == 2)
	{	/* 2 bpp */
		flipMask = 2;
		shiftMask = 0xc0;
		firstOffset = 0x03;
		pnColr = pnColr & 0x03;
	}
	else
	{	/* 4 bpp */
		flipMask = 1;
		shiftMask = 0xf0;
		firstOffset = 0x01;
		pnColr = pnColr & 0x0f;
	}

	dstClass = fillRec->blitRop & 0x0f;
	switch (dstClass)
	{	/* look up the optimization routine */
	  			    /* Memory non-transparent */
	case 0:		/* zREPz   :           src			 */
	case 4:		/* zNREPz  :        (NOT src)		 */
	case 8:		/* zCLEARz :           0's			 */
	case 12:	/* zSETz   :           1's			 */
		optPtr = &SetDestM2_4B;
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 2:		/* zXORz   :       src XOR dst		 */
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &FillOXADestM2_4B;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 11:	/* zANDNz  :     src AND (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
	case 15:	/* zNANDNz : (NOT src) AND (NOT dst) */
		optPtr = &NotDestFillM2_4B;
		break;
	case 10:	/* zNOPz   :           dst <NOP>	 */
		optPtr = &QuickEnd;
		break;
	case 14:	/* zINVERTz:        (NOT dst)		 */
		optPtr = &InvertDestM2_4B;
		break;
	}
	/* 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 = &SolidFillRectM2_4B;
				if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
				continue;
			}
		}
		
		SolidFillRectM2_4B(fillRec);	/* blit the rectangle */
	}

	nuResume(dstBmap);
	return;
}


/* Set up for monocolor pattern fill.  */
void MonoPatternFillM2_4B(blitRcd *fillRec )
{
	int Check_YX_Band(rect *bandRect, rect *blitRectPtr, rect *clipR,
					   int *rectCnt);
	void SolidFillRectM2_4B(blitRcd *fillRec);
	int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
				int isLine);
	int Fill_Clip_Region(blitRcd *fillRec, rect *fillRect);
	void MonoFillDestM2_4B(void);
	void MonoFillOXADestM2_4B(void);
	void NotDestMonoFillM2_4B(void);
	void InvertDestM2_4B(void);
	void QuickEnd(void);
	void nuResume(grafMap *dstBmap);

	rect clipR;	/* Clip rect */
	rect *rListPtr;	/* list pointer */
	int blitMayOverlap = 0;	/* Set false for region clipping*/
	int isLine = 0;	/* Set false */

	rectCnt = fillRec->blitCnt;
	rListPtr = (rect *) fillRec->blitList;
	dstBmap = fillRec->blitDmap;
	pnColr = (char) fillRec->blitFore;
	bkColr = (char) fillRec->blitBack;
	savePat = (image *) patStart;/* retrieve the pattern header address  */
	ptrnData = savePat->imData;/* skip over the pattern header to
									the bit pattern  */
	patHeight = savePat->imHeight;/* height in rows  */
	patWidthInBytes = savePat->imWidth >> 3;
	patLength = patWidthInBytes * patHeight;
	patPlaneOffset = patLength;/* distance from one plane to the next */

	M_PAUSE(dstBmap);

	dstWidth = dstBmap->pixBytes;
	shfCnt = dstBmap->pixBits;	/* determine number of bits per pixel */
	if (shfCnt == 2)
	{	/* 2 bpp */
		flipMask = 2;
		shiftMask = 0xc0;
		firstOffset = 0x03;
	}
	else
	{	/* 4 bpp */
		flipMask = 1;
		shiftMask = 0xf0;
		firstOffset = 0x01;
	}

	dstClass = fillRec->blitRop & 0x0f;
	switch (dstClass)
	{	/* look up the optimization routine */
	  			    /* Memory non-transparent */
	case 0:		/* zREPz   :           src			 */
	case 4:		/* zNREPz  :        (NOT src)		 */
	case 8:		/* zCLEARz :           0's			 */
	case 12:	/* zSETz   :           1's			 */
		optPtr = &MonoFillDestM2_4B;
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 2:		/* zXORz   :       src XOR dst		 */
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &MonoFillOXADestM2_4B;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 11:	/* zANDNz  :     src AND (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
	case 15:	/* zNANDNz : (NOT src) AND (NOT dst) */
		optPtr = &NotDestMonoFillM2_4B;
		break;
	case 10:	/* zNOPz   :           dst <NOP>	 */
		optPtr = &QuickEnd;
		break;
	case 14:	/* zINVERTz:        (NOT dst)		 */
		optPtr = &InvertDestM2_4B;
		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 = &SolidFillRectM2_4B;
				if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
				continue;
			}
		}
		
		SolidFillRectM2_4B(fillRec);	/* blit the rectangle */
	}

	nuResume(dstBmap);
	return;
}


/* Function MultiColorFillRect fills a multicolored rectangle in
the memory */
void MultiColorFillRectM2_4B(blitRcd *blitRec)
{
	int lclByteCnt, lclLineCnt, lclShift;
	int ptrnX, ptrnY;
	int pxShift;
	byte pxBit;
	byte pxColor;

	shfCnt = dstBmap->pixBits;	/* determine number of bits per pixel */
	if (shfCnt == 2)
	{	/* 2 bpp */
		flipMask = 2;
		shiftMask = 0xc0;

⌨️ 快捷键说明

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