📄 dispdrvr.c
字号:
EnableLCDController();
}
}
void CopyFrameBuffer(BOOL gDirection)
{
DWORD i;
unsigned *cfbp;
unsigned *fbp;
cfbp=(unsigned *)gBlankFrameBuffer;
fbp=(unsigned *)gFrameBuffer+(activeFrameBuffer*frameBufferSize);
for (i=0;i<(DispDrvr_cxScreen*DispDrvr_cyScreen*(bpp/8)/4);i++)
{
if (gDirection)
*cfbp++ = *fbp++;
else
*fbp++ = *cfbp++;
}
}
void ClearFrameBuffer(BOOL color)
{
DWORD i;
unsigned *fbp;
fbp=(unsigned *)gFrameBuffer+(activeFrameBuffer*frameBufferSize);
for (i=0;i<(DispDrvr_cxScreen*DispDrvr_cyScreen*(bpp/8)/4);i++)
{
if (color)
*fbp++ = 0xFFFFFFFF; // Ones turn it white
else
*fbp++ = 0x000000000; // Zeros turn it black
}
}
//**********************************************************************
//
//DispDrvrContrastControl:
//
// Modify the contrast according to the Cmd parameter.
// Not supported
//
BOOL DispDrvrContrastControl(int Cmd,DWORD *pValue)
{
// currently does not support changing contrast in software.
return (TRUE);
}
void DirtyRectDumpPortraitLoop_C(BYTE *pDstBuf, BYTE *pSrcBuf, DWORD yTop, DWORD yBottom,
DWORD srcWidthB, DWORD bytesPerRow, DWORD bytesPerPixel,
DWORD srcMarginWidth, DWORD dstMarginWidth)
{
DWORD row,i,j;
if ( bytesPerPixel != 2 )
{
//not 16-bit
for (i=0;i<srcWidthB/bytesPerPixel;i++)
{
for (row=yTop;row < yBottom;row++)
{
for (j=0;j<bytesPerPixel;j++)
{
*pDstBuf++=*(pSrcBuf+j);
}
pSrcBuf-=bytesPerRow;
}
pDstBuf+=dstMarginWidth;
pSrcBuf+=srcMarginWidth+2;
}
}
else
{
WORD *pwDst, *pwSrc;
int rowLen;
//16-bit
srcWidthB >>= 1;
pwDst = (WORD *)pDstBuf;
pwSrc = (WORD *)pSrcBuf;
//first row for pwSrc, then column for pwDst
rowLen = yBottom - yTop;
#ifndef _OPT_ASM
bytesPerRow >>=1;
dstMarginWidth >>=1;
srcMarginWidth >>=1;
for (i=0;i<srcWidthB;i++)
{
for (row=0;row < (rowLen >>2);row++)
{
*pwDst ++ = *pwSrc;
pwSrc-=bytesPerRow;
*pwDst ++ = *pwSrc;
pwSrc-=bytesPerRow;
*pwDst ++ = *pwSrc;
pwSrc-=bytesPerRow;
*pwDst ++ = *pwSrc;
pwSrc-=bytesPerRow;
}
for (row=0;row < (rowLen & 0x3);row++)
{
*pwDst ++ = *pwSrc;
pwSrc-=bytesPerRow;
}
pwDst +=dstMarginWidth;
pwSrc +=srcMarginWidth+1;
}
#else
dirtyRectDump_core_ASM(pwSrc, pwDst, rowLen, srcWidthB, bytesPerRow, srcMarginWidth, dstMarginWidth);
#endif
}
}
void DispDrvrDirtyRectDump(LPCRECT prc)
{
BYTE *pDstBuf,*pSrcBuf,*pSrcMask;
DWORD xLeft,yTop,xRight,yBottom;
DWORD bytesPerRow,bytesPerPixel,srcBytesPerRow;
DWORD row,i,j;
DWORD srcWidthB,srcMarginWidth,clipWidthB,dstMarginWidth,cursorWidthB;
DWORD srcStartRow,dstStartRow;
if (bAllowOSFrameBufferUpdates)
{
bytesPerPixel=bpp/8;
xLeft = prc->left < 0 ? 0 : prc->left;
yTop = prc->top < 0 ? 0 : prc->top;
xRight = prc->right > gDibBufferWidth ? gDibBufferWidth : prc->right;
yBottom = prc->bottom > gDibBufferHeight ? gDibBufferHeight : prc->bottom;
if ((LONG)xLeft >= (LONG)xRight || (LONG)yTop >= (LONG)yBottom) return;
xLeft*=bytesPerPixel;
xRight*=bytesPerPixel;
bytesPerRow=DispDrvr_cxScreen*bytesPerPixel;
srcBytesPerRow=gDibBufferWidth*bytesPerPixel;
srcWidthB = xRight -xLeft;
if (bDoRotation)
{
srcStartRow = yTop * srcBytesPerRow;
srcMarginWidth = srcBytesPerRow-srcWidthB;
dstStartRow = yTop * bytesPerRow;
dstMarginWidth = bytesPerRow-srcWidthB;
pDstBuf = gFrameBuffer + dstStartRow + xLeft;
}
else
{
srcStartRow = (yBottom-1) * srcBytesPerRow;
srcMarginWidth = (yBottom-yTop) * srcBytesPerRow;
dstStartRow = xLeft * DispDrvr_cyScreen;
dstMarginWidth = (DispDrvr_cyScreen-(yBottom-yTop))*bytesPerPixel;
pDstBuf = gFrameBuffer + dstStartRow + (DispDrvr_cyScreen -yBottom)*bytesPerPixel;
}
pSrcBuf = gDibBuffer +srcStartRow +xLeft;
EnterCriticalSection(&displayMutex);
if (bDoRotation)
{
for (row = yTop;row < yBottom;row++)
{
i=srcWidthB;
memcpy(pDstBuf, pSrcBuf, i);
pDstBuf += i + dstMarginWidth;
pSrcBuf += i + srcMarginWidth;
}
}
else
{
DirtyRectDumpPortraitLoop_C(pDstBuf, pSrcBuf, yTop, yBottom, srcWidthB, bytesPerRow,
bytesPerPixel, srcMarginWidth, dstMarginWidth);
}
// Cursor update request?.
if (gDrawCursorFlag &&
gCursorRect.left*bytesPerPixel < (int)xRight && gCursorRect.right*bytesPerPixel > (int)xLeft &&
gCursorRect.top < (int)yBottom && gCursorRect.bottom > (int)yTop)
{
DWORD srcRowMarginB;
DWORD cursorSizeXB;
yTop = gCursorRect.top < 0 ? 0 : gCursorRect.top;
xLeft = gCursorRect.left < 0 ? 0 : gCursorRect.left*bytesPerPixel;
yBottom = gCursorRect.bottom > gDibBufferHeight ? gDibBufferHeight : gCursorRect.bottom;
clipWidthB = gCursorRect.right > gDibBufferWidth ? gCursorRect.right -gDibBufferWidth: 0;
clipWidthB *= bytesPerPixel;
cursorWidthB = CURSOR_XSIZE*bytesPerPixel;
cursorSizeXB = (gCursorRect.right - gCursorRect.left)*bytesPerPixel;
srcWidthB = cursorSizeXB - clipWidthB;
srcRowMarginB = cursorWidthB - cursorSizeXB;
if (bDoRotation)
{
srcStartRow = ((int)yTop - gCursorRect.top)*srcWidthB;
srcMarginWidth = 0;
dstStartRow = yTop * bytesPerRow;
dstMarginWidth = bytesPerRow-srcWidthB;
pDstBuf = gFrameBuffer + dstStartRow + xLeft;
}
else
{
srcStartRow = (yBottom-yTop-1) * cursorWidthB;
srcMarginWidth = (yBottom-yTop) * cursorWidthB;
dstStartRow = xLeft * DispDrvr_cyScreen;
dstMarginWidth = (DispDrvr_cyScreen-(yBottom-yTop))*bytesPerPixel;
pDstBuf = gFrameBuffer + dstStartRow + (DispDrvr_cyScreen -yBottom)*bytesPerPixel;
}
pSrcBuf = (BYTE *)gCursorData + srcStartRow;
pSrcMask = (BYTE *)gCursorMask + srcStartRow;
if (bDoRotation)
{
for (row = yTop; row < yBottom; row++)
{
i=srcWidthB;
pSrcBuf += srcRowMarginB;
pSrcMask += srcRowMarginB;
while (i > 0)
{
if (i<4 || ((unsigned)pDstBuf & 0x3) || ((unsigned)pSrcBuf & 0x3))
{
*pDstBuf &= *pSrcMask;
*pDstBuf++ ^= *pSrcBuf;
pSrcMask++;
pSrcBuf++;
i-=1;
}
else
{
*(unsigned *)pDstBuf &= *(unsigned *)pSrcMask;
*(unsigned *)pDstBuf ^= *(unsigned *)pSrcBuf;
pDstBuf+=4;
pSrcMask+=4;
pSrcBuf+=4;
i-=4;
}
}
pSrcMask += clipWidthB;
pSrcBuf += clipWidthB;
pDstBuf += dstMarginWidth;
}
}
else
{
pSrcBuf += srcRowMarginB;
pSrcMask += srcRowMarginB;
for (i=0;i<srcWidthB/bytesPerPixel;i++)
{
for (row=yTop;row<yBottom;row++)
{
for (j=0;j<bytesPerPixel;j++)
{
*pDstBuf &= *(pSrcMask+j);
*pDstBuf++ ^= *(pSrcBuf+j);
}
pSrcBuf-=cursorWidthB;
pSrcMask-=cursorWidthB;
}
pSrcBuf +=srcMarginWidth+2;
pSrcMask +=srcMarginWidth+2;
pDstBuf +=dstMarginWidth;
}
}
}
LeaveCriticalSection(&displayMutex);
}
}
void DirtyRectDumpPortraitLoop_C_rectfill(BYTE *pDstBuf, WORD srcColor,DWORD yTop,DWORD yBottom,
DWORD srcWidthB, DWORD bytesPerRow, DWORD bytesPerPixel, DWORD srcMarginWidth, DWORD dstMarginWidth)
{
DWORD row,i;
WORD *pwDst;
WORD rowLen;
//16-bit
srcWidthB >>= 1;
pwDst = (WORD *)pDstBuf;
//first row for pwSrc, then column for pwDst
rowLen = (WORD)(yBottom - yTop);
bytesPerRow >>=1;
dstMarginWidth >>=1;
srcMarginWidth >>=1;
for (i=0;i<srcWidthB;i++)
{
for (row=0;row < (DWORD)(rowLen >>2);row++)
{
*pwDst ++ = srcColor;
*pwDst ++ = srcColor;
*pwDst ++ = srcColor;
*pwDst ++ = srcColor;
}
for (row=0;row < (DWORD)(rowLen & 0x3);row++)
{
*pwDst ++ = srcColor;
}
pwDst +=dstMarginWidth;
}
}
void DispDrvrDirtyRectDump_rectfill(LPCRECT prc, DWORD color)
{
BYTE *pDstBuf,*pSrcBuf,*pSrcMask;
WORD srcColor = (WORD)color;
DWORD xLeft,yTop,xRight,yBottom;
DWORD bytesPerRow,bytesPerPixel,srcBytesPerRow;
DWORD row,i,j;
DWORD srcWidthB,srcMarginWidth,clipWidthB,dstMarginWidth,cursorWidthB;
DWORD srcStartRow,dstStartRow;
DWORD srcMarginWidth2;
DWORD dstMarginWidth2;
DWORD dstStep;
if (bAllowOSFrameBufferUpdates)
{
bytesPerPixel=bpp/8;
xLeft = prc->left < 0 ? 0 : prc->left;
yTop = prc->top < 0 ? 0 : prc->top;
xRight = prc->right > gDibBufferWidth ? gDibBufferWidth : prc->right;
yBottom = prc->bottom > gDibBufferHeight ? gDibBufferHeight : prc->bottom;
if ((LONG)xLeft >= (LONG)xRight || (LONG)yTop >= (LONG)yBottom) return;
xLeft*=bytesPerPixel;
xRight*=bytesPerPixel;
bytesPerRow=DispDrvr_cxScreen*bytesPerPixel;
srcBytesPerRow=gDibBufferWidth*bytesPerPixel;
srcWidthB = xRight -xLeft;
if (bDoRotation)
{
srcStartRow = yTop * srcBytesPerRow;
srcMarginWidth = srcBytesPerRow-srcWidthB;
dstStartRow = yTop * bytesPerRow;
dstMarginWidth = bytesPerRow-srcWidthB;
pDstBuf = gFrameBuffer + dstStartRow + xLeft;
}
else
{
srcStartRow = (yBottom-1) * srcBytesPerRow;
srcMarginWidth = (yBottom-yTop) * srcBytesPerRow;
dstStartRow = xLeft * DispDrvr_cyScreen;
dstMarginWidth = (DispDrvr_cyScreen-(yBottom-yTop))*bytesPerPixel;
pDstBuf = gFrameBuffer + dstStartRow + (DispDrvr_cyScreen -yBottom)*bytesPerPixel;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -