File:  [WindowsNT SDKs] / ntddk / src / video / displays / vga256 / pattern.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:31:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntddk-nov-1993, HEAD
Microsoft Windows NT Build 511 (DDK SDK) 11-01-1993

/******************************Module*Header*******************************\
* Module Name: pattern.c
*
* Used for creating and destroying the default patterns to be used on this
* device.
*
* Copyright (c) 1992 Microsoft Corporation
\**************************************************************************/

#include "driver.h"

/******************************Public*Data*Struct*************************\
* gaajPat
*
* These are the standard patterns defined Windows, they are used to produce
* hatch brushes, grey brushes etc.
*
\**************************************************************************/

const ULONG gaaulPat[HS_DDI_MAX][8] = {

// Scans have to be DWORD aligned:

    { 0x00,                // ........     HS_HORIZONTAL 0
      0x00,                // ........
      0x00,                // ........
      0xff,                // ********
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x00 },              // ........

    { 0x08,                // ....*...     HS_VERTICAL 1
      0x08,                // ....*...
      0x08,                // ....*...
      0x08,                // ....*...
      0x08,                // ....*...
      0x08,                // ....*...
      0x08,                // ....*...
      0x08 },              // ....*...

    { 0x80,                // *.......     HS_FDIAGONAL 2
      0x40,                // .*......
      0x20,                // ..*.....
      0x10,                // ...*....
      0x08,                // ....*...
      0x04,                // .....*..
      0x02,                // ......*.
      0x01 },              // .......*

    { 0x01,                // .......*     HS_BDIAGONAL 3
      0x02,                // ......*.
      0x04,                // .....*..
      0x08,                // ....*...
      0x10,                // ...*....
      0x20,                // ..*.....
      0x40,                // .*......
      0x80 },              // *.......

    { 0x08,                // ....*...     HS_CROSS 4
      0x08,                // ....*...
      0x08,                // ....*...
      0xff,                // ********
      0x08,                // ....*...
      0x08,                // ....*...
      0x08,                // ....*...
      0x08 },              // ....*...

    { 0x81,                // *......*     HS_DIAGCROSS 5
      0x42,                // .*....*.
      0x24,                // ..*..*..
      0x18,                // ...**...
      0x18,                // ...**...
      0x24,                // ..*..*..
      0x42,                // .*....*.
      0x81 },              // *......*

    { 0x81,                // *......*     HS_FDIAGONAL1 6
      0x60,                // .**.....
      0x18,                // ...**...
      0x06,                // .....**.
      0x81,                // *......*
      0x60,                // .**.....
      0x18,                // ...**...
      0x06 },              // .....**.

    { 0x81,                // *......*     HS_BDIAGONAL1 7
      0x06,                // .....**.
      0x18,                // ...**...
      0x60,                // .**.....
      0x81,                // *......*
      0x06,                // .....**.
      0x18,                // ...**...
      0x60 },              // .**.....

    { 0xFF,                // ********     HS_SOLID 8
      0xFF,                // ********
      0xFF,                // ********
      0xFF,                // ********
      0xFF,                // ********
      0xFF,                // ********
      0xFF,                // ********
      0xFF },              // ********

    { 0x38,                // ..***...     HS_DENSE1 9
      0x7c,                // .*****..
      0x7c,                // .*****..
      0x38,                // ..***...
      0x83,                // *.....**
      0xc7,                // **...***
      0xc7,                // **...***
      0x83 },              // *.....**

    { 0x38,                // ..***...     HS_DENSE2 10
      0x6c,                // .**.**..
      0x54,                // .*.*.*..
      0x38,                // ..***...
      0x83,                // *.....**
      0xc6,                // **...**.
      0x45,                // .*...*.*
      0x83 },              // *.....**

    { 0x18,                // ...**...     HS_DENSE3 11
      0x3c,                // ..****..
      0x34,                // ..**.*..
      0x18,                // ...**...
      0x81,                // *......*
      0xc3,                // **....**
      0x43,                // .*....**
      0x81 },              // *......*

    { 0x18,                // ...**...     HS_DENSE4 12
      0x2c,                // ..*.**..
      0x24,                // ..*..*..
      0x18,                // ...**...
      0x81,                // *......*
      0xc1,                // **....*.
      0x42,                // .*....*.
      0x81 },              // *......*

    { 0x10,                // ...*....     HS_DENSE5 13
      0x38,                // ..***...
      0x28,                // ..*.*...
      0x10,                // ...*....
      0x01,                // .......*
      0x83,                // *.....**
      0x82,                // *.....*.
      0x01 },              // .......*

    { 0x00,                // ........     HS_DENSE6 14
      0x10,                // ...*....
      0x38,                // ..***...
      0x10,                // ...*....
      0x00,                // ........
      0x01,                // .......*
      0x83,                // *.....**
      0x01 },              // .......*

    { 0x00,                // ........     HS_DENSE7 15
      0x10,                // ...*....
      0x30,                // ..**....
      0x00,                // ........
      0x00,                // ........
      0x01,                // .......*
      0x03,                // ......**
      0x00 },              // ........

    { 0x00,                // ........     HS_DENSE8 16
      0x00,                // ........
      0x20,                // ..*.....
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x02,                // ......*.
      0x00 },              // ........

    { 0x00,                // ........     HS_NOSHADE 17
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x00,                // ........
      0x00 },              // ........

    { 0xAA,                // *.*.*.*.     HS_HALFTONE 18
      0x55,                // .*.*.*.*
      0xAA,                // *.*.*.*.
      0x55,                // .*.*.*.*
      0xAA,                // *.*.*.*.
      0x55,                // .*.*.*.*
      0xAA,                // *.*.*.*.
      0x55 }               // .*.*.*.*
};

// Same pattern, repeated in planar format:

const ULONG gaaulPlanarPat[HS_DDI_MAX][8] = {
    { 0x0000,              // ........     HS_HORIZONTAL 0
      0x0000,              // ........
      0x0000,              // ........
      0xffff,              // ********
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0000 },            // ........

    { 0x0110,              // ....*...     HS_VERTICAL 1
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110 },            // ....*...

    { 0x1001,              // *.......     HS_FDIAGONAL 2
      0x2002,              // .*......
      0x4004,              // ..*.....
      0x8008,              // ...*....
      0x0110,              // ....*...
      0x0220,              // .....*..
      0x0440,              // ......*.
      0x0880 },            // .......*

    { 0x0880,              // .......*     HS_BDIAGONAL 3
      0x0440,              // ......*.
      0x0220,              // .....*..
      0x0110,              // ....*...
      0x8008,              // ...*....
      0x4004,              // ..*.....
      0x2002,              // .*......
      0x1001 },            // *.......

    { 0x0110,              // ....*...     HS_CROSS 4
      0x0110,              // ....*...
      0x0110,              // ....*...
      0xffff,              // ********
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110,              // ....*...
      0x0110 },            // ....*...

    { 0x1881,              // *......*     HS_DIAGCROSS 5
      0x2442,              // .*....*.
      0x4224,              // ..*..*..
      0x8118,              // ...**...
      0x8118,              // ...**...
      0x4224,              // ..*..*..
      0x2442,              // .*....*.
      0x1881 },            // *......*

    { 0x1881,              // *......*     HS_FDIAGONAL1 6
      0x6006,              // .**.....
      0x8118,              // ...**...
      0x0660,              // .....**.
      0x1881,              // *......*
      0x6006,              // .**.....
      0x8118,              // ...**...
      0x0660 },            // .....**.

    { 0x1881,              // *......*     HS_BDIAGONAL1 7
      0x0660,              // .....**.
      0x8118,              // ...**...
      0x6006,              // .**.....
      0x1881,              // *......*
      0x0660,              // .....**.
      0x8118,              // ...**...
      0x6006 },            // .**.....

    { 0xffff,              // ********     HS_SOLID 8
      0xffff,              // ********
      0xffff,              // ********
      0xffff,              // ********
      0xffff,              // ********
      0xffff,              // ********
      0xffff,              // ********
      0xffff },            // ********

    { 0xc11c,              // ..***...     HS_DENSE1 9
      0xe33e,              // .*****..
      0xe33e,              // .*****..
      0xc11c,              // ..***...
      0x1cc1,              // *.....**
      0x3ee3,              // **...***
      0x3ee3,              // **...***
      0x1cc1 },            // *.....**

    { 0xc11c,              // ..***...     HS_DENSE2 10
      0x6336,              // .**.**..
      0xa22a,              // .*.*.*..
      0xc11c,              // ..***...
      0x1cc1,              // *.....**
      0x3663,              // **...**.
      0x2aa2,              // .*...*.*
      0x1cc1 },            // *.....**

    { 0x8118,              // ...**...     HS_DENSE3 11
      0xc33c,              // ..****..
      0xc22c,              // ..**.*..
      0x8118,              // ...**...
      0x1881,              // *......*
      0x3cc3,              // **....**
      0x2cc2,              // .*....**
      0x1881 },            // *......*

    { 0x8118,              // ...**...     HS_DENSE4 12
      0x4334,              // ..*.**..
      0x4224,              // ..*..*..
      0x8118,              // ...**...
      0x1881,              // *......*
      0x3883,              // **....*.
      0x2442,              // .*....*.
      0x1881 },            // *......*

    { 0x8008,              // ...*....     HS_DENSE5 13
      0xc11c,              // ..***...
      0x4114,              // ..*.*...
      0x8008,              // ...*....
      0x0880,              // .......*
      0x1cc1,              // *.....**
      0x1441,              // *.....*.
      0x0880 },            // .......*

    { 0x0000,              // ........     HS_DENSE6 14
      0x8008,              // ...*....
      0xc11c,              // ..***...
      0x8008,              // ...*....
      0x0000,              // ........
      0x0880,              // .......*
      0x1cc1,              // *.....**
      0x0880 },            // .......*

    { 0x0000,              // ........     HS_DENSE7 15
      0x8008,              // ...*....
      0xc00c,              // ..**....
      0x0000,              // ........
      0x0000,              // ........
      0x0880,              // .......*
      0x0cc0,              // ......**
      0x0000 },            // ........

    { 0x0000,              // ........     HS_DENSE8 16
      0x0000,              // ........
      0x4004,              // ..*.....
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0440,              // ......*.
      0x0000 },            // ........

    { 0x0000,              // ........     HS_NOSHADE 17
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0000,              // ........
      0x0000 },            // ........

    { 0x5555,              // *.*.*.*.     HS_HALFTONE 18
      0xaaaa,              // .*.*.*.*
      0x5555,              // *.*.*.*.
      0xaaaa,              // .*.*.*.*
      0x5555,              // *.*.*.*.
      0xaaaa,              // .*.*.*.*
      0x5555,              // *.*.*.*.
      0xaaaa }             // .*.*.*.*
};


/******************************Public*Routine******************************\
* bInitPatterns
*
* This routine initializes the default patterns.
*
\**************************************************************************/

BOOL bInitPatterns(IN PPDEV ppdev, INT cPatterns)
{
    SIZEL           sizl;
    INT             iLoop;

    sizl.cx = 8;
    sizl.cy = 8;

    for (iLoop = 0; iLoop < cPatterns; iLoop++)
    {
        ppdev->ahbmPat[iLoop] = EngCreateBitmap(sizl,
                                                4,          // DWORD aligned
                                                BMF_1BPP,
                                                BMF_TOPDOWN,
                                                (PULONG) &gaaulPat[iLoop][0]);

        if (ppdev->ahbmPat[iLoop] == (HBITMAP) 0)
        {
        // Set the count created so vDisablePatterns will clean up.

            ppdev->cPatterns = iLoop;
            return(FALSE);
        }
    }

    ppdev->cPatterns = cPatterns;
    return(TRUE);
}

/******************************Public*Routine******************************\
* vDisablePatterns
*
* Delete the standard patterns allocated.
*
\**************************************************************************/

VOID vDisablePatterns(IN PPDEV ppdev)
{
    ULONG ulIndex;

// Erase all patterns.

    for (ulIndex = 0; ulIndex < ppdev->cPatterns; ulIndex++)
    {
        EngDeleteSurface((HSURF) ppdev->ahbmPat[ulIndex]);
    }
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.