📄 mqcm2slk.blt
字号:
#ifdef CHECK_8BPP
SCODE MQGC::CM2SLKBlt( GPEBltParms *pBltParms )
{
DEBUGMSG(GPE_ZONE_MQEMUL1,(TEXT("CM2SLKBlt\r\n")));
PBYTE pSrcBits;
ULONG width, height;
ULONG ulCmd, ulOffset, ulDWords, ulByteShift, ulExtras;
long lSrcStride;
ROTATE_PARAMS(pBltParms);
geINIT( pBltParms->pDst );
width = pBltParms->prclDst->right - pBltParms->prclDst->left;
height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
// Calculate the PROGRAMMABLE FIFO Data for 16 BPP Destination.
// 16BPP Source should be handled by CM2SBlt() which source and
// destination color depth are the same (w or w/o lookup table).
lSrcStride = m_pSrc->Stride();
pSrcBits = (PBYTE)m_pSrc->Buffer() +
((pBltParms->prclSrc->top * lSrcStride));
#ifdef CM2SLK_EXCLUDED_CASE
if (m_eFormat == gpe2Bpp)
{
pSrcBits += (pBltParms->prclSrc->left >> 2);
ulByteShift = (ULONG)(pBltParms->prclSrc->left & 0x03UL);
ulCmd = m_ulRop3 | DO_BITBLT | SRC_IS_MEMORY;
ulDWords = (width + ulByteShift + 3UL) >> 2; // num of DWORDS per line
// Calculate Extra bits to pad data up to 128-bit aligned
ulDWords += ((4UL - (ulDWords & 0x03UL)) & 0x03UL);
ulExtras = 0;
ulOffset = (ulByteShift << 28); // can handle up to 3 pixel offset
}
else
#endif
if (m_eFormat == gpe4Bpp)
{
// SRC Read is DWORD
pSrcBits += (pBltParms->prclSrc->left >> 1);
ulByteShift = ((ULONG)pSrcBits & 0x03UL);
pSrcBits -= ulByteShift;
ulByteShift = (ulByteShift << 1) +
(ULONG)(pBltParms->prclSrc->left & 0x01UL);
ulCmd = m_ulRop3 | DO_BITBLT | SRC_IS_MEMORY;
ulDWords = (width + ulByteShift + 3UL) >> 2; // num of DWORDS per line
// Calculate Extra bits to pad data up to 128-bit aligned
ulDWords += ((4UL - (ulDWords & 0x03UL)) & 0x03UL);
ulOffset = (ulByteShift << 28);
ulExtras = 0;
}
#ifdef CM2SLK_EXCLUDED_CASE
else // 16BPP
{
ULONG ulByteSpace;
pSrcBits += (pBltParms->prclSrc->left << 1);
ulByteShift = (ULONG)pSrcBits & 0x03UL;
pSrcBits -= ulByteShift;
ulCmd = m_ulRop3 | DO_BITBLT | SRC_IS_MEMORY | PACKED_MODE;
ulByteSpace = ((0x04UL - ((width + ulByteShift) & 0x03UL)) & 0x03UL)
+ ulByteShift;
ulDWords = (width + ulByteSpace + 3UL) >> 2; // num of DWORDS per line
// Calculate Extra bits to pad data up to 128-bit aligned
ulExtras = (4UL - ((ulDWords * height) & 0x03UL)) & 0x03UL;
ulOffset = (ulByteSpace << 28);
}
#else
else
{
return S_FALSE;
}
#endif //CM2SLK_EXCLUDED_CASE
// Calculate SRC FIFO parameters
m_ulDestXY = (pBltParms->prclDst->top << 16) + pBltParms->prclDst->left
+ ((MQGCSurf *)(pBltParms->pDst))->m_ulTopLeft;
if ( m_pPatternSetup != NullPatternSetup )
{
if ( m_pBrush )
m_lpPattern = (PULONG)m_pBrush->Buffer();
(this->*m_pPatternSetup)( pBltParms, &ulCmd );
}
#ifdef CM2SBLT_TRANSPARENT
if ( pBltParms->bltFlags & BLT_TRANSPARENT )
{
ulCmd |= TRANS_COLOR;
geWAITCMDFIFO( 1 );
geREG(COLOR_COMPARE, (pBltParms->pLookup)[pBltParms->solidColor]);
}
#endif
geWAITCMDFIFO( 4 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
geREG(DEST_XY, m_ulDestXY);
geREG(SRC_STRIDE_OFFSET, ulOffset);
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, ulCmd);
switch (m_eFormat)
{
case gpe4Bpp:
{
PUMP_PACKED_SRCFIFO_LOOKUP4_8BPP(pSrcBits, ulDWords, ulExtras,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
}
break;
#ifdef CM2SLK_EXCLUDED_CASE
case gpe2Bpp:
{
PUMP_PACKED_SRCFIFO_LOOKUP2_8BPP(pSrcBits, ulDWords, ulExtras,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
}
break;
case gpe16Bpp:
{
PUMP_PACKED_SRCFIFO_LOOKUP16_8BPP(pSrcBits, ulDWords, ulExtras,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
}
break;
case gpe24Bpp:
{
PUMP_PACKED_SRCFIFO_LOOKUP24_8BPP(pSrcBits, ulDWords, ulExtras,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
}
break;
case gpe32Bpp:
{
PUMP_PACKED_SRCFIFO_LOOKUP32_8BPP(pSrcBits, ulDWords, ulExtras,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
}
break;
#endif //CM2SLK_EXCLUDED_CASE
}
geTERMINATE();
ROTATE_PARAMS_BACK(pBltParms);
RETURN_CM2SLKBLT;
}
#endif //CHECK_8BPP
#ifdef CHECK_16BPP
#if 1 //HSUTEST Use new algorithm for 8bpp to 16bpp lookup.
SCODE MQGC::CM2SLKBlt16( GPEBltParms *pBltParms )
{
DEBUGMSG(GPE_ZONE_MQEMUL1,(TEXT("CM2SLKBlt16\r\n")));
PBYTE pSrcBits;
PULONG pulData;
ULONG width, height;
ULONG ulCmd, ulOffset, ulDWords;
ULONG ulTail, ulLeadOffset;
ULONG ulTotal;
#ifdef CHECK_SRCFIFO
ULONG ulExtras;
#endif //CHECK_SRCFIFO
long lSrcStride;
long i;
ROTATE_PARAMS(pBltParms);
geINIT( pBltParms->pDst );
ulCmd = m_ulRop3 | DO_BITBLT | SRC_IS_MEMORY | PACKED_MODE;
m_ulDestXY = (pBltParms->prclDst->top << 16) + pBltParms->prclDst->left
+ ((MQGCSurf *)(pBltParms->pDst))->m_ulTopLeft;
width = pBltParms->prclDst->right - pBltParms->prclDst->left;
height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
lSrcStride = pBltParms->pSrc->Stride();
i = (long)(m_pSrc->Buffer()) + (pBltParms->prclSrc->top * lSrcStride);
if ( m_eFormat == gpe8Bpp )
{
i += pBltParms->prclSrc->left;
ulLeadOffset = i & 0x03UL;
pSrcBits = (PBYTE)(i & ~0x01L);
i &= 1L; //see if initial offset for
//starting line is odd
ulTail = width + ulLeadOffset; //tail of a line
ulOffset = (ulTail & 1UL) + i; //calc byte space in a line
ulTotal = (-(long)(((ulOffset + width) * height) >> 1)) & 0x3UL;
//calc remaining bytes after pumping all
ulOffset = (ulOffset << 29) | (i << 4);
//this goes into SRC_STRIDE_OFFSET
ulDWords = (++ulTail) >> 2; //num of dwords per line
ulTail &= 0x02UL; //if 2, has tail (1 src word aligned
//to dword)
lSrcStride -= (long)(ulLeadOffset & 2UL);
//pre-calc bytes to next line
ulLeadOffset = ulLeadOffset >> 1;
ulDWords -= ulLeadOffset;
#ifdef CHECK_SRCFIFO
ulExtras = ulDWords & 0x0FUL;
ulDWords = ulDWords >> 4; //number of 16 src dwords
//(equiv to 32 dst dwords)
#endif //CHECK_SRCFIFO
}
else //if (m_eFormat == gpe4Bpp)
{
#define ulByteShift ulLeadOffset
#define ulByteSpace ulTotal
ulCmd &= ~PACKED_MODE;
// SRC read size = DWORD
pSrcBits = (PBYTE)(i + (pBltParms->prclSrc->left >> 1));
ulByteShift = (ULONG)pSrcBits & 0x03UL;
pSrcBits -= ulByteShift;
ulOffset = (ULONG)(pBltParms->prclSrc->left & 0x01UL);
// Now calculate based on destination byte/dword counts
ulByteSpace = (ulOffset + width) << 1; // width + offset in bytes
ulDWords = (ulByteSpace + 0x3UL) >> 2; // num of DWORDS per line
// Calculate Extra bits to pad data up to 128-bit aligned
ulDWords += (0x04UL - (ulDWords & 0x03UL)) & 0x03UL;
ulOffset <<= 29; // word offset
//ulExtras = 0;
#undef ulByteSSpace
#undef ulByteShift
}
if ( m_pPatternSetup != NullPatternSetup )
{
if ( m_pBrush )
m_lpPattern = (PULONG)m_pBrush->Buffer();
(this->*m_pPatternSetup)( pBltParms, &ulCmd );
}
#ifdef CM2SBLT_TRANSPARENT
if ( pBltParms->bltFlags & BLT_TRANSPARENT )
{
ulCmd |= TRANS_COLOR;
geWAITCMDFIFO( 1 );
geREG(COLOR_COMPARE, (pBltParms->pLookup)[pBltParms->solidColor]);
}
#endif
geWAITCMDFIFO( 4 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
geREG(DEST_XY, m_ulDestXY);
geREG(SRC_STRIDE_OFFSET, ulOffset);
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, ulCmd);
if ( m_eFormat == gpe8Bpp )
{
#define ulData ulCmd
#define ulData2 ulOffset
#ifdef CHECK_SRCFIFO
while( height-- )
{
if ( ulLeadOffset )
{
ulData = pBltParms->pLookup[ *pSrcBits++ ]
| (pBltParms->pLookup[ *pSrcBits++ ] << 16);
geWAITSRCFIFO( 1 );
geSID( ulData );
}
pulData = (PULONG)pSrcBits;
width = (long)ulDWords;
while( width-- )
{
i = 16;
geWAITSRCFIFO( SRC_FIFO_MAX_DWORDS );
while( i-- )
{
ulData2 = *pulData++;
ulData = pBltParms->pLookup[(ulData2 & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >> 8) & 0xFF)] << 16);
geSID( ulData );
ulData =pBltParms->pLookup[((ulData2 >>16) & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >>24) & 0xFF)] << 16);
geSID( ulData );
}
}
if ( ulExtras )
{
i = ulExtras;
geWAITSRCFIFO( (i << 1) );
while( i-- )
{
ulData2 = *pulData++;
ulData = pBltParms->pLookup[(ulData2 & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >> 8) & 0xFF)] << 16);
geSID( ulData );
ulData =pBltParms->pLookup[((ulData2 >>16) & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >>24) & 0xFF)] << 16);
geSID( ulData );
}
}
if ( ulTail )
{
ulData = pBltParms->pLookup[(*pulData &0xFF)]
| (pBltParms->pLookup[ ((*pulData >> 8) &0xFF)] <<16);
geWAITSRCFIFO( 1 );
geSID( ulData );
}
pSrcBits += lSrcStride;
} //height
while( ulTotal-- )
geSID( 0UL );
#else //CHECK_SRCFIFO
while( height-- )
{
if ( ulLeadOffset )
{
ulData = pBltParms->pLookup[ *pSrcBits++ ]
| (pBltParms->pLookup[ *pSrcBits++ ] << 16);
geSID( ulData );
}
pulData = (PULONG)pSrcBits;
width = (long)ulDWords;
while( width-- )
{
ulData2 = *pulData++;
ulData = pBltParms->pLookup[(ulData2 & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >> 8) & 0xFF)] << 16);
geSID( ulData );
ulData =pBltParms->pLookup[((ulData2 >>16) & 0xFF)]
| (pBltParms->pLookup[ ((ulData2 >>24) & 0xFF)] << 16);
geSID( ulData );
}
if ( ulTail )
{
ulData = pBltParms->pLookup[(*pulData &0xFF)]
| (pBltParms->pLookup[ ((*pulData >> 8) &0xFF)] <<16);
geSID( ulData );
}
pSrcBits += lSrcStride;
} //height
while( ulTotal-- )
geSID( 0UL );
#endif //CHECK_SRCFIFO
#undef ulData2
#undef ulData
} //gpe8bpp
else //if ( m_eFormat == gpe4Bpp )
{
//PUMP_PACKED_SRCFIFO_LOOKUP4_16BPP(pSrcBits, ulDWords, ulExtras,
// ulByteShift, lSrcStride, height, (pBltParms->pLookup))
#define ulByteShift ulLeadOffset
#define ulByteSpace ulTotal
PUMP_PACKED_SRCFIFO_LOOKUP4_16BPP(pSrcBits, ulDWords, 0,
ulByteShift, lSrcStride, height, (pBltParms->pLookup))
#undef ulByteSSpace
#undef ulByteShift
}
geTERMINATE();
ROTATE_PARAMS_BACK(pBltParms);
RETURN_CM2SLKBLT16;
}
#else //HSUTEST
SCODE MQGC::CM2SLKBlt16( GPEBltParms *pBltParms )
{
DEBUGMSG(GPE_ZONE_MQEMUL1,(TEXT("CM2SLKBlt16\r\n")));
PBYTE pSrcBits;
ULONG width, height;
ULONG ulCmd, ulOffset, ulDWords, ulByteSpace, ulByteShift,
ulExtras;
long lSrcStride;
ROTATE_PARAMS(pBltParms);
geINIT( pBltParms->pDst );
width = pBltParms->prclDst->right - pBltParms->prclDst->left;
height = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
// Calculate the PROGRAMMABLE FIFO Data for 16 BPP Destination
// 16BPP Source should be handled by CM2SBlt() which source and
// destination color depth are the same (w or w/o lookup table).
lSrcStride = m_pSrc->Stride();
pSrcBits = (PBYTE)(m_pSrc->Buffer()) +
(pBltParms->prclSrc->top * lSrcStride);
#ifdef CM2SLK_EXCLUDED_CASE
if (m_eFormat == gpe2Bpp)
{
ulOffset = (((ULONG)pSrcBits & 0x03UL) << 3) +
(pBltParms->prclSrc->left << 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -