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

📄 misc.cpp

📁 WinCE5.0BSP for Renesas SH7770
💻 CPP
字号:
//
//  Copyright(C) Renesas Technology Corp. 1998-2003. All rights reserved.
//  Portions Copyright (c) 1997 Microsoft Corporation.
//
//  NCG Display Driver for ITS-DS7
//
//  FILE      : misc.cpp
//  CREATED   : 2003.08.28
//  MODIFIED  : 2003.11.18
//  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)
//

#include "precomp.h"
#include "du.h"

/*  DrvGetMasks, notify DDI to current RGB color masks. This  */
/* driver uses either 8bpp palette mode or 16bpp indexed mode */
/* When 8bpp mode, all color mask value is set to 0.          */

ulong BitMasks[] = { 0, 0, 0, 0 };

ULONG *APIENTRY DrvGetMasks(
    DHPDEV dhpdev)
{
    DDGPE *pDDGPE;
    GPEModeEx modeEx;

    pDDGPE = (DDGPE*)dhpdev;
    pDDGPE->GetModeInfoEx(&modeEx, pDDGPE->GetPhysicalModeId());

    BitMasks[0] = modeEx.dwRBitMask;
    BitMasks[1] = modeEx.dwGBitMask;
    BitMasks[2] = modeEx.dwBBitMask;
    BitMasks[3] = modeEx.dwAlphaBitMask;

    return BitMasks;
}


/* InVBlank, notify whether it is in vertical blank or not.   */
/* Unfortunately this driver cannot support this function.    */

int NCG::InVBlank()
{
    return 0;
}


/*  WaitForVBlank, waits until vertical blank timing reaches. */
/* VBlank event is asserted in interrupt service thread.      */

/*  Application programs can use this method by calling       */
/* 'WaitForVerticalBlank' method. Unfortunately this blocks   */
/* other DirectDraw calls while waiting, so this driver pro-  */
/* vides named event to enables application to wait without   */
/* blocking other DirectDraw calls.                           */

void NCG::WaitForVBlank()
{
    DWORD nRet;

    nRet = WaitForSingleObject(m_hVBlank, 100);
    if (nRet == WAIT_FAILED) {
        RETAILMSG(1,
            (TEXT("WaitForVBlank: Failed.\r\n")));
        return;
    }
    if (nRet == WAIT_TIMEOUT) {
        RETAILMSG(1,
            (TEXT("WaitForVBlank: Time out.\r\n")));
    }
    return;
}


/*  GetPhysicalVideoMemory, returns video memory base pointer */
/* in vertual address and available video memory size.        */
void NCG::GetPhysicalVideoMemory(
    PULONG pPhysicalMemoryBase, 
    PULONG pVideoMemorySize
    )
{
    *pPhysicalMemoryBase = (unsigned long)m_pLAW;
    *pVideoMemorySize = m_nVideoMemorySize; // total size
}


/*  SetPalette, set RGB value to specified palette entries.   */
/* DU supports 256 palette entries and RGB888 format.         */

SCODE NCG::SetPalette(
    const PALETTEENTRY *src,
    unsigned short firstEntry,
    unsigned short numEntries )
{
	int		n;

    DEBUGMSG(GPE_ZONE_ENTER,(TEXT("+NCG::SetPalette\r\n")));
    if (firstEntry < 0 || firstEntry + numEntries > 256)
        return E_INVALIDARG;

    for (n = 0; n < numEntries; n++) {
		m_pDUCPnRegs[0][firstEntry + n]
			= (src->peRed << 16) | (src->peGreen << 8) | src->peBlue;
    }
	m_pDURegs[DU_CPCR] = CPCR_CP1CE;

    DEBUGMSG(GPE_ZONE_ENTER,(TEXT("-NCG::SetPalette\r\n")));
    return S_OK;
}


ULONG NCG::DrvEscape(
    SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
    int     RetVal = 0; // Default not supported

//    DEBUGMSG(1,(TEXT("NCG::DrvEscape(0x%X, %d(0x%X), %d, 0x%X, %d, 0x%X)\r\n"),
//                pso, iEsc, iEsc, cjIn, pvIn, cjOut, pvOut));

    switch (iEsc) {
    case QUERYESCSUPPORT :
        if ((cjIn == sizeof(DWORD)) && (pvIn != NULL)) {
            DWORD   SupportChk;
            SupportChk = *(DWORD *)pvIn;
            switch (SupportChk) {
            case GETVFRAMEPHYSICAL :
            case GETVFRAMELEN :
                RetVal = 1;
                break;
            }
        }
        else {
            SetLastError(ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
        break;

    case GETVFRAMEPHYSICAL :
        if ((cjOut == sizeof(DWORD)) && (pvOut != NULL)) {
            *(DWORD *)pvOut = m_nLAWPhysical;
            RetVal = 1;
        } 
        else {
            SetLastError(ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
        break;

    case GETVFRAMELEN :
        if ((cjOut == sizeof(DWORD)) && (pvOut != NULL)) {
            *(DWORD *)pvOut = m_nVideoMemorySize;
            RetVal = 1;
        } 
        else {
            SetLastError(ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
        break;

    }
    return (ULONG) RetVal;
}

⌨️ 快捷键说明

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