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

📄 cursor.cpp

📁 Sm501 VGA芯片wince下驱动代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    // If panel output is enabled, disable panel HWC

    // Hwc's Enable bit (Bit 31) is tied to Vsync and will only be set/cleared
    // during the next Vsync. Meanwhile, another request to disable/enable
    // Hwc could arrive. Therefore, need to set m_nPanelHwcOnOff to indicate
    // whether Hwc is currently enabled/disabled and write this value to Bit 31
    // whenever there is a write to PANEL_HWC_ADDRESS register outside of
    // DisableCursor()/EnableCursor() functions.
    //
    // This fixes the problem where the cursor appears on
    // both screens simultaneously in Multimon mode when running ddex1.exe
    // (DirectDraw sample application).
    m_nPanelHwcOnOff = 0;

    ULONG dwAdd = PEEK_32(PANEL_HWC_ADDRESS);
    dwAdd = FIELD_SET(dwAdd, PANEL_HWC_ADDRESS, ENABLE, DISABLE);
    POKE_32(PANEL_HWC_ADDRESS, dwAdd);
}

void SMI::EnableCursor(void)
{
    // If panel output is enabled, enable panel HWC

    // Hwc's Enable bit (Bit 31) is tied to Vsync and will only be set/cleared
    // during the next Vsync. Meanwhile, another request to disable/enable
    // Hwc could arrive. Therefore, need to set m_nPanelHwcOnOff to indicate
    // whether Hwc is currently enabled/disabled and write this value to Bit 31
    // whenever there is a write to PANEL_HWC_ADDRESS register outside of
    // DisableCursor()/EnableCursor() functions.
    //
    m_nPanelHwcOnOff = 1;

    ULONG dwAdd = PEEK_32(PANEL_HWC_ADDRESS);
    dwAdd = FIELD_SET(dwAdd, PANEL_HWC_ADDRESS, ENABLE, ENABLE);
    POKE_32(PANEL_HWC_ADDRESS, dwAdd);
}

void SMI::SetupCursor(void)
{
#ifdef CMDLIST
	m_nVideoMemoryAvail = m_nVideoMemoryAvail - CURSUR_IMAGE_SIZE - m_cmdlist_size;
#else // CMDLIST
    m_nVideoMemoryAvail = m_nVideoMemoryAvail - CURSUR_IMAGE_SIZE;
#endif // CMDLIST
    m_nCursorMemory = m_nVideoMemoryAvail;
	DisableCursor();
	
	// Clear Cursor Mem - Cannot at this point, because memory not ready
	//memset((PUCHAR) m_pLAW+m_nCursorMemory, 0, 2048);

	SetCursorAddress(m_nCursorMemory);
}

SCODE SMI::RotateCursorShape(int angle)
{

#ifdef ROTATION_ENABLE
	if (angle == 0)
		return S_OK;

	BYTE *pByte, *pCursor;
	ULONG ulBase, ulIndex;
	BYTE src[256], dst[256]; /* 128 = 8 x 32 */
	BYTE  jMask, j, bitMask;
	int x, y, cx = 32, cy = 32, tx;

	pCursor = pByte = m_pLAW + m_nCursorMemory;

	memset(src, 0x00, sizeof(src));
	memset(dst, 0x00, sizeof(dst));

	//Save the original pointer shape into local memory shapeRow[]
	for (y=0; y<cy; y++)
	{
		for (x=0; x<cx/4; x++)
			src[y*8+x] = pByte[x];
		pByte+=16;
	}

	switch (angle)
	{
	case DMDO_90:
		for (y = 0; y < cy; y++)
		{		
			jMask = 0x02 << ((y&3)*2);
			for (x = 0; x < cx; x++)
			{
				j  = src[y*8 + x/4];
				bitMask = 0x02 << ((x&3)*2);

				ulBase  = (31 - x) * 8;
				ulIndex = (ulBase + y / 4);
				
				if (j & bitMask)
					dst[ulIndex] |= jMask;
				if (j & (bitMask>>1))
					dst[ulIndex] |= (jMask >> 1);
			}
		}
		tx = m_nXHot;
		m_nXHot = m_nYHot;
		m_nYHot = 31 - tx;
		break;

	case DMDO_180:
		for (y = 0; y < cy; y++)
		{
			ulBase = (31 - y) * 8;
			for (x = 0; x < cx; x++)
			{
				j = src[y*8 + x/4];
				ulIndex = (ulBase + (31 - x) / 4);

				bitMask = 0x80 >> ((x&3)*2);
				jMask = 0x02 << ((x&3)*2);
				if (j & bitMask)
					dst[ulIndex] |= jMask;

				bitMask = 0x80 >> ((x&3)*2+1);
				if (j & bitMask)
					dst[ulIndex] |= (jMask >> 1);
			}
		}

		m_nXHot = 31 - m_nXHot;
		m_nYHot = 31 - m_nYHot;
		break;

	case DMDO_270:
 		for (y = 0; y < cy; y++)
		{
			jMask  = 0x80 >> ((y&3)*2);

			// Write available bits into shapeRow
			for (x = 0; x < cx; x++)
			{
				j = src[y*8 + x/4];
				bitMask = 0x02 << ((x&3)*2);

				ulBase = x * 8;
				ulIndex = (ulBase + (31 - y) / 4);

				if (j & bitMask)
					dst[ulIndex] |= jMask;
				if (j & (bitMask>>1))
					dst[ulIndex] |= (jMask >> 1);
			}
		}
		tx = m_nXHot;
		m_nXHot = 31 - m_nYHot;
		m_nYHot = tx;
		break;
	}
	
	for (y=0; y<cy; y++)
	{
		for (x=0; x<cx/4; x++)
			pCursor[x] = dst[y*8+x];
		pCursor+=16;
	}

#endif // ROTATION_ENABLE
	return S_OK;
}

void AddString(LPTSTR pBuf, LPTSTR pStr)
{
	LPTSTR pBufTemp = pBuf;
	LPTSTR pStrTemp = pStr;

	while (*pBufTemp != '\0') pBufTemp++;

	while (*pStrTemp != '\0')
	{
		*pBufTemp = *pStrTemp;
		pBufTemp++; pStrTemp++;
	}
	*pBufTemp = '\0';
	return;
}

void SMI::AdjustCursorShape(void)
{

	BYTE *pByte, *pCursor;
	ULONG ulIndex;
	BYTE src[1024], dst[1024]; /* 128 = 16 x 64 */
	BYTE  j, jMask, bitMask;
	int x, y, cx = 32, cy = 32, dx, dy, tx = 64/4;
	DWORD dwCxZoom, dwCyZoom;

	if (m_SMISettings.m_nCursorZoomEnabled != 1)
		return;

	if ( ((DWORD)m_SMISettings.m_dwCxPanel == m_SMISettings.m_dwCxZoom) ||
		 ((DWORD)m_SMISettings.m_dwCyPanel == m_SMISettings.m_dwCyZoom) )
			return;

	dwCxZoom = (m_SMISettings.m_dwCxZoom < m_SMISettings.m_dwCxPanel / 2) ? 
					(m_SMISettings.m_dwCxPanel / 2) :
					m_SMISettings.m_dwCxZoom;

	dwCyZoom = (m_SMISettings.m_dwCyZoom < m_SMISettings.m_dwCyPanel / 2) ? 
					(m_SMISettings.m_dwCyPanel / 2) :
					m_SMISettings.m_dwCyZoom;

	pCursor = pByte = m_pLAW + m_nCursorMemory;

	//Save the original pointer shape into local memory src
	memcpy(src, pByte, sizeof(src));
	memset(dst, 0x00, sizeof(dst));

	dx = (cx * m_SMISettings.m_dwCxPanel)/dwCxZoom;
	dy = (cy * m_SMISettings.m_dwCyPanel)/dwCyZoom;

	/*
	RETAILMSG(1,(TEXT("Original Cursor\r\n")));
	for (y = 0; y < cy; y++)
	{
		TCHAR cBuffer[1024];
		TCHAR cTemp[1024];
		*cBuffer = '\0';
		for (x = 0; x < cx/4; x++)
		{
			wsprintf((LPTSTR)cTemp,L"%02X ",src[y*tx+x]);
			AddString((LPTSTR)cBuffer,(LPTSTR)cTemp);
		}
		AddString((LPTSTR)cBuffer,L"\r\n");
		RETAILMSG(1,(TEXT("%s"),cBuffer));
	}
	*/
	
	// Stretch in Y
	for (y = 0; y < dy; y++)
	{
		for (x = 0; x < cx; x++)
		{
			ulIndex = (y*tx + x/4);
			j = src[(y*dwCyZoom/m_SMISettings.m_dwCyPanel)*tx + x/4];

			bitMask = 0x01 << ((x&3)*2);
			if (j & bitMask) dst[ulIndex] |= bitMask;

			bitMask = 0x01 << ((x&3)*2+1);
			if (j & bitMask) dst[ulIndex] |= bitMask;
		}
	}

	/*	
	RETAILMSG(1,(TEXT("Stretch Y Cursor\r\n")));
	for (y = 0; y < dy; y++)
	{
		TCHAR cBuffer[1024];
		TCHAR cTemp[1024];
		*cBuffer = '\0';
		for (x = 0; x < cx/4; x++)
		{
			wsprintf((LPTSTR)cTemp,L"%02X ",dst[y*tx+x]);
			AddString((LPTSTR)cBuffer,(LPTSTR)cTemp);
		}
		AddString((LPTSTR)cBuffer,L"\r\n");
		RETAILMSG(1,(TEXT("%s"),cBuffer));
	}
	//*/

	// Clear old Src
	memset(src, 0x00, sizeof(src));

	// Stretch in X
	for (y = 0; y < dy; y++)
	{
		for (x = 0; x < dx; x++)
		{
			ulIndex = (y*tx + x/4);
			j = dst[y*tx + (x*dwCxZoom/m_SMISettings.m_dwCxPanel)/4];

			jMask = 0x01 << (((x*dwCxZoom/m_SMISettings.m_dwCxPanel)&3)*2);
			bitMask = 0x01 << ((x&3)*2);
			if (j & jMask) src[ulIndex] |= bitMask;

			jMask = 0x01 << (((x*dwCxZoom/m_SMISettings.m_dwCxPanel)&3)*2+1);
			bitMask = 0x01 << ((x&3)*2+1);
			if (j & jMask) src[ulIndex] |= bitMask;
		}
	}

	/*
	RETAILMSG(1,(TEXT("Stretch X Cursor\r\n")));
	for (y = 0; y < dy; y++)
	{
		TCHAR cBuffer[1024];
		TCHAR cTemp[1024];
		*cBuffer = '\0';
		for (x = 0; x < dx/4; x++)
		{
			wsprintf((LPTSTR)cTemp,L"%02X ",src[y*tx+x]);
			AddString((LPTSTR)cBuffer,(LPTSTR)cTemp);
		}
		AddString((LPTSTR)cBuffer,L"\r\n");
		RETAILMSG(1,(TEXT("%s"),cBuffer));
	}
	//*/

	// Adjust Cursor Hot Spot
	m_nXHot = (m_nXHot * m_SMISettings.m_dwCxPanel)/dwCxZoom;
	m_nYHot = (m_nYHot * m_SMISettings.m_dwCyPanel)/dwCyZoom;

	// Copy back to memory	
	memcpy(pByte, src, sizeof(src));

	return;
}

⌨️ 快捷键说明

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