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

📄 m8b_lin.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 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          */
/*                                                                       */
/*      m8b_lin.c                                        1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the thin line drawing functions for 8 bit     */
/* memory.                                                               */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*      Robert G. Burrill, Accelerated Technology, Inc.                  */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      None                                                             */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*		None                                                             */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*		   NAME            DATE                    REMARKS               */
/*                                                                       */
/*		   BobB			  5/7/98		Removed unused line              */
/*         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 mwLIA is a special case optimization for thin line
drawing to 8 bit memory destinations, rectangular and/or region
clipping. */
void mwLIA(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 M8BURTable(void);
	void M8BMRTable(void);
	void M8BMOTable(void);
	void M8BUXTable(void);
	void M8BMXTable(void);
	void M8BMATable(void);
	void M8BMO_NDTable(void);
	void M8BMA_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 region clipping */
/* 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 */

		lclPenColor = (byte) lineRec->blitBack;
	}
	else
	{	/* pattern 1 is the only other possibility */
		lclPenColor = (byte) lineRec->blitFore;
	}

	dstClass = dstClass & 0x0f;	/* we don't care about transparency */
	lclPenColor = lclPenColor ^ FlipTable[dstClass];	/* NOT the
											color if appropriate */
	lclPenColor = lclPenColor | ForceTableOr[dstClass];	/* make
									the color 0xff if appropriate */
	lclPenColor = lclPenColor & 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 = &M8BURTable;
		}
		else
		{	/* masked */
			optPtr = &M8BMRTable;
		}
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
		optPtr = &M8BMOTable;
		break;
	case 2:		/* zXORz   :       src XOR dst		 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 14:	/* zINVERTz:        (NOT dst)		 */
		if (lclPortMask == 0xff) 
		{	/* unmasked */
			optPtr = &M8BUXTable;
		}
		else
		{	/* masked */
			optPtr = &M8BMXTable;
		}
		break;
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &M8BMATable;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
		optPtr = &M8BMO_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 = &M8BMA_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;
}


/* BobB 5/7/98 - moved ClipAndDrawEntry here since this file is
generic */
/* Function ClipAndDrawEntry perform trivial clipping/clipping
categorization. */
void ClipAndDrawEntry(void)
{
	int mwLC(void);

	lineEncode = 0;	/* determine clipping category */
	if (dRect.Xmin < cRect.Xmin)
	{
		lineEncode += 18;
	}
	else
	{
		if (dRect.Xmin > cRect.Xmax) lineEncode += 9;
	}

	if (dRect.Ymin < cRect.Ymin)
	{
		lineEncode += 27;
	}
	else
	{
		if (dRect.Ymin > cRect.Ymax) lineEncode += 54;
	}

	if (dRect.Xmax < cRect.Xmin)
	{
		lineEncode += 2;
	}
	else
	{
		if (dRect.Xmax > cRect.Xmax) lineEncode += 1;
	}

	if (dRect.Ymax < cRect.Ymin)
	{
		lineEncode += 3;
	}
	else
	{
		if (dRect.Ymax > cRect.Ymax) lineEncode += 6;
	}

	/* perform the clipping and set the drawing variables */
	if (mwLC()) return;	/* return if the line is completely clipped,
						with nothing left to draw */

	/* point to the row table entry for the initial row */
	rowTablePtr[0] = (long *)(rowTablePtr[1] + dRect.Ymin);

	optPtr();	/* vector to the low-level optimization routine */

	return;
}


#define M8BMRYMLR M8BMRV
#define M8BMRXMLR M8BMRH
#define M8BMRDLR M8BMRH
#define M8BMRXMRL M8BMRDRL
#define M8BMXYMLR M8BMXV
#define M8BMXXMLR M8BMXH
#define M8BMXDLR M8BMXH
#define M8BMXXMRL M8BMXDRL
#define M8BMOYMLR M8BMOV
#define M8BMOXMLR M8BMOH
#define M8BMODLR M8BMOH
#define M8BMOXMRL M8BMODRL
#define M8BMOYMLR_ND M8BMOV_ND
#define M8BMOXMLR_ND M8BMOH_ND
#define M8BMODLR_ND M8BMOH_ND
#define M8BMOXMRL_ND M8BMODRL_ND
#define M8BMAYMLR M8BMAV
#define M8BMAXMLR M8BMAH
#define M8BMADLR M8BMAH
#define M8BMAXMRL M8BMADRL
#define M8BMAYMLR_ND M8BMAV_ND
#define M8BMAXMLR_ND M8BMAH_ND
#define M8BMADLR_ND M8BMAH_ND
#define M8BMAXMRL_ND M8BMADRL_ND


void M8BURTable(void)
{
	void M8BURYMRL(void);
	void M8BURV(void);
	void M8BURYMLR(void);
	void M8BURDLR(void);
	void M8BURXMLR(void);
	void M8BURH(void);
	void M8BURDRL(void);
	void M8BURXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BURYMRL();
		break;
	case 1:	
		M8BURV();
		break;
	case 2:	
		M8BURYMLR();
		break;
	case 3:	
		M8BURDLR();
		break;
	case 4:	
		M8BURXMLR();
		break;
	case 5:	
		M8BURH();
		break;
	case 6:	
		M8BURDRL();
		break;
	case 7:	
		M8BURXMRL();
		break;
	}

	return;
}


void M8BMRTable(void)
{
	void M8BMRYMRL(void);
	void M8BMRV(void);
	void M8BMRYMLR(void);
	void M8BMRDLR(void);
	void M8BMRXMLR(void);
	void M8BMRH(void);
	void M8BMRDRL(void);
	void M8BMRXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BMRYMRL();
		break;
	case 1:	
		M8BMRV();
		break;
	case 2:	
		M8BMRYMLR();
		break;
	case 3:	
		M8BMRDLR();
		break;
	case 4:	
		M8BMRXMLR();
		break;
	case 5:	
		M8BMRH();
		break;
	case 6:	
		M8BMRDRL();
		break;
	case 7:	
		M8BMRXMRL();
		break;
	}

	return;
}


void M8BMOTable(void)
{
	void M8BMOYMRL(void);
	void M8BMOV(void);
	void M8BMOYMLR(void);
	void M8BMODLR(void);
	void M8BMOXMLR(void);
	void M8BMOH(void);
	void M8BMODRL(void);
	void M8BMOXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BMOYMRL();
		break;
	case 1:	
		M8BMOV();
		break;
	case 2:	
		M8BMOYMLR();
		break;
	case 3:	
		M8BMODLR();
		break;
	case 4:	
		M8BMOXMLR();
		break;
	case 5:	
		M8BMOH();
		break;
	case 6:	
		M8BMODRL();
		break;
	case 7:	
		M8BMOXMRL();
		break;
	}

	return;
}


void M8BUXTable(void)
{
	void	M8BUXYMRL(void);
	void	M8BUXV(void);
	void	M8BUXYMLR(void);
	void	M8BUXDLR(void);
	void	M8BUXXMLR(void);
	void	M8BUXH(void);
	void	M8BUXDRL(void);
	void	M8BUXXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BUXYMRL();
		break;
	case 1:	
		M8BUXV();
		break;
	case 2:	
		M8BUXYMLR();
		break;
	case 3:	
		M8BUXDLR();
		break;
	case 4:	
		M8BUXXMLR();
		break;
	case 5:	
		M8BUXH();
		break;
	case 6:	
		M8BUXDRL();
		break;
	case 7:	
		M8BUXXMRL();
		break;
	}

	return;
}


void M8BMXTable(void)
{
	void M8BMXYMRL(void);
	void M8BMXV(void);
	void M8BMXYMLR(void);
	void M8BMXDLR(void);
	void M8BMXXMLR(void);
	void M8BMXH(void);
	void M8BMXDRL(void);
	void M8BMXXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BMXYMRL();
		break;
	case 1:	
		M8BMXV();
		break;
	case 2:	
		M8BMXYMLR();
		break;
	case 3:	
		M8BMXDLR();
		break;
	case 4:	
		M8BMXXMLR();
		break;
	case 5:	
		M8BMXH();
		break;
	case 6:	
		M8BMXDRL();
		break;
	case 7:	
		M8BMXXMRL();
		break;
	}

	return;
}


void M8BMATable(void)
{
	void M8BMAYMRL(void);
	void M8BMAV(void);
	void M8BMAYMLR(void);
	void M8BMADLR(void);
	void M8BMAXMLR(void);
	void M8BMAH(void);
	void M8BMADRL(void);
	void M8BMAXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M8BMAYMRL();
		break;
	case 1:	
		M8BMAV();
		break;

⌨️ 快捷键说明

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