Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Blit without mask - BltBitMap equivalent, but less safe
- * Channels:
- * A: mask const, read disabled
- * B: src read
- * C: dest read
- * D: dest write
- * Descending mode is used under 2 cases:
- * - Blit needs shifting to left with previous data coming from right (ubSrcDelta > ubDstDelta)
- * - Ascending right mask shifted more than 16 bits
- * Source and destination regions should not overlap.
- * Function is slightly slower (~0.5 - 1.5ms) than bltBitMap:
- * - Pre-loop calculations take ~50us on ASC mode, ~80us on DESC mode
- * - Rewriting to assembly could speed things up a bit
- */
- BYTE _blitCopy(
- tBitMap *pSrc, WORD wSrcX, WORD wSrcY,
- tBitMap *pDst, WORD wDstX, WORD wDstY, WORD wWidth, WORD wHeight,
- UBYTE ubMinterm, UBYTE ubMask, UWORD uwLine, char *szFile
- ) {
- if(!blitCheck(pSrc, wSrcX, wSrcY, pDst, wDstX, wDstY, wWidth, wHeight, uwLine, szFile))
- return 0;
- // Helper vars
- UWORD uwBlitWords, uwBlitWidth, uwSrcOffs, uwDstOffs;
- UBYTE ubShift, ubSrcDelta, ubDstDelta, ubWidthDelta, ubMaskFShift, ubMaskLShift, ubPlane;
- // Blitter register values
- UWORD uwBltCon0, uwBltCon1, uwFirstMask, uwLastMask;
- WORD wSrcModulo, wDstModulo;
- ubSrcDelta = wSrcX & 0xF;
- ubDstDelta = wDstX & 0xF;
- ubWidthDelta = (ubSrcDelta + wWidth) & 0xF;
- if(ubSrcDelta > ubDstDelta || ((wWidth+ubDstDelta+15) & 0xFFF0)-(wWidth+ubSrcDelta) > 16) {
- uwBlitWidth = (wWidth+(ubSrcDelta>ubDstDelta?ubSrcDelta:ubDstDelta)+15) & 0xFFF0;
- uwBlitWords = uwBlitWidth >> 4;
- ubMaskFShift = ((ubWidthDelta+15)&0xF0)-ubWidthDelta;
- ubMaskLShift = uwBlitWidth - (wWidth+ubMaskFShift);
- uwFirstMask = 0xFFFF << ubMaskFShift;
- uwLastMask = 0xFFFF >> ubMaskLShift;
- if(ubMaskLShift > 16) // Fix for 2-word blits
- uwFirstMask &= 0xFFFF >> (ubMaskLShift-16);
- ubShift = uwBlitWidth - (ubDstDelta+wWidth+ubMaskFShift);
- uwBltCon1 = ubShift << BSHIFTSHIFT | BLITREVERSE;
- uwSrcOffs = pSrc->BytesPerRow * (wSrcY+wHeight-1) + ((wSrcX+wWidth+ubMaskFShift-1)>>3);
- uwDstOffs = pDst->BytesPerRow * (wDstY+wHeight-1) + ((wDstX+wWidth+ubMaskFShift-1) >> 3);
- }
- else {
- uwBlitWidth = (wWidth+ubDstDelta+15) & 0xFFF0;
- uwBlitWords = uwBlitWidth >> 4;
- ubMaskFShift = ubSrcDelta;
- ubMaskLShift = uwBlitWidth-(wWidth+ubSrcDelta);
- uwFirstMask = 0xFFFF >> ubMaskFShift;
- uwLastMask = 0xFFFF << ubMaskLShift;
- ubShift = ubDstDelta-ubSrcDelta;
- uwBltCon1 = ubShift << BSHIFTSHIFT;
- uwSrcOffs = pSrc->BytesPerRow * wSrcY + (wSrcX>>3);
- uwDstOffs = pDst->BytesPerRow * wDstY + (wDstX>>3);
- }
- uwBltCon0 = (ubShift << ASHIFTSHIFT) | USEB|USEC|USED | ubMinterm;
- wSrcModulo = pSrc->BytesPerRow - (uwBlitWords<<1);
- wDstModulo = pDst->BytesPerRow - (uwBlitWords<<1);
- ubMask &= 0xFF >> (8- (pSrc->Depth < pDst->Depth? pSrc->Depth: pDst->Depth));
- ubPlane = 0;
- while(ubMask) {
- if(ubMask & 1)
- g_sBlitManager.pBlitterSetFn(
- uwBltCon0, uwBltCon1, // bltconX
- uwFirstMask, uwLastMask, // bltaXwm
- 0, wSrcModulo, wDstModulo, wDstModulo, // bltXmod
- 0, // bltapt
- pSrc->Planes[ubPlane] + uwSrcOffs, // bltbpt
- pDst->Planes[ubPlane] + uwDstOffs, // bltcpt
- pDst->Planes[ubPlane] + uwDstOffs, // bltdpt
- 0xFFFF, 0, 0, // bltXdat
- (wHeight << 6) | uwBlitWords // bltsize
- );
- ubMask >>= 1;
- ++ubPlane;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement