635 lines
27 KiB
C
635 lines
27 KiB
C
|
/******************************Module*Header*******************************\
|
||
|
* Module Name: driver.h
|
||
|
*
|
||
|
* Contains prototypes for the display driver.
|
||
|
*
|
||
|
* Copyright (c) 1992-1995 Microsoft Corporation
|
||
|
\**************************************************************************/
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Put all the conditional-compile constants here. There had better
|
||
|
// not be many!
|
||
|
|
||
|
// Multi-board support can be enabled by setting this to 1:
|
||
|
|
||
|
#define MULTI_BOARDS 0
|
||
|
|
||
|
// This is the maximum number of boards we'll support in a single
|
||
|
// virtual driver:
|
||
|
|
||
|
#if MULTI_BOARDS
|
||
|
#define MAX_BOARDS 16
|
||
|
#define IBOARD(ppdev) ((ppdev)->iBoard)
|
||
|
#else
|
||
|
#define MAX_BOARDS 1
|
||
|
#define IBOARD(ppdev) 0
|
||
|
#endif
|
||
|
|
||
|
// Useful for visualizing the 2-d heap:
|
||
|
|
||
|
#define DEBUG_HEAP 0
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Miscellaneous shared stuff
|
||
|
|
||
|
#define DLL_NAME L"Weitekp9" // Name of the DLL in UNICODE
|
||
|
#define STANDARD_DEBUG_PREFIX "Weitek: " // All debug output is prefixed
|
||
|
// by this string
|
||
|
#define ALLOC_TAG '9pwD' // Dwp9
|
||
|
// Four byte tag (characters in
|
||
|
// reverse order) used for memory
|
||
|
// allocations
|
||
|
|
||
|
#define CLIP_LIMIT 50 // We'll be taking 800 bytes of stack space
|
||
|
|
||
|
#define DRIVER_EXTRA_SIZE 0 // Size of the DriverExtra information in the
|
||
|
// DEVMODE structure
|
||
|
|
||
|
#define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'. Has to
|
||
|
// be at least enough to store an entire
|
||
|
// scan line (i.e., 6400 for 1600x1200x32).
|
||
|
|
||
|
#if defined(ALPHA)
|
||
|
#define XFER_BUFFERS 16 // Defines the maximum number of write buffers
|
||
|
// possible on any Alpha. Must be a power
|
||
|
#else // of two.
|
||
|
#define XFER_BUFFERS 1 // On non-alpha systems, we don't have to
|
||
|
// worry about the chip caching our bus
|
||
|
#endif // writes.
|
||
|
|
||
|
#define XFER_MASK (XFER_BUFFERS - 1)
|
||
|
|
||
|
typedef struct _CLIPENUM {
|
||
|
LONG c;
|
||
|
RECTL arcl[CLIP_LIMIT]; // Space for enumerating complex clipping
|
||
|
|
||
|
} CLIPENUM; /* ce, pce */
|
||
|
|
||
|
typedef struct _PDEV PDEV; // Handy forward declaration
|
||
|
|
||
|
VOID vSetClipping(PDEV*, RECTL*);
|
||
|
VOID vResetClipping(PDEV*);
|
||
|
VOID vPutBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
|
||
|
VOID vGetBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////
|
||
|
// Status flags
|
||
|
|
||
|
typedef enum {
|
||
|
STAT_P9000 = 0x0001, // P9000 running (as opposed to a P9100)
|
||
|
STAT_UNACCELERATED = 0x0002, // P9000 running at 16bpp or higher
|
||
|
STAT_8BPP = 0x0004, // Running at 8bpp
|
||
|
STAT_16BPP = 0x0008, // Running at 16bpp
|
||
|
STAT_24BPP = 0x0010, // Running at 24bpp
|
||
|
STAT_BRUSH_CACHE = 0x0020, // Brush cache successfully allocated
|
||
|
STAT_CIRCLE_CACHE = 0x0040, // Circle cache successfully allocated
|
||
|
} STATUS;
|
||
|
|
||
|
// P9000() returns TRUE if running on a P9000:
|
||
|
|
||
|
#define P9000(ppdev) (ppdev->flStat & STAT_P9000)
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// DriverSpecificAttributeFlags
|
||
|
//
|
||
|
// These flags must match those defined in p9.h for the weitekp9 miniport
|
||
|
//
|
||
|
|
||
|
#define CAPS_WEITEK_CHIPTYPE_IS_P9000 0x0001 // The video card has a p9000
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Text stuff
|
||
|
|
||
|
BOOL bEnableText(PDEV*);
|
||
|
VOID vDisableText(PDEV*);
|
||
|
VOID vAssertModeText(PDEV*, BOOL);
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Brush stuff
|
||
|
|
||
|
// 'Slow' brushes are used when we don't have hardware pattern capability,
|
||
|
// and we have to handle patterns using screen-to-screen blts:
|
||
|
|
||
|
#define SLOW_BRUSH_CACHE_DIM 3 // Controls the number of brushes cached
|
||
|
// in off-screen memory, when we don't
|
||
|
// have hardware pattern support.
|
||
|
// We allocate 3 x 3 brushes, so we can
|
||
|
// cache a total of 9 brushes:
|
||
|
#define SLOW_BRUSH_COUNT (SLOW_BRUSH_CACHE_DIM * SLOW_BRUSH_CACHE_DIM)
|
||
|
#define SLOW_BRUSH_DIMENSION 64 // After alignment is taken care of,
|
||
|
// every off-screen brush cache entry
|
||
|
// will be 64 pels in both dimensions
|
||
|
#define SLOW_BRUSH_ALLOCATION (SLOW_BRUSH_DIMENSION + 8)
|
||
|
// Actually allocate 72x72 pels for each
|
||
|
// pattern, using the 8 extra for brush
|
||
|
// alignment
|
||
|
|
||
|
#define RBRUSH_2COLOR 1 // Monochrome brush
|
||
|
#define RBRUSH_4COLOR 2 // 4-colour brush
|
||
|
|
||
|
#define TOTAL_BRUSH_COUNT SLOW_BRUSH_COUNT
|
||
|
// This is the maximum number of brushes
|
||
|
// we can possibly have cached off-screen
|
||
|
#define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
|
||
|
// and this is the number of pels
|
||
|
|
||
|
typedef struct _BRUSHENTRY BRUSHENTRY;
|
||
|
|
||
|
// NOTE: Changes to the RBRUSH or BRUSHENTRY structures must be reflected
|
||
|
// in strucs.inc!
|
||
|
|
||
|
typedef struct _RBRUSH {
|
||
|
FLONG fl; // Type flags
|
||
|
ULONG ulColor[4]; // 0 -- background colour if 2-colour brush
|
||
|
// 1 -- foreground colour if 2-colour brush
|
||
|
// 2 -- 3rd colour if 4-colour brush
|
||
|
// 3 -- 4th colour if 4-colour brush
|
||
|
BRUSHENTRY* apbe[MAX_BOARDS];// Points to brush-entry that keeps track
|
||
|
// of the cached off-screen brush bits
|
||
|
ULONG aulPattern[1]; // Open-ended array for keeping copy of the
|
||
|
// Don't put anything // actual pattern bits in case the brush
|
||
|
// after here, or // origin changes, or someone else steals
|
||
|
// you'll be sorry! // our brush entry (declared as a ULONG
|
||
|
// for proper dword alignment)
|
||
|
|
||
|
} RBRUSH; /* rb, prb */
|
||
|
|
||
|
typedef struct _BRUSHENTRY {
|
||
|
RBRUSH* prbVerify; // We never dereference this pointer to
|
||
|
// find a brush realization; it is only
|
||
|
// ever used in a compare to verify
|
||
|
// that for a given realized brush, our
|
||
|
// off-screen brush entry is still valid.
|
||
|
LONG x; // x-position of cached pattern
|
||
|
LONG y; // y-position of cached pattern
|
||
|
|
||
|
} BRUSHENTRY; /* be, pbe */
|
||
|
|
||
|
typedef union _RBRUSH_COLOR {
|
||
|
RBRUSH* prb;
|
||
|
ULONG iSolidColor;
|
||
|
} RBRUSH_COLOR; /* rbc, prbc */
|
||
|
|
||
|
#define CIRCLE_DIMENSION 32 // Maximum size of a cached circle
|
||
|
#define CIRCLE_ALLOCATION_CX (CIRCLE_DIMENSION + 4)
|
||
|
#define CIRCLE_ALLOCATION_CY (CIRCLE_DIMENSION)
|
||
|
// Actually allocate 36x32 pels for each
|
||
|
// circle, using the 4 extra for dword
|
||
|
// alignment
|
||
|
#define TOTAL_CIRCLE_COUNT 4 // Number of cached circles
|
||
|
|
||
|
typedef struct _CIRCLEENTRY {
|
||
|
LONG x; // x-position of off-screen circle allocation
|
||
|
LONG y; // y-position of off-screen circle allocation
|
||
|
LONG xCached; // x-position in allocation where circle starts
|
||
|
LONG yCached; // y-position in allocation where circle starts
|
||
|
RECTFX rcfxCircle; // Normalized bound-box of circle
|
||
|
BOOL bStroke; // TRUE if stroked, FALSE if filled
|
||
|
} CIRCLEENTRY;
|
||
|
|
||
|
VOID vSlowPatRealize(PDEV*, RBRUSH*);
|
||
|
|
||
|
BOOL bEnableBrushCache(PDEV*);
|
||
|
VOID vDisableBrushCache(PDEV*);
|
||
|
VOID vAssertModeBrushCache(PDEV*, BOOL);
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Stretch stuff
|
||
|
|
||
|
typedef struct _STR_BLT {
|
||
|
PDEV* ppdev;
|
||
|
PBYTE pjSrcScan;
|
||
|
LONG lDeltaSrc;
|
||
|
LONG XSrcStart;
|
||
|
PBYTE pjDstScan;
|
||
|
LONG lDeltaDst;
|
||
|
LONG XDstStart;
|
||
|
LONG XDstEnd;
|
||
|
LONG YDstStart;
|
||
|
LONG YDstCount;
|
||
|
ULONG ulXDstToSrcIntCeil;
|
||
|
ULONG ulXDstToSrcFracCeil;
|
||
|
ULONG ulYDstToSrcIntCeil;
|
||
|
ULONG ulYDstToSrcFracCeil;
|
||
|
ULONG ulXFracAccumulator;
|
||
|
ULONG ulYFracAccumulator;
|
||
|
} STR_BLT;
|
||
|
|
||
|
typedef VOID (*PFN_DIRSTRETCH)(STR_BLT*);
|
||
|
|
||
|
VOID vDirectStretch8Narrow(STR_BLT*);
|
||
|
VOID vDirectStretch8(STR_BLT*);
|
||
|
VOID vDirectStretch16(STR_BLT*);
|
||
|
VOID vDirectStretch32(STR_BLT*);
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Dither stuff
|
||
|
|
||
|
// Describes a single colour tetrahedron vertex for dithering:
|
||
|
|
||
|
typedef struct _VERTEX_DATA {
|
||
|
ULONG ulCount; // Number of pixels in this vertex
|
||
|
ULONG ulVertex; // Vertex number
|
||
|
} VERTEX_DATA; /* vd, pv */
|
||
|
|
||
|
VERTEX_DATA* vComputeSubspaces(ULONG, VERTEX_DATA*);
|
||
|
VOID vDitherColor(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
|
||
|
VOID vRealize4ColorDither(RBRUSH*, ULONG);
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// Heap stuff
|
||
|
|
||
|
typedef enum {
|
||
|
OFL_INUSE = 1, // The device bitmap is no longer located in
|
||
|
// off-screen memory; it's been converted to
|
||
|
// a DIB
|
||
|
OFL_AVAILABLE = 2, // Space is in-use
|
||
|
OFL_PERMANENT = 4 // Space is available
|
||
|
} OHFLAGS; // Space is permanently allocated; never free it
|
||
|
|
||
|
typedef struct _DSURF DSURF;
|
||
|
typedef struct _OH OH;
|
||
|
typedef struct _OH
|
||
|
{
|
||
|
OHFLAGS ofl; // OH_ flags
|
||
|
LONG x; // x-coordinate of left edge of allocation
|
||
|
LONG y; // y-coordinate of top edge of allocation
|
||
|
LONG cx; // Width in pixels of allocation
|
||
|
LONG cy; // Height in pixels of allocation
|
||
|
OH* pohNext; // When OFL_AVAILABLE, points to the next free node,
|
||
|
// in ascending cxcy value. This is kept as a
|
||
|
// circular doubly-linked list with a sentinel
|
||
|
// at the end.
|
||
|
// When OFL_INUSE, points to the next most recently
|
||
|
// blitted allocation. This is kept as a circular
|
||
|
// doubly-linked list so that the list can be
|
||
|
// quickly be updated on every blt.
|
||
|
OH* pohPrev; // Opposite of 'pohNext'
|
||
|
ULONG cxcy; // Width and height in a dword for searching
|
||
|
OH* pohLeft; // Adjacent allocation when in-use or available
|
||
|
OH* pohUp;
|
||
|
OH* pohRight;
|
||
|
OH* pohDown;
|
||
|
DSURF* pdsurf; // Points to our DSURF structure
|
||
|
VOID* pvScan0; // Points to start of first scan-line
|
||
|
}; /* oh, poh */
|
||
|
|
||
|
// This is the smallest structure used for memory allocations:
|
||
|
|
||
|
typedef struct _OHALLOC OHALLOC;
|
||
|
typedef struct _OHALLOC
|
||
|
{
|
||
|
OHALLOC* pohaNext;
|
||
|
OH aoh[1];
|
||
|
} OHALLOC; /* oha, poha */
|
||
|
|
||
|
typedef struct _HEAP
|
||
|
{
|
||
|
LONG cxMax; // Largest possible free space by area
|
||
|
LONG cyMax;
|
||
|
OH ohAvailable; // Head of available list (pohNext points to
|
||
|
// smallest available rectangle, pohPrev
|
||
|
// points to largest available rectangle,
|
||
|
// sorted by cxcy)
|
||
|
OH ohDfb; // Head of the list of all DFBs currently in
|
||
|
// offscreen memory that are eligible to be
|
||
|
// tossed out of the heap (pohNext points to
|
||
|
// the most recently blitted; pohPrev points
|
||
|
// to least recently blitted)
|
||
|
OH* pohFreeList; // List of OH node data structures available
|
||
|
OHALLOC* pohaChain; // Chain of allocations
|
||
|
} HEAP; /* heap, pheap */
|
||
|
|
||
|
typedef enum {
|
||
|
DT_SCREEN, // Surface is kept in screen memory
|
||
|
DT_DIB // Surface is kept as a DIB
|
||
|
} DSURFTYPE; /* dt, pdt */
|
||
|
|
||
|
typedef struct _DSURF
|
||
|
{
|
||
|
DSURFTYPE dt; // DSURF status (whether off-screen or in a DIB)
|
||
|
SIZEL sizl; // Size of the original bitmap (could be smaller
|
||
|
// than poh->sizl)
|
||
|
PDEV* ppdev; // Need this for deleting the bitmap
|
||
|
union {
|
||
|
OH* poh; // If DT_SCREEN, points to off-screen heap node
|
||
|
SURFOBJ* pso; // If DT_DIB, points to locked GDI surface
|
||
|
};
|
||
|
|
||
|
// The following are used for DT_DIB only...
|
||
|
|
||
|
ULONG cBlt; // Counts down the number of blts necessary at
|
||
|
// the current uniqueness before we'll consider
|
||
|
// putting the DIB back into off-screen memory
|
||
|
ULONG iUniq; // Tells us whether there have been any heap
|
||
|
// 'free's since the last time we looked at
|
||
|
// this DIB
|
||
|
|
||
|
} DSURF; /* dsurf, pdsurf */
|
||
|
|
||
|
// GDI expects dword alignment for any bitmaps on which it is expected
|
||
|
// to draw. Since we occasionally ask GDI to draw directly on our off-
|
||
|
// screen bitmaps, this means that any off-screen bitmaps must be dword
|
||
|
// aligned in the frame buffer. We enforce this merely by ensuring that
|
||
|
// all off-screen bitmaps are four-pel aligned (we may waste a couple of
|
||
|
// pixels at the higher colour depths):
|
||
|
|
||
|
#define HEAP_X_ALIGNMENT 4
|
||
|
|
||
|
// Number of blts necessary before we'll consider putting a DIB DFB back
|
||
|
// into off-screen memory:
|
||
|
|
||
|
#define HEAP_COUNT_DOWN 6
|
||
|
|
||
|
// Flags for 'pohAllocate':
|
||
|
|
||
|
typedef enum {
|
||
|
FLOH_ONLY_IF_ROOM = 0x00000001, // Don't kick stuff out of off-
|
||
|
// screen memory to make room
|
||
|
} FLOH;
|
||
|
|
||
|
BOOL bEnableOffscreenHeap(PDEV*);
|
||
|
VOID vDisableOffscreenHeap(PDEV*);
|
||
|
BOOL bAssertModeOffscreenHeap(PDEV*, BOOL);
|
||
|
|
||
|
OH* pohMoveOffscreenDfbToDib(PDEV*, OH*);
|
||
|
BOOL bMoveDibToOffscreenDfbIfRoom(PDEV*, DSURF*);
|
||
|
OH* pohAllocatePermanent(PDEV*, LONG, LONG);
|
||
|
BOOL bMoveAllDfbsFromOffscreenToDibs(PDEV* ppdev);
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// Pointer stuff
|
||
|
|
||
|
BOOL bEnablePointer(PDEV*);
|
||
|
VOID vDisablePointer(PDEV*);
|
||
|
VOID vAssertModePointer(PDEV*, BOOL);
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// Palette stuff
|
||
|
|
||
|
BOOL bEnablePalette(PDEV*);
|
||
|
VOID vDisablePalette();
|
||
|
VOID vAssertModePalette(PDEV*, BOOL);
|
||
|
|
||
|
BOOL bInitializePalette(PDEV*, DEVINFO*);
|
||
|
VOID vUninitializePalette(PDEV*);
|
||
|
|
||
|
#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// Low-level blt function prototypes
|
||
|
|
||
|
typedef VOID (FNFILL)(PDEV*, LONG, RECTL*, ULONG, RBRUSH_COLOR, POINTL*);
|
||
|
typedef VOID (FNXFER)(PDEV*, LONG, RECTL*, ULONG, SURFOBJ*, POINTL*,
|
||
|
RECTL*, XLATEOBJ*);
|
||
|
typedef VOID (FNCOPY)(PDEV*, LONG, RECTL*, ULONG, POINTL*, RECTL*);
|
||
|
typedef BOOL (FNFASTFILL)(PDEV*, LONG, POINTFIX*, ULONG, ULONG, RBRUSH*, POINTL*);
|
||
|
|
||
|
FNFILL vFillPat;
|
||
|
FNFILL vFillSolid;
|
||
|
FNFILL vFillSolidP9000HighColor;
|
||
|
FNXFER vXfer1bpp;
|
||
|
FNXFER vXfer4bpp;
|
||
|
FNXFER vXferNative;
|
||
|
FNCOPY vCopyBlt;
|
||
|
FNFASTFILL bFastFill;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////
|
||
|
// Capabilities flags
|
||
|
//
|
||
|
// These are private flags passed to us from the miniport. They
|
||
|
// come from the high word of the 'AttributeFlags' field of the
|
||
|
// 'VIDEO_MODE_INFORMATION' structure (found in 'ntddvdeo.h') passed
|
||
|
// to us via an 'VIDEO_QUERY_AVAIL_MODES' or 'VIDEO_QUERY_CURRENT_MODE'
|
||
|
// IOCTL.
|
||
|
//
|
||
|
// NOTE: These definitions must match those in the miniport's header!
|
||
|
|
||
|
typedef enum {
|
||
|
} CAPS;
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////
|
||
|
// The Physical Device data structure
|
||
|
|
||
|
typedef struct _PDEV
|
||
|
{
|
||
|
LONG xOffset;
|
||
|
LONG yOffset;
|
||
|
BYTE* pjBase; // Points to coprocessor base address
|
||
|
BYTE* pjScreen; // Points to base screen address
|
||
|
LONG lDelta; // Distance from one scan to the next.
|
||
|
LONG iBoard; // Logical multi-board identifier
|
||
|
// (zero by default)
|
||
|
ULONG iBitmapFormat; // BMF_8BPP, BMF_16BPP, BMF_24BPP or
|
||
|
// BMF_32BPP (our current colour
|
||
|
// depth)
|
||
|
VOID* pvTmpBuffer; // General purpose temporary buffer,
|
||
|
// TMP_BUFFER_SIZE bytes in size
|
||
|
// (Remember to synchronize if you
|
||
|
// use this for device bitmaps or
|
||
|
// async pointers)
|
||
|
// -------------------------------------------------------------------
|
||
|
// NOTE: Changes up to here in the PDEV structure must be reflected in
|
||
|
// i386\strucs.inc (assuming you're on an x86, of course)!
|
||
|
|
||
|
BOOL bEnabled; // In graphics mode (not full-screen)
|
||
|
CAPS flCaps; // Capabilities flags
|
||
|
STATUS flStat; // Status flags
|
||
|
LONG cjScreen; // Screen size in bytes
|
||
|
|
||
|
HANDLE hDriver; // Handle to \Device\Screen
|
||
|
HDEV hdevEng; // Engine's handle to PDEV
|
||
|
HSURF hsurfScreen; // Engine's handle to screen surface
|
||
|
DSURF* pdsurfScreen; // Our private DSURF for the screen
|
||
|
|
||
|
LONG cxScreen; // Visible screen width
|
||
|
LONG cyScreen; // Visible screen height
|
||
|
LONG cxMemory; // Width of Video RAM
|
||
|
LONG cyMemory; // Height of Video RAM
|
||
|
LONG cBitsPerPel; // Bits per pel (8, 15, 16, 24 or 32)
|
||
|
ULONG ulMode; // Mode the mini-port driver is in.
|
||
|
|
||
|
FLONG flHooks; // What we're hooking from GDI
|
||
|
LONG cjPel; // Number of bytes per pel
|
||
|
ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
|
||
|
// 0xffffffff if 32bpp
|
||
|
UCHAR* pucCsrBase; // Mapped IO port base for this PDEV
|
||
|
|
||
|
////////// Low-level blt function pointers:
|
||
|
|
||
|
FNFILL* pfnFillSolid;
|
||
|
FNFILL* pfnFillPat;
|
||
|
FNXFER* pfnXfer1bpp;
|
||
|
FNXFER* pfnXfer4bpp;
|
||
|
FNXFER* pfnXferNative;
|
||
|
FNCOPY* pfnCopyBlt;
|
||
|
|
||
|
////////// Palette stuff:
|
||
|
|
||
|
PALETTEENTRY* pPal; // The palette if palette managed
|
||
|
HPALETTE hpalDefault; // GDI handle to the default palette.
|
||
|
FLONG flRed; // Red mask for 16/32bpp bitfields
|
||
|
FLONG flGreen; // Green mask for 16/32bpp bitfields
|
||
|
FLONG flBlue; // Blue mask for 16/32bpp bitfields
|
||
|
ULONG cPaletteShift; // number of bits the 8-8-8 palette must
|
||
|
// be shifted by to fit in the hardware
|
||
|
// palette.
|
||
|
////////// Heap stuff:
|
||
|
|
||
|
HEAP heap; // All our off-screen heap data
|
||
|
ULONG iHeapUniq; // Incremented every time room is freed
|
||
|
// in the off-screen heap
|
||
|
SURFOBJ* psoPunt; // Wrapper surface for having GDI draw
|
||
|
// on off-screen bitmaps
|
||
|
SURFOBJ* psoPunt2; // Another one for off-screen to off-
|
||
|
// screen blts
|
||
|
OH* pohScreen; // Off-screen heap structure for the
|
||
|
// visible screen
|
||
|
|
||
|
////////// Pointer stuff:
|
||
|
|
||
|
ULONG cjPointerAttributes; // Size of pPointerAttributes buffer
|
||
|
BOOL bHwPointerActive; // Currently using the h/w pointer?
|
||
|
POINTL ptlHotSpot; // For remembering pointer hot spot
|
||
|
VIDEO_POINTER_CAPABILITIES PointerCapabilities;
|
||
|
VIDEO_POINTER_ATTRIBUTES* pPointerAttributes;
|
||
|
|
||
|
////////// Brush stuff:
|
||
|
|
||
|
LONG iBrushCache; // Index for next brush to be allocated
|
||
|
LONG cBrushCache; // Total number of brushes cached
|
||
|
BRUSHENTRY abe[TOTAL_BRUSH_COUNT]; // Keeps track of brush cache
|
||
|
LONG iCircleCache; // Index for next circle to be allocated
|
||
|
CIRCLEENTRY ace[TOTAL_CIRCLE_COUNT];// Keeps track of circle cache
|
||
|
|
||
|
} PDEV, *PPDEV;
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// Miscellaneous prototypes:
|
||
|
|
||
|
BOOL bIntersect(RECTL*, RECTL*, RECTL*);
|
||
|
LONG cIntersect(RECTL*, RECTL*, LONG);
|
||
|
DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION*, DWORD*);
|
||
|
|
||
|
BOOL bInitializeModeFields(PDEV*, GDIINFO*, DEVINFO*, DEVMODEW*);
|
||
|
|
||
|
BOOL bEnableHardware(PDEV*);
|
||
|
VOID vDisableHardware(PDEV*);
|
||
|
BOOL bAssertModeHardware(PDEV*, BOOL);
|
||
|
|
||
|
extern BYTE gaRop3FromMix[];
|
||
|
extern BYTE gabMixNeedsPattern[];
|
||
|
extern BYTE gabRopNeedsPattern[];
|
||
|
extern ULONG gaulP9000OpaqueFromRop2[];
|
||
|
extern ULONG gaulP9000TransparentFromRop2[];
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// The x86 C compiler insists on making a divide and modulus operation
|
||
|
// into two DIVs, when it can in fact be done in one. So we use this
|
||
|
// macro.
|
||
|
//
|
||
|
// Note: QUOTIENT_REMAINDER implicitly takes unsigned arguments.
|
||
|
|
||
|
#if defined(i386)
|
||
|
|
||
|
#define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
|
||
|
{ \
|
||
|
__asm mov eax, ulNumerator \
|
||
|
__asm sub edx, edx \
|
||
|
__asm div ulDenominator \
|
||
|
__asm mov ulQuotient, eax \
|
||
|
__asm mov ulRemainder, edx \
|
||
|
}
|
||
|
|
||
|
#else
|
||
|
|
||
|
#define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
|
||
|
{ \
|
||
|
ulQuotient = (ULONG) ulNumerator / (ULONG) ulDenominator; \
|
||
|
ulRemainder = (ULONG) ulNumerator % (ULONG) ulDenominator; \
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
// OVERLAP - Returns TRUE if the same-size lower-right exclusive
|
||
|
// rectangles defined by 'pptl' and 'prcl' overlap:
|
||
|
|
||
|
#define OVERLAP(prcl, pptl) \
|
||
|
(((prcl)->right > (pptl)->x) && \
|
||
|
((prcl)->bottom > (pptl)->y) && \
|
||
|
((prcl)->left < ((pptl)->x + (prcl)->right - (prcl)->left)) && \
|
||
|
((prcl)->top < ((pptl)->y + (prcl)->bottom - (prcl)->top)))
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////
|
||
|
// These Mul prototypes are thunks for multi-board support:
|
||
|
|
||
|
ULONG MulGetModes(HANDLE, ULONG, DEVMODEW*);
|
||
|
DHPDEV MulEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
|
||
|
ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
|
||
|
VOID MulCompletePDEV(DHPDEV, HDEV);
|
||
|
HSURF MulEnableSurface(DHPDEV);
|
||
|
BOOL MulStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
|
||
|
POINTL*, LINEATTRS*, MIX);
|
||
|
BOOL MulFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
|
||
|
MIX, FLONG);
|
||
|
BOOL MulBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||
|
RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
|
||
|
VOID MulDisablePDEV(DHPDEV);
|
||
|
VOID MulDisableSurface(DHPDEV);
|
||
|
BOOL MulAssertMode(DHPDEV, BOOL);
|
||
|
VOID MulMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
|
||
|
ULONG MulSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
|
||
|
LONG, LONG, LONG, RECTL*, FLONG);
|
||
|
ULONG MulDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
|
||
|
BOOL MulSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
|
||
|
BOOL MulCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
|
||
|
BOOL MulTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
|
||
|
BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||
|
VOID MulDestroyFont(FONTOBJ*);
|
||
|
BOOL MulPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||
|
BOOL MulRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
|
||
|
ULONG);
|
||
|
HBITMAP MulCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
|
||
|
VOID MulDeleteDeviceBitmap(DHSURF);
|
||
|
BOOL MulStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||
|
COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
|
||
|
ULONG);
|
||
|
VOID MulSynchronize(DHPDEV, RECTL*);
|
||
|
|
||
|
// These Dbg prototypes are thunks for debugging:
|
||
|
|
||
|
ULONG DbgGetModes(HANDLE, ULONG, DEVMODEW*);
|
||
|
DHPDEV DbgEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
|
||
|
ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
|
||
|
VOID DbgCompletePDEV(DHPDEV, HDEV);
|
||
|
HSURF DbgEnableSurface(DHPDEV);
|
||
|
BOOL DbgStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
|
||
|
POINTL*, LINEATTRS*, MIX);
|
||
|
BOOL DbgFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
|
||
|
MIX, FLONG);
|
||
|
BOOL DbgBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||
|
RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
|
||
|
VOID DbgDisablePDEV(DHPDEV);
|
||
|
VOID DbgDisableSurface(DHPDEV);
|
||
|
BOOL DbgAssertMode(DHPDEV, BOOL);
|
||
|
VOID DbgMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
|
||
|
ULONG DbgSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
|
||
|
LONG, LONG, LONG, RECTL*, FLONG);
|
||
|
ULONG DbgDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
|
||
|
BOOL DbgSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
|
||
|
BOOL DbgCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
|
||
|
BOOL DbgTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
|
||
|
BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||
|
VOID DbgDestroyFont(FONTOBJ*);
|
||
|
BOOL DbgPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
|
||
|
BOOL DbgRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
|
||
|
ULONG);
|
||
|
HBITMAP DbgCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
|
||
|
VOID DbgDeleteDeviceBitmap(DHSURF);
|
||
|
BOOL DbgStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
|
||
|
COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
|
||
|
ULONG);
|
||
|
VOID DbgSynchronize(DHPDEV, RECTL*);
|
||
|
ULONG DbgEscape(SURFOBJ*, ULONG, ULONG, VOID*, ULONG, VOID*);
|