Borland Turbo Pascal / Turbo C BGI Driver for TIGA V1.10 Graphics Interface =========================================================================== (C) Copyright 1990 by Tree Soft Systems Rolf Bartz, West Germany Annastrae 2b, D-5102 Wrselen, Fax: +49 2405 94986 BGIDEMO program (C) Copyright 1988 by Borland International, Inc. Used with kind permission of Borland International, Inc. The following files are on your disk: TIGA.BGI BGI driver for TIGA V1.10 graphics interface BGIPRIMS.RLM User extended primitives for TIGA BGI BGIDEMO.EXE Demonstration program for BGI drivers READMEGR.DOC German documentation READMEUS.DOC English documentation Supported Graphics Cards ======================== This BGI driver supports ALL graphics cards that implement TIGA version 1.10. The resolution and number of colors is dynamic and set externally by the user. The BGI driver automatically adapts to the selected mode. For installation of the TIGA interface see the manual of your graphics card. There is also documented how to switch between different modes (with TIGAMODE). TIGA.BGI BGI Driver =================== This BGI driver supports ALL available TIGA video modes with a maximum resolution of 16384x16384 and 256 colors. The driver recognizes the with TIGACD or TIGAMODE selected default mode. All other modes are alternatively available. Please remember to set the TIGA environment variable, otherwise several TIGA system files and system programs are not found. The meaning of the several options is described in your TIGA manual. The line SET TIGA=-mC:\TIGA\SYSTEM -lC:\TIGA\LIBRARY -i0x7F for example sets the TIGA system directory to C:\TIGA\SYSTEM, the TIGA library directory to C:\TIGA\LIBRARY, and the interrupt level to INT 7FH. In the TIGA system directory all the TIGA system programs must be located, especially TIGALNK.EXE. In the library directory the TIGA library modules must be located, especially EXTPRIMS.RLM and BGIPRIMS.RLM. It is important, that during the initialization of the TIGA driver the accompanying module BGIPRIMS.RLM is in the current directory or in the TIGA library directory. It is strongly recommended to copy this module to the TIGA library directory. If more than one TIGA card is installed in the system, then more than one TIGA communication driver (TIGACD.EXE) can be installed in parallel, where each TIGACD must have a different interrupt level. But the handling is very circum- stantial (at least in a single tasking environment), because at a given time only one environment variable can be set, so only one driver can be active. In a multitasking environment different processes easily can access different TIGA cards. The assignments of TIGA modes to BGI mode numbers are as follows: Mode Card ---- ---------------------------------------------------------------------- 1 Default mode of TIGA card 2 first available mode for TIGA card ... ... n+1 last (n-th) available mode for TIGA card So the BGI modus number 1 always uses the TIGA mode that the user has specified with TIAGCD or TIGAMODE at last. How to include the drivers in Turbo Pascal ========================================== For Turbo Pascal, you must include the following code in your program. Supported is Turbo Pascal version 5.x. var GraphDriver: integer; (* global variable for use with InitGraph *) GraphMode: integer; (* global variable for use with InitGraph *) TIGADriverMode: integer; (* global variable to hold TIGA mode *) (* AutoDetect function for TIGA driver. Each driver must have its own *) (* AutoDetect function. It is called by InitGraph and must return the mode *) (* number to be used if this driver shall get activated or grError if this *) (* driver is not going to be used. *) (*$F+*) function AutoDetectTIGA: integer (*$F-*); begin AutoDetectTIGA := TIGADriverMode end; procedure InitializeGraphics; var DriverNumber, ErrorCode: integer; begin (* ... other code ... *) (* Add TIGA driver to driver table and assign AutoDetect function. *) DriverNumber := InstallUserDriver ('TIGA', @AutoDetectTIGA); if GraphResult <> grOK then begin WriteLn ('Error installing BGI driver TIGA.'); Halt (1) end; (* If you want to register the TIGA driver and link it directly into your *) (* program, you must call RegisterBGIDriver exactly HERE. *) (* ... other code, perhaps load other drivers ... *) (* Init graphics mode, for example TIGA default mode *) GraphDriver := Detect; (* request autodetection *) TIGADriverMode := 1; (* enable TIGA driver in default mode *) (* ... other code, disable all other drivers ... *) (* At this time there must be at least about 48KB of free DOS memory *) (* available to execute the TIGA linker TIGALNK.EXE *) InitGraph (GraphDriver, GraphMode, ''); ErrorCode := GraphResult; if ErrorCode <> grOK then begin WriteLn ('Graphics error: ', GraphErrorMsg (ErrorCode)); Halt (1) end; (* ... other code ... *) end; How to include the drivers in Turbo C ===================================== For Turbo C, you must include the following code in your program. Supported is Turbo C version 2.0 and Turbo C++ version 1.0. int GraphDriver; /* global variable for use with InitGraph */ int GraphMode; /* global variable for use with InitGraph */ int TIGADriverMode; /* global variable to hold TIGA mode */ /* AutoDetect function for TIGA driver. Each driver must have its own */ /* AutoDetect function. It is called by InitGraph and must return the mode */ /* number to be used if this driver shall get activated or grError if this */ /* driver is not going to be used. */ int huge AutoDetectTIGA (void) { return (TIGADriverMode); } void InitializeGraphics (void) { int DriverNumber; int ErrorCode; /* ... other code ... */ /* Add TIGA driver to driver table and assign AutoDetect function. */ DriverNumber = installuserdriver ("TIGA", AutoDetectTIGA); if (graphresult () != grOk) { printf ("Error installing BGI driver TIGA.\n"); exit (1); }; /* If you want to register the TIGA driver and link it directly into your */ /* program, you must call registerbgidriver exactly HERE. */ /* ... other code, perhaps load other drivers ... */ /* Init graphics mode, for example TIGA16 default mode */ GraphDriver = DETECT; /* request autodetection */ TIGADriverMode = 1; /* enable TIGA driver in default mode */ /* ... other code, disable all other drivers ... */ /* At this time there must be at least about 48KB of free DOS memory */ /* available to execute the TIGA linker TIGALNK.EXE */ initgraph (&GraphDriver, &GraphMode, ""); ErrorCode = graphresult (); if (ErrorCode != grOk) { printf ("Graphics Error: %s\n", grapherrormsg (ErrorCode)); exit (1); }; /* ... other code ... */ } BGIDEMO BGI driver sample program ================================= This is a modified version of the BGIDEMO program shipped by Borland to demonstrate the features of their BGI drivers. It is adapted to support installable drivers. The usage is: BGIDEMO Driver [Mode [Option]] where Driver is the name of the driver (TIGA), and Mode is the requested mode number. If you omit Mode, you will get a list of all available modes. This feature only works with our BGI drivers. Option is special for TIGA drivers: it selects between the working modes "compatible" and "fast". Enter a "0" for compatible or a "1" for fast. Enhancements ============ All our BGI drivers have an "Info Mode": mode number 0. If you use the normal InitGraph procedure to start up the BGI driver in mode 0, the graphics system will be enabled, but there will be NO video mode switching. So you can use the GetModeRange procedure and the GetModeName function to get information about the supported video modes without actually switching to any mode. The special function GetModeName (0) returns the name of the driver, for example "BGI Driver TIGA V2.00". The TIGA driver has a second special function. The Borland Graphics Interface is designed for normal, "dumb" graphics cards. Many of the features of a fast graphics processor like the TMS34010 or an intelligent graphics interface like TIGA cannot be used. Therefore the driver has two working modes. The default mode is "compatible". Here the TIGA driver acts like all the other dumb BGI drivers. In the extended modes "TIGAxxx" special features of TIGA are used. These features increase the performence, but come hand in hand with some incompati- bilities. The following flags are available: TIGACircles: ------------ Draws circles, ellipses and arcs directly with TIGA instead of using the normal emulation routine. Therefore the function GetArcCoords does not work, it returns wrong values. TIGAPalette255: --------------- Normally the RGB parameters that are passed to the SetRGBPalette procedure are in the range 0..63, where 0 means no and 63 means maximum intensity. This is for compatibility to the standard VGA drivers, that can use only 6 bits for R, G and B. If you want to use all 8 bits, with this mode you can extend the range to 0..255. You select between the two modes with the procedure SetWriteMode. Declare the following constants in your program: const CompatibilityMode = $00 SHL 3; TIGACircles = $01 SHL 3; TIGAPalette255 = $02 SHL 3; Every time you call SetWriteMode you must add one of these constants to the parameter, for example: SetWriteMode (XORPut + TIGACircles + TIGAPalette255); (* selects write mode "XOR", fast circles and extended palette *) SetWriteMode (CopyPut + CompatibilityMode); (* selects write mode "Copy" and working mode "compatible" *) SetWriteMode (NOTPut); (* select write mode "NOT" and working mode "compatible" *) You can switch between the working modes at any time. ATTENTION: ---------- Every call to InitGraph or SetGraphMode resets the working mode to "compatible". So you must place an explicit SetWriteMode (CopyPut + TIGACircles) after every call to InitGraph and SetGraphMode if you want to use "fast circles" for example. Restrictions ============ In order for the BGI driver to work properly, the TIGA interface must be loaded. This normally is done by a device driver and/or a TSR program. They normally are included with your graphics card. To check whether TIGA is installed, initialize the BGI driver in info mode 0 and call GetMaxMode. Is only the info mode available, then there is no TIGA interface loaded. Arc, Circle, Ellipse, FillEllipse, PieSlice, Sector: ---------------------------------------------------- In "CompatibilityMode" these functions are executed using an emulation routine, in the mode "TIGACircles" they are passed directly to TIGA. The direct execution by TIGA is much faster than emulation, but the GetArcCoords does not work (see there). DetectGraph: ------------ This is an internal function of the Borland graphics interface. It cannot recognize TIGA cards, but instead calls all installed AutoDetect functions. FillPoly: --------- If the FillPoly function is to be executed directly by TIGA, then the TIGA graphics manager requires a workspace on the TIGA card, that is at least as large as a 1 bit deep bitmap of the same size as the screen. On some TIGA cards (especially those with minimum memory or extremly high resolutions) this amount of memory is not available. Then a slower emulation routine automatically is invoked. GetArcCoords: ------------- Due to a bug in the Borland graphics system this function is not passed to the BGI driver. Therefore it works only together with the emulation routine for circular and elliptic arcs. In the mode "TIGACircles" wrong values are returned. GetAspectRatio: --------------- The aspect ratio is recalculated by the TIGA driver for every mode. If GetMaxX <= GetMaxY then a screen ratio of 4:3 (landscape monitor) is assumed, else 3:4 (portrait monitor) is used. In some special cases this can lead to miscalculations, i.e. when 512x768 is displayed centered on a landscape monitor. GetDriverName: -------------- Due to a bug in the GRAPH unit the function GetDriverName returns an empty string when used in conjunction with user installable drivers. This occurs with Turbo Pascal only. GetPalette (Palette), GetDefaultPalette (Palette): -------------------------------------------------- This function originally was designed for EGA and VGA cards in the 16 color modes. Due to a bug in the Borland graphics system the number of palette entries always MUST be 16+1. For sake of compatibility the TIGA driver here returns the default palette of an EGA/VGA card. See SetPalette, SetAllPalette. InitGraph, SetGraphMode: ------------------------ Please remember that every call to InitGraph or SetGraphMode resets the working mode of the TIGA driver to "CompatibilityMode". ATTENTION: During the call to InitGraph or SetGraphMode the following files are accessed: the TIGA linker TIGALNK.EXE, the TIGA graphics manager TIGAGM.OUT, the extended primitives EXTPRIMS.RLM and the BGI primitives BGIPRIMS.RLM. All these files must be installed properly. IMPORTANT: Because the TIGA modules are loaded at program run time, free DOS memory must be available to execute the TIGA linker TIGALNK.EXE as a child process. Most versions of TIGALNK.EXE need about 48KB. In Turbo Pascal you can achieve this by using the $M directive and reducing the heap size (Options/Compiler/Memory Sizes in the Turbo Pascal programming environment). InstallUserDriver: ------------------ This function adds the name of a BGI driver to an internal driver table of the Borland graphics interface. This function does NOT load the driver, this is done later by InitGraph (if the driver is not registered in the meantime). See the sample programs in the sections "How to include the drivers ...". OutText, OutTextXY: ------------------- The upper 128 characters of the DefaultFont are defined in a table pointed to by INT 1FH (this table is loaded by the DOS GRAFTABL command for example). These characters cannot be changed after initialization (InitGraph) of the TIGA driver, because for speed reasons they are copied to the TIGA card. DefaultFont character with CharSize 2 (16x16) and larger cannot be display in transparency mode by the TIGA interface. That means, the characters are drawn in the actual foreground color on a solid rectangle in the current background color. The current background color can be changed using SetBkColor. RegisterBGIDriver: ------------------ Also the TIGA driver can be linked directly into your program using the RegisterBGIDriver function. NEVERTHELESS you must use the InstallUserDriver function to add the name of the driver to the driver table. RegisterBGIDriver must be called AFTER InstallUserDriver and BEFORE InitGraph. The Turbo Pascal and Turbo C Reference Guides describe how to convert a BGI driver into an object file (using BINOBJ.EXE or BGIOBJ.EXE) and how to link an object file to a Pascal or C program. See the sample programs in the sections "How to include the drivers ...". ATTENTION: Only the BGI driver file TIGA.BGI can be linked to your program, the file BGIPRIMS.RLM will be searched for and read by the TIGA linker TIGALNK.EXE, therefore it must remain a normal file. But you should copy the BGIPRIMS.RLM to the TIGA library directory, so that it can easily be found. SetActivePage, SetVisualPage: ----------------------------- These functions are supported by the TIGA BGI, provided that multiple display pages are available. This depends on the TIGA card and on resolution and number of colors. Unfortunately there is no elegant way to check how many display pages are available. You must simply try it (for example using PutPixel and GetPixel). SetAllPalette (Palette): ------------------------ This function originally is designed for EGA/VGA cards in the 16 color modes. For compatibility's sake calls to SetAllPalette are automatically translated internally into calls to SetRGBPalette. Due to a bug in the Borland graphics system the number of palette entries in Palette always must be 16+1. The entries 0..15 change the lower 16 palette entries of the TIGA card. The colors given are based upon the 64 standard EGA colors (0..63). The TIGA palette then is set to the corresponding RGB values. The overscan color (entry #16) is ignored, because it cannot be set with TIGA. Remember: This is no EGA/VGA card, so direct EGA/VGA BIOS calls do NOT work. SetBkColor (Color): ------------------- With a CGA card and with some EGA/VGA cards this functions sets the overscan color. The overscan color cannot be set with TIGA. Please avoid using this function. In the original EGAVGA.BGI this function as an additional effect sets the palette entry #0 to Color. If you need to change this entry, do it using SetPalette (0, Color) instead. In the TIGA driver this function is used to set the background color for DefaultFont characters with CharSize 2 (16x16) and larger, because they cannot be display in transparency mode by the TIGA interface. That means, the characters are drawn in the actual foreground color on a solid rectangle in the current background color. This background color can be changed using SetBkColor. SetPalette (ColorIndex, Color): ------------------------------- This function originally is designed for EGA/VGA cards in the 16 color modes. For compatibility's sake calls to SetPalette are automatically translated internally into calls to SetRGBPalette. ColorIndex specifies the number of the entry to be changed. Ths Color given is based upon the 64 standard EGA colors (0..63). The TIGA palette then is set to the corresponding RGB value. Remember: This is no EGA/VGA card, so direct EGA/VGA BIOS calls do NOT work. SetRGBPalette (ColorIndex, RedValue, GreenValue, BlueValue): ------------------------------------------------------------ You should try to change the TIGA only with this function. ColorIndex is the number of the palette entry to be changed. RedValue, GreenValue and BlueValue are the components of the color to be set. Due to a bug in the original Borland EGAVGA.BGI there only the lower 6 bits of RedValue, GreenValue and BlueValue are used. So the value range is limited to 0..63. For compatibility's sake the TIGA driver uses the same range. But with the flag "TIGAPalette255" you can change the value range to 0..255 (see under "Enhancements"). Remember: This is no EGA/VGA card, so direct EGA/VGA BIOS calls do NOT work. SetWriteMode: ------------- With this function you can change the working mode of the TIGA driver. See under "Enhancements".