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

📄 m24b_lin.c

📁 与Nucleus Plus配套的图形库
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************/
/*                                                                       */
/*         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.                                     */
/*                                                                       */
/*************************************************************************/

/*************************************************************************/
/*                                                                       */
/* FILE NAME                                            VERSION          */
/*                                                                       */
/*      m24b_lin.c                                       1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the thin line drawing functions for 24 bit    */
/* memory.                                                               */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, Accelerated Technology, Inc.                  */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*		None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*		   NAME            DATE                    REMARKS               */
/*                                                                       */
/*         BobB          11/18/99     Corrected region clipping test     */
/*                                                                       */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h"    /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h"    /* MetaWINDOW Port & Bitmap Definitions */
#include "metaproc.h"
#include "grafdata.h"
#include "blit_5.h"


/* Function mwLIA24 is a special case optimization for thin line
drawing to 24 bit memory destinations, rectangular and/or region
clipping. */
void mwLIA24(blitRcd *lineRec)
{
	void ClipAndDrawEntry(void);
	int Set_Up_Clip(blitRcd *clipBlit, rect *clipR, int blitMayOverlap,
				int isLine);
	int Line_Clip_Region(int rectCnt, lineS *destRect);
	void nuResume(grafMap *argGRAFMAP);
	void M24BURTable(void);
	void M24BMRTable(void);
	void M24BMOTable(void);
	void M24BUXTable(void);
	void M24BMXTable(void);
	void M24BMATable(void);
	void M24BMO_NDTable(void);
	void M24BMA_NDTable(void);
	void QuickEnd(void);
	lineS *listPtr;	/* Pointer to line to draw */
	int blitMayOverlap = 0;	/* Set false */
	int isLine = 1;	/* Set true */
	/* Table used to NOT the source color according to raster op. */
	byte FlipTable[16] = {0,    0,    0,    0xff,
						  0xff, 0xff, 0xff, 0,
						  0,    0,    0,    0,
						  0,    0xff, 0,    0xff};
	/* Table used to force the source color to 0xff according to raster op. */
	byte ForceTableOr[16] = {0,    0,    0,    0,
							 0,    0,    0,    0,
							 0,    0,    0,    0,
							 0xff, 0,    0xff, 0};
	/* Table used to force the source color to 0 according to raster op. */
	byte ForceTableAnd[16] = {0xff, 0xff, 0xff, 0xff,
							  0xff, 0xff, 0xff, 0xff,
							  0,    0xff, 0xff, 0xff,
							  0xff, 0xff, 0xff, 0xff};

	/* set up the rectangular/region clip info */
	if (Set_Up_Clip(lineRec, &cRect, blitMayOverlap, isLine)) return;
	/* do we need to worry about clipping at all*/
/* BobB 11/18/99 - corrected the following line
	if (clipToRectFlag == 0) */
	if (clipToRegionFlag == 0)
	{	/* no--valid coordinates are guaranteed at a higher level */
		cRect.Xmax--;	/* the clipping code expects an old-style
						Metawindow clip rect */
		cRect.Ymax--;
	}
	else
	{	/* yes, copy the clip rect to the base, unchanging clip rect */
		bcXmin = cRect.Xmin;
		bcYmin = cRect.Ymin;
		bcXmax = cRect.Xmax - 1;
		bcYmax = cRect.Ymax - 1;
	}

	listPtr = (lineS *) lineRec->blitList;	/* set up local variables */
	rectCnt =  lineRec->blitCnt;
	lclPortMask =  lineRec->blitMask;
	dstClass = lineRec->blitRop;

	if (lineRec->blitPat == 0)	/* pattern 0? */
	{	/* yes, use background color */
		if (dstClass & 0x10) return;	/* done if transparent */

		lclPenColorR = (byte) (lineRec->blitBack >> 16);
		lclPenColorG = (byte) ((lineRec->blitBack >> 8) & 0xff);
		lclPenColorB = (byte) (lineRec->blitBack & 0xff);
	}
	else
	{	/* pattern 1 is the only other possibility */
		lclPenColorR = (byte) (lineRec->blitFore >> 16);
		lclPenColorG = (byte) ((lineRec->blitFore >> 8) & 0xff);
		lclPenColorB = (byte) (lineRec->blitFore & 0xff);
	}

	dstClass = dstClass & 0x0f;	/* we don't care about transparency */
	lclPenColorR = lclPenColorR ^ FlipTable[dstClass];	/* NOT the
											color if appropriate */
	lclPenColorR = lclPenColorR ^ FlipTable[dstClass];	/* NOT the
											color if appropriate */
	lclPenColorR = lclPenColorR ^ FlipTable[dstClass];	/* NOT the
											color if appropriate */
	lclPenColorG = lclPenColorG | ForceTableOr[dstClass];	/* make
									the color 0xff if appropriate */
	lclPenColorG = lclPenColorG | ForceTableOr[dstClass];	/* make
									the color 0xff if appropriate */
	lclPenColorG = lclPenColorG | ForceTableOr[dstClass];	/* make
									the color 0xff if appropriate */
	lclPenColorB = lclPenColorB & ForceTableAnd[dstClass];	/* make
									the color 0 if appropriate */
	lclPenColorB = lclPenColorB & ForceTableAnd[dstClass];	/* make
									the color 0 if appropriate */
	lclPenColorB = lclPenColorB & ForceTableAnd[dstClass];	/* make
									the color 0 if appropriate */
	dstBmap =  lineRec->blitDmap;
	M_PAUSE(dstBmap);	/* lock grafMap */

	dstWidth = dstBmap->pixBytes;
	rowTablePtr[1] = (long *) dstBmap->mapTable[0];

	switch (dstClass)
	{	/* look up the optimization routine */
	  			    /* LCD non-transparent */
	case 0:		/* zREPz   :           src			 */
	case 4:		/* zNREPz  :        (NOT src)		 */
	case 8:		/* zCLEARz :           0's			 */
	case 12:	/* zSETz   :           1's			 */
		if (lclPortMask == 0xff) 
		{	/* unmasked */
			optPtr = &M24BURTable;
		}
		else
		{	/* masked */
			optPtr = &M24BMRTable;
		}
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
		optPtr = &M24BMOTable;
		break;
	case 2:		/* zXORz   :       src XOR dst		 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 14:	/* zINVERTz:        (NOT dst)		 */
		if (lclPortMask == 0xff) 
		{	/* unmasked */
			optPtr = &M24BUXTable;
		}
		else
		{	/* masked */
			optPtr = &M24BMXTable;
		}
		break;
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &M24BMATable;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
		optPtr = &M24BMO_NDTable;
		break;
	case 10:	/* zNOPz   :           dst <NOP>	 */
		optPtr = &QuickEnd;
		break;
	case 11:	/* zANDNz  :     src AND (NOT dst)	 */
	case 15:	/* zNANDNz : (NOT src) AND (NOT dst) */
		optPtr = &M24BMA_NDTable;
		break;
	}

	if (clipToRegionFlag != 0)
	{	/* handle region clipping in a separate loop */
		LineDrawer = &ClipAndDrawEntry;
		Line_Clip_Region(rectCnt, listPtr);

		nuResume(dstBmap);
		return;
	}

	while (rectCnt-- > 0)
	{	/* Main line-drawing loop. */
		dRect.Xmin = listPtr->lStart.X;
		dRect.Ymin = listPtr->lStart.Y;
		dRect.Xmax = listPtr->lEnd.X;
		dRect.Ymax = listPtr->lEnd.Y;
		drawStat = (char) listPtr->flStat;
		listPtr++;

		ClipAndDrawEntry();	/* clip and draw the line */
	}

	nuResume(dstBmap);
	return;
}


#define M24BMRYMLR M24BMRV
#define M24BMRXMLR M24BMRH
#define M24BMRDLR M24BMRH
#define M24BMRXMRL M24BMRDRL
#define M24BMXYMLR M24BMXV
#define M24BMXXMLR M24BMXH
#define M24BMXDLR M24BMXH
#define M24BMXXMRL M24BMXDRL
#define M24BMOYMLR M24BMOV
#define M24BMOXMLR M24BMOH
#define M24BMODLR M24BMOH
#define M24BMOXMRL M24BMODRL
#define M24BMOYMLR_ND M24BMOV_ND
#define M24BMOXMLR_ND M24BMOH_ND
#define M24BMODLR_ND M24BMOH_ND
#define M24BMOXMRL_ND M24BMODRL_ND
#define M24BMAYMLR M24BMAV
#define M24BMAXMLR M24BMAH
#define M24BMADLR M24BMAH
#define M24BMAXMRL M24BMADRL
#define M24BMAYMLR_ND M24BMAV_ND
#define M24BMAXMLR_ND M24BMAH_ND
#define M24BMADLR_ND M24BMAH_ND
#define M24BMAXMRL_ND M24BMADRL_ND


void M24BURTable(void)
{
	void M24BURYMRL(void);
	void M24BURV(void);
	void M24BURYMLR(void);
	void M24BURDLR(void);
	void M24BURXMLR(void);
	void M24BURH(void);
	void M24BURDRL(void);
	void M24BURXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BURYMRL();
		break;
	case 1:	
		M24BURV();
		break;
	case 2:	
		M24BURYMLR();
		break;
	case 3:	
		M24BURDLR();
		break;
	case 4:	
		M24BURXMLR();
		break;
	case 5:	
		M24BURH();
		break;
	case 6:	
		M24BURDRL();
		break;
	case 7:	
		M24BURXMRL();
		break;
	}

	return;
}


void M24BMRTable(void)
{
	void M24BMRYMRL(void);
	void M24BMRV(void);
	void M24BMRYMLR(void);
	void M24BMRDLR(void);
	void M24BMRXMLR(void);
	void M24BMRH(void);
	void M24BMRDRL(void);
	void M24BMRXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMRYMRL();
		break;
	case 1:	
		M24BMRV();
		break;
	case 2:	
		M24BMRYMLR();
		break;
	case 3:	
		M24BMRDLR();
		break;
	case 4:	
		M24BMRXMLR();
		break;
	case 5:	
		M24BMRH();
		break;
	case 6:	
		M24BMRDRL();
		break;
	case 7:	
		M24BMRXMRL();
		break;
	}

	return;
}


void M24BMOTable(void)
{
	void M24BMOYMRL(void);
	void M24BMOV(void);
	void M24BMOYMLR(void);
	void M24BMODLR(void);
	void M24BMOXMLR(void);
	void M24BMOH(void);
	void M24BMODRL(void);
	void M24BMOXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMOYMRL();
		break;
	case 1:	
		M24BMOV();
		break;
	case 2:	
		M24BMOYMLR();
		break;
	case 3:	
		M24BMODLR();
		break;
	case 4:	
		M24BMOXMLR();
		break;
	case 5:	
		M24BMOH();
		break;
	case 6:	
		M24BMODRL();
		break;
	case 7:	
		M24BMOXMRL();
		break;
	}

	return;
}


void M24BUXTable(void)
{
	void	M24BUXYMRL(void);
	void	M24BUXV(void);
	void	M24BUXYMLR(void);
	void	M24BUXDLR(void);
	void	M24BUXXMLR(void);
	void	M24BUXH(void);
	void	M24BUXDRL(void);
	void	M24BUXXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BUXYMRL();
		break;
	case 1:	
		M24BUXV();
		break;
	case 2:	
		M24BUXYMLR();
		break;
	case 3:	
		M24BUXDLR();
		break;
	case 4:	
		M24BUXXMLR();
		break;
	case 5:	
		M24BUXH();
		break;
	case 6:	
		M24BUXDRL();
		break;
	case 7:	
		M24BUXXMRL();
		break;
	}

	return;
}


void M24BMXTable(void)
{
	void M24BMXYMRL(void);
	void M24BMXV(void);
	void M24BMXYMLR(void);
	void M24BMXDLR(void);
	void M24BMXXMLR(void);
	void M24BMXH(void);
	void M24BMXDRL(void);
	void M24BMXXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMXYMRL();
		break;
	case 1:	
		M24BMXV();
		break;
	case 2:	
		M24BMXYMLR();
		break;
	case 3:	
		M24BMXDLR();
		break;
	case 4:	
		M24BMXXMLR();
		break;
	case 5:	
		M24BMXH();
		break;
	case 6:	
		M24BMXDRL();
		break;
	case 7:	
		M24BMXXMRL();
		break;
	}

	return;
}


void M24BMATable(void)
{
	void M24BMAYMRL(void);
	void M24BMAV(void);
	void M24BMAYMLR(void);
	void M24BMADLR(void);
	void M24BMAXMLR(void);
	void M24BMAH(void);
	void M24BMADRL(void);
	void M24BMAXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMAYMRL();
		break;
	case 1:	
		M24BMAV();
		break;
	case 2:	
		M24BMAYMLR();
		break;
	case 3:	
		M24BMADLR();
		break;
	case 4:	
		M24BMAXMLR();
		break;
	case 5:	
		M24BMAH();
		break;
	case 6:	
		M24BMADRL();
		break;
	case 7:	
		M24BMAXMRL();
		break;
	}

	return;
}


void M24BMO_NDTable(void)
{
	void M24BMOYMRL_ND(void);
	void M24BMOV_ND(void);
	void M24BMOYMLR_ND(void);
	void M24BMODLR_ND(void);
	void M24BMOXMLR_ND(void);
	void M24BMOH_ND(void);
	void M24BMODRL_ND(void);
	void M24BMOXMRL_ND(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMOYMRL_ND();
		break;
	case 1:	
		M24BMOV_ND();
		break;
	case 2:	
		M24BMOYMLR_ND();
		break;
	case 3:	
		M24BMODLR_ND();
		break;
	case 4:	
		M24BMOXMLR_ND();
		break;
	case 5:	
		M24BMOH_ND();
		break;
	case 6:	
		M24BMODRL_ND();
		break;
	case 7:	
		M24BMOXMRL_ND();
		break;
	}

	return;
}


void M24BMA_NDTable(void)
{
	void M24BMAYMRL_ND(void);
	void M24BMAV_ND(void);
	void M24BMAYMLR_ND(void);
	void M24BMADLR_ND(void);
	void M24BMAXMLR_ND(void);
	void M24BMAH_ND(void);
	void M24BMADRL_ND(void);
	void M24BMAXMRL_ND(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M24BMAYMRL_ND();
		break;
	case 1:	
		M24BMAV_ND();
		break;
	case 2:	
		M24BMAYMLR_ND();
		break;
	case 3:	
		M24BMADLR_ND();
		break;

⌨️ 快捷键说明

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