📄 m24b_fil.c
字号:
case 8: /* zCLEARz */
bkColr24 = 0; /* sets all source bits to 0 */
pnColr24 = 0;
break;
case 12: /* zSETz */
case 14: /* zINVERTz */
bkColr24 = -1; /* sets all source bits to 1 */
pnColr24 = -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 = &SolidFillRectM24;
if (Fill_Clip_Region(fillRec, &dRect) == 0) break;
continue;
}
}
SolidFillRectM24(fillRec); /* blit the rectangle */
}
nuResume(dstBmap);
return;
}
/* Function MultiColorFillRectM24 fills a multicolored rectangle in
the memory */
void MultiColorFillRectM24(blitRcd *blitRec)
{
int lclByteCnt, lclLineCnt;
int ptrnX, ptrnY, ptrnCntr;
lclLineCnt = dRect.Ymax - dRect.Ymin - 1;
dstBgnByte = 3 * dRect.Xmin;
byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
dstNextRow = dstBmap->pixBytes - (3 * byteCntM1) - 3;
ptrnY = dRect.Ymin % patHeight; /* start of pattern allignment */
ptrnY *= patWidthInBytes;
dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
+ dstBgnByte;
while (lclLineCnt-- >= 0)
{ /* for each row */
ptrnX = (3 * dRect.Xmin) % patWidthInBytes;
lclByteCnt = byteCntM1;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
ptrnCntr = ptrnX + ptrnY;
*dstPtr++ = savePat->imData[ptrnCntr++];
*dstPtr++ = savePat->imData[ptrnCntr++];
*dstPtr++ = savePat->imData[ptrnCntr];
ptrnX += 3;
if (ptrnX == patWidthInBytes) ptrnX = 0;
}
dstPtr += dstNextRow; /* advance to next row */
ptrnY += patWidthInBytes;
if (ptrnY == patLength) ptrnY = 0;
}
return;
}
/* Function SolidFillRect fills the rectangle on the screen */
void SolidFillRectM24(blitRcd *blitRec)
{
lineCntM1 = dRect.Ymax - dRect.Ymin - 1;
dstBgnByte = 3 * dRect.Xmin;
byteCntM1 = dRect.Xmax - dRect.Xmin - 1;
dstNextRow = dstBmap->pixBytes - (3 * byteCntM1) - 3;
dstPtr = (byte *) (*(dstBmap->mapTable[0] + dRect.Ymin))
+ dstBgnByte;
optPtr(); /* blit the rectangle */
return;
}
/* Function InvertDestMem24 inverts the destination pixel data. */
void InvertDestMem24(void)
{
byte *lclDstPtr;
int lclLineCnt, lclByteCnt;
lclDstPtr = dstPtr; /* set up local pointers */
lclLineCnt = lineCntM1;
while (lclLineCnt-- >= 0)
{ /* for each row */
lclByteCnt = (3 * byteCntM1) + 2;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
*lclDstPtr = ~(*lclDstPtr);
lclDstPtr++;
}
lclDstPtr += dstNextRow; /* advance to next row */
}
return;
}
/* Function SetDestMem24 sets the destination pixel data. */
void SetDestMem24(void)
{
byte *lclDstPtr, pnColrR, pnColrG, pnColrB;
int lclLineCnt, lclByteCnt;
lclDstPtr = dstPtr; /* set up local pointers */
lclLineCnt = lineCntM1;
pnColrR = (byte) (pnColr24 >> 16); /* set up local colors */
pnColrG = (pnColr24 >> 8) & 0xff;
pnColrB = pnColr24 & 0xff;
while (lclLineCnt-- >= 0)
{ /* for each row */
lclByteCnt = byteCntM1;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
*lclDstPtr++ = pnColrR;
*lclDstPtr++ = pnColrG;
*lclDstPtr++ = pnColrB;
}
lclDstPtr += dstNextRow; /* advance to next row */
}
return;
}
/* Function NotDestFillMem24 handles memory "not dst" by inverting the
destination first. */
void NotDestFillMem24(void)
{
void InvertDestMem24(void);
void FillOXADestMem24(void);
InvertDestMem24();
FillOXADestMem24(); /* fill this rectangle */
return;
}
/* Function NotDestMonoFillMem24 handles memory "not dst" by inverting
the destination first. */
void NotDestMonoFillMem24(void)
{
void InvertDestMem24(void);
void MonoFillOXADestMem24(void);
InvertDestMem24();
MonoFillOXADestMem24(); /* fill this rectangle */
return;
}
/* Function MonoFillDestMem24 sets the destination pixel data to pnColr24
if the source is 1 else bkColr24. */
void MonoFillDestMem24(void)
{
byte *lclDstPtr, pnColrR, pnColrG, pnColrB;
byte bkColrR, bkColrG, bkColrB;
int lclLineCnt, lclByteCnt;
int ptrnX, ptrnY, ptrnByte, ptrnBt;
lclDstPtr = dstPtr; /* set up local pointers */
lclLineCnt = lineCntM1;
pnColrR = (byte) (pnColr24 >> 16); /* set up local colors */
pnColrG = (pnColr24 >> 8) & 0xff;
pnColrB = pnColr24 & 0xff;
bkColrR = (byte) (bkColr24 >> 16);
bkColrG = (bkColr24 >> 8) & 0xff;
bkColrB = bkColr24 & 0xff;
ptrnY = dRect.Ymin % patHeight; /* start of pattern allignment */
ptrnY *= patWidthInBytes;
while (lclLineCnt-- >= 0)
{ /* for each row */
ptrnX = dRect.Xmin % patWidthInBytes;
ptrnBt = (128 >> (dRect.Xmin & 7));
ptrnByte = savePat->imData[ptrnX + ptrnY];
lclByteCnt = byteCntM1;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
if (ptrnByte & ptrnBt)
{ /* source is 1 */
*lclDstPtr++ = pnColrR;
*lclDstPtr++ = pnColrG;
*lclDstPtr++ = pnColrB;
}
else
{ /* source is 0 */
*lclDstPtr++ = bkColrR;
*lclDstPtr++ = bkColrG;
*lclDstPtr++ = bkColrB;
}
ptrnBt = ptrnBt >> 1;
if (ptrnBt == 0)
{
ptrnBt = 128;
ptrnX++;
if (ptrnX == patWidthInBytes) ptrnX = 0;
ptrnByte = savePat->imData[ptrnX + ptrnY];
}
}
lclDstPtr += dstNextRow; /* advance to next row */
ptrnY += patWidthInBytes;
if (ptrnY == patLength) ptrnY = 0;
}
return;
}
/* Function FillOXADestMem24 sets the destination pixel data based on
the logical function "OR", "XOR" or "AND". */
void FillOXADestMem24(void)
{
byte *lclDstPtr, pnColrR, pnColrG, pnColrB;
int lclLineCnt, lclByteCnt;
int logFnc;
lclDstPtr = dstPtr; /* set up local pointers */
lclLineCnt = lineCntM1;
logFnc = (dstClass & 3); /* only two lower bits needed */
pnColrR = (byte) (pnColr24 >> 16); /* set up local colors */
pnColrG = (pnColr24 >> 8) & 0xff;
pnColrB = pnColr24 & 0xff;
while (lclLineCnt-- >= 0)
{ /* for each row */
lclByteCnt = byteCntM1;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
switch (logFnc)
{
case 0: /* handled elsewhere */
case 1: /* "OR" */
*lclDstPtr = *lclDstPtr | pnColrR;
lclDstPtr++;
*lclDstPtr = *lclDstPtr | pnColrG;
lclDstPtr++;
*lclDstPtr = *lclDstPtr | pnColrB;
lclDstPtr++;
break;
case 2: /* "XOR" */
*lclDstPtr = *lclDstPtr ^ pnColrR;
lclDstPtr++;
*lclDstPtr = *lclDstPtr ^ pnColrG;
lclDstPtr++;
*lclDstPtr = *lclDstPtr ^ pnColrB;
lclDstPtr++;
break;
case 3: /* "AND" */
*lclDstPtr = *lclDstPtr & pnColrR;
lclDstPtr++;
*lclDstPtr = *lclDstPtr & pnColrG;
lclDstPtr++;
*lclDstPtr = *lclDstPtr & pnColrB;
lclDstPtr++;
}
}
lclDstPtr += dstNextRow; /* advance to next row */
}
return;
}
/* Function MonoFillOXADestMem24 sets the destination pixel data based on
the logical function "OR", "XOR" or "AND" and the pattern bit. */
void MonoFillOXADestMem24(void)
{
byte *lclDstPtr;
int lclLineCnt, lclByteCnt;
int logFnc;
int ptrnX, ptrnY, ptrnByte, ptrnBt, ptrnColr;
lclDstPtr = dstPtr; /* set up local pointers */
lclLineCnt = lineCntM1;
logFnc = (dstClass & 3); /* only two lower bits needed */
ptrnY = dRect.Ymin % patHeight; /* start of pattern allignment */
ptrnY *= patWidthInBytes;
while (lclLineCnt-- >= 0)
{ /* for each row */
ptrnX = dRect.Xmin % patWidthInBytes;
ptrnBt = (128 >> (dRect.Xmin & 7));
ptrnByte = savePat->imData[ptrnX + ptrnY];
lclByteCnt = byteCntM1;
while (lclByteCnt-- >= 0)
{ /* for each byte in the row */
if (ptrnByte & ptrnBt)
{
ptrnColr = pnColr24;
}
else
{
ptrnColr = bkColr24;
}
switch (logFnc)
{
case 0: /* handled elsewhere */
case 1: /* "OR" */
*lclDstPtr = *lclDstPtr | (ptrnColr >> 16);
lclDstPtr++;
*lclDstPtr = *lclDstPtr | ((ptrnColr >> 8) & 0xff);
lclDstPtr++;
*lclDstPtr = *lclDstPtr | (ptrnColr & 0xff);
lclDstPtr++;
break;
case 2: /* "XOR" */
*lclDstPtr = *lclDstPtr ^ (ptrnColr >> 16);
lclDstPtr++;
*lclDstPtr = *lclDstPtr ^ ((ptrnColr >> 8) & 0xff);
lclDstPtr++;
*lclDstPtr = *lclDstPtr ^ (ptrnColr & 0xff);
lclDstPtr++;
break;
case 3: /* "AND" */
*lclDstPtr = *lclDstPtr & (ptrnColr >> 16);
lclDstPtr++;
*lclDstPtr = *lclDstPtr & ((ptrnColr >> 8) & 0xff);
lclDstPtr++;
*lclDstPtr = *lclDstPtr & (ptrnColr & 0xff);
lclDstPtr++;
}
ptrnBt = ptrnBt >> 1;
if (ptrnBt == 0)
{
ptrnBt = 128;
ptrnX++;
if (ptrnX == patWidthInBytes) ptrnX = 0;
ptrnByte = savePat->imData[ptrnX + ptrnY];
}
}
lclDstPtr += dstNextRow; /* advance to next row */
ptrnY += patWidthInBytes;
if (ptrnY == patLength) ptrnY = 0;
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -