📄 mqxptext.blt
字号:
#if defined( CHECK_8BPP ) || defined( CHECK_16BPP ) || defined( CHECK_32BPP )
SCODE MQGC::XPTextBlt( GPEBltParms *pBltParms )
{
PULONG pulSrc;
long srcX, srcY, width, height, lDestXY;
long lDWords, lBitSpace, lSpace, i;
long lSrcStride, lOffset, lExtras;
#ifdef CHECK_SRCFIFO
long lExtras2;
#endif //CHECK_SRCFIFO
long srcRight;
DEBUGMSG(GPE_ZONE_MQEMUL1,(TEXT("XPTextBlt\r\n")));
ROTATE_PARAMS(pBltParms);
geINIT( pBltParms->pDst );
#if 0
lDestXY = (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->pMask->Stride(); //AAF0 Rop4 always gives
//positive strides
srcX = pBltParms->prclMask->left;
srcY = pBltParms->prclMask->top;
#else
lSrcStride = pBltParms->pMask->Stride(); //AAF0 Rop4 always gives
lDestXY = (pBltParms->prclDst->top << 16) + pBltParms->prclDst->left
+((MQGCSurf *)(pBltParms->pDst))->m_ulTopLeft;
//positive strides
srcX = pBltParms->prclMask->left;
srcY = pBltParms->prclMask->top;
srcRight = pBltParms->prclMask->right;
width = srcRight - srcX;
height = pBltParms->prclMask->bottom - srcY;
#endif
i = (long)(pBltParms->pMask->Buffer()) + (srcY * lSrcStride);
lOffset = ((i & 0x03L) << 3) + srcX;
pulSrc = (PULONG)(((i & ~0x03L) + (lOffset >> 3)) & ~0x03UL);
//aligned to dword
lOffset &= 0x01FUL;
//Compute bit space.
lSrcStride = lSrcStride << 3; //Get Src Stride bits
lSpace = lSrcStride - width;
if ( lSrcStride > 0 && lSpace < 64 )
{
lBitSpace = lSpace;
#if defined(BUG_MONO_READ_MISS) && !defined(_USE_MQEMUL)
//The fix for this bug is to extend the width to include bitspace
//and use clipping to clip out additional width.
i = (width + lBitSpace) << m_ulBPPShift;
if ( i < 16 || i > 32 )
#endif //BUG_MONO_READ_MISS
{
lDWords = (((width + lBitSpace) * (height - 1)) + width
+ lOffset + 31L) >> 5;
#ifdef _USE_MQEMUL //emulation is not doing a good job on
//trans_mono, bg_color is required
geWAITCMDFIFO( 6 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
geREG(DEST_XY, ((pBltParms->prclDst->top << 16)
+ pBltParms->prclDst->left
+((MQGCSurf *)(pBltParms->pDst))
->m_ulTopLeft));
geREG(FG_COLOR, pBltParms->solidColor);
geREG(BG_COLOR, ~(pBltParms->solidColor));
geREG(SRC_STRIDE_OFFSET, (lOffset | (lBitSpace << 25)));
#else //_USE_MQEMUL
geWAITCMDFIFO( 5 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
//geREG(DEST_XY, ((pBltParms->prclDst->top << 16)
// + pBltParms->prclDst->left
// +((MQGCSurf *)(pBltParms->pDst))
// ->m_ulTopLeft));
geREG(DEST_XY, lDestXY);
geREG(FG_COLOR, pBltParms->solidColor);
geREG(SRC_STRIDE_OFFSET, (lOffset | (lBitSpace << 25)));
#endif //_USE_MQEMUL
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, (DO_BITBLT | MONO_SRC | SRC_IS_MEMORY
| PACKED_MODE | TRANS_MONO | 0xCCUL));
}
#if defined(BUG_MONO_READ_MISS) && !defined(_USE_MQEMUL)
else
{
i = (height << 16) | width;
width += lBitSpace;
lDWords = ((width * height) + lOffset + 31L) >> 5;
geWAITCMDFIFO( 7 );
geREG(WIDTH_HEIGHT, (i + lBitSpace)); //extend width
geREG(DEST_XY, lDestXY);
geREG(CLIP_LeftT, lDestXY);
geREG(CLIP_RightB, (lDestXY + i - 0x00010001));//inclusive
geREG(FG_COLOR, pBltParms->solidColor);
geREG(SRC_STRIDE_OFFSET, lOffset);
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, (DO_BITBLT | MONO_SRC | SRC_IS_MEMORY
| CLIP_ENABLE | PACKED_MODE | TRANS_MONO
| 0xCCUL));
}
#endif //BUG_MONO_READ_MISS
//Really Packed
//Src data packed. Calculate total and extra dwords first.
#if 0 //Don't use multiply operator
lBitSpace += width;
lDWords = width + lOffset;
while( --height )
lDWords += lBitSpace;
lDWords = (lDWords + 31L) >> 5;
#else
// lDWords = (((width + lBitSpace) * (height - 1)) + width
// + lOffset + 31L) >> 5;
#endif
#ifdef CHECK_SRCFIFO
lExtras = lDWords & 0x1FUL;
lExtras2 = -lExtras & 0x03;
lDWords = lDWords >> 5; //number of 32 dwords;
while( lDWords-- )
{
i = 32;
geWAITSRCFIFO( 32 );
while( i-- )
geSID( (*pulSrc++) );
}
if ( lExtras )
{
geWAITSRCFIFO( lExtras );
while ( lExtras-- )
geSID( (*pulSrc++) );
while ( lExtras2-- )
geSID( 0UL );
}
#else //CHECK_SRCFIFO
lExtras = -lDWords & 0x3UL;
while( lDWords-- )
geSID( (*pulSrc++) );
while( lExtras-- )
geSID( 0UL );
#endif //CHECK_SRCFIFO
//PUMP_REALLY_PACKED_SRCFIFO(pulSrc, ulDWords, lExtras)
}
else
{
if ( lSrcStride > 0 )
{
lBitSpace = (-srcRight & 0x1F) + ((lSrcStride + srcX) & 0x1FUL);
if ( lBitSpace < 32 )
lBitSpace += 32;
}
else
{
lSpace = -lSrcStride - width;
if ( lSpace < 64 )
lBitSpace = lSpace;
else
{
lBitSpace = (-(srcX+width) & 0x1F)
+ ((-lSrcStride + srcX) & 0x1FUL);
if ( lBitSpace < 32 )
lBitSpace += 32;
}
}
#if defined(BUG_MONO_READ_MISS) && !defined(_USE_MQEMUL)
//The fix for this bug is to extend the width to include bitspace
//and use clipping to clip out additional width.
i = (width + lBitSpace) << m_ulBPPShift;
if ( i < 16 || i > 32 )
#endif //BUG_MONO_READ_MISS
{
#ifdef _USE_MQEMUL //emulation is not doing a good job on
//trans_mono, bg_color is required
geWAITCMDFIFO( 6 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
geREG(DEST_XY, ((pBltParms->prclDst->top << 16)
+ pBltParms->prclDst->left
+((MQGCSurf *)(pBltParms->pDst))
->m_ulTopLeft));
geREG(FG_COLOR, pBltParms->solidColor);
geREG(BG_COLOR, ~(pBltParms->solidColor));
geREG(SRC_STRIDE_OFFSET, (lOffset | (lBitSpace << 25)));
#else //_USE_MQEMUL
geWAITCMDFIFO( 5 );
geREG(WIDTH_HEIGHT, ((height << 16) | width));
//geREG(DEST_XY, ((pBltParms->prclDst->top << 16)
// + pBltParms->prclDst->left
// +((MQGCSurf *)(pBltParms->pDst))
// ->m_ulTopLeft));
geREG(DEST_XY, lDestXY);
geREG(FG_COLOR, pBltParms->solidColor);
geREG(SRC_STRIDE_OFFSET, (lOffset | (lBitSpace << 25)));
#endif //_USE_MQEMUL
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, (DO_BITBLT | MONO_SRC | SRC_IS_MEMORY
| PACKED_MODE | TRANS_MONO | 0xCCUL));
lBitSpace += width; //Added width
}
#if defined(BUG_MONO_READ_MISS) && !defined(_USE_MQEMUL)
else
{
i = (height << 16) | width;
width += lBitSpace;
geWAITCMDFIFO( 7 );
geREG(WIDTH_HEIGHT, (i + lBitSpace)); //extend width
geREG(DEST_XY, lDestXY);
geREG(CLIP_LeftT, lDestXY);
geREG(CLIP_RightB, (lDestXY + i - 0x00010001));//inclusive
geREG(FG_COLOR, pBltParms->solidColor);
geREG(SRC_STRIDE_OFFSET, lOffset);
SET_GE_DEST_STRIDE(m_ulDestStride);
geREG(DRAW_CMD, (DO_BITBLT | MONO_SRC | SRC_IS_MEMORY
| CLIP_ENABLE | PACKED_MODE | TRANS_MONO
| 0xCCUL));
lBitSpace = width; //Added width
}
#endif //BUG_MONO_READ_MISS
lExtras = 0;
while( height-- )
{
lSpace = (long)pulSrc; //Use lSpace as temp var
if ( height > 0 )
lDWords = (lOffset + lBitSpace) >> 5;
else
lDWords = (lOffset + width + 31) >> 5;
lExtras += lDWords;
#ifdef CHECK_SRCFIFO
lExtras2 = lDWords & 0x1fL;
lDWords = lDWords >> 5; //number of 32 dwords
while( lDWords-- )
{
i = 32;
geWAITSRCFIFO( 32 );
while( i-- )
geSID( (*pulSrc++) );
}
if ( lExtras2 )
{
geWAITSRCFIFO( lExtras2 );
while( lExtras2-- )
geSID( (*pulSrc++) );
}
#else //CHECK_SRCFIFO
while( lDWords-- )
geSID( (*pulSrc++) );
#endif //CHECK_SRCFIFO
lOffset += lSrcStride; //Advance bit offset
pulSrc = (PULONG)(lSpace + ((lOffset & ~0x1F) >> 3));
//lSpace has prev pulSrc
lOffset &= 0x1FL; //only keep 32bit offset
}
//No need to wait for srcfifo here since any previous call to
//wait-for-srcfifo actually waits for 128bit aligned number of slots
lExtras = -lExtras & 0x03L;
while( lExtras-- )
geSID( 0UL ); //Padded to total of 128bit
//aligned
//PUMP_PACKED_SRCFIFO(pulSrc, ulDWords, lExtras, ulDWordsTotal,
// lSrcStride, height)
}
#if 0
if ( lSpace < 64 )
{
//Really Packed
//Src data packed. Calculate total and extra dwords first.
#if 0 //Don't use multiply operator
lBitSpace += width;
lDWords = width + lOffset;
while( --height )
lDWords += lBitSpace;
lDWords = (lDWords + 31L) >> 5;
#else
lDWords = (((width + lBitSpace) * (height - 1)) + width
+ lOffset + 31L) >> 5;
#endif
#ifdef CHECK_SRCFIFO
lExtras = lDWords & 0x1FUL;
lExtras2 = -lExtras & 0x03;
lDWords = lDWords >> 5; //number of 32 dwords;
while( lDWords-- )
{
i = 32;
geWAITSRCFIFO( 32 );
while( i-- )
geSID( (*pulSrc++) );
}
if ( lExtras )
{
geWAITSRCFIFO( lExtras );
while ( lExtras-- )
geSID( (*pulSrc++) );
while ( lExtras2-- )
geSID( 0UL );
}
#else //CHECK_SRCFIFO
lExtras = -lDWords & 0x3UL;
while( lDWords-- )
geSID( (*pulSrc++) );
while( lExtras-- )
geSID( 0UL );
#endif //CHECK_SRCFIFO
//PUMP_REALLY_PACKED_SRCFIFO(pulSrc, ulDWords, lExtras)
}
else
{
lExtras = 0;
lBitSpace += width; //Added width
while( height-- )
{
lSpace = (long)pulSrc; //Use lSpace as temp var
if ( height > 0 )
lDWords = (lOffset + lBitSpace) >> 5;
else
lDWords = (lOffset + width + 31) >> 5;
lExtras += lDWords;
#ifdef CHECK_SRCFIFO
lExtras2 = lDWords & 0x1fL;
lDWords = lDWords >> 5; //number of 32 dwords
while( lDWords-- )
{
i = 32;
geWAITSRCFIFO( 32 );
while( i-- )
geSID( (*pulSrc++) );
}
if ( lExtras2 )
{
geWAITSRCFIFO( lExtras2 );
while( lExtras2-- )
geSID( (*pulSrc++) );
}
#else //CHECK_SRCFIFO
while( lDWords-- )
geSID( (*pulSrc++) );
#endif //CHECK_SRCFIFO
//For AAF0 Rop4, SrcStride always > 0
lOffset += lSrcStride; //Advance bit offset
pulSrc = (PULONG)(lSpace + ((lOffset & ~0x1F) >> 3));
//lSpace has prev pulSrc
lOffset &= 0x1FL; //only keep 32bit offset
}
//No need to wait for srcfifo here since any previous call to
//wait-for-srcfifo actually waits for 128bit aligned number of slots
lExtras = -lExtras & 0x03L;
while( lExtras-- )
geSID( 0UL ); //Padded to total of 128bit
//aligned
//PUMP_PACKED_SRCFIFO(pulSrc, ulDWords, lExtras, ulDWordsTotal,
// lSrcStride, height)
}
#endif //0
geTERMINATE();
ROTATE_PARAMS_BACK(pBltParms);
#if 0 //def DEBUG //HSUTEST
{
ULONG loop, status;
loop = 2000UL;
while( loop-- )
{
status = cpuREAD( DRAW_STATUS );
status &= GE_BUSY | SRC_FIFO_MASK | CMD_FIFO_MASK;
if ( status == 0x810 )
break;
}
if ( status != 0x810 )
{
//DebugBreak();
TCHAR buf[80];
loop = geRREG( SRC_STRIDE_OFFSET );
wsprintf( buf, TEXT("XP:%x,%x,%d,%d,%d,%d\r\n"),
status,loop,width,ulSpace,lSrcStride,
pBltParms->prclMask->left
);
OutputDebugStringW( buf );
}
}
#endif
RETURN_XPTEXT;
}
#endif //CHECK_s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -