⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dispdrvr.c

📁 针对Intel Xscale PXA255的WinCE boot loader源代码包!极具参考价值!
💻 C
📖 第 1 页 / 共 3 页
字号:
		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 (bLandscapeDisplay) {
			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 (bLandscapeDisplay) {
			for (row = yTop;row < yBottom;row++) {
				i=srcWidthB;
#if 0
				while(i > 0) 
				{
					if (i<4 || ((unsigned)pDstBuf & 0x3) || ((unsigned)pSrcBuf & 0x3)) 
					{
					  *pDstBuf++ = *pSrcBuf;
					  pSrcBuf++;
					  i-=1;
					} else 
					{
						*(unsigned *)pDstBuf = *(unsigned *)pSrcBuf;
						pDstBuf+=4;
					  
						pSrcBuf+=4;
						i-=4;
					}
				}
				pSrcBuf	+= srcMarginWidth;
				pDstBuf	+= dstMarginWidth;
#else // !0
				memcpy(pDstBuf, pSrcBuf, i);
				pDstBuf += i + dstMarginWidth;
				pSrcBuf += i + srcMarginWidth;
#endif // 0
			}
		} else {
			
			DirtyRectDumpPortraitLoop_C(pDstBuf, pSrcBuf, yTop, yBottom, srcWidthB, bytesPerRow, 
										bytesPerPixel, srcMarginWidth, dstMarginWidth);
		}
			// Cursor update request?.
		if (gDrawCursorFlag &&
			gCursorRect.left*bytesPerPixel < xRight && gCursorRect.right*bytesPerPixel > xLeft &&
			(DWORD)gCursorRect.top < yBottom && (DWORD)gCursorRect.bottom > yTop) {

			DWORD srcRowMarginB;
			DWORD cursorSizeXB;

			yTop=gCursorRect.top;
				// Clip off cursor if past bottom of screen
			yBottom = gCursorRect.bottom > gDibBufferHeight ? gDibBufferHeight : gCursorRect.bottom;
				// Now clip off cursor if past right side of screen
			clipWidthB=gCursorRect.right > gDibBufferWidth ? gCursorRect.right -gDibBufferWidth: 0;
			clipWidthB*=bytesPerPixel;
			xLeft=gCursorRect.left*bytesPerPixel;
			cursorWidthB=CURSOR_XSIZE*bytesPerPixel;
			cursorSizeXB=(gCursorRect.right - gCursorRect.left)*bytesPerPixel;
			srcWidthB=cursorSizeXB - clipWidthB;
			srcRowMarginB = cursorWidthB - cursorSizeXB;
			if (bLandscapeDisplay) {
				srcStartRow			= 0;
				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 (bLandscapeDisplay) {
				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 (bLandscapeDisplay) {
			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;
			dstStep = DispDrvr_cyScreen*bytesPerPixel; //portrait frame buffer step
			srcMarginWidth2		= DispDrvr_cxScreen* bytesPerPixel + ((xRight-xLeft)) ;
			dstMarginWidth2		= (xRight-xLeft)*dstStep/bytesPerPixel;

		}
		pSrcBuf = gDibBuffer +srcStartRow +xLeft;
		EnterCriticalSection(&displayMutex);
		if (bLandscapeDisplay) {
			for (row = yTop;row < yBottom;row++) {
				i=srcWidthB;
				while(i > 0) 
				{
					if (i<4 || ((unsigned)pDstBuf & 0x3) || ((unsigned)pSrcBuf & 0x3)) 
					{
					  *pDstBuf++ = *pSrcBuf;
					  pSrcBuf++;
					  i-=1;
					} else 
					{
						*(unsigned *)pDstBuf = *(unsigned *)pSrcBuf;
						pDstBuf+=4;
					  
						pSrcBuf+=4;
						i-=4;
					}
				}
				pSrcBuf	+= srcMarginWidth;
				pDstBuf	+= dstMarginWidth;
			}
		} else {
		
			DirtyRectDumpPortraitLoop_C_rectfill(pDstBuf,
									   srcColor,
										  yTop,
										  yBottom,
										  srcWidthB,
										  bytesPerRow, 
										  bytesPerPixel,
										  srcMarginWidth, 
										  dstMarginWidth);
		}
			// Cursor update request?.
		if (gDrawCursorFlag &&
			gCursorRect.left*bytesPerPixel < xRight && gCursorRect.right*bytesPerPixel > xLeft &&
			(DWORD)gCursorRect.top < yBottom && (DWORD)gCursorRect.bottom > yTop) {

			DWORD srcRowMarginB;
			DWORD cursorSizeXB;

			yTop=gCursorRect.top;
				// Clip off cursor if past bottom of screen
			yBottom = gCursorRect.bottom > gDibBufferHeight ? gDibBufferHeight : gCursorRect.bottom;
				// Now clip off cursor if past right side of screen
			clipWidthB=gCursorRect.right > gDibBufferWidth ? gCursorRect.right -gDibBufferWidth : 0;
			clipWidthB*=bytesPerPixel;
			xLeft=gCursorRect.left*bytesPerPixel;
			cursorWidthB=CURSOR_XSIZE*bytesPerPixel;
			cursorSizeXB=(gCursorRect.right - gCursorRect.left)*bytesPerPixel;
			srcWidthB=cursorSizeXB - clipWidthB;
			srcRowMarginB = cursorWidthB - cursorSizeXB;
			if (bLandscapeDisplay) {
				srcStartRow			= 0;
				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 (bLandscapeDisplay) {
				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 DispDrvrDirtyRectDump2(LPCRECT prc,DWORD color)
{
	WORD	*pDstBuf;
	WORD    srcColor = (WORD)color;
    
	DWORD	xLeft,yTop,xRight,yBottom;
	
	DWORD	srcWidthB,dstMarginWidth;
	DWORD	dstStartRow;
	
	if (bAllowOSFrameBufferUpdates)
	{
		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;
	
		srcWidthB = xRight -xLeft;
		dstStartRow			= xLeft * DispDrvr_cyScreen;
		dstMarginWidth		= (DispDrvr_cyScreen-(yBottom-yTop));
		pDstBuf				= (WORD*)gFrameBuffer + dstStartRow + (DispDrvr_cyScreen -yBottom);
		
		EnterCriticalSection(&displayMutex);

		ellipse_core_ASM(srcColor, (dstMarginWidth+1)*2,srcWidthB,pDstBuf);
		
		LeaveCriticalSection(&displayMutex);
	}
}

void DispDrvrMoveCursor(INT32 xLocation,INT32 yLocation)
{

    // First clear the cursor's old location
    gDrawCursorFlag = FALSE;
    DispDrvrDirtyRectDump(&gCursorRect);
    // Now set the new location of the cursor and redraw
    gCursorRect.left = xLocation - gxHot;
    if (gCursorRect.left < 0) {
		gCursorRect.left = 0;
    }
    gCursorRect.top = yLocation - gyHot;
    if (gCursorRect.top < 0) {
		gCursorRect.top = 0;
    }
    gCursorRect.right = xLocation - gxHot + CURSOR_XSIZE;
    gCursorRect.bottom = yLocation - gyHot + CURSOR_YSIZE;
    gDrawCursorFlag = TRUE;
    DispDrvrDirtyRectDump(&gCursorRect);
}

#define VIDEO_REG_PATH	TEXT("Drivers\\Display\\Intel")
#define VIDEO_ROW_RES	TEXT("CxScreen")
#define VIDEO_COL_RES	TEXT("CyScreen")
#define PIXEL_DEPTH		TEXT("Bpp")
#define VIDEO_DISPLAY_TYPE TEXT("DisplayType")
#define VIDEO_BUFFER	TEXT("UseFrameBuffer")

BOOL ReadRegistryData()
{
    LONG    regError;
    HKEY	hKey;
    DWORD   dwDataSize;
	DWORD   dwUsePhysicalFrameBuffer;
    TCHAR   DisplayType[64];

	bpp=0;
	DispDrvr_cyScreen = 0;
	DispDrvr_cxScreen = 0;
    dwUsePhysicalFrameBuffer = 0;

	// Open the registry key
    regError = RegOpenKeyEx(HKEY_LOCAL_MACHINE,VIDEO_REG_PATH,0,KEY_ALL_ACCESS,&hKey);
    if (regError != ERROR_SUCCESS) {
        DEBUGMSG(DEBUGZONE(0),(VIDEO_REG_PATH));
   		DEBUGMSG(DEBUGZONE(0),(TEXT("Failed opening \\Drivers\\Display\\Intel\r\n")));
        return (FALSE);        
    }

	// Display width
	dwDataSize = sizeof(DispDrvr_cxScreen);
    regError = RegQueryValueEx(hKey,VIDEO_ROW_RES, NULL, NULL,(LPBYTE)&DispDrvr_cxScreen,&dwDataSize);
    if (regError != ERROR_SUCCESS) {
        DEBUGMSG(DEBUGZONE(0),(TEXT("Failed to get display x value, Error 0x%X\r\n"),regError));
        return (FALSE);
    }

	// Display height
	dwDataSize = sizeof(DispDrvr_cyScreen);
    regError = RegQueryValueEx(hKey,VIDEO_COL_RES,NULL,NULL,(LPBYTE)&DispDrvr_cyScreen,&dwDataSize);
    if (regError != ERROR_SUCCESS) {
        DEBUGMSG(DEBUGZONE(0),(TEXT("Failed to get display y value, Error 0x%X\r\n"),regError));
        return (FALSE);
    }

	// Color depth
	dwDataSize = sizeof(bpp);
	regError=RegQueryValueEx(hKey,PIXEL_DEPTH,NULL,NULL,(LPBYTE)&bpp,&dwDataSize);
    if (regError != ERROR_SUCCESS) {
        bpp=0;
    }

	// Display Type
	dwDataSize = sizeof(DisplayType);
    regError = RegQueryValueEx(hKey,VIDEO_DISPLAY_TYPE,NULL,NULL,(LPBYTE)DisplayType,&dwDataSize);
    if (regError != ERROR_SUCCESS) {
        DEBUGMSG(DEBUGZONE(0),(TEXT("Failed to get display type, Error 0x%X\r\n"),regError));
        return (FALSE);
    }

    // Decide whether to use expose the physical frame buffer to GDI, or an off
    // screen buffer.
    dwDataSize = sizeof(dwUsePhysicalFrameBuffer);
    regError = RegQueryValueEx(hKey,VIDEO_BUFFER,NULL,NULL,(LPBYTE)&dwUsePhysicalFrameBuffer,&dwDataSize);
    if (regError != ERROR_SUCCESS) {
        DEBUGMSG(DEBUGZONE(0),(TEXT("Failed to get display frame buffer value, Error 0x%X\r\n"),regError));
    }

	RegCloseKey (hKey);
    RETAILMSG(0, (TEXT("Done getting Registry values:\r\nbpp: 0x%x\r\n CxScreen: 0x%x\r\n CyScreen: 0x%x\r\nDisplay Type: %s\r\n"), bpp, DispDrvr_cxScreen, DispDrvr_cyScreen,DisplayType));
		
	if (_wcsicmp(DisplayType, TEXT("LTM04C380K")) == 0)
		nDisplayType = LTM04C380K;
	else if (_wcsicmp(DisplayType, TEXT("LTM04C387S")) == 0)
		nDisplayType = LTM04C387S;
	else if (_wcsicmp(DisplayType, TEXT("LQ039Q2DS54")) == 0)
		nDisplayType = LQ039Q2DS54;
	else if (_wcsicmp(DisplayType, TEXT("LM8V31")) == 0)
		nDisplayType = LM8V31;
	else if (_wcsicmp(DisplayType, TEXT("LM057QCTT03")) == 0)
		nDisplayType = LM057QCTT03;
	else if (_wcsicmp(DisplayType, TEXT("TFTQVGA")) == 0)
		nDisplayType = TFTQVGA;
	else if (_wcsicmp(DisplayType, TEXT("LQ64D341")) == 0)
		nDisplayType = LQ64D341;
	//JiangFQ add 2004/5/21 01:07

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -