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

📄 ncg.h

📁 WinCE5.0BSP for Renesas SH7770
💻 H
字号:
/*
//  Copyright(C) Renesas Technology Corp. 1998-2004. All rights reserved.
//  Portions Copyright (c) 1997 Microsoft Corporation.
//
//  NCG Display Driver for ITS-DS7
//
//  FILE      : ncg.h
//  CREATED   : 2003.08.28
//  MODIFIED  : 2005.11.10
//  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)
//              2003.11.18
//              - Removed unused code.
//              2004.03.01
//              - Changed the name of variables, functions and definitions.
//              2005.09.20
//              - Added SZBUILDDATE macro.
//              - Added nPixelFormat to struct ModeInit.
//              - Changed default pixel format specification.
*/

#ifndef __NCG_H__
#define __NCG_H__

#define SZDRIVERNAME                    TEXT("NCG DDGPE display driver")
#define SZVERSION                       TEXT("0.2.0.20051110")
#define SZBUILDDATE                     TEXT(__DATE__)

#define NCG_FBBASE						0xAE000000	/* Check config.bib */
#define NCG_FBSIZE						0x02000000	/* 32MB */

/* Default Pixel Format */
#define DEFAULTPIXELFORMAT 				1	/* 0:INDEX8, 1:RGB565, 2:ARGB1555 */

/* Default Color */
#define DEFAULTCOLOR_DISPLAYOFF			0x0000007C
#define DEFAULTCOLOR_BACKGROUND			0x00000000

/* Cursor */
#define CURSOR_XSIZE                    64
#define CURSOR_YSIZE                    64
#define CURSOR_BYTES                    (CURSOR_XSIZE * CURSOR_YSIZE)

#define NUMDISPMODES                    1

/* In fact, contrast control is not supported by hardware. */
#define CONTRAST_CMD_GET                0
#define CONTRAST_CMD_SET                1
#define CONTRAST_CMD_INCREASE           2
#define CONTRAST_CMD_DECREASE           3
#define CONTRAST_CMD_DEFAULT            4

struct ModeInit
{
    GPEModeEx   gpeModeEx;
    int         nPixelFormat;
    DWORD       DURegs[0x30];
};

class NCGSurf;

/* class definitions */

class NCG  : public DDGPE
{
private:
    volatile unsigned long *m_pDURegs;      // DU register base address
    volatile unsigned long *m_pDUPnRegs[NCGDU_MAXPLANES];
                                            // DU Plane n register base address
    volatile unsigned long *m_pDUCPnRegs[NCGDU_MAXPALETTES];
                                            // DU Color Palette n register base address

    volatile unsigned char *m_pLAW;         // Linear access window (virtual)
    int             m_nVideoMemorySize;     // Size in bytes of video RAM total
    SurfaceHeap     *m_pVideoMemoryHeap;    // Base entry representing all video memory
    int             m_nScreenStride;        // Stride of 2d memory in bytes
    int             m_nScreenBpp;           // Bits/pixel
    ULONG           m_nLAWPhysical;         // Physical address of LAW

	NCGSurf			*m_pBltSrcSurf;
	NCGSurf			*m_pBltDstSurf;
    NCGSurf         *m_pVisiblePlane[NCGDU_MAXPLANES];  // Visible surface object
    BOOL            m_bFlippingPlane[NCGDU_MAXPLANES];  // flipping flag

    DWORD           m_dwIntrId_DU;           // interrupt ID
    HANDLE          m_hIntrEvent_DU;         // handle for main interrupt event
    HANDLE          m_hIntrThread_DU;        // handle for interrupt thread

    HANDLE          m_hVBlank;				// handle to notify arrival of vertical blank

    BYTE            m_nContrastCurrent;     // Contrast, unused in this driver

    BOOL            m_bCursorFlag;
    RECT            m_CursorRect;

    /* ================  NCG.cpp  ================ */
public:
                    NCG();
    virtual SCODE   SetMode( int modeNo, HPALETTE *pPalette );
    virtual SCODE   GetModeInfo( GPEMode *pMode, int modeNo );
    virtual int     NumModes();
    virtual SCODE   GetModeInfoEx( GPEModeEx *pModeEx, int modeNo );
    virtual BOOL    ContrastControl( ULONG cmd, ULONG *pValue );
private:
    void            SetRegisters( int nModeIndex );

    /* ================  Cursor.cpp  ================ */
public:
    virtual SCODE   SetPointerShape(
                        GPESurf *pMask,
                        GPESurf *pColorSurf,
                        int xHot,
                        int yHot,
                        int cx,
                        int cy );
    virtual SCODE   MovePointer( int x, int y );

    /* ================   Intr.cpp   ================ */
public:
    void            IntrThreadProc_DU();

    /* ================   Misc.cpp   ================ */
public:
    virtual int     InVBlank();
    virtual void    WaitForVBlank();
    virtual void    GetPhysicalVideoMemory(
                        PULONG pPhysicalMemoryBase, 
                        PULONG pVideoMemorySize );
    virtual SCODE   SetPalette(
                        const PALETTEENTRY *src,
                        unsigned short firstEntry,
                        unsigned short numEntries );
    DWORD           GetFreeVideoMemory();
    virtual ULONG   DrvEscape(
                        SURFOBJ *pso,
                        ULONG iEsc,
                        ULONG cjIn,
                        PVOID pvIn,
                        ULONG cjOut,
                        PVOID pvOut);

    /* ================   Surf.cpp   ================ */
public:
    virtual SCODE   AllocSurface(
                        GPESurf **ppSurf,
                        int width,
                        int height,
                        EGPEFormat format,
                        int surfaceFlags );
    virtual SCODE   AllocSurface(
                        DDGPESurf **ppSurf,
                        int width,
                        int height,
                        EGPEFormat format,
                        EDDGPEPixelFormat pixelFormat,
                        int surfaceFlags );
    virtual SCODE   AllocSurface(
                        NCGSurf **ppSurf,
                        int width,
                        int height,
                        EGPEFormat format,
                        EDDGPEPixelFormat pixelFormat,
                        int surfaceFlags );
    virtual SCODE   DetectPixelFormat(
                        DWORD dwCaps,
                        DDPIXELFORMAT *pddpf,
                        EGPEFormat *pFormat,
                        EDDGPEPixelFormat *pPixelFormat );
    virtual void    SetVisibleSurface( GPESurf *pSurf );
    virtual void    SetVisibleSurface( GPESurf *pSurf, BOOL bWaitForVBlank );
    BOOL            SearchSurface(
                        LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface,
                        DWORD nSearchOffset );

    DWORD           Blt( LPDDHAL_BLTDATA pd );
    DWORD           GetBltStatus(
                        LPDDRAWI_DDRAWSURFACE_LCL   lpDDSurface,
                        DWORD dwFlags);

    DWORD           Flip( LPDDHAL_FLIPDATA pd );
    DWORD           GetFlipStatus( LPDDHAL_GETFLIPSTATUSDATA pd );

    /* ================   Line.cpp   ================ */
public:
    virtual SCODE   Line( GPELineParms *pLineParms, EGPEPhase phase );

    /* ================    Blt.cpp   ================ */
public:
    virtual SCODE   BltPrepare( GPEBltParms *pBltParms );
    virtual SCODE   BltComplete( GPEBltParms *pBltParms );

};


class NCGSurf : public DDGPESurf
{
private:
    SurfaceHeap     *m_pHeap;
    int             m_nSrcCount;
    int             m_nDstCount;

public:
    NCGSurf        *m_pSurfList;
    DWORD           m_dwSurfaceID;
    DWORD           m_dwLayerID;

public:
                    NCGSurf(                   // Create video-memory surface
                        int width,
                        int height,
                        unsigned long offset,
                        void *pBits,
                        int stride,
                        EGPEFormat format,
                        EDDGPEPixelFormat pixelFormat,
                        SurfaceHeap *pHeap );
                    NCGSurf(                   // Create video-memory surface
                        int width,
                        int height,
                        unsigned long offset,
                        void *pBits,
                        int stride,
                        EGPEFormat format,
                        SurfaceHeap *pHeap );
                    NCGSurf(                   // Create system-memory surface
                        int width,
                        int height,
                        int stride,
                        EGPEFormat format,
                        EDDGPEPixelFormat pixelFormat );

    void            IncSrcCount() { m_nSrcCount++; }
    void            DecSrcCount() { m_nSrcCount--; }
    int             GetSrcCount() { return m_nSrcCount; }
    void            IncDstCount() { m_nDstCount++; }
    void            DecDstCount() { m_nDstCount--; }
    int             GetDstCount() { return m_nDstCount; }

    virtual         ~NCGSurf( void );
};

/* external (global) variables */

extern DDHALMODEINFO modeInfo[];

extern ModeInit NCGMode[];
extern DWORD g_dwVideoMemoryAddress;
extern DWORD g_dwVideoMemorySize;
extern DWORD g_dwRegisterAddress;
extern DWORD g_dwInterruptNumber;
extern DWORD g_dwIntrThreadPriority;
extern TCHAR* g_szModeString;

extern DWORD g_dwCursorBufferOffset;

#endif __NCG_H__

⌨️ 快捷键说明

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