コード例 #1
0
ファイル: BLAST Copy.c プロジェクト: mctully/tntbasic
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ BlastCopy16
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// BlastCopy16 is used in the same way as BlastCopy except it does 16 bit deep copies
void BlastCopy16(BCPtr source,BCPtr dest,const Rect *sourceRect,const Rect *destRect)
{
    unsigned char	*srcPtr,*destPtr,*srcRowStart,*destRowStart;
    unsigned long	miscCount;
    unsigned long	yCount;
    unsigned long	heightToCopy=sourceRect->bottom-sourceRect->top;
    unsigned long	widthToCopy=sourceRect->right-sourceRect->left;
    unsigned long	srcRB,destRB;

    srcRB=source->rowBytes;
    destRB=dest->rowBytes;
    srcRowStart=source->baseAddr+srcRB*sourceRect->top+sourceRect->left*sizeof(unsigned short);
    destRowStart=dest->baseAddr+destRB*destRect->top+destRect->left*sizeof(unsigned short);

    if (IsDoubleAligned(srcRowStart,destRowStart,srcRB,destRB))
    {
        BlastCopyDoubleAligned(srcRowStart,destRowStart,srcRB,destRB,widthToCopy*2,heightToCopy);
        return;
    }

    for (yCount=0; yCount<heightToCopy; yCount++)
    {
        srcPtr=srcRowStart;
        srcRowStart+=srcRB;
        destPtr=destRowStart;
        destRowStart+=destRB;

        miscCount=widthToCopy;

        // Move the data in the biggest chunks possible
#ifdef powerc
        // raa PowerPC 601, 8 bytes in one move command
        if (g601Chip)
        {
            while (miscCount>=sizeof(double)/2)
            {
                *((double *)destPtr)++=*((double *)srcPtr)++;
                miscCount-=sizeof(double)/2;
            }
        }
#endif

        while(miscCount>=sizeof(unsigned long)/2)
        {
            *((unsigned long *)destPtr)++=*((unsigned long *)srcPtr)++;
            miscCount-=sizeof(unsigned long)/2;
        }

        while(miscCount>=sizeof(unsigned short)/2)
        {
            *((unsigned short *)destPtr)++=*((unsigned short *)srcPtr)++;
            miscCount-=sizeof(unsigned short)/2;
        }
    }
}
コード例 #2
0
ファイル: BLAST Copy.c プロジェクト: MaddTheSane/tntbasic
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ BlastCopy16
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// BlastCopy16 is used in the same way as BlastCopy except it does 16 bit deep copies
void BlastCopy16(BCPtr source,BCPtr dest,const Rect *sourceRect,const Rect *destRect)
{
	unsigned char	*srcPtr,*destPtr,*srcRowStart,*destRowStart;
	unsigned long	miscCount;
	unsigned long	yCount;
	unsigned long	heightToCopy=sourceRect->bottom-sourceRect->top;
	unsigned long	widthToCopy=sourceRect->right-sourceRect->left;
	unsigned long	srcRB,destRB;
	
	srcRB=source->rowBytes;
	destRB=dest->rowBytes;
	srcRowStart=source->baseAddr+srcRB*sourceRect->top+sourceRect->left*sizeof(unsigned short);
	destRowStart=dest->baseAddr+destRB*destRect->top+destRect->left*sizeof(unsigned short);
	
	if (IsDoubleAligned(srcRowStart,destRowStart,srcRB,destRB))
	{
		BlastCopyDoubleAligned(srcRowStart,destRowStart,srcRB,destRB,widthToCopy*2,heightToCopy);
		return;
	}
	
	for (yCount=0; yCount<heightToCopy; yCount++)
	{
		srcPtr=srcRowStart;
		srcRowStart+=srcRB;
		destPtr=destRowStart;
		destRowStart+=destRB;
		
		miscCount=widthToCopy;
	
		// Move the data in the biggest chunks possible
			while (miscCount>=sizeof(double)/2)
			{
				unsigned long long *aDestPtr = ((unsigned long long *)destPtr);
				unsigned long long *aSrcPtr = ((unsigned long long *)srcPtr);
				*aDestPtr = *aSrcPtr;
				aDestPtr++;
				aSrcPtr++;
				miscCount-=sizeof(unsigned long long)/2;
			}
		
		while(miscCount>=sizeof(unsigned long)/2)
		{
			unsigned long *aDestPtr = ((unsigned long *)destPtr);
			unsigned long *aSrcPtr = ((unsigned long *)srcPtr);
			*aDestPtr = *aSrcPtr;
			aDestPtr++;
			aSrcPtr++;
			miscCount -= sizeof(unsigned long)/2;
		}
		
		while(miscCount>=sizeof(unsigned short)/2)
		{
			unsigned short *aDestPtr = ((unsigned short *)destPtr);
			unsigned short *aSrcPtr = ((unsigned short *)srcPtr);
			*aDestPtr = *aSrcPtr;
			aDestPtr++;
			aSrcPtr++;
			miscCount -= sizeof(unsigned short)/2;
		}
	}
}