📄 m16b_lin.c
字号:
/*************************************************************************/
/* */
/* 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 */
/* */
/* m16b_lin.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the thin line drawing functions for 16 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 mwLIA16 is a special case optimization for thin line
drawing to 16 bit memory destinations, rectangular and/or region
clipping. */
void mwLIA16(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 M16BURTable(void);
void M16BMRTable(void);
void M16BMOTable(void);
void M16BUXTable(void);
void M16BMXTable(void);
void M16BMATable(void);
void M16BMO_NDTable(void);
void M16BMA_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. */
word FlipTable16[16] = {0, 0, 0, 0xffff,
0xffff, 0xffff, 0xffff, 0,
0, 0, 0, 0,
0, 0xffff, 0, 0xffff};
/* Table used to force the source color to 0xffff according to raster op. */
word ForceTableOr16[16] = {0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0xffff, 0, 0xffff, 0};
/* Table used to force the source color to 0 according to raster op. */
word ForceTableAnd16[16] = {0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff,
0, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff};
/* 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 */
lclPenColor16 = (word) lineRec->blitBack;
}
else
{ /* pattern 1 is the only other possibility */
lclPenColor16 = (word) lineRec->blitFore;
}
dstClass = dstClass & 0x0f; /* we don't care about transparency */
lclPenColor16 = lclPenColor16 ^ FlipTable16[dstClass]; /* NOT the
color if appropriate */
lclPenColor16 = lclPenColor16 | ForceTableOr16[dstClass]; /* make
the color 0xff if appropriate */
lclPenColor16 = lclPenColor16 & ForceTableAnd16[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 == 0xffff)
{ /* unmasked */
optPtr = &M16BURTable;
}
else
{ /* masked */
optPtr = &M16BMRTable;
}
break;
case 1: /* zORz : src OR dst */
case 5: /* zNORz : (NOT src) OR dst */
optPtr = &M16BMOTable;
break;
case 2: /* zXORz : src XOR dst */
case 6: /* zNXORz : (NOT src) XOR dst */
case 14: /* zINVERTz: (NOT dst) */
if (lclPortMask == 0xffff)
{ /* unmasked */
optPtr = &M16BUXTable;
}
else
{ /* masked */
optPtr = &M16BMXTable;
}
break;
case 3: /* zNANDz : (NOT src) AND dst */
case 7: /* zANDz : src AND dst */
optPtr = &M16BMATable;
break;
case 9: /* zORNz : src OR (NOT dst) */
case 13: /* zNORNz : (NOT src) OR (NOT dst) */
optPtr = &M16BMO_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 = &M16BMA_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 M16BMRYMLR M16BMRV
#define M16BMRXMLR M16BMRH
#define M16BMRDLR M16BMRH
#define M16BMRXMRL M16BMRDRL
#define M16BMXYMLR M16BMXV
#define M16BMXXMLR M16BMXH
#define M16BMXDLR M16BMXH
#define M16BMXXMRL M16BMXDRL
#define M16BMOYMLR M16BMOV
#define M16BMOXMLR M16BMOH
#define M16BMODLR M16BMOH
#define M16BMOXMRL M16BMODRL
#define M16BMOYMLR_ND M16BMOV_ND
#define M16BMOXMLR_ND M16BMOH_ND
#define M16BMODLR_ND M16BMOH_ND
#define M16BMOXMRL_ND M16BMODRL_ND
#define M16BMAYMLR M16BMAV
#define M16BMAXMLR M16BMAH
#define M16BMADLR M16BMAH
#define M16BMAXMRL M16BMADRL
#define M16BMAYMLR_ND M16BMAV_ND
#define M16BMAXMLR_ND M16BMAH_ND
#define M16BMADLR_ND M16BMAH_ND
#define M16BMAXMRL_ND M16BMADRL_ND
void M16BURTable(void)
{
void M16BURYMRL(void);
void M16BURV(void);
void M16BURYMLR(void);
void M16BURDLR(void);
void M16BURXMLR(void);
void M16BURH(void);
void M16BURDRL(void);
void M16BURXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BURYMRL();
break;
case 1:
M16BURV();
break;
case 2:
M16BURYMLR();
break;
case 3:
M16BURDLR();
break;
case 4:
M16BURXMLR();
break;
case 5:
M16BURH();
break;
case 6:
M16BURDRL();
break;
case 7:
M16BURXMRL();
break;
}
return;
}
void M16BMRTable(void)
{
void M16BMRYMRL(void);
void M16BMRV(void);
void M16BMRYMLR(void);
void M16BMRDLR(void);
void M16BMRXMLR(void);
void M16BMRH(void);
void M16BMRDRL(void);
void M16BMRXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BMRYMRL();
break;
case 1:
M16BMRV();
break;
case 2:
M16BMRYMLR();
break;
case 3:
M16BMRDLR();
break;
case 4:
M16BMRXMLR();
break;
case 5:
M16BMRH();
break;
case 6:
M16BMRDRL();
break;
case 7:
M16BMRXMRL();
break;
}
return;
}
void M16BMOTable(void)
{
void M16BMOYMRL(void);
void M16BMOV(void);
void M16BMOYMLR(void);
void M16BMODLR(void);
void M16BMOXMLR(void);
void M16BMOH(void);
void M16BMODRL(void);
void M16BMOXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BMOYMRL();
break;
case 1:
M16BMOV();
break;
case 2:
M16BMOYMLR();
break;
case 3:
M16BMODLR();
break;
case 4:
M16BMOXMLR();
break;
case 5:
M16BMOH();
break;
case 6:
M16BMODRL();
break;
case 7:
M16BMOXMRL();
break;
}
return;
}
void M16BUXTable(void)
{
void M16BUXYMRL(void);
void M16BUXV(void);
void M16BUXYMLR(void);
void M16BUXDLR(void);
void M16BUXXMLR(void);
void M16BUXH(void);
void M16BUXDRL(void);
void M16BUXXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BUXYMRL();
break;
case 1:
M16BUXV();
break;
case 2:
M16BUXYMLR();
break;
case 3:
M16BUXDLR();
break;
case 4:
M16BUXXMLR();
break;
case 5:
M16BUXH();
break;
case 6:
M16BUXDRL();
break;
case 7:
M16BUXXMRL();
break;
}
return;
}
void M16BMXTable(void)
{
void M16BMXYMRL(void);
void M16BMXV(void);
void M16BMXYMLR(void);
void M16BMXDLR(void);
void M16BMXXMLR(void);
void M16BMXH(void);
void M16BMXDRL(void);
void M16BMXXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BMXYMRL();
break;
case 1:
M16BMXV();
break;
case 2:
M16BMXYMLR();
break;
case 3:
M16BMXDLR();
break;
case 4:
M16BMXXMLR();
break;
case 5:
M16BMXH();
break;
case 6:
M16BMXDRL();
break;
case 7:
M16BMXXMRL();
break;
}
return;
}
void M16BMATable(void)
{
void M16BMAYMRL(void);
void M16BMAV(void);
void M16BMAYMLR(void);
void M16BMADLR(void);
void M16BMAXMLR(void);
void M16BMAH(void);
void M16BMADRL(void);
void M16BMAXMRL(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BMAYMRL();
break;
case 1:
M16BMAV();
break;
case 2:
M16BMAYMLR();
break;
case 3:
M16BMADLR();
break;
case 4:
M16BMAXMLR();
break;
case 5:
M16BMAH();
break;
case 6:
M16BMADRL();
break;
case 7:
M16BMAXMRL();
break;
}
return;
}
void M16BMO_NDTable(void)
{
void M16BMOYMRL_ND(void);
void M16BMOV_ND(void);
void M16BMOYMLR_ND(void);
void M16BMODLR_ND(void);
void M16BMOXMLR_ND(void);
void M16BMOH_ND(void);
void M16BMODRL_ND(void);
void M16BMOXMRL_ND(void);
switch (lineDir) /* appropriate for the line direction */
{
case 0:
M16BMOYMRL_ND();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -