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

📄 cursor.cpp

📁 WinCE5.0BSP for Renesas SH7770
💻 CPP
字号:
//
//  Copyright(C) Renesas Technology Corp. 1998-2004. All rights reserved.
//  Portions Copyright (c) 1997 Microsoft Corporation.
//
//  NCG Display Driver for ITS-DS7
//
//  FILE      : cursor.cpp
//  CREATED   : 2003.08.28
//  MODIFIED  : 2004.09.02
//  AUTHOR    : Renesas Technology Corp.
//  HARDWARE  : RENESAS ITS-DS7
//  HISTORY   : 
//              2003.08.28
//              - Created prototype code.
//                (based on Q2SD Display Driver for PFM-DS6C Ver.3.1.0)
//              2004.09.02
//              - Modified data type mismatch.
//

#include "precomp.h"

extern DWORD gCursorData[CURSOR_BYTES / 4];
extern DWORD gCursorMask[CURSOR_BYTES / 4];
extern DWORD gxHot;
extern DWORD gyHot;
extern int   gStride;
extern int   gDisplayOffsetX;
extern int   gDisplayOffsetY;

SCODE NCG::SetPointerShape(
    GPESurf *pMask,
    GPESurf *pColorSurf,
    int xHot,
    int yHot,
    int cX,
    int cY)
{
    int     i, row, col;
    int     bitMask;
    BYTE    bAND, bXOR;
    PBYTE   pCM, pCD;
    BYTE    bPtnCheck; // Does the pattern has actual screen image?
    DWORD   dwDPPR;

    if (!pMask ) {
        memset (gCursorMask, 0xFF, sizeof(gCursorMask));
        memset (gCursorData, 0x00, sizeof(gCursorData));
        m_bCursorFlag = FALSE;
    } 
    else {
        bPtnCheck = 0;
        for (row=0; row < 64; row++) {
            pCM = (PBYTE)(gCursorMask+(row*CURSOR_XSIZE/4));
            pCD = (PBYTE)(gCursorData+(row*CURSOR_XSIZE/4));

            memset (pCM, 0xFF, CURSOR_XSIZE);
            memset (pCD, 0x00, CURSOR_XSIZE);
            if (row < cY) {
                for (col = 0; col < cX/8; col++) {
                    bAND = ((unsigned char *)pMask->Buffer()+row*pMask->Stride())[col];
                    bXOR = ((unsigned char *)pMask->Buffer()+(cY+row)*pMask->Stride())[col];
                    bPtnCheck |= ~bAND | bXOR;
                    for (bitMask=0x0080, i=0; i < 8; bitMask >>=1, i++) {
                        pCM[col*8+i] = (BYTE)((bAND & bitMask) ? 0xFF : 0x00);
                        pCD[col*8+i] = (BYTE)((bXOR & bitMask) ? 0xFF : 0x00);
                    }
                }
            }
        }
        gxHot = xHot;
        gyHot = yHot;
        m_bCursorFlag = bPtnCheck != 0;
    }

	volatile unsigned char	*pCursor, data;
	int						index, n;

	m_pDUCPnRegs[3][0] = 0x00000000;
	m_pDUCPnRegs[3][1] = 0x00FFFFFF;
	m_pDUCPnRegs[3][2] = 0x00000000;
	m_pDUCPnRegs[3][3] = 0x00808080;
	m_pDURegs[DU_CP4TR] = 0x00000004;
	m_pDURegs[DU_CPCR] = CPCR_CP4CE;

	pCursor = (volatile unsigned char *)(m_pLAW + g_dwCursorBufferOffset);

    pCM = (PBYTE)gCursorMask;
    pCD = (PBYTE)gCursorData;
    for (row = 0; row < CURSOR_YSIZE; row++) {
        for (col = 0, n = 0; col < CURSOR_XSIZE; col++) {
            index = row * CURSOR_XSIZE + col;
            if (pCM[index] == 0) {
                if ( pCD[index] == 0) { /* Black */
                    data = 0;
                }
                else { /* White */
                    data = 1;
                }
            }
            else {
                if ( pCD[index] == 0) { /* Transparent */
                    data = 2;
                }
                else { /* Gray, instead of XOR. */
                    data = 3;
                }
            }
            *pCursor++ = data;
        }
    }

	dwDPPR = m_pDURegs[DU_DPPR];
	if (m_bCursorFlag) {	// turn on
		dwDPPR &= 0xFFFFFFF0;
		dwDPPR |= 0x0000000D;	// 1:Plane 6
	}
	else {					// turn off
		dwDPPR &= 0xFFFFFFF0;
    }
	m_pDURegs[DU_DPPR] = dwDPPR;

    return S_OK;
}


SCODE NCG::MovePointer(int xPosition, int yPosition)
{
    BOOL    bShow;

    if (xPosition < 0 || xPosition >= m_nScreenWidth ||
        yPosition < 0 || yPosition >= m_nScreenHeight) {
        bShow = FALSE;
    }
    else {
        bShow = TRUE;
    }

    m_CursorRect.left = xPosition - gxHot;
    if (m_CursorRect.left < 0) {
        m_CursorRect.left = 0;
    }
    m_CursorRect.top = yPosition - gyHot;
    if (m_CursorRect.top < 0) {
        m_CursorRect.top = 0;
    }
    m_CursorRect.right = xPosition - gxHot + CURSOR_XSIZE;
    m_CursorRect.bottom = yPosition - gyHot + CURSOR_YSIZE;

	m_pDUPnRegs[5][DU_PnDPXR] = m_CursorRect.left;
	m_pDUPnRegs[5][DU_PnDPYR] = m_CursorRect.top;

    return S_OK;
}

⌨️ 快捷键说明

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