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

📄 m1b_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          */
/*                                                                       */
/*      m1b_lin.c                                        1.9             */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*      All                                                              */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      This file contains the thin line drawing functions for 1 bit     */
/* memory or LCD.                                                        */
/*                                                                       */
/* 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 mwLI1Bit is a special case optimization for thin line
drawing to 1 bit memory destinations, rectangular and/or region
clipping. */
void mwLI1Bit(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 M1BURTable(void);
/*	void M1BMRTable(void);*/
	void M1BMOTable(void);
	void M1BUXTable(void);
/*	void M1BMXTable(void);*/
	void M1BMATable(void);
	void M1BMO_NDTable(void);
	void M1BMA_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,    0x01,
						  0x01, 0x01, 0x01, 0,
						  0,    0,    0,    0,
						  0,    0x01, 0,    0x01};
	/* Table used to force the source color to 0x01 according to raster op. */
	byte ForceTableOr[16] = {0,    0,    0,    0,
							 0,    0,    0,    0,
							 0,    0,    0,    0,
							 0x01, 0,    0x01, 0};
	/* Table used to force the source color to 0 according to raster op. */
	byte ForceTableAnd[16] = {0x01, 0x01, 0x01, 0x01,
							  0x01, 0x01, 0x01, 0x01,
							  0,    0x01, 0x01, 0x01,
							  0x01, 0x01, 0x01, 0x01};

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

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

	if(lclPenColor != 0) lclPenColor = 1;	/* force color 0 or 1 */
	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 0x01 if appropriate */
	lclPenColor = lclPenColor & ForceTableAnd[dstClass];	/* make
									the color 0 if appropriate */
	lclPenColor = lclPenColor & ((byte) lclPortMask);
	dstBmap =  lineRec->blitDmap;
	M_PAUSE(dstBmap);	/* lock grafMap */

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

	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 = &M1BURTable;
		break;
	case 1:		/* zORz    :       src OR  dst		 */
	case 5:		/* zNORz   :    (NOT src) OR  dst	 */
		optPtr = &M1BMOTable;
		break;
	case 2:		/* zXORz   :       src XOR dst		 */
	case 6:		/* zNXORz  :    (NOT src) XOR dst	 */
	case 14:	/* zINVERTz:        (NOT dst)		 */
			optPtr = &M1BUXTable;
		break;
	case 3:		/* zNANDz  :    (NOT src) AND dst	 */
	case 7:		/* zANDz   :       src AND dst		 */
		optPtr = &M1BMATable;
		break;
	case 9:		/* zORNz   :     src OR  (NOT dst)	 */
	case 13:	/* zNORNz  : (NOT src) OR  (NOT dst) */
		optPtr = &M1BMO_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 = &M1BMA_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 M1BMOYMLR M1BMOV
#define M1BMOXMLR M1BMOH
#define M1BMODLR M1BMOH
#define M1BMOXMRL M1BMODRL
#define M1BMOYMLR_ND M1BMOV_ND
#define M1BMOXMLR_ND M1BMOH_ND
#define M1BMODLR_ND M1BMOH_ND
#define M1BMOXMRL_ND M1BMODRL_ND
#define M1BMAYMLR M1BMAV
#define M1BMAXMLR M1BMAH
#define M1BMADLR M1BMAH
#define M1BMAXMRL M1BMADRL
#define M1BMAYMLR_ND M1BMAV_ND
#define M1BMAXMLR_ND M1BMAH_ND
#define M1BMADLR_ND M1BMAH_ND
#define M1BMAXMRL_ND M1BMADRL_ND


void M1BURTable(void)
{
	void M1BURYMRL(void);
	void M1BURV(void);
	void M1BURYMLR(void);
	void M1BURDLR(void);
	void M1BURXMLR(void);
	void M1BURH(void);
	void M1BURDRL(void);
	void M1BURXMRL(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BURYMRL();
		break;
	case 1:	
		M1BURV();
		break;
	case 2:	
		M1BURYMLR();
		break;
	case 3:	
		M1BURDLR();
		break;
	case 4:	
		M1BURXMLR();
		break;
	case 5:	
		M1BURH();
		break;
	case 6:	
		M1BURDRL();
		break;
	case 7:	
		M1BURXMRL();
		break;
	}

	return;
}


void M1BMOTable(void)
{
	void M1BMOYMRL(void);
	void M1BMOV(void);
	void M1BMOYMLR(void);
	void M1BMODLR(void);
	void M1BMOXMLR(void);
	void M1BMOH(void);
	void M1BMODRL(void);
	void M1BMOXMRL(void);

	if(lclPenColor == 0) return;	/* nothing to do */
	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BMOYMRL();
		break;
	case 1:	
		M1BMOV();
		break;
	case 2:	
		M1BMOYMLR();
		break;
	case 3:	
		M1BMODLR();
		break;
	case 4:	
		M1BMOXMLR();
		break;
	case 5:	
		M1BMOH();
		break;
	case 6:	
		M1BMODRL();
		break;
	case 7:	
		M1BMOXMRL();
		break;
	}

	return;
}


void M1BUXTable(void)
{
	void	M1BUXYMRL(void);
	void	M1BUXV(void);
	void	M1BUXYMLR(void);
	void	M1BUXDLR(void);
	void	M1BUXXMLR(void);
	void	M1BUXH(void);
	void	M1BUXDRL(void);
	void	M1BUXXMRL(void);

	if(lclPenColor == 0) return;	/* nothing to do */
	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BUXYMRL();
		break;
	case 1:	
		M1BUXV();
		break;
	case 2:	
		M1BUXYMLR();
		break;
	case 3:	
		M1BUXDLR();
		break;
	case 4:	
		M1BUXXMLR();
		break;
	case 5:	
		M1BUXH();
		break;
	case 6:	
		M1BUXDRL();
		break;
	case 7:	
		M1BUXXMRL();
		break;
	}

	return;
}


void M1BMATable(void)
{
	void M1BMAYMRL(void);
	void M1BMAV(void);
	void M1BMAYMLR(void);
	void M1BMADLR(void);
	void M1BMAXMLR(void);
	void M1BMAH(void);
	void M1BMADRL(void);
	void M1BMAXMRL(void);

	if(lclPenColor == 1) return;	/* nothing to do */
	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BMAYMRL();
		break;
	case 1:	
		M1BMAV();
		break;
	case 2:	
		M1BMAYMLR();
		break;
	case 3:	
		M1BMADLR();
		break;
	case 4:	
		M1BMAXMLR();
		break;
	case 5:	
		M1BMAH();
		break;
	case 6:	
		M1BMADRL();
		break;
	case 7:	
		M1BMAXMRL();
		break;
	}

	return;
}


void M1BMO_NDTable(void)
{
	void M1BMOYMRL_ND(void);
	void M1BMOV_ND(void);
	void M1BMOYMLR_ND(void);
	void M1BMODLR_ND(void);
	void M1BMOXMLR_ND(void);
	void M1BMOH_ND(void);
	void M1BMODRL_ND(void);
	void M1BMOXMRL_ND(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BMOYMRL_ND();
		break;
	case 1:	
		M1BMOV_ND();
		break;
	case 2:	
		M1BMOYMLR_ND();
		break;
	case 3:	
		M1BMODLR_ND();
		break;
	case 4:	
		M1BMOXMLR_ND();
		break;
	case 5:	
		M1BMOH_ND();
		break;
	case 6:	
		M1BMODRL_ND();
		break;
	case 7:	
		M1BMOXMRL_ND();
		break;
	}

	return;
}


void M1BMA_NDTable(void)
{
	void M1BMAYMRL_ND(void);
	void M1BMAV_ND(void);
	void M1BMAYMLR_ND(void);
	void M1BMADLR_ND(void);
	void M1BMAXMLR_ND(void);
	void M1BMAH_ND(void);
	void M1BMADRL_ND(void);
	void M1BMAXMRL_ND(void);

	switch (lineDir)	/* appropriate for the line direction */
	{
	case 0:	
		M1BMAYMRL_ND();
		break;
	case 1:	
		M1BMAV_ND();
		break;
	case 2:	
		M1BMAYMLR_ND();
		break;
	case 3:	
		M1BMADLR_ND();
		break;
	case 4:	
		M1BMAXMLR_ND();
		break;
	case 5:	
		M1BMAH_ND();
		break;
	case 6:	
		M1BMADRL_ND();
		break;
	case 7:	
		M1BMAXMRL_ND();
		break;
	}

	return;
}


/* Low-level line drawing optimizations. */
/* Unmasked low-level optimizations. */

/*	Horizontal left->right replace.	*/
void M1BURH(void)
{
	int i;
	byte pxBit;

	pxBit = (byte) (0x80 >> (dRect.Xmin & 0x07));
	dstPtr = (byte *) *rowTablePtr[0] + (dRect.Xmin >> 3);
	for (i = 0; i <= majorAxisLengthM1; i++)
	{
		if(lclPenColor)

⌨️ 快捷键说明

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