## Display Device Driver Reference for OS/2

[prev][next][parent][TOC]

### eddh_SrcDestBlt (EDDHBBLT.ASM)

The eddh_SrcDestBlt function handles BitBlts involving some source with the display as a destination. It iterates through multiple clip rectangles, copying from the source to the display. The source may be either monochrome or a bit map of the same color depth as the display. The source may be a system-memory bit map, a portion of the visible display (for example, a scroll box), or in VRAM in the bit-map cache. The following is a pseudocode version of eddh_SrcDestBlt:

    eddh_SrcDestBlt:
    //this first part is mostly for the software drawing version of this
    //routine, eddf_SrcDestBlt, although some of the hardware-drawing code
    //eventually reads details from the various shadows of the pixmaps.

    get the destination address
    set pixmapA = destination bit map parameters
    if expanding from monochrome source to color
            set pixmapC = source bit map parameters
    else
            set pixmapB = source bit map parameters

    do
            dec     CountOfClipRects
            if the blt intersects the clipping rectangle
                    set pattern map
                    set source map
                    set destination map
                    set pixel op
                    if source has VRAM marker
                            //source is in VRAM
                            call SrcSpecialist
                    else
                            //source is in system memory
                            call SoftSrcSpecialist
            get next clipping rectangle
    while CountOfClipRects > 0

The eddh_SrcDestBlt function rolls through the clipping rectangles passed in from the GRE, and for each rectangle (if the blt intersects it), the eddh_SrcDestBlt function calls either SrcSpecialist, if the source is the display, or SoftSrcSpecialist, if the source is a memory bit map. SrcSpecialist takes the arguments set up by eddh_SrcDestBlt, and performs a VRAM-to-VRAM blt. The arguments it takes are passed in XGA-style in the Shadow8514Regs. The following is an example:

    ; use ebx as a pointer to the destination bit-map header
            mov     ebx, AIxfer.pbmhDest

    ; convert destination bit map address to x and y for 8514
    hardware
            memregread      eax,dest_map
            mov     x_dst,ax
            ror     eax,16
            mov     y_dst,ax
            calc8514xy  [ebx].bit map_address
            add     x_dst,dx
            add     y_dst,ax

In this case, the X-Y coordinates of the destination are passed in the dest _map. Because the destination is the display, the bit map_address field of the AIxfer is set up with a dummy address in VRAM (this is why calc8514xy macro is used). Likewise, the source X-Y coordinates are passed in the source_map and AIxfer.pbmhSrc. AIxfer is a large union used throughout the driver to pass parameters from the high-level portions of the driver down to the various worker routines. For BitBlt, it is defined as type BITBLTPB , which is defined in the EDDHTYPE.H module. AIxfer holds pointers to the source and destination bit-map headers, the area of display affected by the blt (stored as rectangles), and parameters used by stretch blt.

Essentially, everything gets set up just as if the operation were going to occur on an XGA, and then the lowest level routines translate the parameters into a format appropriate to the display hardware.

SrcSpecialist handles operations such as scrolling, copying the contents of a window from one portion of the display to another, and copying bit maps out of the off-screen VRAM cache onto the display. It controls both color and monochrome bit maps, although this is not obvious from reading the code , because of idiosyncrasies of the 8514/A adapter. The 8514/A, and the S3 chip, treat monochrome data in VRAM as a rectangle of pels that occupies only a single plane. Only a few registers distinguish between blting a color or monochrome bit map from VRAM-to-VRAM. Most of these operations are hidden in TransferShadowRegisters. Many graphics accelerator chip sets do not support monochrome expansion from VRAM-to-VRAM at all. One of the most common uses of monochrome data is a mask for icons that are put on the display. When an icon is displayed on the desktop, the first operation that occurs is a monochrome mask that is ANDed onto the display. This operation creates a black hole on the desktop in the shape of the icon. The color portion of the icon bit map is then ORed in over this hole.

In the S3 driver, both the mask and the bit map will be in the cache. If your hardware does not support monochrome expansion from VRAM-to-VRAM, then make the following change to PixBltThroughClipsViaPhunk() in pixblt.c:

    original, about line 306:

    #ifdef BPP24
    if ( !pHWMap->vertical_bmaps ) {
    #endif
     if ( AIxfer.pbmhSrc->Info.Width <= VRAM_BM_CACHE_HOR_SIZE &&
          AIxfer.pbmhSrc->Info.Height <= VRAM_BM_CACHE_VERT_SIZE )
     #endif
     {
       if ( cache_bit map(AIxfer.pbmhSrc) )
       {
          // Caching the bit map may have corrupted some of the Color and Mix
          // Registers.  Restore them before calling PixBltThroughClips().
               TransferShadowRegisters( TSR_COLOUR_MIX );
               PixBltThroughClips();
               return;
       }
     }

    modified, for no cached monochrome maps:

    #ifdef BPP24
    if ( !pHWMap->vertical_bmaps ) {
    #endif
     if ( AIxfer.pbmhSrc->Info.Width <= VRAM_BM_CACHE_HOR_SIZE &&
          AIxfer.pbmhSrc->Info.Height <= VRAM_BM_CACHE_VERT_SIZE &&
          AIxfer.pbmhSrc->Info.BitCount != 1)
     #endif
     {
       if ( cache_bit map(AIxfer.pbmhSrc) )
       {
          // Caching the bit map may have corrupted some of the Color and Mix
          // Registers.  Restore them before calling PixBltThroughClips().
               TransferShadowRegisters( TSR_COLOUR_MIX );
               PixBltThroughClips();
               return;
       }
     }

Making this change to pixblt.c will prevent caching of monochrome bit maps and will be passed to SoftSrcSpecialist. SoftSrcSpecialist copies bit maps to the display in a variety of formats. When transferring color bit maps to the display, SoftSrcSpecialist uses the S3 pel-transfer register. At 8 bits-per-pel, it uses a memory-mapped version of the register for better performance. At 16 bits-per-pel, it swaps the bytes in each pel prior to writing the pel to the pel-transfer register. This is unnecessary, because the order of bytes written via the pixel transfer register can be swapped in hardware by simply setting a bit in one of the S3 registers. Thus, it is the extra work the driver is doing when it swaps bytes that is unnecessary. For further information, see 16-Bit-Per-Pel Support.) For monochrome data at 8-or 16-bits-per-pel, SoftSrcSpecialist copies the monochrome bit map through the pel transfer register. This is easier on the S3 chip than on the 8514/A as the S3 chip requires no special alignment of monochrome data. The drawing engine of the 86C80X and S3 Vision chips does not directly support packed 24 bit-color. Therefore, when expanding a monochrome bit map at 24-bits-per-pel, it calls Copy24MonoMixToVRAM, in HWACCESS.ASM. This routine processes monochrome expansion to 24-bit-color expansion in software by way of the S3 chip's aperture into video memory.