|
|
1.1 ! root 1: /******************************Module*Header*******************************\ ! 2: * Module Name: driver.h ! 3: * ! 4: * Contains prototypes for the 256 colour VGA driver. ! 5: * ! 6: * NOTE: Must mirror driver.inc! ! 7: * ! 8: * Copyright (c) 1992 Microsoft Corporation ! 9: \**************************************************************************/ ! 10: ! 11: #ifndef _DRIVER_ ! 12: #define _DRIVER_ ! 13: ! 14: #include "stdlib.h" ! 15: #include "stddef.h" ! 16: #include "windows.h" ! 17: #include "winddi.h" ! 18: #include "devioctl.h" ! 19: #include "ntddvdeo.h" ! 20: ! 21: #include "debug.h" ! 22: ! 23: typedef struct _PDEV PDEV, *PPDEV; ! 24: ! 25: // ! 26: // Sizes assumed for 1-window and 2 RW-window banks. ! 27: // ! 28: ! 29: #define BANK_SIZE_1_WINDOW 0x10000L ! 30: #define BANK_SIZE_2RW_WINDOW 0x08000L ! 31: ! 32: // ! 33: // Temporary buffer must be at least as large as a bank. ! 34: // Must also be a multiple of 4. ! 35: // ! 36: ! 37: #define TMP_BUFFER_SIZE (BANK_SIZE_1_WINDOW) ! 38: ! 39: /**************************************************************************\ ! 40: * ! 41: * Specifies desired justification for requestion scan line within bank window ! 42: * ! 43: \**************************************************************************/ ! 44: ! 45: typedef enum { ! 46: JustifyTop = 0, ! 47: JustifyBottom, ! 48: } BANK_JUST; ! 49: ! 50: /**************************************************************************\ ! 51: * ! 52: * Specifies which window is to be mapped by two-window bank handler. ! 53: * ! 54: \**************************************************************************/ ! 55: ! 56: typedef enum { ! 57: MapSourceBank = 0, ! 58: MapDestBank, ! 59: } BANK_JUST; ! 60: ! 61: /**************************************************************************\ ! 62: * ! 63: * Bank clipping info ! 64: * ! 65: \**************************************************************************/ ! 66: ! 67: typedef struct { ! 68: RECTL rclBankBounds; // describes pixels addressable in this bank ! 69: ULONG ulBankOffset; // offset of bank start from bitmap start, if ! 70: // the bitmap were linearly addressable ! 71: } BANK_INFO, *PBANK_INFO; ! 72: ! 73: /**************************************************************************\ ! 74: * ! 75: * Bank control function vector ! 76: * ! 77: \**************************************************************************/ ! 78: ! 79: typedef VOID (*PFN_PlanarEnable)(); ! 80: typedef VOID (*PFN_PlanarDisable)(); ! 81: typedef VOID (*PFN_PlanarControl)(PPDEV, ULONG, BANK_JUST); ! 82: typedef VOID (*PFN_PlanarControl2)(PPDEV, ULONG, BANK_JUST, ULONG); ! 83: typedef VOID (*PFN_PlanarNext)(PPDEV); ! 84: typedef VOID (*PFN_PlanarNext2)(PPDEV, ULONG); ! 85: typedef VOID (*PFN_BankControl)(PPDEV, ULONG, BANK_JUST); ! 86: typedef VOID (*PFN_BankControl2)(PPDEV, ULONG, BANK_JUST, ULONG); ! 87: typedef VOID (*PFN_BankNext)(PPDEV); ! 88: typedef VOID (*PFN_BankNext2)(PPDEV, ULONG); ! 89: ! 90: /**************************************************************************\ ! 91: * ! 92: * Miscellaneous driver flags ! 93: * ! 94: \**************************************************************************/ ! 95: ! 96: #define DRIVER_PLANAR_CAPABLE 0x01L ! 97: #define DRIVER_USE_OFFSCREEN 0x02L // if not set, don't use offscreen memory ! 98: // for long operations (because the ! 99: // memory won't be refreshed) ! 100: #define DRIVER_HAS_OFFSCREEN 0x04L // if not set, can't use any offscreen ! 101: // memory ! 102: ! 103: /**************************************************************************\ ! 104: * ! 105: * Bank status flags ! 106: * ! 107: \**************************************************************************/ ! 108: ! 109: #define BANK_BROKEN_RASTER1 0x01L // If bank1 or read bank has broken raster ! 110: #define BANK_BROKEN_RASTER2 0x02L // If bank2 or write bank has broken raster ! 111: #define BANK_BROKEN_RASTERS (BANK_BROKEN_RASTER1 | BANK_BROKEN_RASTER2) ! 112: #define BANK_PLANAR 0x04L // If in planar mode ! 113: ! 114: /**************************************************************************\ ! 115: * ! 116: * Structure for maintaining a realized brush: ! 117: * ! 118: \**************************************************************************/ ! 119: ! 120: extern const ULONG gaaulPlanarPat[][8]; // Hatch brushes in preferred format ! 121: ! 122: #define RBRUSH_BLACKWHITE 0x001L // Black and white brush ! 123: #define RBRUSH_2COLOR 0x002L // 2 color brush ! 124: #define RBRUSH_NCOLOR 0x004L // n color brush ! 125: #define RBRUSH_4PELS_WIDE 0x008L // Brush is 4xN ! 126: ! 127: #define BRUSH_SIZE 64 // An 8x8 8bpp brush needs 64 bytes ! 128: #define BRUSH_MAX_CACHE_SIZE 330 // Maximum brush cache size (chose 330 ! 129: // so that BRUSHCACHEENTRY array ! 130: // would fit entirely in 1 page) ! 131: ! 132: typedef struct _RBRUSH ! 133: { ! 134: FLONG fl; // Flags ! 135: LONG xBrush; // Realized brush's x brush origin ! 136: ! 137: // Info for 2 color brushes: ! 138: ! 139: ULONG ulFgColor; // Foreground color ! 140: ULONG ulBkColor; // Background color ! 141: ! 142: // Info for n color brushes: ! 143: ! 144: LONG cy; // Height of pattern ! 145: LONG cyLog2; // log2 of the height ! 146: LONG iCache; // Cache entry index. Zero is not ! 147: // a valid index. ! 148: ! 149: // Pattern in preferred format: ! 150: ! 151: ULONG aulPattern[BRUSH_SIZE / sizeof(ULONG)]; ! 152: ! 153: } RBRUSH; /* rb */ ! 154: ! 155: typedef struct _BRUSHCACHEENTRY ! 156: { ! 157: RBRUSH* prbVerifyRealization; // We never dereference this pointer ! 158: // to find a brush realization; ! 159: // it is only ever used in a compare ! 160: // to verify that for a realized brush, ! 161: // its off-screen cache entry is still ! 162: // valid. ! 163: LONG yCache; // Scan where entry's bits live ! 164: LONG ulCache; // Offset to cache entry from screen ! 165: // start (assuming planar format -- ! 166: // if you want the non-planar offset, ! 167: // multiply by 4) ! 168: ! 169: } BRUSHCACHEENTRY; /* bce */ ! 170: ! 171: /**************************************************************************\ ! 172: * ! 173: * Physical device data structure ! 174: * ! 175: \**************************************************************************/ ! 176: ! 177: // *********************************************************** ! 178: // *** MUST match the assembler version in i386\driver.inc *** ! 179: // *********************************************************** ! 180: ! 181: typedef struct _PDEV ! 182: { ! 183: FLONG fl; // Driver flags (DRIVER_xxx) ! 184: HANDLE hDriver; // Handle to \Device\Screen ! 185: HDEV hdevEng; // Engine's handle to PDEV ! 186: HSURF hsurfEng; // Engine's handle to surface ! 187: HANDLE hsurfBm; // Handle to the "punt" surface ! 188: SURFOBJ* pSurfObj; // pointer to the locked "punt" surface ! 189: ! 190: HPALETTE hpalDefault; // Handle to the default palette for device. ! 191: ! 192: PBYTE pjScreen; // This is pointer to base screen address ! 193: ULONG cxScreen; // Visible screen width ! 194: ULONG cyScreen; // Visible screen height ! 195: ULONG ulMode; // Mode the mini-port driver is in. ! 196: LONG lDeltaScreen; // Distance from one scan to the next. ! 197: ! 198: FLONG flRed; // For bitfields device, Red Mask ! 199: FLONG flGreen; // For bitfields device, Green Mask ! 200: FLONG flBlue; // For bitfields device, Blue Mask ! 201: ULONG ulBitCount; // # of bits per pel -- can be only 8 ! 202: ! 203: DDAOBJ* pdda; // DDA drawing object for trapezoids ! 204: ! 205: GDIINFO* pGdiInfo; // Pointer to temporary buffer for GDIINFO struct ! 206: DEVINFO* pDevInfo; // Pointer to temporary buffer for DEVINFO struct ! 207: ! 208: ULONG ulrm0_wmX; // Four values (one per byte) to set ! 209: // GC5 to to select read mode 0 ! 210: // together with write modes 0-3 ! 211: ! 212: BYTE* pjGlyphFlipTableBase; // Base allocated address for flip ! 213: // table; the pointer we use is this ! 214: // pointer rounded up to the nearest ! 215: // 256-byte boundary ! 216: BYTE* pjGlyphFlipTable; // Pointer to table used to flip glyph ! 217: // bits 0-3 and 4-7 ! 218: PALETTEENTRY* pPal; // If this is pal managed, this is the pal ! 219: ! 220: // Off screen save stuff: ! 221: ! 222: HBITMAP hbmTmp; // Handle to temporary buffer ! 223: SURFOBJ* psoTmp; // Temporary surface ! 224: PVOID pvTmp; // Pointer to temporary buffer ! 225: ULONG cyTmp; // # of scans in temporary surface ! 226: ! 227: // Brush cache: ! 228: ! 229: LONG iCache; // Index for next brush to be allocated ! 230: LONG iCacheLast; // Last valid cache index (so the ! 231: // number of entries in cache is ! 232: // iCacheLast + 1) ! 233: BRUSHCACHEENTRY* pbceCache; // Pointer to allocated cache ! 234: ! 235: // Bank manager stuff common between planar and non-planar modes: ! 236: ! 237: LONG cTotalScans; // Number of usable on and off-screen ! 238: // scans ! 239: PVIDEO_BANK_SELECT pBankInfo; // Bank info for current mode returned ! 240: // by miniport ! 241: ! 242: FLONG flBank; // Flags for current bank state ! 243: ! 244: ULONG ulBitmapSize; // Length of bitmap if there were no ! 245: // banking, in CPU addressable bytes ! 246: ULONG ulWindowBank[2]; // Current banks mapped into windows ! 247: // 0 & 1 ! 248: PVOID pvBitmapStart; // Single-window bitmap start pointer ! 249: // (adjusted as necessary to make ! 250: // window map in at proper offset) ! 251: PVOID pvBitmapStart2Window[2];// Double-window window 0 and 1 bitmap ! 252: // start ! 253: ! 254: // Non-planar mode specific bank management control stuff: ! 255: ! 256: VIDEO_BANK_TYPE vbtBankingType; // Type of banking ! 257: PFN pfnBankSwitchCode; // Pointer to bank switch code ! 258: ! 259: LONG lNextScan; // Offset to next bank in bytes ! 260: BYTE* pjJustifyTopBank; // Pointer to lookup table for ! 261: // converting scans to banks ! 262: BANK_INFO* pbiBankInfo; // Array of bank clip info ! 263: ULONG ulJustifyBottomOffset; // # of scans from top to bottom ! 264: // of bank, for bottom justifying ! 265: ULONG iLastBank; // Index of last valid bank in ! 266: // pbiBankInfo table ! 267: ULONG ulBank2RWSkip; // Offset from one bank index to next ! 268: // to make two 32K banks appear to be ! 269: // one seamless 64K bank ! 270: ! 271: PFN_BankControl pfnBankControl; // Pointer to bank control function ! 272: PFN_BankControl2 pfnBankControl2Window; // Pointer to double-window bank ! 273: // control function ! 274: PFN_BankNext pfnBankNext; // Pointer to next bank function ! 275: PFN_BankNext2 pfnBankNext2Window; // Pointer to double-window next ! 276: // bank function ! 277: ! 278: RECTL rcl1WindowClip; // Single-window banking clip rect ! 279: RECTL rcl2WindowClip[2]; // Double-window banking clip rects for ! 280: // windows 0 & 1 ! 281: ! 282: // Planar mode specific bank management control stuff: ! 283: ! 284: VIDEO_BANK_TYPE vbtPlanarType; // Type of planar banking ! 285: ! 286: PFN pfnPlanarSwitchCode; // Pointer to planar bank switch ! 287: // code ! 288: ! 289: LONG lPlanarNextScan; // Offset to next planar bank in ! 290: // bytes ! 291: BYTE* pjJustifyTopPlanar; // Pointer to lookup table for ! 292: // converting scans to banks ! 293: BANK_INFO* pbiPlanarInfo; // Array of bank clip info ! 294: ULONG ulPlanarBottomOffset;// # of scans from top to bottom ! 295: // of bank, for bottom justifying ! 296: ULONG iLastPlanar; // Index of last valid bank in ! 297: // pbiPlanarInfo table ! 298: ULONG ulPlanar2RWSkip; // Offset from one bank index to next ! 299: // to make two 32K banks appear to be ! 300: // one seamless 64K bank ! 301: ! 302: PFN_PlanarControl pfnPlanarControl; // Planar one window bank control ! 303: PFN_PlanarControl2 pfnPlanarControl2; // Planar two window bank control ! 304: ! 305: PFN_PlanarNext pfnPlanarNext; // Planar one window next bank ! 306: PFN_PlanarNext2 pfnPlanarNext2; // Planar two window next bank ! 307: ! 308: RECTL rcl1PlanarClip; // Single-window banking clip rect ! 309: RECTL rcl2PlanarClip[2]; // Double-window banking clip rects for ! 310: // windows 0 & 1 ! 311: ! 312: PFN_PlanarEnable pfnPlanarEnable; // Function to enable planar mode ! 313: PFN_PlanarDisable pfnPlanarDisable; // Function to disable planar mode ! 314: ! 315: // Smart bank manager stuff: ! 316: ! 317: LONG iLastScan; // Last scan we want to enumerate ! 318: PVOID pvSaveScan0; // Surface's original pvScan0 ! 319: RECTL rclSaveBounds; // Clip Object's original bounds ! 320: CLIPOBJ* pcoNull; // Points to an empty clip object ! 321: // we can use when we're given a ! 322: // NULL CLIPOBJ pointer ! 323: BYTE iSaveDComplexity; // Clip Object's original complexity ! 324: BYTE fjSaveOptions; // Clip Object's original flags ! 325: BYTE ajFiller[2]; // Pack dword alignment ! 326: ! 327: // NOTE: This stuff must come at the end of the structure, so that we don't ! 328: // have to declare an array size in the ASM version: ! 329: ! 330: ULONG cPatterns; // Count of bitmap patterns created ! 331: HBITMAP ahbmPat[HS_DDI_MAX]; // Engine handles to standard patterns ! 332: }; /* pdev */ ! 333: ! 334: // Palette stuff: ! 335: ! 336: #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256)) ! 337: ! 338: // Size of the driver extra information in the DEVMODe structure passed ! 339: // to and from the display driver ! 340: ! 341: #define DRIVER_EXTRA_SIZE 0 ! 342: ! 343: // When calling vEnumStart, make sure you set bAll to FALSE. This will tell ! 344: // the Engine to only enumerate rectangles in rclBounds. ! 345: ! 346: // Hooks and Driver function table. ! 347: ! 348: #define HOOKS_BMF8BPP (HOOK_BITBLT | HOOK_TEXTOUT | HOOK_FILLPATH | \ ! 349: HOOK_COPYBITS | HOOK_STROKEPATH | HOOK_PAINT | \ ! 350: HOOK_STRETCHBLT) ! 351: ! 352: #define BB_RECT_LIMIT 50 ! 353: ! 354: typedef struct _BBENUM ! 355: { ! 356: ULONG c; ! 357: RECTL arcl[BB_RECT_LIMIT]; ! 358: } BBENUM; ! 359: ! 360: typedef struct _BBENUMTRAP ! 361: { ! 362: ULONG c; ! 363: TRAPEZOID atrap[BB_RECT_LIMIT]; ! 364: } BBENUMTRAP; ! 365: ! 366: #define MAX_DDA_RECTS 50 // most rects we want enumerated by DDAOBJ at once ! 367: ! 368: typedef struct _DDAENUM ! 369: { ! 370: LONG yTop; ! 371: LONG yBottom; ! 372: LONG axPairs[MAX_DDA_RECTS]; ! 373: } DDAENUM; ! 374: ! 375: #define TO_RECT_LIMIT 20 ! 376: ! 377: typedef struct _TEXTENUM ! 378: { ! 379: ULONG c; ! 380: RECTL arcl[TO_RECT_LIMIT]; ! 381: } TEXTENUM; ! 382: ! 383: // Initialization stuff: ! 384: ! 385: BOOL bEnableBanking(PPDEV); ! 386: VOID vDisableBanking(PPDEV); ! 387: BOOL bInitPDEV(PPDEV,PDEVMODEW); ! 388: BOOL bInitSURF(PPDEV,BOOL); ! 389: BOOL bInitPaletteInfo(PPDEV); ! 390: BOOL bInit256ColorPalette(PPDEV); ! 391: BOOL bInitPatterns(PPDEV, INT); ! 392: VOID vInitBrushCache(PPDEV); ! 393: VOID vDisablePalette(PPDEV); ! 394: VOID vDisablePatterns(PPDEV); ! 395: VOID vDisableSURF(PPDEV); ! 396: VOID vDisableBrushCache(PPDEV); ! 397: VOID vResetBrushCache(PPDEV); ! 398: VOID vInitRegs(PPDEV); ! 399: DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); ! 400: ! 401: // Smart bank manager stuff: ! 402: ! 403: CLIPOBJ* pcoBankStart(PPDEV, RECTL*, SURFOBJ*, CLIPOBJ*); ! 404: BOOL bBankEnum(PPDEV, SURFOBJ*, CLIPOBJ*); ! 405: VOID vBankStartBltSrc(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*); ! 406: BOOL bBankEnumBltSrc(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*); ! 407: VOID vBankStartBltDest(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*); ! 408: BOOL bBankEnumBltDest(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*); ! 409: ! 410: // Fill routines: ! 411: ! 412: typedef union _RBRUSH_COLOR { ! 413: RBRUSH* prb; ! 414: ULONG iSolidColor; ! 415: } RBRUSH_COLOR; /* rbc */ ! 416: ! 417: typedef VOID (*PFNFILL)(PPDEV, ULONG, PRECTL, MIX, RBRUSH_COLOR, POINTL*); ! 418: ! 419: VOID vTrgBlt(PPDEV, ULONG, PRECTL, MIX, RBRUSH_COLOR, POINTL*); ! 420: VOID vMonoPat(PPDEV, ULONG, PRECTL, MIX, RBRUSH_COLOR, POINTL*); ! 421: VOID vColorPat(PPDEV, ULONG, PRECTL, MIX, RBRUSH_COLOR, POINTL*); ! 422: ! 423: // Other prototypes: ! 424: ! 425: BOOL b2ColorBrush(ULONG* pvBits, BYTE* pjFgColor, BYTE* pjBkColor); ! 426: VOID vPlanarCopyBits(PPDEV, RECTL*, POINTL*); ! 427: BOOL bIntersectRect(RECTL*, RECTL*, RECTL*); ! 428: VOID vSetWriteModes(ULONG *); ! 429: VOID vClearMemDword(PULONG * pulBuffer, ULONG ulDwordCount); ! 430: VOID vSrcCopy8bpp(PPDEV, RECTL*, POINTL*, LONG, VOID*); ! 431: VOID vFastLine(PPDEV, PATHOBJ*, LONG, ULONG); ! 432: ! 433: #endif // _DRIVER_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.