[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
The Driver Status Table

BGI requires that each driver contain a Driver Status Table (DST) to
determine the basic characteristics of the device that the driver
addresses. As an example, the DST for a CGA display is shown here:

STATUS STRUC
STAT    DB      0               ; Current Device Status (0 = No Errors)
DEVTYP  DB      0               ; Device Type Identifier (must be 0)
XRES    DW      639             ; Device Full Resolution in X Direction
YRES    DW      199             ; Device Full Resolution in Y Direction
XEFRES  DW      639             ; Device Effective X Resolution
YEFRES  DW      199             ; Device Effective Y Resolution
XINCH   DW      9000            ; Device X Size in inches*1000
YINCH   DW      7000            ; Device Y Size in inches*1000
ASPEC   DW      4500            ; Aspect Ratio = (y_size/x_size) * 10000
        DB      8h
        DB      8h              ; for compatibility, use these values
        DB      90h
        DB      90h
STATUS  ENDS

The BGI interface provides a system for reporting errors to the BGI Kernel
and to the higher level code developed using Borland's language packages.
This is done using the STAT field of the Driver Status Table. This field
should be filled in by the driver code if an error is detected during the
execution of the device installation (INSTALL). The following error codes
are predefined in include file GRAPHICS.H for Turbo C and in the Graphics
unit for Turbo Pascal.

   grOk               =   0     Normal Operation, No errors
   grNoInitGraph      =  -1
   grNotDetected      =  -2
   grFileNotFound     =  -3
   grInvalidDriver    =  -4
   grNoLoadMem        =  -5
   grNoScanMem        =  -6
   grNoFloodMem       =  -7
   grFontNotFound     =  -8
   grNoFontMem        =  -9
   grInvalidMode      = -10
   grError            = -11     Generic Driver Error
   grIOerror          = -12
   grInvalidFont      = -13
   grInvalidFontNum   = -14
   grInvalidDeviceNum = -15

The next field in the Device Status Table, DEVTYP, describes the class of
the device that the driver controls; for screen devices, this value is
always 0.

The next four fields, XRES, YRES, XEFRES, and YEFRES contain the number of
pixels available to BGI on this device in the horizontal and vertical
dimensions, minus one. For screen devices, XRES=XEFRES and YRES=YEFRES.
The XINCH and YINCH fields are the number of inches horizontally and
vertically into which the device's pixels are mapped, times 1000. These
fields in conjunction with XRES and YRES permit device resolution (DPI, or
dots per inch) calculation.

        Horizontal resolution (DPI) = (XRES+1) / (XINCH/1000)
        Vertical resolution (DPI)  = (YRES+1) / (YINCH/1000)

The ASPEC (aspect ratio) field is effectively a multiplier/divisor pair
(the divisor is always 10000) that is applied to Y coordinate values to
produce aspect-ratio adjusted images (e.g., round circles). For example,
an ASPEC field of 4500 implies that the application will have to transform
Y coordinates by the ratio 4500/10000 when drawing circles to that device
if it expects them to be round. Individual monitor variations may require
an additional adjustment by the application.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson