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

📄 gpeaccel.cpp

📁 EP931X系列的WinCE显示器驱动源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//****************************************************************************
// 
// 
SCODE GPEAccel::MovePointer(INT xPosition, INT yPosition)
{
    DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("GPEAccel::MovePointer(%d, %d)\r\n"), xPosition, yPosition));
    ULONG ulXYLOC;

    
    if (xPosition != -1 || yPosition != -1)
    {
        m_xPosition = xPosition;
        m_yPosition = yPosition;

        //
        // Compute new cursor rect
        //
        m_CursorRect.left = xPosition - m_CursorHotspot.x;
        m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
        m_CursorRect.top = yPosition - m_CursorHotspot.y;
        m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;

        if(m_bCursorHasShape)
        {
            ulXYLOC = CURSORXYLOC_XMASK & ((m_StartStop.ulHActiveStart  - m_CursorRect.left)<<CURSORXYLOC_XSHIFT);
            ulXYLOC |= CURSORXYLOC_YMASK & ((m_StartStop.ulVActiveStart - m_CursorRect.top)<<CURSORXYLOC_YSHIFT);
            ulXYLOC |= m_bCursorEnabled? CURSORXYLOC_CEN: 0;

        }
        m_bCursorEnabled = TRUE;
    }
    else
    {
        ulXYLOC             = 0;
        m_bCursorEnabled    = FALSE;        
    }

    //
    // Write the New XY Cursor value.
    //
    *RASTER_CURSORXYLOC = ulXYLOC;

    return  S_OK;
}

//****************************************************************************
// GPEAccel::WaitForNotBusy
//****************************************************************************
// In the EP9312 Video is never busy. 
//
void   GPEAccel::WaitForNotBusy(void)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::WaitForNotBusy\r\n")));
    return;
}

//****************************************************************************
// GPEAccel::IsBusy
//****************************************************************************
// In the EP9312 Video is never busy. 
// 
int  GPEAccel::IsBusy(void)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::IsBusy\r\n")));
    return  0;
}


//****************************************************************************
// GPEAccel::GetPhysicalVideoMemory
//****************************************************************************
// Get the Physical memory base and video memory size.
//
void  GPEAccel::GetPhysicalVideoMemory
(
    unsigned long *physicalMemoryBase, 
    unsigned long *videoMemorySize
)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::GetPhysicalVideoMemory\r\n")));

    *physicalMemoryBase = m_pvFlatFrameBuffer;
    *videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
}

//****************************************************************************
// GPEAccel::AllocSurface
//****************************************************************************
// AllocateSurface
SCODE   GPEAccel::AllocSurface
(
    GPESurf     **surface, 
    INT         width, 
    INT         height, 
    EGPEFormat  format, 
    INT         surfaceFlags
)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::AllocSurface\r\n")));

    if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
    {

            RETAILMSG(1,(TEXT("AllocSurface out of memory error.\r\n")));
        return  E_OUTOFMEMORY;
    }

    //
    // Allocate from system memory
    //
    *surface = new GPESurf(width, height, format);

    if (*surface != NULL)
    {
        //
        // Check that the bits were allocated succesfully
        //
        if (((*surface)->Buffer()) == NULL)
        {
            //
            // Clean up
            //
            delete *surface;                
            RETAILMSG(1,(TEXT("BPESurf->Buffer error\r\n")));
        }
        else
        {
            return S_OK;
        }
    }
    RETAILMSG(1,(TEXT("New GPESurf() error\r\n")));
    return E_OUTOFMEMORY;
}

//****************************************************************************
// GPEAccel::WrappedEmulatedLine
//****************************************************************************
// 
// 
//
SCODE GPEAccel::WrappedEmulatedLine (GPELineParms *lineParameters)
{
    SCODE   retval;
    RECT    bounds;
    int     N_plus_1;               // Minor length of bounding rect + 1

    // calculate the bounding-rect to determine overlap with cursor
    if (lineParameters->dN)         // The line has a diagonal component (we'll refresh the bounding rect)
    {
        N_plus_1 = 2 + ((lineParameters->cPels * lineParameters->dN) / lineParameters->dM);
    }
    else
    {
        N_plus_1 = 1;
    }

    switch(lineParameters->iDir)
    {
        case 0:
            bounds.left = lineParameters->xStart;
            bounds.top = lineParameters->yStart;
            bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
            bounds.bottom = bounds.top + N_plus_1;
            break;
        case 1:
            bounds.left = lineParameters->xStart;
            bounds.top = lineParameters->yStart;
            bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
            bounds.right = bounds.left + N_plus_1;
            break;
        case 2:
            bounds.right = lineParameters->xStart + 1;
            bounds.top = lineParameters->yStart;
            bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
            bounds.left = bounds.right - N_plus_1;
            break;
        case 3:
            bounds.right = lineParameters->xStart + 1;
            bounds.top = lineParameters->yStart;
            bounds.left = lineParameters->xStart - lineParameters->cPels;
            bounds.bottom = bounds.top + N_plus_1;
            break;
        case 4:
            bounds.right = lineParameters->xStart + 1;
            bounds.bottom = lineParameters->yStart + 1;
            bounds.left = lineParameters->xStart - lineParameters->cPels;
            bounds.top = bounds.bottom - N_plus_1;
            break;
        case 5:
            bounds.right = lineParameters->xStart + 1;
            bounds.bottom = lineParameters->yStart + 1;
            bounds.top = lineParameters->yStart - lineParameters->cPels;
            bounds.left = bounds.right - N_plus_1;
            break;
        case 6:
            bounds.left = lineParameters->xStart;
            bounds.bottom = lineParameters->yStart + 1;
            bounds.top = lineParameters->yStart - lineParameters->cPels;
            bounds.right = bounds.left + N_plus_1;
            break;
        case 7:
            bounds.left = lineParameters->xStart;
            bounds.bottom = lineParameters->yStart + 1;
            bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
            bounds.top = bounds.bottom - N_plus_1;
            break;
        default:
            RETAILMSG(1,(TEXT("Invalid direction: %d\r\n"), lineParameters->iDir));
            return E_INVALIDARG;
    }


    // do emulated line
    retval = EmulatedLine (lineParameters);

    return  retval;

}
//****************************************************************************
// GPEAccel::Line
//****************************************************************************
// 
// 
SCODE GPEAccel::Line
(   
    GPELineParms    *lineParameters, 
    EGPEPhase       phase
)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::Line\r\n")));

    if (phase == gpeSingle || phase == gpePrepare)
    {

        if ((lineParameters->pDst != m_pPrimarySurface))
        {
            lineParameters->pLine = EmulatedLine;
        }
        else
        {
            lineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) WrappedEmulatedLine;
        }
    }
    return S_OK;
}

//****************************************************************************
// GPEAccel::BltPrepare
//****************************************************************************
// 

SCODE   GPEAccel::BltPrepare(GPEBltParms *blitParameters)
{
    // RECTL   rectl;

    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::BltPrepare\r\n")));

    //
    // default to base EmulatedBlt routine
    //
    blitParameters->pBlt = EmulatedBlt;

    //
    // see if there are any optimized software blits available
    //
    EmulatedBltSelect02(blitParameters);
    EmulatedBltSelect08(blitParameters);
    EmulatedBltSelect16(blitParameters);

    return S_OK;
}

//****************************************************************************
// GPEAccel::BltComplete
//****************************************************************************
// 
SCODE   GPEAccel::BltComplete(GPEBltParms *blitParameters)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::BltComplete\r\n")));

    return S_OK;
}

//****************************************************************************
// GPEAccel::InVBlank
//****************************************************************************
// We don't have to worry about blanking.
//
INT    GPEAccel::InVBlank(void)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::InVBlank\r\n")));
    return 0;
}

//****************************************************************************
// PrintPalette
//****************************************************************************
// Debug routine to print out the current palette
// 
//
void PrintPalette()
{
    #ifdef DEBUG
    ULONG   ulEntry;
    DEBUGMSG (GPE_ZONE_PALETTE, (L"GPEAccel: Current Palette, "));
    
    //
    // If the print Palette zone is enabled print out the palette whenever
    // we open the palette.
    //
    if(GPE_ZONE_PALETTE)
    {
        for(ulEntry = 0; ulEntry < 256 ; ulEntry+=4)
        {
            DEBUGMSG
            (
                GPE_ZONE_PALETTE, 
                (
                    L"Entry 0x%03x:  0x%08x  0x%08x  0x%08x  0x%08x\n",
                    ulEntry,
                    RASTER_COLOR_LUT[ulEntry],
                    RASTER_COLOR_LUT[ulEntry + 1],
                    RASTER_COLOR_LUT[ulEntry + 2],
                    RASTER_COLOR_LUT[ulEntry + 3]
                )
            );
        }
    }        
    #endif //DEBUG
}
//****************************************************************************
// GPEAccel::SetPalette
//****************************************************************************
// Set up the Color Look up table.   There are two LUT's in hardware.
// the lookup table that is visible is not the one that is accessable.
// 
//
SCODE  GPEAccel::SetPalette
(
    const PALETTEENTRY  *source, 
    USHORT              firstEntry, 
    USHORT              numEntries
)
{
    DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::SetPalette\r\n")));
    ULONG   ulEntry;
    ULONG   ulCount;

    if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
    {
        RETAILMSG(1,(TEXT("SetPalette invalid arguments\r\n")));
        return  E_INVALIDARG;
    }

    //
    // Copy into our palette.
    //
    memcpy((void *)&m_Palette[firstEntry], source, sizeof(PALETTEENTRY) * numEntries);
    

    //
    // I would do a memory copy but the red and blue
    // palette entries are reversed.
    //
    for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
    {
        unsigned char red, green, blue;

        //
        // Get the values for Red, Green and Blue.
        //
        red     = source[ulEntry].peRed ;
        green   = source[ulEntry].peGreen;
        blue    = source[ulEntry].peBlue;

        //
        // Program up the Color lookup table.
        //
        RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
    }
    
    //
    // Switch to the other LUT and program the same values.
    //                                       
    *RASTER_LUTCONT          ^= LUTCONT_SWTCH;
    
    //
    // Wait until a palette switch occurs at the end of the frame.
    //
    for(ulCount = 0 ;; ulCount++)
    {
        //
        // Put a small delay to wait for the change.
        //
        Sleep(1);
        
        //
        // Has the switch occured.
        //
        if(((*RASTER_LUTCONT & LUTCONT_SSTAT) && (*RASTER_LUTCONT &LUTCONT_SWTCH)) ||
          (!(*RASTER_LUTCONT & LUTCONT_SSTAT) && !(*RASTER_LUTCONT & LUTCONT_SWTCH)))
        {
            break;
        }
        
        if(ulCount > 100)
        {
            DEBUGMSG (GPE_ZONE_INIT, (TEXT("ERROR: Palette switch never occured.\n")));
        }
    }

    
    //
    // I would do a memory copy but the red and blue
    // palette entries are reversed.
    //
    for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
    {
        unsigned char    red, green, blue;

        //
        // Get the values for Red, Green and Blue.
        //
        red     = source[ulEntry].peRed ;
        green   = source[ulEntry].peGreen;
        blue    = source[ulEntry].peBlue;

        //
        // Program up the Color lookup table.
        //
        RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
    }
    
    //
    // Print out the palette to the debugger if the debug zone is enabled.
    //
    PrintPalette();


    return  S_OK;
}

//****************************************************************************
// GPEAccel::GetGraphicsCaps
//****************************************************************************
// 
// 
ULONG   GPEAccel::GetGraphicsCaps()
{
    if (m_pMode)
    {
        //
        // if in 16bpp mode, return GCAPS_GRAY16 to denote that we support 
        // anti-aliased fonts
        if (m_pMode->Bpp == 16)     
        {
            return  GCAPS_GRAY16;
        }
    }
    return  0;
}

//****************************************************************************
// RegisterDDHALAPI
//****************************************************************************
// no DDHAL support
// 
void  RegisterDDHALAPI(void)
{
    return; 
}

ULONG gBitMasks[] = { 0x0001,0x0002,0x0000 };


//****************************************************************************
// DrvGetMasks
//****************************************************************************
//
//
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
    return gBitMasks;
}


⌨️ 快捷键说明

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