%OUTFILE TG.TPH
%DESCRIPTION Turbo Graphics Help

%0
 Turbo Graphics Help file for Turbo/Borland Pascal 7

%1
 I want help in find out what is wrong with this context (1).

This is a dummy screen for debugging, doesn't work properly for some
unknown reason (using my TPH compiler).

%2
 Turbo Graphics Contents
 

 Welcome to the

     -= Turbo Graphics =-

            On-Line Help for Turbo Pascal


Turbo Graphics is a full featured library for Turbo Pascal including:

   Drivers and unit for native SVGA card
    control, including support for accelerator
    functions in many of today's cards.
   A unit supplying many graphics primitives
    for drawing anything on a SVGA card.
   A unit for various font/text drawing.
   A unit for controlling the VGA palette and
    other colour operations.
   A unit with various memory control and
    management operations, including support
    for XMS and EMS memory.
   A virtual RAM screen unit, "VScreens", that
    allows all graphic operations to occur in
    RAM instead of normal video memory.
   A unit that displays various graphic files
    including:  PCX, BMP, GIF, TIFF, Targa,
    IFF/ILBM, ICO, FLI/FLC and TGI.
   A unit to support SVGA mouse cursors (and
    control - custom handlers can be linked in
    for other automated mouse operations.
   A unit providing a complete and sofisticated
    event handler, suitable for GUI applications.

Currently is only available for real mode programs.

In the next versions, the following support will be added:
   A sound unit
   A printer unit
   A games unit (inc. enhanced keyboard support)
   A 3D unit
   A multitasking GUI library

 General units in the library:
  ~TGProcs~:10
  ~TGDriver~:100
  ~TGraph~:200
  ~TGText~:300
  ~TGColour~:400
  ~TGMemory~:500
  ~TGVScrns~:600
  ~TGImage~:700
  ~TGMouse~:800
  ~TGEvents~:900

  ~Help, Bugs, Errors, Suggestions, etc~:3

%3
 Help, Bugs, Errors, Suggestions, etc.
 
If you need any help at all with Turbo Graphics, you can contact us at
our E-Mail address listed below, and we will give as much help as
possible, with no charge, registering or whatsoever.

If you find any bugs, errors, omissions, or anything of the kind, also
please contact us and report the error and the code that created this error
(or we won't be able to find it).  Spelling & grammar corrections for this
help file is also appreciated.

Also, as a final note, if you have any ideas or suggestions you would
like implemented in Turbo Graphics, please call also, as we strongly rely
on what other people think of this, and try to please all with this software.

Ways of contacting us:

E-Mail Addresses:

  naujok@barney.eng.monash.edu.au

"Snail" Mail:

  Barry Naujok
  40 Frederick Street
  Caulfield Sth,  Vic,  3162
  Australia

Telephone:

  61-3-578-7718


Thanks very much for looking at this software and hope it
satisfies your programming requirements,

%10
 TGProcs Unit
 
The TGProcs unit contains a set of general purpose types and routines
for the use in Turbo Graphics and other applications.

It does not rely on any other units.

 Procedures and functions:
  ~Abort~:11
  ~Processor~:12
  ~Protected~:13

  ~MultiTasker~:30
  ~TimeSlice~:31
  ~PreventSwitching~:32
  ~ResumeSwitching~:33
  ~MultiTaskerVersion~:34

  ~ReadKey~:14
  ~KeyPressed~:15
  ~Delay~:16
  ~Sound~:17
  ~NoSound~:18

  ~GetKey~:22
  ~SetTypematicRate~:23

  ~ExePath~:24
  ~NoExt~:25

  ~ColdBoot~:28
  ~WarmBoot~:29

  ~ScreenOn~:41
  ~ScreenOff~:42

  ~IPos~:45
  ~Lower~:46
  ~RScan~:47
  ~Scan~:48
  ~Upper~:49

  ~StrDel~:52
  ~StrIns~:50
  ~StrLIns~:51

 Types:
  ~PByte~:80
  ~PWord~:81
  ~PInt~:82
  ~PLongInt~:83
  ~AByte~:84
  ~AChar~:85
  ~AWord~:86
  ~AInt~:87
  ~ALongInt~:88

 Constants:
  ~kbXXX constants~:90

%11
 Abort (procedure)     ~(TGProcs Unit)~:10
 
Exits the program writing an error message (or whatever).

 Declaration:
  procedure Abort(msg:string);

 Remarks:
Abort restores text mode if the current video mode is not text and then
prints "msg" and exits the program.

%12
 Processor (function)     ~(TGProcs Unit)~:10
 
Returns the processor type in the computer.

 Declaration:
  function Processor:Byte;

 Remarks:
Processor returns the Intel CPU type installed in the computer that this
software is running on.  It does not provide exact details (such as whether
it is a SX or DX, clock speed, etc), but just the basic CPU type, suitable
for executing machine specific instuctions (in assembler).

 What is returns:
   8088    - 0
   8086    - 1
   80286   - 2
   80386   - 3
   i486    - 4
   Pentium - 5
   (and more when a Pentium assembler becomes available).

 See Also:
  ~Protected~:13

%13
 Protected (function)     ~(TGProcs Unit)~:10
 
Determines whether the computer is in Protected mode or Real mode.

 Declaration:
  function Protected:Boolean;

 Remarks:
Protected returns True if the computer (a 286 minimum) is currently
running in Protected mode or False if running in Real mode.

 See Also:
  ~Processor~:12

%30
 MultiTasker (function)     ~(TGProcs Unit)~:10
 
Returns what multitasker is active, if any

 Declaration:
  function MultiTasker:Byte;

 Remarks:
If no multitasker is active, MultiTasker returns 0, else it returns a value
according to the multitasker that is active"
  0 - No Multitasker is present
  1 - DesqView 2.26+
  2 - TaskView, TopView, OmniView and clones
  3 - DoubleDOS
  4 - Windows in 386 Enhanced mode (and Win386)

There are 5 constants for these values returned:
  mtskNone
  mtskDesqView
  mtskTopView
  mtskDoubleDOS
  mtskWindows

 See Also:
  ~TimeSlice~:31
  ~PreventSwitching~:32
  ~ResumeSwitching~:33
  ~MultiTaskerVersion~:34

%31
 TimeSlice (procedure)     ~(TGProcs Unit)~:10
 
Causes the current task to give up the rest of its time slice.

 Declaration:
  procedure TimeSlice;

 Remarks:
If a multitasker is present, and the program running is idle (like waiting
for a user event), the program can call this procedure to give up the rest
of its time slice for more efficient multitasking.

 See Also:
  ~MultiTasker~:30
  ~PreventSwitching~:32
  ~ResumeSwitching~:33
  ~MultiTaskerVersion~:34

%32
 PreventSwitching (procedure)     ~(TGProcs Unit)~:10
 
Suspends multitasking and only services the current task.

 Declaration:
  procedure PreventSwitching;

If a multitasker is present, this procedure suspends multitasking operations
having all CPU time to the program.  This is useful during critical program
functions.

 See Also:
  ~MultiTasker~:30
  ~TimeSlice~:31
  ~ResumeSwitching~:33
  ~MultiTaskerVersion~:34

%33
 ResumeSwitching (procedure)     ~(TGProcs Unit)~:10
 
Resumes multitasking after it has been suspended.

 Declaration:
  procedure ResumeSwitching;

 Remarks:
If a multitasker is present, and PreventSwitching was called to stop the
multitasker from multitasking, this is called to let the multitasker resume
multitasking.

 See Also:
  ~MultiTasker~:30
  ~TimeSlice~:31
  ~PreventSwitching~:32
  ~MultiTaskerVersion~:34

%34
 MultiTaskerVersion (function)     ~(TGProcs Unit)~:10
 
Returns the version of the active multitasker.

 Declaration:
  function MultiTaskerVersion:Word;

 Remarks:
Returns the version number for DESQview 2.26+, TopView, Windows
(200h for 2.xx), 0 for all others or no multitasker present,
& unknown for OmniView.

 See Also:
  ~MultiTasker~:30
  ~TimeSlice~:31
  ~PreventSwitching~:32
  ~ResumeSwitching~:33

%14
 ReadKey (function)     ~(TGProcs Unit)~:10
 
Reads a character from the keyboard.

 Declaration:
  function ReadKey:Char;

 Remarks:
It returns a character or an extended scan code.

The character is not echoed to the screen.

This is an identical alternative to the one in the CRT unit, so the
CRT unit doesn't have to be used with BNGui applications.

 See Also:
  ~KeyPressed~:15

 Sample Code:

 {ReadKey.PAS}

 {Sample code for the ReadKey function.}

 uses TGProcs;

 var
   C: Char;

 begin
   Writeln('Please press a key');
   C := ReadKey;
   Writeln(' You pressed ', C, ', whose ASCII value is ', Ord(C), '.');
 end.


%15
 KeyPressed (function)     ~(TGProcs Unit)~:10
 
Determines if a key has been pressed on the keyboard.

 Declaration:
  function KeyPressed:Boolean;

 Remarks:
It returns True if key has been pressed, False if key has not been pressed.

The key can be read using the ReadKey function.

This is an identical alternative to the one in the CRT unit, so the
CRT unit doesn't have to be used with BNGui applications.

 See Also:
  ~ReadKey~:14

 Sample Code:

 {KeyPress.PAS}

 {Sample code for the KeyPressed function.}

 uses TGProcs;

 begin
   repeat
     Write('Xx');
   until KeyPressed;
 end.


%16
 Delay (procedure)     ~(TGProcs Unit)~:10
 
Delays a specified number of milliseconds.

 Declaration:
  procedure Delay(ms:Word);

 Remarks:
"ms" specifies the number of milliseconds to wait.

Delay is an approximation, so the delay period will not last
exactly "ms" milliseconds.

This is an identical alternative to the one in the CRT unit, so the
CRT unit doesn't have to be used with BNGui applications.

 Sample Code:

 {Delay.PAS}

 {Sample code for the Delay, NoSound, and Sound  procedures.}

 uses TGProcs;

 begin
   Sound(220);        { Beep }
   Delay(200);        { For 200 ms }
   NoSound;           { Relief! }
 end.


%17
 Sound (procedure)     ~(TGProcs Unit)~:10
 
Starts the internal speaker.

 Declaration:
  procedure Sound(Hz:Word);

 Remarks:
"Hz" specifies the frequency of the emitted sound in hertz.  The
speaker continues until explicitly turned off by a call to NoSound.

This is an identical alternative to the one in the CRT unit, so the
CRT unit doesn't have to be used with BNGui applications.

 See Also:
  ~NoSound~:18

 SampleCode:

 {Delay.PAS}

 {Sample code for the Delay, NoSound, and Sound  procedures.}

 uses TGProcs;

 begin
   Sound(220);        { Beep }
   Delay(200);        { For 200 ms }
   NoSound;           { Relief! }
 end.


%18
 NoSound (procedure)     ~(TGProcs Unit)~:10
 
Turns off the computer's internal speaker.

 Declaration:
  procedure NoSound;

 Remarks:
The following program fragment emits a 440-hertz tone for half a second:

  Sound(440);
  Delay(500);
  NoSound;

This is an identical alternative to the one in the CRT unit, so the
CRT unit doesn't have to be used with BNGui applications.

 See Also:
  ~Sound~:17

 Sample Code:

 {Delay.PAS}

 {Sample code for the Delay, NoSound, and Sound  procedures.}

 uses TGProcs;

 begin
   Sound(220);        { Beep }
   Delay(200);        { For 200 ms }
   NoSound;           { Relief! }
 end.


%22
 GetKey (function)     ~(TGProcs Unit)~:10
 

 Declaration:
  function GetKey:Char;

%23
 SetTypematicRate (procedure)     ~(TGProcs Unit)~:10
 

 Declaration:
  procedure SetTypematicRate(delay,rate:Byte);

%24
 ExePath (function)     ~(TGProcs Unit)~:10
 
Returns the full path where the program running is.

 Declaration:
  function ExePath:string;

 Remarks:
ExePath returns the full path of where the current program that is running
is run from.  It can be used before filenames that load other miscellaneous
files to be used.  The last character in the string is a "\".

%25
 NoExt (function)     ~(TGProcs Unit)~:10
 
Tells whether the specified filename contains an extension.

 Declaration:
  function NoExt(fname:string):Boolean;

 Remarks:
It returns True if "fname" does not have an extension in the name, or false
if it does.

%28
 ColdBoot (procedure)     ~(TGProcs Unit)~:10
 
This procedure cold boots the computer.

 Declaration
  procedure ColdBoot;

 Remarks:
ColdBoot cold boots the computer, making the computer go through all
startup tests.

 See Also:
  ~WarmBoot~:29

%29
 WarmBoot (procedure)     ~(TGProcs Unit)~:10
 
This procedure warm boots the computer.

 Declaration
  procedure WarmBoot;

 Remarks:
WarmBoot warm boots the computer as if Ctrl-Alt-Del was pressed.
The computer does not go through all startup tests.

 See Also:
  ~ColdBoot~:28

%41
 ScreenOn (procedure)     ~(TGProcs Unit)~:10
 
Unblanks the screen.

 Declaration:
  procedure ScreenOff;

 Remarks:
It unblanks the screen that was previously blanked by ScreenOff
without destroying the contents off the screen, and works in any
video modes.

 See Also:
  ~ScreenOn~:42

%42
 ScreenOff (procedure)     ~(TGProcs Unit)~:10
 
Blanks the screen.

 Declaration:
  procedure ScreenOff;

 Remarks:
It blanks the screen without destroying the contents off the screen, and
works in any video modes.

 See Also:
  ~ScreenOn~:41

%45
 IPos (function)     ~(TGProcs Unit)~:10
 
Searches for a substring in a string without case sensitivity.

 Declaration:
  function IPos(s,substr:String):Byte;

 Remarks:
"substr" and "s" are string-type expressions. IPos searches for "substr"
within "s" without case sensitivity, and returns an integer value that
is the index of the first character of "substr" within "s". If "substr" is
not found, IPos returns zero.

 See Also:
  ~Lower~:46
  ~RScan~:47
  ~Scan~:48
  ~Upper~:49

 Sample Code:

 {IPos.PAS}

 {Sample code for the IPos function.}

 uses TGProcs;

 var S, SubStr: String;
     P: Byte;
 begin
   Readln(S);
   Readln(SubStr);
   P := IPos(S, SubStr);
   if P = 0 then
     Writeln('Substring not found')
   else
     Writeln('Substring found at index ', P);
 end.


%46
 Lower (function)     ~(TGProcs Unit)~:10
 
Converts a string to lower case.

 Declaration:
  function Lower(s:String):String;

 Remarks:
Lower returns a copy of "s" with all upper case characters converted
to lower case.

 See Also:
  ~IPos~:45
  ~RScan~:47
  ~Scan~:48
  ~Upper~:49

 Sample Code:

 {Upper.PAS}

 {Sample code for the Lower and Upper function.}

 uses TGProcs;

 var S: String;
 begin
  Readln(S);
  Writeln(Upper(S));
  Writeln(Lower(S));
 end.


%47
 RScan (function)     ~(TGProcs Unit)~:10
 
Returns the position of the last occurrence of a character in a string.

 Declaration:
  function RScan(s:String; c:Char):Byte;

 Remarks:
RScan returns the position of the last occurrence of "c" in "s".
If "c" does not occur in "s", RScan returns a zero.

 See Also:
  ~IPos~:45
  ~Lower~:46
  ~Scan~:48
  ~Upper~:49

 Sample Code:

 {RScan.PAS}

 {Sample code for the RScan function.}

 { Return the position of the name part of a full path name }

 uses TGProcs;

 function NamePart(FileName: String): String;
 var
   P: Byte;
 begin
   P := RScan(FileName, '\');
   if P = 0 then
   begin
     P := RScan(FileName, ':');
     if P = 0 then P := 1;
   end;
   NamePart := Copy(FileName, P, 255);
 end;

 begin
   Writeln (NamePart('C:\Test.fil'));
 end.


%48
 Scan (function)     ~(TGProcs Unit)~:10
 
Returns the position of the first occurrence of a character in a string.

 Declaration:
  function Scan(s:String; c:Char):Byte;

 Remarks:
Scan returns the position of the first occurrence of "c" in "s".
If "c" does not occur in "s", Scan returns zero.

 See Also:
  ~IPos~:45
  ~Lower~:46
  ~RScan~:47
  ~Upper~:49

 Sample Code:

 {Scan.PAS}

 {Sample code for the Scan function.}

 { Return true if file name has wildcards in it }

 uses TGProcs;

 function HasWildcards(FileName: String): Boolean;
 begin
  HasWildcards := (Scan(FileName, '*') <> 0) or
    (Scan(FileName, '?') <> 0);
 end;

 begin
   Writeln ('Has wildcards: ', HasWildCards('C:\Test.*'));
 end.


%49
 Upper (function)     ~(TGProcs Unit)~:10
 
Converts a string to upper case.

 Declaration:
  function Upper(s:String):String;

 Remarks:
Upper returns a copy of "s" with all lower case characters converted
to upper case.

 See Also:
  ~IPos~:45
  ~Lower~:46
  ~RScan~:47
  ~Scan~:48

 Sample Code:

 {Upper.PAS}

 {Sample code for the Lower and Upper function.}

 uses TGProcs;

 var S: String;
 begin
  Readln(S);
  Writeln(Upper(S));
  Writeln(Lower(S));
 end.


%50
 StrIns (function)     ~(TGProcs Unit)~:10
 
Inserts a substring into a string.

 Declaration:
  function StrIns(Dest,Source:PChar; Index:Word):PChar;

 Remarks:
StrIns inserts Source into Dest at the Indexth position.  It does not
perform any range checking, and therefore the destination buffer must
have room for at least StrLen(Dest)+StrLen(Source)+1 characters.

 See Also:
  ~StrLIns~:51
  ~StrDel~:52
  Strings unit

 Sample Code:

  {StrIns.PAS}

  {Sample code for the StrIns function.}

  uses Strings,TGProcs;

  var
    s: array [0..20] of Char;

  begin
    StrCopy(s,'Honest Lincoln');
    StrIns(s,'Abe ',7);  { 'Honest Abe Lincoln' }
    Writeln(s);
  end.


%51
 StrLIns (function)     ~(TGProcs Unit)~:10
 
Inserts a substring into a string.

 Declaration:
  function StrLIns(Dest,Source:PChar; Index,MaxLen:Word):PChar;

 Remarks:
StrIns inserts Source into Dest at the Indexth position.
The resulting string StrLen(Dest) will not be longer than MaxLen.

 See Also:
  ~StrIns~:50
  ~StrDel~:52
  Strings unit

 Sample Code:

  {StrLIns.PAS}

  {Sample code for the StrLIns function.}

  uses Strings,TGProcs;

  var
    s: array [0..15] of Char;

  begin
    StrCopy(s,'Honest Lincoln');
    StrLIns(s,'Abe ',7,SizeOf(s)-1);  { 'Honest Abe Linc' }
    Writeln(s);
  end.


%52
 StrDel (function)     ~(TGProcs Unit)~:10
 
Deletes a substring from a string.

 Declaration:
  function StrDel(s:PChar; Index,Count:Word):PChar;

 Remarks:
StrDel deletes Count characters from S starting at the Indexth position. If
Index is larger than the length of S, no characters are deleted. If Count
specifies more characters than remain starting at the Indexth position, the
remainder of the string is deleted.

 See Also:
  ~StrIns~:50
  ~StrLIns~:51
  Strings unit


  {StrDel.PAS}

  {Sample code for the StrDel function.}

  uses Strings,TGProcs;

  var
    s : array [0..20] of Char;

  begin
    StrPCopy(s,'Honest Abe Lincoln');
    StrDel(s,7,4);
    Writeln(s); { 'Honest Lincoln' }
  end.


%80
 PByte (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  PByte = ^Byte;

 Remarks:
PByte defines a pointer to an 8-bit unsigned value.

%81
 PWord (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  PWord = ^Word;

 Remarks:
PWord defines a pointer to a 16-bit unsigned value.

%82
 PInt (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  PInt = ^Int;

 Remarks:
PInt defines a pointer to a 16-bit signed value.

%83
 PLongInt (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  PLongInt = ^LongInt;

 Remarks:
PLongInt defines a pointer to a 32-bit signed value.

%84
 AByte (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  AByte = array [0..0] of Byte;

 Remarks:
AByte defines a an array type for accessing dynamically allocated variables
as arrays.  Range checking must be off.

 Example:

 uses TGProcs;

 var Buf: PByte;

 begin
   GetMem(Buf, 1000);
   AByte(Buf^)[100] := 10;
     { Set the 101st byte in Buf to 10 }
   Writeln('The value of the 500th byte in Buf is ',
     AByte(Buf^)[499]);
 end.


%85
 AChar (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  AChar = array [0..0] of Char;

 Remarks:

%86
 AWord (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  AWord = array [0..0] of Word;

 Remarks:
AWord defines a an array type for accessing dynamically allocated variables
as arrays.  Range checking must be off.

 Example:

 uses TGProcs;

 var Buf: PByte;

 begin
   GetMem(Buf, 1000); { 1000 bytes = 500 words }
   AWord(Buf^)[100] := 500;
     { Set the 101st word in Buf to 500 }
   Writeln('The value of the 200th word in Buf is ',
     AWord(Buf^)[199]);
 end.


%87
 AInt (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  AInt = array [0..0] of Integer;

 Remarks:
AInt defines a an array type for accessing dynamically allocated variables
as arrays.  Range checking must be off.

 Example:

 uses TGProcs;

 var Buf: PByte;

 begin
   GetMem(Buf, 1000); { 1000 bytes = 500 integers }
   AInt(Buf^)[100] := -500;
     { Set the 101st integer in Buf to -500 }
   Writeln('The value of the 200th integer in Buf is ',
     AInt(Buf^)[199]);
 end.


%88
 ALongInt (type)     ~(TGProcs Unit)~:10
 
 Declaration:
  ALongInt = array [0..0] of LongInt;

 Remarks:
ALongInt defines a an array type for accessing dynamically allocated variables
as arrays.  Range checking must be off.

 Example:

 uses TGProcs;

 var Buf: PByte;

 begin
   GetMem(Buf, 1000); { 1000 bytes = 250 longints }
   AByte(Buf^)[100] := -123456;
     { Set the 101st longint in Buf to -123456 }
   Writeln('The value of the 200th longint in Buf is ',
     ALongInt(Buf^)[199]);
 end.


%90
 Keyboard constants     ~(TGProcs Unit)~:10
 
All function and other extended miscellaneous keys all generate a simple
ASCII value that ~GetKey~:22 returns.  The ~TGEvents~:900 unit uses these
constants too when a key event occurs.

The following are constants used to represent the function keys returns
on the keyboard:

  Key         Value
 
  kbF1         $0F
  kbF2         $10
  kbF3         $11
  kbF4         $12
  kbF5         $13
  kbF6         $14
  kbF7         $15
  kbF8         $16
  kbF9         $17
  kbF10        $18
  kbF11        $19
  kbF12        $1A
             
  kbIns        1
  kbDel        2
  kbHome       3
  kbEnd        4
  kbPgUp       5
  kbPgDn       6
  kbUp         7
  kbDown       10
  kbLeft       11
  kbRight      12
  kbEsc        27
  kbEnter      13
  kbTab        9
  kbBkSp       8
  kbSpc        32
  kbPrtScn     14
             
  kbPause      28  (These are only TGEvents keys)
  kbBreak      29
  kbSysRq      31
  kbAlt        30

%100
 TGDriver Unit
 

The TGDriver unit provides a standard set of procedures, functions and
symbols for standard and native Super VGA programming.

The drivers that come with the unit support various video card natively,
providing full known functionality and speed (especially compared to using
the VESA standard).  The drivers also provide support for the more common
hardware functions for real speed, including: Mouse Cursor, BitBlt, Line
drawing, Filled rectangles, etc.

 Functions and Procedures:
  ~GetCardInfo~:101
  ~GetModeInfo~:102
  ~SetMode~:103
  ~GetMode~:104
  ~SetRWBank~:105
  ~SetWBank~:106
  ~SetRBank~:107
  ~GetWBank~:108
  ~GetRBank~:109
  ~SetLineLength~:110
  ~GetLineLength~:111
  ~SetDisplayStart~:112
  ~GetDisplayStart~:113
  ~SetSplitScreen~:114
  ~GetSplitScreen~:115
  ~SetClipArea~:116
  ~SetViewPort~:117
  ~GetViewPort~:122
  ~SetActivePage~:118
  ~GetActivePage~:119
  ~SetVisualPage~:120
  ~GetVisualPage~:121
  ~FindMode~:123

 Types:
  ~TCardInfo~:150
  ~TModeInfo~:151
  ~TRect~:152
  ~TFunctionList~:153

 Variables:
  ~CardInfo~:160
  ~ModeInfo~:161
  ~ClipRect~:162

 Constants:
  ~vmXXX~:170

%101
 GetCardInfo (procedure)     ~(TGDriver Unit)~:100
 
Gets general information on the graphics card.

 Declaration:
  procedure GetCardInfo;

 Remarks:
The procedure fills the ~CardInfo~:160 variable with information on the
installed graphics card.

This procedure is automatically called when the program loads, so this
will not have to be called.

 See Also:
  ~GetModeInfo~:102

%102
 GetModeInfo (procedure)     ~(TGDriver Unit)~:100
 
Get information on a specific TGDriver video mode.

 Declaration:
  procedure GetModeInfo(mode:Word);

 Remarks:
The procedure fills the ~ModeInfo~:161 variable with information on the
mode specified.

 See Also:
  ~GetCardInfo~:101
  ~SetMode~:103

%103
 SetMode (function)     ~(TGDriver Unit)~:100
 
Sets a new video mode.

 Declaration:
  function SetMode(mode:Word):Boolean;

 Remarks:
The function set a new video mode that can either be a standard mode
or TGDriver SVGA mode.  It returns True if it succeeds in
setting the mode desired, else it returns False if the mode is not available.

 See Also:
  ~GetMode~:104
  ~Video Modes~:170

%104
 GetMode (function)     ~(TGDriver Unit)~:100
 
Gets the current video mode.

 Declaration:
  function GetMode:Word;

 Remarks:
Returns the currently active video mode.  Only works after a mode has been
previously set.

 See Also:
  ~SetMode~:103
  ~Video Modes~:170

%105
 SetRWBank (procedure)     ~(TGDriver Unit)~:100
 
Sets the 64k bank position for both reading and writing.

 Declaration:
  procedure SetRWBank(bank:Word);

 Remarks:
Sets the 64k bank position for both reading and writing.
It also updates ModeInfo.ReadBank and ModeInfo.WriteBank.

 See Also:
  ~SetWBank~:106
  ~SetRBank~:107
  ~GetWBank~:108
  ~GetRBank~:109

%106
 SetWBank (procedure)     ~(TGDriver Unit)~:100
 
Sets the 64k bank position for writing.

 Declaration:
  procedure SetWBank(bank:Word);

 Remarks:
Sets the 64k bank position for writing only, and the read
bank is not modified (unless the faRWBank attribute is clear in CardInfo).
It also updates ModeInfo.WriteBank (and ModeInfo.ReadBank if separate
read/write banks aren't supported).

 See Also:
  ~SetRWBank~:105
  ~SetRBank~:107
  ~GetWBank~:108
  ~GetRBank~:109

%107
 SetRBank (procedure)     ~(TGDriver Unit)~:100
 
Sets the 64k bank position for reading.

 Declaration:
  procedure SetRBank(bank:Word);

 Remarks:
Sets the 64k bank position for reading only, and the write
bank is not modified (unless the faRWBank attribute is clear in CardInfo).
It also updates ModeInfo.ReadBank (and ModeInfo.WriteBank if separate
read/write banks aren't supported).

 See Also:
  ~SetRWBank~:105
  ~SetWBank~:106
  ~GetWBank~:108
  ~GetRBank~:109

%108
 GetWBank (function)     ~(TGDriver Unit)~:100
 
Returns the position of the 64k write bank.

 Declaration:
  function GetWBank:Word;

 Remarks:
The function gets the location of the write bank.

 See Also:
  ~SetRWBank~:105
  ~SetWBank~:106
  ~SetRBank~:107
  ~GetRBank~:109

%109
 GetRBank (function)     ~(TGDriver Unit)~:100
 
Returns the position of the 64k read bank.

 Declaration:
  function GetRBank:Word;

 Remarks:
The function gets the location of the read bank.

 See Also:
  ~SetRWBank~:105
  ~SetWBank~:106
  ~SetRBank~:107
  ~GetWBank~:108

%110
 SetLineLength (function)     ~(TGDriver Unit)~:100
 
Sets the number of pixels per line.

 Declaration:
  function SetLineLength(len:Word):Word;

 Remarks:
SetLineLength sets the number of logical number of pixels per line (or
number of characters per line if in text mode).  The visible number of
pixels remains the same, but if the length is greater, the rest are off
the egde of the screen therefore making a larger "logical screen".

It returns the actual number of pixels per line (the video card cannot
set any exact number of pixels per line, but to every 4, 8 or 16 pixels
depending on the card and mode).

It also updates the ~ModeInfo~:161 variable, updating the Width and Bytes
fields.

This is useful for horizontal scrolling.

 See Also:
  ~GetLineLength~:111
  ~SetDisplayStart~:112

%111
 GetLineLength (function)     ~(TGDriver Unit)~:100
 
Gets the number of pixels per line.

 Declaration:
  function GetLineLength:Word;

 Remarks:
GetLineLength returns the number of logical number of pixels per line (or
number of characters per line if in text mode).  The visible number of
pixels remains the same, but if the length is greater, the rest are off
the egde of the screen therefore making a larger "logical screen".

 See Also:
  ~SetLineLength~:110
  ~GetDisplayStart~:113

%112
 SetDisplayStart (procedure)     ~(TGDriver Unit)~:100
 
Set the location of the top-left pixel on the screen in relation to
the start of the video buffer.

 Declaration:
  procedure SetDisplayStart(x,y:Word);

 Remarks:
SetDisplayStart sets the first visible pixel on the screen in relation
to the first pixel in the video buffer ($A000:0000).

This is can be used for page-flipped animation and/or
horizontal & vertical scrolling.

 See Also:
  ~GetDisplayStart~:113
  ~SetViewPort~:117
  ~SetVisualPage~:120
  ~SetActivePage~:118
  ~SetLineLength~:110
  ~SetSplitScreen~:114

 Sample Code:

  {DispStrt.PAS}

  {Sample code for the SetDisplayStart procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i : Integer;
  begin
    SetMode(vm640x480x256c);
    FilledEllipse(320, 200, 150, 100, 12);
    for i:=0 to 100 do
      SetDisplayStart(i,i);
    ReadKey;
    SetMode(vmOriginal);
  end.


%113
 GetDisplayStart (procedure)     ~(TGDriver Unit)~:100
 
Get the location of the top-left pixel on the screen in relation to
the absolute origin of the video buffer.

 Declaration:
  procedure GetDisplayStart(var x,y:Word);

 Remarks:
Returns the location of the first visible pixel on the screen in relation
to the start of the video buffer ($A000:0000).

 See Also:
  ~SetDisplayStart~:112
  ~GetVisualPage~:121
  ~GetActivePage~:119
  ~GetSplitScreen~:115

%114
 SetSplitScreen (procedure)    ~(TGDriver Unit)~:100
 
Sets the line at which the screen is split.

 Declaration:
  procedure SetSplitScreen(line:Integer);

 Remarks:
A split screen can be make where the top part of the screen is set using
SetDisplayStart, and the bottom part of the screen is the start of video
memory ($A000:0000).

This procedure sets the line at which the screen is split.  The maximum
line is 1023 while the minimum is 0.  To unsplit the screen, either set
1023 or -1 (both are effectively identical, -1 is clearer to read).

The split screen will only be visible if the line set is less than the
screen height.

 See Also:
  ~GetSplitScreen~:115
  ~SetDisplayStart~:112

%115
 GetSplitScreen (function)    ~(TGDriver Unit)~:100
 
Returns the line at which the screen is split.

 Declaration:
  function GetSplitScreen:Integer;

 Remarks:
A split screen can be make where the top part of the screen is set using
SetDisplayStart, and the bottom part of the screen is the start of video
memory ($A000:0000).

This function returns the line at which the screen is split.  The maximum
line is 1023 while the minimum is 0.  If the screen is not split, it
returns -1.

 See Also:
  ~SetSplitScreen~:114
  ~GetDisplayStart~:113


%116
 SetClipArea (procedure)     ~(TGDriver Unit)~:100
 
Sets the corners of the clipping rectangle used for drawing on
the screen.

 Declaration:
  procedure SetClipArea(xl,yl,xh,yh:Integer);

 Remarks:
(xl,yl) is the top left corner, and (xh,yh) is the bottom right
corner of the clipping rectangle.  Drawing procedures should
use this to make sure nothing is drawn outside this area.

 See Also:
  ~ClipRect~:162
  ~SetViewPort~:117
  ~TGraph Unit~:200

%117
 SetViewPort (procedure)     ~(TGDriver Unit)~:100
 
Sets the "window" and origin for graphic output.

 Declaration:
  procedure SetViewPort(xl,yl,xh,yh:Integer);

 Remarks:
(xl,yl) define the upper left corner of the viewport, and (xh,yh) define
the lower right corner (0 <= xl < xh and 0 <= yl < yh). The upper left
corner of a viewport is (0,0).

All graphics commands are viewport-relative. In the following example,
the coordinates of the dot in the middle are relative to the boundaries
of the viewport.

The following will not draw the complete line requested because the line
will be clipped to the current viewport:

  SetViewPort(10, 10, 20, 20);
  DrawLine(0, 5, 15, 5, 15);

The line would start at absolute coordinates (10,15) and terminate at
absolute coordinates (25,15), but the actual line that would be drawn
would start at absolute coordinates (10,15) and terminate at
coordinates (20,15).

It changes the ~ClipRect~:162 coordintes.

 See Also:
  ~GetViewPort~:122
  ~SetClipArea~:116
  ~SetDisplayStart~:112
  ~SetActivePage~:118
  ~BNGraph Unit~:200

 Sample Code:

  {SetVwPrt.PAS}

  {Sample code for the SetViewPort procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm800x600x16);
    SetViewPort(0,600,799,1199);
    DrawRect(10, 20, 30, 40);
    SetDisplayStart(0,600);
    ReadKey;
    SetMode(vmOriginal);
  end.


%122
 GetViewPort (procedure)     ~(TGDriver Unit)~:100
 

%123
 FindMode (function)     ~(TGDriver Unit)~:100
 

%118
 SetActivePage (function)     ~(TGDriver Unit)~:100
 
Set the active page for graphics output.

 Declaration:
  procedure SetActivePage(page:Byte);

 Remarks:
Makes Page the active graphics page, directing all subsequent graphics
output to Page.

With multiple graphics pages, a program can direct graphics output to an
offscreen page, then quickly display the offscreen image by changing the
visual page with the SetVisualPage procedure. This technique is
especially useful for animation.

 See Also:
  ~SetVisualPage~:120
  ~GetActivePage~:119
  ~SetViewPort~:117

 Sample Code:

  {Setactpg.PAS}

  {Sample code for the SetActivePage procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
   if not(SetMode(vm640x480x256c)) then Halt;
   SetActivePage(1);
   DrawRect(10, 20, 30, 40, 14);
   SetVisualPage(1);
   Readkey;
   SetMode(vmOriginal);
  end.


%119
 GetActivePage (function)     ~(TGDriver Unit)~:100
 
Returns the current active graphics page.

 Declaration:
  function GetActivePage:Byte;

 Remarks:


 See Also:
  ~GetVisualPage~:121
  ~SetActivePage~:118
  ~SetViewPort~:117

%120
 SetVisualPage (function)     ~(TGDriver Unit)~:100
 
Sets the visual graphics page number.

 Declaration:
  procedure SetVisualPage(page:Byte);

 Remarks:
Makes Page the visual graphics page.

With multiple graphics pages, a program can direct graphics output to
an offscreen page, then quickly display the offscreen image by changing
the visual page with the SetVisualPage procedure. This technique is
especially useful for animation.

 See Also:
  ~SetActivePage~:118
  ~GetVisualPage~:121
  ~SetDisplayStart~:112

 Sample Code:

  {Setvispg.PAS}

  {Sample code for the SetVisualPage procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    if not(SetMode(vm640x480x256c)) then Halt;
    SetActivePage(1);
    DrawRect(10, 20, 30, 40, 14);
    SetVisualPage(1);
    Readkey;
    SetMode(vmOriginal);
  end.


%121
 GetVisualPage (function)     ~(TGDriver Unit)~:100
 
Returns the current active visual page.

 Declaration:
  function GetVisualPage:Byte;

 Remarks:


 See Also:
  ~GetActivePage~:119
  ~SetVisualPage~:120
  ~GetDisplayStart~:113

%170
 Video Mode constants     ~(TGDriver Unit)~:100
 
The constants follow a standard notation:

The first two letters are "vm", the followed by the horizontal resolution,
then a "x", then the vertical resolution, then another "x" and finally
the colour mode.

vmOriginal is used to set the mode the computer was in when the program
started up, and should be called when the program exits.

  Constant          Value
 
  vmOriginal        $FF
 
  16 colour modes
 
  vm320x200x16      $20
  vm640x400x16      $21
  vm640x480x16      $22
  vm800x600x16      $23
  vm1024x768x16     $24
  vm1152x864x16     $25
  vm1280x960x16     $26
  vm1280x1024x16    $27
  vm1600x1200x16    $28
 
  256 colour chained modes
 
  vm320x200x256c    $30
  vm640x400x256c    $31
  vm640x480x256c    $32
  vm800x600x256c    $33
  vm1024x768x256c   $34
  vm1152x864x256c   $35
  vm1280x960x256c   $36
  vm1280x1024x256c  $37
  vm1600x1200x256c  $38
 
  256 colour unchained modes
 
  vm320x200x256u    $40
  vm640x400x256u    $41
  vm640x480x256u    $42
  vm800x600x256u    $43
  vm1024x768x256u   $44
  vm1152x864x256u   $45
  vm1280x960x256u   $46
  vm1280x1024x256u  $47
  vm1600x1200x256u  $48
 
  32k HiColour modes
 
  vm320x200x32k     $50
  vm640x400x32k     $51
  vm640x480x32k     $52
  vm800x600x32k     $53
  vm1024x768x32k    $54
  vm1152x864x32k    $55
  vm1280x960x32k    $56
  vm1280x1024x32k   $57
  vm1600x1200x32k   $58
 
  64k HiColour modes
 
  vm320x200x64k     $60
  vm640x400x64k     $61
  vm640x480x64k     $62
  vm800x600x64k     $63
  vm1024x768x64k    $64
  vm1152x864x64k    $65
  vm1280x960x64k    $66
  vm1280x1024x64k   $67
  vm1600x1200x64k   $68
 
  16M TrueColour modes
 
  vm320x200x16M     $70
  vm640x400x16M     $71
  vm640x480x16M     $72
  vm800x600x16M     $73
  vm1024x768x16M    $74
  vm1152x864x16M    $75
  vm1280x960x16M    $76
  vm1280x1024x16M   $77
  vm1600x1200x16M   $78

%161
 ModeInfo (variable)     ~(TGDriver Unit)~:100
 
Stores information on a particular video mode.

It is set by ~GetModeInfo~:102 and ~SetMode~:103.  The parameters
can also be directly set by user applications if something
needs to be changed, like virtual screens (in RAM).

 See Also:
  ~TModeInfo~:151

%151
 TModeInfo (type)     ~(TGDriver Unit)~:100
 
Structure for ~ModeInfo~:161 that ~GetModeInfo~:102 and ~SetMode~:103
set when called for storing information on a video mode.

 TModeInfo = record
   Attr      : Word;      Attributes about video mode
                             0 - SVGA mode (extended features available)
                             1 - Hardware mouse available
                             2 - Hardware BitBlt available
                             3 - Hardware 90 deg. Line drawing available
                             4 - Hardware any angle Line drawing avail.
   Width     : Word;      Pixel width of video mode
   Height    : Word;      Pixel height of video mode
   Bytes     : Word;      Number of bytes per line in the mode
   Model     : Byte;      Memory model of the mode
                             1 - 16 colour mode
                             2 - 256c colour mode
                             3 - 256u colour mode
                             4 - 15/16bit HiColour mode (32K or 64K colours)
                             5 - 24 bit TrueColour mode -> 24 bbp
                             6 - 24 bit TrueColour mode -> 32 bbp
   Bits      : Byte;      Number of bits per colour/pixel
   BufOfs    : Word;      Offset of video buffer (for VScreens)
   BufSeg    : Word;      Segment of video buffer
   FirstBank : Word;      Video bank number at (x,y) = (0,0)
   ReadBank  : Word;      Currently set Read Bank (used for speed)
   WriteBank : Word;      Currently set Write Bank (used for speed)
   XOffset,
   YOffset   : Integer;   ViewPort origin

   DrvFuncs  : ~TFunctionList~:153;
 end;

%150
 TCardInfo (type)     ~(TGDriver Unit)~:100
 
Structure for ~CardInfo~:160 that ~GetCardInfo~:101 sets when called for
storing information on a video system.

 TCardInfo = record
   Version  : Word;    - Turbo Graphics Driver version number
   CardName : PChar;   - Pointer to name of card
   Memory   : Word;    - Number of 64k memory blocks on card
   NumModes : Word;    - Specifies number of video modes available
   ModeList : ^Byte;   - Pointer to list of video modes supported
 end;

%153
 TFunctionList (type)     ~(TGDriver Unit)~:100
 

 TFunctionList = record
   IsCard            : Pointer;
   GetCardInfo       : Pointer;
   GetModeInfo       : Pointer;
   SetMode           : Pointer;
   GetMode           : Pointer;
   SetRWBank         : Pointer;
   SetRBank          : Pointer;
   SetWBank          : Pointer;
   GetRBank          : Pointer;
   GetWBank          : Pointer;
   SetLineLength     : Pointer;
   GetLineLength     : Pointer;
   SetDisplayStart   : Pointer;
   GetDisplayStart   : Pointer;

   EnableCursor      : Pointer;
   SetCursorImage    : Pointer;
   SetCursorPosition : Pointer;
   SetCursorColours  : Pointer;

   BitBlt            : Pointer;

   DrawVLine         : Pointer;
   DrawHLine         : Pointer;
   DrawLine          : Pointer;

   FillRectangle     : Pointer;
 end;

 See Also:
  ~TModeInfo~:151

%160
 CardInfo (variable)     ~(TGDriver Unit)~:100
 
Stores information on a video system.

It is set by ~GetCardInfo~:101.

 See Also:
  ~TCardInfo~:150

%152
 TRect (type)     ~(TGDriver Unit)~:100
 
A type for rectangle coordinates.

 TRect = record
           xl, yl, xh, yh : Integer;
         end;

It is used by the ~ClipRect~:162 variable.

%162
 ClipRect (variable)     ~(TGDriver Unit)~:100
 
This is a global variable used for specifying a clipping rectangle
to be used when drawing.

 Declaration:
  ClipRect : ~TRect~:152;

All drawing is supposed to occur within this rectangle (not outside).

 See Also:
  ~SetClipArea~:116
  ~SetViewPort~:117

%200
 TGraph Unit - v1.0
 

The TGraph unit provide a range of procedures to draw SVGA graphics
using the ~TGDriver Unit~:100 functions and variables.

The unit supports all colours and resolutions on any VGA or SVGA card
(driver allowing).  They will NOT work on EGA systems, as the 16 colour
routines use a VGA only write mode.

 See:
  ~TGraph Procedures and Functions~:201
  ~TGraph Constants, Variables and Types~:202


One final note:

The differences between 256c and 256u are than 256c is the standard
linear "chained" 256 colour mode that most people are familiar with.
256u is the not-so standard "unchained" 256 colour mode.  It uses the
planar fashion similar to the 16 colour mode.  It's most common
implementation of this mode is "Mode-X" and other similar
modes, especially in programs like XLib.  Most of the 256u routines are
about 3 times faster than the equivalent 256c routines, some are slower
(diagonal lines) and some go up to almost 6 times faster (pattern fills
with a non-transparent background).

%201
 TGraph Procedures and Functions
 
These are the functions and procedures that currently make up the
TGraph unit:

 Screen Clearing:
  ~FillScr~:210
  ~FillViewPort~:211

 Pixels:
  ~DrawPixel~:212
  ~GetPixel~:213

 Lines:
  ~DrawLine~:214
  ~DrawAngleLine~:256
  ~ThickLine~:215
  ~HLine~:216

 Relative Lines:
  ~MoveTo~:217
  ~MoveRel~:218
  ~DrawTo~:219
  ~DrawRel~:220
  ~GetX~:221
  ~GetY~:222

 Rectangles:
  ~DrawRect~:223
  ~FilledRect~:224
  ~ThickRect~:225

  ~ShadowRect~:226

 Rounded Rectangles:
  ~DrawRoundRect~:227
  ~FilledRoundRect~:228
  ~ThickRoundRect~:229

 Circles:
  ~DrawCircle~:230
  ~FilledCircle~:231
  ~ThickCircle~:232

 Ellipses:
  ~DrawEllipse~:233
  ~FilledEllipse~:234
  ~ThickEllipse~:235
  ~DrawSEllipse~:236

 Arcs & Sectors (Pie slices):
  ~DrawArc~:237
  ~ThickArc~:238
  ~DrawSector~:239
  ~FilledSector~:240

 Curves:
  ~DrawBezier~:241

 Flood Fills:
  ~FloodFill~:242
  ~BorderFill~:243

 Polygons:
  ~DrawPoly~:244
  ~FilledPoly~:245
  ~ConvexPoly~:246

 BitBlts:
  ~BlockSize~:247
  ~GetBlock~:248
  ~PutBlock~:249
  ~PutTransBlock~:250
  ~PutStyleBlock~:251

 GUI Objects:
  ~DrawButton~:252
  ~DrawFrame~:253
  ~DrawHDivider~:254
  ~DrawVDivider~:255

 Virtual Screens:
  See ~TGVScrns unit~:600

%202
 TGraph Constants, Variables and Types
 

 Constants:
  ~doXXX-constants~:270
  ~lsXXX-constants~:271
  ~btXXX-constants~:272
  ~fpXXX-constants~:273
  ~Dithering-constants~:274

 Variables:
  ~DrawOp~:280
  ~LineStyle~:281
  ~BkColour~:282
  ~FillPattern~:283
  ~ArcCoords~:284

 Types:
  ~TPoint~:290
  ~TPattern~:291

%210
 FillScr (procedure)     ~(TGraph Unit)~:200
 
Clears the active page with colour "c".

 Declaration:
  procedure FillScr(c:LongInt);

 Remarks:
This clears exactly one screen according to ModeInfo.Height (can be changed
to clear larger or smaller parts of the screen) from the origin of the
current Active Page.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FillViewPort~:211
  ~SetViewPort~:117

 Sample Code:

  {Fillscr.PAS}

  {Sample code for the FillScr procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    FillScr(4);
    Readkey;
    SetMode(vmOriginal);
  end.


%211
 FillViewPort (procedure)     ~(TGraph Unit)~:200
 
Clears the current ViewPort with colour "c".

 Declaration:
  procedure FillViewPort(c:LongInt);

 Remarks:
Clears the current ViewPort only with the colour "c".

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FillScr~:210
  ~SetViewPort~:117

 Sample Code:

  {FilVwPrt.PAS}

  {Sample code for the FillViewPort procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    SetViewPort(20,20,620,460);
    FillViewPort(4);
    Readkey;
    SetMode(vmOriginal);
  end.


%212
 DrawPixel (procedure)     ~(TGraph Unit)~:200
 
Plots a pixel at (x,y).

 Declaration:
  procedure DrawPixel(x,y:Integer; c:LongInt);

 Remarks:
Plots a point in the colour defined by "c" at (x,y) according to the
setting of ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~GetPixel~:213

 Sample Code:

  {PutPixel.PAS}

  {Sample code for the PutPixel procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    Randomize;
    repeat
      DrawPixel(Random(640), Random(480), 15); { Plot "stars" }
      Delay(10);
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%213
 GetPixel (function)     ~(TGraph Unit)~:200
 
Gets the pixel value at (x,y).

 Declaration:
  function GetPixel(x,y:Integer):LongInt;

 Remarks:
Gets the colour of the pixel at (x,y).

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutPixel~:212

 Sample Code:

  {Getpixel.PAS}

  {Sample code for the GetPixel function.}

  uses TGProcs, TGDriver, TGraph;

  var
    PixelColor: Word;
  begin
    SetMode(vm640x480x16);
    PixelColor := GetPixel(10, 10);
    if PixelColor = 0 then
      DrawPixel(10, 10, 15);
    Readkey;
    SetMode(vmOriginal);
  end.


%214
 DrawLine (procedure)     ~(TGraph Unit)~:200
 
Draws a line from the point (xl,yl) to (xh,yh).

 Declaration:
  procedure DrawLine(xl,yl,xh,yh:Integer; c:LongInt);

 Remarks:
Draws a one pixel thick line in the style defined by the ~LineStyle~:281
variable and uses the colour passed in "c".  It uses the ~DrawOp~:280
variable to determine whether the line is copied ANDed, ORed or XORed
to the screen.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawAngleLine~:256
  ~ThickLine~:215
  ~DrawTo~:219
  ~DrawRel~:220
  ~DrawRect~:223

 Sample Code:

  {Drawline.PAS}

  {Sample code for the DrawLine procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    Randomize;
    repeat
      DrawLine(Random(640), Random(480), Random(640),
        Random(480), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%256
 DrawAngleLine (procedure)     ~(TGraph Unit)~:200
 
Draws a line from (x,y) with a specified length and angle.

 Declaration:
  procedure DrawAngleLine(x,y:Integer; angle,len:Word; c:LongInt);

 Remarks:
Draws a one pixel thick line in the style defined by the ~LineStyle~:281
variable and uses the colour passed in "c".  It uses the ~DrawOp~:280
variable to determine whether the line is copied ANDed, ORed or XORed
to the screen.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawLine~:214
  ~DrawTo~:219
  ~DrawRel~:220

 Sample Code:

  {Angline.PAS}

  {Sample code for the DrawAngleLine procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    Randomize;
    repeat
      DrawAngleLine(Random(640), Random(480), Random(360),
        Random(500), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%215
 ThickLine (procedure)     ~(TGraph Unit)~:200
 
Draws a thick line from the point (xl,yl) to (xh,yh).

 Declaration:
  procedure ThickLine(xl,yl,xh,yh:Integer; t:Byte; c:LongInt);

 Remarks:
Draws a "t" pixel thick line in the colour passed in "c".
It uses the current ~FillPattern~:283 and ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawLine~:214
  ~DrawAngleLin~:256
  ~DrawTo~:219
  ~DrawRel~:220
  ~ThickRect~:225

 Sample Code:

  {Thckline.PAS}

  {Sample code for the ThickLine procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    Randomize;
    repeat
      ThickLine(Random(640), Random(480), Random(640),
        Random(480), Random(16), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%216
 HLine (procedure)     ~(TGraph Unit)~:200
 

%217
 MoveTo (procedure)     ~(TGraph Unit)~:200
 
Moves the current pointer (CP) to (x,y).

 Declaration:
  procedure MoveTo(x,y:Integer);

 Remarks:
The CP is similar to the text mode cursor except the CP is not visible.
The following routines move the CP:
 ~MoveTo~:217
 ~MoveRel~:218
 ~DrawTo~:219
 ~DrawRel~:220
 ~GetX~:221
 ~GetY~:222

 Sample Code:

  {Moveto.PAS}

  {Sample code for the MoveTo procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    MoveTo(0, 0); { Upper left corner of viewport }
    DrawTo(ModeInfo.Width-1, ModeInfo.Height-1, 7);
    Readkey;
    SetMode(vmOriginal);
  end.


%218
 MoveRel (procedure)     ~(TGraph Unit)~:200
 
Moves the current pointer (CP) a relative distance from its
current position.

 Declaration:
  procedure MoveRel(dx,dy:Integer);

 Remarks:
If the CP is at (x,y), then MoveRel moves the CP to ((x+dx),(y+dy)).

 See Also:
  ~MoveTo~:217
  ~DrawTo~:218
  ~DrawRel~:219
  ~GetX~:220
  ~GetY~:221

 Sample Code:

  {Moverel.PAS}

  {Sample code for the MoveRel procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    MoveTo(1, 2);
    MoveRel(10, 10); { Move to the point (11, 12) }
    DrawPixel(GetX, GetY, 15);
    Readkey;
    SetMode(vmOriginal);
  end.


%219
 DrawTo (procedure)     ~(TGraph Unit)~:200
 
Draws a line from the current pointer (CP) to (x,y).

 Declaration:
  procedure DrawTo(x,y:Integer; c:LongInt);

 Remarks:
Draws a line using the current ~DrawOp~:280 and ~LineStyle~:281 and uses
the colour set by "c".  DrawTo moves the CP to (x,y).

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawLine~:214
  ~DrawAngleLine~:256
  ~DrawRel~:220
  ~MoveTo~:217
  ~MoveRel~:218
  ~GetX~:221
  ~GetY~:222

 Sample Code:

  {DrawTo.PAS}

  {Sample code for the DrawTo procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    Randomize;
    repeat
      DrawTo(Random(640), Random(480), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%220
 DrawRel (procedure)     ~(TGraph Unit)~:200
 
Draws a line relative to the current pointer (CP) and moves
the CP to (x1,y1).

 Declaration:
  procedure DrawRel(dx,dy:Integer; c:LongInt);

 Remarks:
Draws the line from the CP (x0,y0) to a point (x1,y1), where

  x1 = x0 + dx
  y1 = y0 + dy

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawLine~:214
  ~DrawAngleLine~:256
  ~DrawTo~:219
  ~MoveTo~:217
  ~MoveRel~:218
  ~GetX~:221
  ~GetY~:222

 Sample Code:

  {DrawRel.PAS}

  {Sample code for the DrawRel procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    MoveTo(1, 2);
    DrawRel(100, 100);   { Draw to the point (101,102) }
    Readkey;
    SetMode(vmOriginal);
  end.


%221
 GetX (function)     ~(TGraph Unit)~:200
 
Returns X coordinate of current pointer (CP).

 Declaration:
  function GetX:Integer;

 Remarks:
The value of GetX is relative to the dimensions of the active viewport,
as the following example illustrate.

  MoveTo(5, 5);
  Moves CP to absolute (5, 5), and GetX returns a value of 5.

 See Also:
  ~MoveTo~:217
  ~MoveRel~:218
  ~DrawTo~:219
  ~DrawRel~:220
  ~GetY~:222

 Sample Code:

  {Getxy.PAS}

  {Sample code for the GetX and GetY functions.}

  uses TGProcs, TGDriver, TGraph, TGText;

  var
    x, y: Integer;
  begin
    SetMode(vm640x480x16);
    DrawStr(GetX,GetY,'Currently here.',7);
    MoveRel(50,50);
    DrawStr(GetX,GetY,'Now here.',7);
    Readkey;
    SetMode(vmOriginal);
  end.


%222
 GetY (function)     ~(TGraph Unit)~:200
 
Returns Y coordinate of current pointer (CP).

 Declaration:
  function GetY:Integer;

 Remarks:
The value of GetY is relative to the dimensions of the active viewport,
as the following example illustrate.

  MoveTo(5, 5);
  Moves CP to absolute (5, 5), and GetY returns a value of 5.

 See Also:
  ~MoveTo~:217
  ~MoveRel~:218
  ~DrawTo~:219
  ~DrawRel~:220
  ~GetX~:221

 Sample Code:

  {Getxy.PAS}

  {Sample code for the GetX and GetY functions.}

  uses TGProcs, TGDriver, TGraph, TGText;

  var
    x, y: Integer;
  begin
    SetMode(vm640x480x16);
    DrawStr(GetX,GetY,'Currently here.',7);
    MoveRel(50,50);
    DrawStr(GetX,GetY,'Now here.',7);
    Readkey;
    SetMode(vmOriginal);
  end.


%223
 DrawRect (procedure)     ~(TGraph Unit)~:200
 
Draws a rectangle, using the current line style and draw operation.

 Declaration:
  procedure DrawRect(xl,yl,xh,yh:Integer; c:LongInt);

 Remarks:
(xl,yl) defines the upper left corner of the rectangle, and (xh,yh) defines
the lower right corner.

Draws the rectangle in the current ~DrawOp~:280 and ~LineStyle~:281, in the
colour specified by "c".

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FilledRect~:224
  ~ThickRect~:225
  ~DrawRoundRect~:227
  ~FilledRoundRect~:228
  ~ThickRoundRect~:229

 Sample Code:

  {DrawRect.PAS}

  {Sample code for the DrawRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    X1, Y1, X2, Y2: Integer;
  begin
    SetMode(vm640x480x16);
    repeat
      X1 := Random(640);
      Y1 := Random(480);
      X2 := Random(640 - X1) + X1;
      Y2 := Random(480 - Y1) + Y1;
      DrawRect(X1, Y1, X2, Y2, Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%224
 FilledRect (procedure)     ~(TGraph Unit)~:200
 
Draws a filled rectangle using the current FillPattern.

 Declaration:
  procedure FilledRect(xl,yl,xh,yh:Integer; c:LongInt);

 Remarks:
FilledRect draws a filled-in rectangle (used in bar charts, for example)
using the current ~FillPattern~:283, ~BkColour~:282 (background colour of the
fill pattern) and ~DrawOp~:280 and the foreground pattern colour passed
in "c".  To draw an outlined rectangle, use DrawRect.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawRect~:223
  ~ThickRect~:225
  ~DrawRoundRect~:227
  ~FilledRoundRect~:228
  ~ThickRoundRect~:229
  ~ShadowRect~:226

 Sample Code:

  {FillRect.PAS}

  {Sample code for the FilledRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    I, Width: Integer;
  begin
    SetMode(vm640x480x16);
    Width := 10;
    FillPattern := fpThatches;
    for I := 1 to 5 do begin
      BkColour := i xor 8;
      FilledRect(I*Width, I*10, Succ(I)*Width, 200, i);
    end;
    Readkey;
    SetMode(vmOriginal);
  end.


%225
 ThickRect (procedure)     ~(TGraph Unit)~:200
 
Draws a rectangle using thick lines.

 Declaration:
  procedure ThickRect(xl,yl,xh,yh:Integer; t:Byte; c:LongInt);

 Remarks:
(xl,yl) defines the upper left corner of the rectangle, and (xh,yh) defines
the lower right corner.

Draws the rectangle with the line thickness set by "t" and the colour
specified by "c".  It uses the current ~FillPattern~:283 and ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawRect~:223
  ~FilledRect~:224
  ~DrawRoundRect~:227
  ~FilledRoundRect~:228
  ~ThickRoundRect~:229

 Sample Code:

  {ThckRect.PAS}

  {Sample code for the ThickRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    X1, Y1, X2, Y2: Integer;
  begin
    SetMode(vm640x480x16);
    repeat
      X1 := Random(640);
      Y1 := Random(480);
      X2 := Random(640 - X1) + X1;
      Y2 := Random(480 - Y1) + Y1;
      ThickRect(X1, Y1, X2, Y2, Random(16), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%227
 DrawRoundRect (procedure)     ~(TGraph Unit)~:200
 
Draws a rectangle with round corners.

 Declaration:
  procedure DrawRoundRect(xl,yl,xh,yh,r:Integer; c:LongInt);

 Remarks:
(xl,yl) defines the upper left corner of the rectangle, and (xh,yh) defines
the lower right corner.

Draws the rectangle in the current ~DrawOp~:280 and ~LineStyle~:281, in the
colour specified by "c".  The radius of the corners is specified by "r".

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawRect~:223
  ~FilledRect~:224
  ~ThickRect~:225
  ~FilledRoundRect~:228
  ~ThickRoundRect~:229

 Sample Code:

  {DRndRect.PAS}

  {Sample code for the DrawRoundRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    X1, Y1, X2, Y2, R: Integer;
  begin
    SetMode(vm640x480x16);
    repeat
      X1 := Random(640);
      Y1 := Random(480);
      X2 := Random(640 - X1) + X1;
      Y2 := Random(480 - Y1) + Y1;
      R := (X2 - X1) div 2;
      if (Y2 - Y1) < R then R := (Y2 - Y1) div 2;
      R := Random(R);
      DrawRoundRect(X1, Y1, X2, Y2, R, Random(15)+1);
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%228
 FilledRoundRect (procedure)     ~(TGraph Unit)~:200
 
Draws a filled rectangle with round corners using the current FillPattern.

 Declaration:
  procedure FilledRoundRect(xl,yl,xh,yh:Integer; r:Word; c:LongInt);

 Remarks:
FilledRound Rect draws a filled-in rectangle (used in bar charts, for
example) using the current ~FillPattern~:283, ~BkColour~:282 (background colour
of the fill pattern) and ~DrawOp~:280 and the foreground pattern colour
passed in "c".  To draw an outlined rectangle, use DrawRoundRect.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawRect~:223
  ~FilledRect~:224
  ~ThickRect~:225
  ~DrawRoundRect~:227
  ~ThickRoundRect~:229

 Sample Code:

  {FlRndRct.PAS}

  {Sample code for the FilledRoundRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    X1, Y1, X2, Y2, R: Integer;
  begin
    SetMode(vm640x480x16);
    FillPattern := fpThatches;
    BkColour := -1;  { Transparent background }
    repeat
      X1 := Random(640);
      Y1 := Random(480);
      X2 := Random(640 - X1) + X1;
      Y2 := Random(480 - Y1) + Y1;
      R := (X2 - X1) div 2;
      if (Y2 - Y1) < R then R := (Y2 - Y1) div 2;
      R := Random(R);
      FilledRoundRect(X1, Y1, X2, Y2, R, Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%229
 ThickRoundRect (procedure)     ~(TGraph Unit)~:200
 
Draws a rectangle with round corners using thick lines.

 Declaration:
  procedure ThickRoundRect(xl,yl,xh,yh,r:Integer; t:Byte; c:LongInt);

 Remarks:
(xl,yl) defines the upper left corner of the rectangle, and (xh,yh) defines
the lower right corner.

Draws the rectangle with the line thickness set by "t" and the colour
specified by "c".  The radius of the corners is specified by "r".

It uses the current ~FillPattern~:283 and ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawRect~:223
  ~FilledRect~:224
  ~ThickRect~:225
  ~DrawRoundRect~:227
  ~FilledRoundRect~:228

 Sample Code:

  {ThkRdRct.PAS}

  {Sample code for the ThickRoundRect procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    X1, Y1, X2, Y2, R: Integer;
  begin
    SetMode(vm640x480x16);
    repeat
      X1 := Random(640);
      Y1 := Random(480);
      X2 := Random(640 - X1) + X1;
      Y2 := Random(480 - Y1) + Y1;
      R := (X2 - X1) div 2;
      if (Y2 - Y1) < R then R := (Y2 - Y1) div 2;
      R := Random(R);
      ThickRoundRect(X1, Y1, X2, Y2, R, Random(16), Random(16));
    until KeyPressed;
    ReadKey;
    SetMode(vmOriginal);
  end.


%226
 ShadowRect (procedure)     ~(TGraph Unit)~:200
 
Draws a bar that is "darker" than the area it is drawn on.

 Declaration:
  procedure ShadowRect(xl,yl,xh,yh:Integer);

 Remarks:
This procedure is used in BNGui for drawing shadows "under" dialog boxes,
windows, menus, etc.  It gives the GUI a more 3 dimensional effect.

In 16 colour mode, the rectangle from (xl,yl) to (xh,yh) is dithered with
black to form a darker region.

In 256 colour mode, only the first 20 colours are darkened with the second
20 colours (which are half intensity versions of the first 20 - see the
~TGColour Unit~:400).  The last 216 colours remain unaltered.

In Hi/True Colour modes (15,16 & 24 bits per pixel), the pixel value is halved.

 Restrictions:
Must be in graphics mode.

Currently only supports 16 & 256c colour modes.

 See Also:
  ~FilledRect~:224

%230
 DrawCircle (procedure)     ~(TGraph Unit)~:200
 
Draws a circle (in the colour set by "c"), using (x,y) as the center point.

 Declaration:
  procedure DrawCircle(x,y:Integer; d:Word; c:LongInt);

 Remarks:
Draws a circle in the colour set by "c" with a diameter of "d".  It also
uses the current ~LineStyle~:281.

Even diameters are rounded down to odd diameters.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FilledCircle~:231
  ~ThickCircle~:232
  ~DrawEllipse~:233
  ~DrawArc~:237
  ~DrawSector~:239

 Sample Code:

  {DrawCirc.PAS}

  {Sample code for the DrawCircle procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    for i := 1 to 5 do
      DrawCircle(100, 100, i * 20, i);
    Readkey;
    SetMode(vmOriginal);
  end.


%231
 FilledCircle (procedure)     ~(TGraph Unit)~:200
 
Draws a filled circle (in the colour set by "c"), using (x,y)
as the center point.

 Declaration:
  procedure FilledCircle(x,y:Integer d:Word; c:LongInt);

 Remarks:
Draws a filled circle in the colour set by "c" with a diameter of "d",
using the current ~FillPattern~:283 and ~DrawOp~:280.  ~BkColour~:282 is
the colour of the background of the fill pattern.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawCircle~:230
  ~ThickCircle~:232
  ~FilledEllipse~:234
  ~FilledSector~:240

 Sample Code:

  {FillCirc.PAS}

  {Sample code for the FilledCircle procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    DrawOp := doOr;
    FillPattern := fpFineWeave;
    for i := 5 downto 1 do begin
      BkColour:=i;
      FilledCircle(100, 100, i * 20, i);
    end;
    Readkey;
    SetMode(vmOriginal);
  end.


%232
 ThickCircle (procedure)     ~(TGraph Unit)~:200
 
Draws a thick lined circle (in the colour set by "c"), using (x,y)
as the center point with a thickness of "t".

 Declaration:
  procedure ThickCircle(x,y:Integer; d:Word; t:Byte; c:LongInt);

 Remarks:
Draws a circle in the colour set by "c" with a diameter of "d" with
a thickness of "t".

It uses the current ~FillPattern~:283 and ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawCircle~:230
  ~FilledCircle~:232
  ~ThickEllipse~:235
  ~ThickArc~:238

 Sample Code:

  {ThckCirc.PAS}

  {Sample code for the ThickCircle procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    for i := 1 to 5 do
      ThickCircle(100, 100, i * 20, i * 2, i);
    Readkey;
    SetMode(vmOriginal);
  end.


%233
 DrawEllipse (procedure)     ~(TGraph Unit)~:200
 
Draws a ellipse (in the colour set by "c"), using (x,y)
as the center point.

 Declaration:
  procedure DrawEllipse(x,y:Integer; a,b:Word; c:LongInt);

 Remarks:
Draws a ellipse in the colour set by "c" with diameters
of "a" (the x axis) and "b" (the y axis).

Even diameters are rounded down to odd diameters.  If even diameters are
required, use the slower DrawSEllipse.

Also, if the ellipse is needed with a LineStyle, use DrawSEllipse.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FilledEllipse~:234
  ~ThickEllipse~:235
  ~DrawSEllipse~:236
  ~DrawCircle~:232
  ~DrawArc~:237
  ~DrawSector~:239

 Sample Code:

  {DrwEllps.PAS}

  {Sample code for the DrawEllipse procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    for i := 1 to 5 do
      DrawEllipse(100, 100, i * 15, i * 10, 7);
    Readkey;
    SetMode(vmOriginal);
  end.


%234
 FilledEllipse (procedure)     ~(TGraph Unit)~:200
 
Draws a solid ellipse (in the colour set by "c"), using (x,y)
as the center point.

 Declaration:
  procedure FilledEllipse(x,y,a,b:Integer; c:LongInt);

 Remarks:
Draws a solid filled ellipse in the colour set by "c" with diameters of
"a" and "b", using the current ~FillPattern~:283 and ~DrawOp~:280, with the
background colour of the fill being set by ~BkColour~:282.

Use SolidEllipse if FillPattern and DrawOp are not used, and even
diameters aren't required.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawEllipse~:233
  ~ThickEllipse~:235
  ~DrawSEllipse~:236
  ~FilledCircle~:231
  ~FilledSector~:240

 Sample Code:

  {FillElps.PAS}

  {Sample code for the FilledEllipse procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    DrawOp := doOr;
    FillPattern := fpWeave;
    for i := 5 downto 1 do begin
      BkColour := i;
      FilledEllipse(100, 100, i * 15, i * 10, i + 8);
    end;
    Readkey;
    SetMode(vmOriginal);
  end.


%235
 ThickEllipse (procedure)     ~(TGraph Unit)~:200
 
Draws a thick lined ellipse (in the colour set by "c", using (x,y)
as the center point with a thickness of "t".

 Declaration:
  procedure ThickEllipse(x,y:Integer; a,b:Word; t:Byte; c:LongInt);

 Remarks:
Draws a ellipse in the colour set by "c" with diameters of
"a" and "b" with a thickness of "t".

It uses the current ~FillPattern~:283 and ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawEllipse~:233
  ~FilledEllipse~:234
  ~DrawSEllipse~:236
  ~ThickCircle~:232
  ~ThickArc~:238

 Sample Code:

  {ThckElps.PAS}

  {Sample code for the ThickEllipse procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    for i := 1 to 5 do
      ThickEllipse(100, 100, i * 15, i * 10, i * 2, i);
    Readkey;
    SetMode(vmOriginal);
  end.


%236
 DrawSEllipse (procedure)     ~(TGraph Unit)~:200
 
Draws a ellipse (in the colour set by "c"), using (x,y)
as the center point.

 Declaration:
  procedure PutSEllipse(x,y:Integer; a,b:Word; c:LongInt);

 Remarks:
Draws a ellipse in the colour set by "c" with radii of "a" and "b"
using the current ~DrawOp~:280 and ~LineStyle~:281.

Use DrawEllipse if DrawOp and LineStyle doesn't need to be used, and
even diameters aren't required.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawEllipse~:233
  ~FilledEllipse~:234
  ~ThickEllipse~:235
  ~DrawCircle~:230
  ~DrawArc~:237
  ~DrawSector~:239

 Sample Code:

  {DwsEllps.PAS}

  {Sample code for the DrawSEllipse procedure.}

  uses TGProcs, TGDriver, TGraph;

  var
    i: Integer;
  begin
    SetMode(vm640x480x16);
    LineStyle:=lsDash;
    for i := 1 to 5 do
      DrawSEllipse(100, 100, i * 15, i * 10, 7);
    Readkey;
    SetMode(vmOriginal);
  end.


%237
 DrawArc (procedure)     ~(TGraph Unit)~:200
 
Draws an elliptical arc.

 Declaration:
  procedure PutArc(x,y:Integer; sangle,eangle,a,b:Word; c:LongInt);

 Remarks:
Draws an arc from "sangle" (start angle) to "eangle" (end angle),
with diameters "a" and "b" using (x,y) as the center point and "c" as
the colour.  It uses the current ~DrawOp~:280.

A start angle of 0 and an end angle of 360 will draw and fill a complete
ellipse. The angles for PutArc, PutSector and FilledSector are
counter-clock-wise with 0 degrees at 3 o'clock, 90 degrees at
12 o'clock, and so on.

It updates the ~ArcCoords~:284 variable.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~ThickArc~:238
  ~DrawSector~:239
  ~FilledSector~:240
  ~DrawBezier~:241
  ~DrawEllipse~:233
  ~DrawCircle~:230

 Sample Code:

  {DrawArc.PAS}

  {Sample code for the DrawArc procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    DrawArc(100, 100, 0, 360, 30, 50, 14);
    DrawArc(100, 100, 0, 150, 50, 30, 12);
    Readkey;
    SetMode(vmOriginal);
  end.


%238
 ThickArc (procedure)     ~(TGraph Unit)~:200
 
Draws a thick elliptical arc.

 Declaration:
  procedure ThickArc(x,y:Integer; sangle,eangle,a,b:Word;
                     t:Byte; c:LongInt);

 Remarks:

 See Also:
  ~DrawArc~:237

%239
 DrawSector (procedure)     ~(TGraph Unit)~:200
 
Draws a hollow elliptical sector.

 Declaration:
  procedure DrawSector(x,y:Integer; sangle,eangle,a,b:Word; c:LongInt);

 Remarks:
Using (x,y) as the center point, "a" and "b" specify the horizontal
and vertical diameters, respectively; DrawSector draws from "sangle" to
"eangle", outlined with the colour "c".

A start angle of 0 and an end angle of 360 will draw and fill a complete
ellipse. The angles for DrawArc, DrawSector and FilledSector are
counter-clock-wise with 0 degrees at 3 o'clock, 90 degrees at
12 o'clock, and so on.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FilledSector~:240
  ~DrawArc~:237
  ~ThickArc~:238
  ~DrawEllipse~:233
  ~DrawCircle~:230

 Sample Code:

  {DrawSctr.PAS}

  {Sample code for the DrawSector procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    DrawSector(320, 200, 0, 45, 150, 100, 14);
    DrawSector(320, 200, 180, 135, 150, 150, 12);
    Readkey;
    SetMode(vmOriginal);
  end.


%240
 FilledSector (procedure)     ~(TGraph Unit)~:200
 
Draws and fills an elliptical sector.

 Declaration:
  procedure FilledSector(x,y:Integer; sangle,eangle,a,b:Word; c:LongInt);

 Remarks:
Using (x,y) as the center point, "a" and "b" specify the horizontal
and vertical diameters, respectively; FilledSector draws a sector from
"sangle" to "eangle", filled with the current ~FillPattern~:283 using
colour "c" and the background colour ~BkColour~:282.

A start angle of 0 and an end angle of 360 will draw and fill a complete
ellipse. The angles for DrawArc, DrawSector and FilledSector are
counter-clock-wise with 0 degrees at 3 o'clock, 90 degrees at
12 o'clock, and so on.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawSector~:239
  ~DrawArc~:237
  ~ThickArc~:238
  ~FilledEllipse~:234
  ~FilledCircle~:231

 Sample Code:

  {FillSctr.PAS}

  {Sample code for the FilledSector procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    FillPattern := fpGrey50;
    FilledSector(320, 200, 0, 45, 150, 100, 14);
    FilledSector(320, 200, 180, 135, 150, 150, 12);
    Readkey;
    SetMode(vmOriginal);
  end.


%241
 DrawBezier (procedure)     ~(TGraph Unit)~:200
 
Draws a bezir curve between two end points according to two control points.

 Declaration:
  procedure DrawBezier(E1x,E1y,C1x,C1y,C2x,C2y,E2x,E2y:Integer; c:LongInt);

 Remarks:
DrawBezier draws a bezir curve between the two end points, (E1x,E1y) and
(E2x,E2y), according to two control points for each end point, (C1x,C1y)
and (C2x,C2y), with colour "c" and the current ~DrawOp~:280.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawArc~:237

 Sample Code:

  {Bezier.PAS}

  {Sample code for the DrawBezier procedure.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(12);
    Randomize;
    DrawBezier(Random(640),Random(480),Random(640),Random(480),
               Random(640),Random(480),Random(640),Random(480),15);
    Readkey;
    SetMode(vmOriginal);
  end.


%242
 FloodFill (procedure)     ~(TGraph Unit)~:200
 
Fills an area at (sdx,sdy) of the same colour with a new colour "c".

 Declaration:
  procedure FloodFill(sdx,sdy:Integer; c:LongInt);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~BorderFill~:243

%243
 BorderFill (procedure)     ~(TGraph Unit)~:200
 
Fills a region bordered by colour "b" with a new colour "c".

 Declaration:
  procedure BorderFill(sdx,sdy:Integer; c,b:LongInt);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FloodFill~:242

%244
 DrawPoly (procedure)     ~(TGraph Unit)~:200
 
Draws a the outline of a polygon.

 Declaration:
  procedure DrawPoly(var VertexPoints; numPoints:Integer; c:Longint;
                     XOffset,YOffset:Integer);

 Remarks:
VertexPoints is an untyped parameter that contains the coordinates of each
vertex in the polygon relative to (XOffset,YOffset).  numPoints specifies
the number of coordinates in VertexPoints. A coordinate consists of two
words, an X and a Y value, using ~TPoint~:290 is suggested.

DrawPoly draws all the lines using the colour defined by "c" using the
current ~DrawOp~:280 and ~LineStyle~:281.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~FilledPoly~:245
  ~ConvexPoly~:246

 Sample Code:

  {DrawPoly.PAS}

  {Sample code for the DrawPoly procedure.}

  uses TGProcs, TGDriver, TGraph;

  const
    Triangle: array[1..3] of TPoint = ((x:50; y:100),
      (x:100; y:100), (x:150; y:150));
  begin
    SetMode(vm640x480x16);
    DrawPoly(Triangle, SizeOf(Triangle) div SizeOf(TPoint), 11, 50, 100);
    Readkey;
    SetMode(vmOriginal);
  end.


%245
 FilledPoly (function)     ~(TGraph Unit)~:200
 
Draws a solid polygon.

 Declaration:
  procedure FilledPoly(var VertexPoints; numPoints:Integer; c:Longint;
                       XOffset,YOffset:Integer);

 Remarks:
VertexPoints is an untyped parameter that contains the coordinates of each
vertex in the polygon relative to (XOffset,YOffset).  numPoints specifies
the number of coordinates in VertexPoints. A coordinate consists of two
words, an X and a Y value, using ~TPoint~:231 is suggested.

FilledPoly calculates all the horizontal intersections, and then fills the
polygon using the colour defined by "c" using the current ~DrawOp~:280 and
~FillPattern~:283 and ~BkColour~:282.

It returns false if it doesn't succeed in allocating memory for the
scan converter.

If the polygon is "simple" use ConvexPoly as it is faster.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawPoly~:244
  ~ConvexPoly~:246

 Sample Code:

  {FlldPoly.PAS}

  {Sample code for the FilledPoly procedure.}

  uses TGProcs, TGDriver, TGraph;

  const
    Triangle: array[1..3] of TPoint = ((x:50; y:100),
      (x:100; y:100), (x:150; y:150));
  begin
    SetMode(vm640x480x16);
    FilledPoly(Triangle, SizeOf(Triangle) div SizeOf(TPoint), 11, 50, 100);
    Readkey;
    SetMode(vmOriginal);
  end.


%246
 ConvexPoly (function)     ~(TGraph Unit)~:200
 
Draws a solid convex polygon.

 Declaration:
  procedure ConvexPoly(var VertexPoints; numPoints:Integer; c:Longint;
                       XOffset,YOffset:Integer);

 Remarks:
ConvexPoly draws simple (monotone-vertical) polygons with colour "c" using
the current ~FillPattern~:283 and ~DrawOp~:280.

The polygon must not have any intersecting edges, if it does, use the
slower FillPoly.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawPoly~:244
  ~FilledPoly~:245

%247
 BlockSize (function)    ~(TGraph Unit)~:200
 
Returns the number of bytes needed to store an area for GetBlock.

 Declaration:
  procedure BlockSize(xl,yl,xh,yh:Integer):LongInt;

 Remarks:
BlockSize returns the number of bytes needed to store the area specified
by (xl,yl) and (xh,yh) into memory using GetBlock.  It returns a LongInt
type for the future when Get/PutBlock works with EMS and XMS memory.

It is suggested to call this function before allocating memory for
GetBlock.

 SeeAlso:
  ~GetBlock~:248
  ~PutBlock~:249

 Sample Code:

  {BlkSize.PAS}

  {Sample code for the BlockSize function.}

  uses TGProcs, TGDriver, TGraph;

  var
    block : Pointer;
    i     : Integer;

  begin
    SetMode(vm640x480x16);
    Randomize;
    for i:=1 to 2000 do
      DrawPixel(Random(640),Random(480),Random(16));
    GetMem(block,BlockSize(50,50,100,100);
    GetBlock(50,50,100,100,block^);
    for i:=1 to 10 do
      PutBlock(Random(590),Random(430),block^);
    FreeMem(block,BlockSize(50,50,100,100);
    Readkey;
    SetMode(vmOriginal);
  end.


%248
 GetBlock (procedure)    ~(TGraph Unit)~:200
 
Saves a bit image of the specified region into a buffer.

 Declaration:
  procedure GetBlock(xl,yl,xh,yh:Integer; var blk);

 Remarks:
xl, yl, xh, and yh define a rectangular region on the screen.  "blk" is an
untyped parameter that must be greater than or equal to 4 plus the amount of
area defined by the region. The two words of the block store the width
and height of the region.

The remaining part of then block is used to save the bit image itself. Use
the BlockSize function to determine the size requirements of the block.

 Restrictions:
Must be in graphics mode.
The memory required to save the region must be less than 64K.

 See Also:
  ~BlockSize~:247
  ~PutBlock~:249
  ~PutTransBlock~:250
  ~PutStyleBlock~:251

%249
 PutBlock (procedure)    ~(TGraph Unit)~:200
 
Puts a bit image onto the screen.

 Declaration:
  procedure PutBlock(x,y:Integer; var blk);

 Remarks:
(x,y) is the upper left corner of a rectangular region on the screen.
"blk" is an untyped parameter that contains the height and width of the
region, and the bit image that will be put onto the screen.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutTransBlock~:250
  ~PutStyleBlock~:251
  ~GetBlock~:248
  ~BlockSize~:247

%250
 PutTransBlock (procedure)    ~(TGraph Unit)~:200
 

 Declaration:
  procedure PutTransBlock(x,y:Integer; var blk);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutBlock~:249
  ~PutStyleBlock~:251
  ~GetBlock~:248
  ~BlockSize~:247

%251
 PutStyleBlock (procedure)    ~(TGraph Unit)~:200
 

 Declaration:
  procedure PutStyleBlock(x,y:Integer; var blk; op:Byte);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutBlock~:249
  ~PutTransBlock~:250
  ~GetBlock~:248
  ~BlockSize~:247

%252
 DrawButton (procedure)     ~(TGraph Unit)~:200
 
Draws a pushbutton on the screen for a user interface.

 Declaration:
  procedure DrawButton(xl,yl,xh,yh:Integer; c:LongInt; h:ShortInt);

 Remarks:
PutButton draws a button with corners at (xl,yl) and (xh,yh), with a
height of "h".  For an unpressed button, h is positive, and if pressed,
h is negative.  "c" specifies the colour of the button face, the edges
are various shades of grey.

 ~btXXX-constants~:272

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawFrame~:253
  ~DrawHDivider~:254
  ~DrawVDivider~:255

%253
 DrawFrame (procedure)     ~(TGraph Unit)~:200
 

 Declaration:
  procedure DrawFrame(xl,yl,xh,yh:Integer; c:LongInt; h,w:ShortInt);

 Remarks:

 ~btXXX-constants~:272

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawButton~:252
  ~DrawHDivider~:254
  ~DrawVDivider~:255

%254
 DrawHDivider (procedure)     ~(TGraph Unit)~:200
 

 Declaration:
  procedure DrawHDivider(xl,xh,y:Integer; h,w:ShortInt);

 See Also:
  ~DrawButton~:252
  ~DrawFrame~:253
  ~DrawVDivider~:255

%255
 DrawVDivider (procedure)     ~(TGraph Unit)~:200
 

 Declaration:
  procedure DrawVDivider(x,yl,yh:Integer; h,w:ShortInt);

 See Also:
  ~DrawButton~:252
  ~DrawFrame~:253
  ~DrawHDivider~:254

%280
 DrawOp (variable)     ~(TGraph Unit)~:200
 
The DrawOp variable specifies how graphic primitives are drawn
on the screen.

 Declaration:
  DrawOp : Byte;

Four line types are possible:
  - Replaced
  - ANDed
  - ORed
  - XORed

These four types are represented by four ~doXXX-constants.~:270

%281
 LineStyle (variable)     ~(TGraph Unit)~:200
 
The LineStyle variable specifies a 16-bit pattern that is used to
draw lines.  A custom line style can be set.

 Declaration:
  LineStyle : Word;

There are eight standard ~lsXXX-constants.~:271

The procedures that supports line styles are:
  - PutLine
  - PutRect
  - and all OldXXX procedures.

%282
 BkColour (variable)     ~(TGraph Unit)~:200
 
BkColour is used when pattern fills are used.

 Declaration:
  BkColour : LongInt;

It is also used for procedures that use a ~FillPattern~:283 for
specifying the background colour of the patterned fill.

If BkColour is set to -1 then it assumed that the background is transparent.

%283
 FillPattern (variable)     ~(TGraph Unit)~:200
 
FillPattern specifies the fill pattern used by FilledXXX procedures.

 Declaration:
  FillPattern : ~TPattern~:291;

FillPattern specifies the current 8x8 matrix used to fill the procedures
that use pattern fills (see below).

There are currently 32 standard fill pattern types defined by a series
of ~fpXXX-constants~:273.

Also, there is an array of 17 patterns defined used for dithering 2
colours to form more colours.  See ~Dithering-constants~:274.

%284
 ArcCoords (variable)     ~(TGraph Unit)~:200
 
Contains the coordinates of the last DrawArc command.

 Declaration:
  ArcCoords : record
    cx,cy,sx,sy,ex,ey : Integer;
  end;

 Remarks:
ArcCoords contains a variable containing the center point (cx,cy),
the starting position (sx,sy), and the ending position (ex,ey) of
the last DrawArc or similar command.

These values are useful if you need to connect a line to the end of an arc.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~DrawArc~:237
  ~DrawSector~:239
  ~FilledSector~:240

 Sample Code:

  {Arccoord.PAS}

  {Sample code for the ArcCoords variable.}

  uses TGProcs, TGDriver, TGraph;

  begin
    SetMode(vm640x480x16);
    DrawArc(100, 100, 30, 40, 0, 270, 14);
    with ArcCoords do
      DrawLine(sx, sy, ex, ey, 15);
    Readkey;
    SetMode(vmOriginal);
  end.


%290
 TPoint (type)     ~(TGraph Unit)~:200
 
A type defined for your convenience.  Both fields are of type
Integer.  It is typically used for polygon drawing.

 Declaration:
  TPoint = record
    x, y : integer;
  end;

%291
 TPattern (type)     ~(TGraph Unit)~:200
 
A type used for defining an 8x8 matrix used for pattern fills.

 Declaration:
  TPattern = array [0..7] of Byte;

 See Also:
  ~FillPattern~:283

%270
 Draw-Op constants     ~(TGraph Unit)~:200
 
Four ~DrawOps~:280 are supported for graphic primitives, these are:

  Constants  Value
 
  doRep      $00    (Default)
  doAnd      $08
  doOr       $10
  doXor      $18

%271
 Line-Style constants     ~(TGraph Unit)~:200
 
There are eight standard ~LineStyles~:281 for drawing graphic primitives,
these are:

  Constants     Value  Pattern
 
  lsSolid (Def) $FFFF  
  lsClear       $0000 
  lsDot         $AAAA                 
  lsDash        $3C3C                
  lsLongDash    $1FF8           
  lsDashDot     $FC9F          
  lsDotDashDot  $4FF2             
  lsFaintDot    $8888                       

%272
 Button-Type constants     ~(TGraph Unit)~:200
 
There are currently size different types of button types (other
than the standard type) used by ~DrawButton~:252 and ~DrawFrame~:253:

  Constants     Value    Description
 
  btNoFill     $1000000  Don't fill the button face
  btThin       $2000000  Put a thin black line around the button
  btTrendy    $20000000  Put a "ridge" around the button

Note:
These are LongInt types because they are passed to the procedure
in the colour parameter.

%273
 Fill Pattern constants     ~(TGraph Unit)~:200
 
These are the standard ~FillPatterns~:283 supplied in TGraph used by
FilledXXX and ThickXXX procedures.

  Constants     Description
 
  BGI Fill Patterns
 
  fpSolid       Solid fill using draw colour
  fpClear       Solid fill using BkColour
  fpLine        Horizontal lines
  fpLtSlash     /// fill
  fpSlash       /// thick fill
  fpBkSlash     \\\ thick fill
  fpLtBkSlash   \\\ fill
  fpHatch       Light hatch fill
  fpXHatch      Cross hatch fill
  fpInterleave  Interleaving line
  fpWideDot     Widely spaced dot
  fpCloseDot    Closely spaced dot
 
  Windows Background Fill Patterns
 
  fpGrey50     
  fpBoxes      
  fpCritters   
  fpDiamonds   
  fpPaisley    
  fpPattern    
  fpQuilt      
  fpScottie    
  fpSpinner    
  fpThatches   
  fpTulip      
  fpWaffle     
  fpWeave      
 
  Other Fill Patterns
 
  fpBrick      
  fpDiagBrick  
  fpBalls      
  fpShingles   
  fpCircles    
  fpScales     
  fpFineWeave  

%274
 Dithering constants     ~(TGraph Unit)~:200
 
There are 17 standard "dithering" patterns used for dithering two colours
to form another colour.

 Declaration:
  DitherPtrns : array [0..16] of ~TPattern~:291;

The patterns range from 0% [0] (blank foreground) to 100% [16] (solid
foreground) in even steps.

 See Also:
  ~FillPattern~:283
  ~fpXXX-constants~:273

 Sample Code:
  ~Dither.PAS~:299

%299
 { Dither.PAS }

 { Demonstrates TGraph dithering constants forming a Gradient Fill }

 uses TGProcs,TGDriver,TGraph,TGColour,TGText;

 var
   i : Byte;
   d,s : Integer;

 begin
   SetMode(vm800x600x16);
   d:=ModeInfo.Height shr 5;
   s:=d shl 4;
   SetStandardPalette;
   asm
         mov     ax,1010h { Set dark blue to half intensity of blue }
         mov     bx,1
         mov     dh,0
         mov     ch,0
         mov     cl,37
         int     10h
   end;
   ScreenOff;
   for i:=0 to 15 do begin
     FillPattern:=DitherPtrns[16-i];
     BkColour:=1;
     FilledRect(0,i*d,ModeInfo.Width,(i+1)*d-1,9);
     BkColour:=-1;
     FilledRect(0,i*d+s,ModeInfo.Width,(i+1)*d+s-1,1);
     if i=0 then begin
       BkColour:=0;
       FillPattern:=DitherPtrns[8];
       FilledRect(ModeInfo.Width shr 1,i*d+s,ModeInfo.Width,(i+1)*d+s-1,9);
     end;
   end;
   DrawStr(8,4,'Gradient fill using 3 colours (Black, Dark Blue and Blue).',14);
   ScreenOn;
   ReadKey;
   for i:=0 to 15 do begin
     FillPattern:=DitherPtrns[16-i];
     BkColour:=0;
     FilledRect(0,i*d*2,ModeInfo.Width,(i+1)*d*2-1,9);
   end;
   DrawStr(8,4,'Gradient fill using 2 colours (Black and Blue).',14);
   ReadKey;
   SetMode(vmOriginal);
 end.

%300
 TGText Unit
 

The TGText unit provides all the functions for draw graphics text in
Turbo Graphics library.  It supports the loading of various fonts from
TGF files and displaying of them.  TG Fonts support both standard
monochrome bitmapped fonts as well as multicolour fonts.

Text can be drawn horizontally, like normal, but also, in another function,
the letters can be rotated through 90, 180 and 270 degrees, as well as an
italic function.  Currently, text can also be drawn horizontally and
vertically as well.

A new addition to this unit will allow text to be drawn at any angle, and
will also allow scaling and any other shearing or other 2 dimensional
transformations.

In the next version, TrueType font support will be added as well.

One last comment on the text, a background colour can be specified to allow
flicker free continuous update of text information (such as the time), so
the old text doesn't have to be erased to draw the new text.  Generally,
though, this is quite a bit slower than the standard transparent background.

 Functions and Procedures:
  ~ChooseFont~:310
  ~CharWidth~:311
  ~CharHeight~:312
  ~TextWidth~:313

  ~DrawChar~:320
  ~DrawStr~:321
  ~DrawCentreStr~:322
  ~DrawText~:323

  ~DrawTransStr~:330
  ~DrawRotStr~:331
  ~DrawScaleStr~:332

 Types:
  ~TFontSet~:370

 Variables:
  ~CurFont~:380
  ~TextBkColour~:381
  ~TextStyle~:382
  ~TextSpace~:383

 Constants:
  ~fntXXX~:390
  ~tsXXX~:391
  ~txSolid~:392
  ~BIOSFont~:393

 See Also:
  ~TG font format~:305

%305
 TG Font Format     ~(TGText Unit)~:300
 

This is the format for the Data field of ~TFontSet~:370...

  FontType : Byte;  (offset 0)
  
    This is the type of TG Font:
      0 - Monochrome bitmapped
      1 - Colour bitmapped              (256 colours only)
      2 - Colour bitmapped with palette (256 colours only)

  Height : Byte;  (offset 1)
  
    The pixel height of the bitmapped font.

  Top : Byte;  (offset 2)
  
    The typographical top line of the letters from
    the top line of the font.

  Bottom : Byte;  (offset 3)
  
    The typographical bottom line of the letters
    from the top line of the font.

  First : Byte;  (offset 4)
  
    The first letter in the bitmap.

  Last : Byte;  (offset 5)
  
    The last letter in the bitmap.

  Width : Word;  (offset 6)
  
    The byte width of the font bitmap.

  CharWidths : array [First..Last] of Byte;  (offset 8)
  
    The pixel width of each letter in the font bitmap.

  CharOffsets : array [First..Last] of Word;  (offset 8 + (Last-First+1))
  
    The offset from the start of the Data field
    to the location of the first byte of the
    letter in the bitmap.

    Each letter is byte aligned within the bitmap.

  
   These fields are for FontType 2 (coloured bitmap with palette)...
  
     Size : Byte;  (offset 8 + (Last-First+1)*3)
     
       Size of the colour palette.
  
     FirstCol : Byte;  (offset 9 + (Last-First+1)*3)
     
       First colour to set in the palette.
  
     Palette : array [1..Size] of TColour;  (offset 10 + (Last-First+1)*3)
     
       The actual colour palette.
  

  Bitmap : array [1..Width*Height] of Byte;  (offset - see CharOffsets)
  
    The actual font bitmap, it is one big horizontal bitmap,
    the width is "Width" bytes, and "Height" lines.

     First                                                 -> Last
    
     !"#$%&'()*+,-./0123456789
    


%310
 ChooseFont (function)     ~(TGText Unit)~:300
 
Makes the specified font the current font.

 Declaration:
  function ChooseFont(name:String; size:Byte):Boolean;

 Remarks:
Firstly, tries to find the specified font in the loaded font list, if found,
sets ~CurFont~:380 to the matching font.  If the font has not been
previously loaded, the "name" file is opened and searched through the file
for a matching font of the same height as "size".

If no matching font can be found, the function returns False, otherwise,
returns True.

 See Also:
  ~DrawStr~:321
  ~DrawText~:323
  ~BIOSFont constant~:393

%311
 CharWidth (function)     ~(TGText Unit)~:300
 
Gets the pixel width of a character in a font.

 Declaration:
  function CharWidth(c:Char):Byte;

 Remarks:
Returns the width of the character "c" in pixels of the proportional
spaced font specified by ~CurFont~:380.

 See Also:
  ~CharHeight~:312
  ~TextWidth~:313
  ~ChooseFont~:310
  ~DrawChar~:320
  ~DrawStr~:321
  ~DrawText~:323

 Sample Code:

  {ChrWidth.PAS}

  {Sample code for the CharWidth function.}

  uses TGProcs, TGDriver, TGText;

  begin
    SetMode(vm640x480x16);
    LoadAFont('Roman',35);
    PutChar(10, 10, 'B', 14, FontSet);
    PutChar(10 + CharWidth('A', FontSet), 'B', 66, 12, FontSet);
    Readkey;
    SetMode(vmOriginal);
  end.


%312
 CharHeight (function)     ~(TGText Unit)~:300
 
Gets the pixel heigth of a font.

 Declaration:
  function CharHeight:Byte;

 Remarks:
Returns the height of the currently selected font, ~CurFont~:380, in pixels.

 See Also:
  ~CharWidth~:311
  ~TextWidth~:313
  ~ChooseFont~:310
  ~DrawChar~:320
  ~DrawStr~:321
  ~DrawText~:323

 Sample Code:

  {CharHght.PAS}

  {Sample code for the CharHeight function.}

  uses TGProcs, TGDriver, TGText;

  begin
    SetMode(vm640x480x16);
    ChooseFont('Roman',35);
    DrawStr(10, 10, 'Line 1', 14);
    DrawStr(10, 10 + CharHeight, 'Line 2', 12);
    Readkey;
    SetMode(vmOriginal);
  end.


%313
 TextWidth (function)     ~(TGText Unit)~:300
 
Gets the pixel length of a string using a proportional spaced font.

 Declaration:
  function TextWidth(s:String):Integer;

 Remarks:
Returns the length of the entire string "s", using the set font
~CurFont~:380, in pixels.

 See Also:
  ~CharHeight~:312
  ~CharWidth~:311
  ~ChooseFont~:310
  ~DrawStr~:321
  ~DrawText~:323

 Sample Code:

  {TxtWidth.PAS}

  {Sample code for the TextWidth function.}

  uses TGProcs, TGDriver, TGText;

  begin
    SetMode(vm640x480x16);
    ChooseFont('Roman',35);
    DrawStr(10, 10, 'First', 14);
    DrawStr(10 + TextWidth('First '), 10, 'Second', 12);
    Readkey;
    SetMode(vmOriginal);
  end.


%320
 DrawChar (procedure)     ~(TGText Unit)~:300
 
Draws a single character at (x,y).

 Declaration:
  procedure DrawChar(x,y:Integer; l:Char; c:LongInt);

 Remarks:
Draws a character "l" at top-left corner (x,y) using the font specified
by ~CurFont~:380 with foreground colour "c".

If the ~txSolid~:392 constant is added to the colour, then the background
of the letter is drawn with the colour specified by ~TextBkColour~:381.

 See Also:
  ~ChooseFont~:310
  ~DrawStr~:321
  ~DrawText~:323

%321
 DrawStr (procedure)     ~(TGText Unit)~:300
 
Draws a proportional spaced left justified string at (x,y).

 Declaration:
  procedure DrawStr(x,y:Integer; s:String; c:LongInt);

 Remarks:
Draws a left justified string using the font specified by ~CurFont~:380
which is loaded by ChooseFont.  "c" specifies the foreground colour of
the string, and if the ~txSolid~:392 constant is added to "c", the
background of the string is drawn to, according to ~TextBkColour~:381.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~ChooseFont~:310
  ~DrawChar~:320
  ~DrawText~:323
  ~DrawCentreStr~:322

%322
 DrawCentreStr (procedure)     ~(TGText Unit)~:300
 
Draws a proportional spaced string centred at (x,y).

 Declaration:
  procedure DrawCentreStr(x,y:Integer; s:String; c:LongInt);

 Remarks:
Draws a horizontally centred string at (x,y) using the font specified
by ~CurFont~:380 which is loaded by ChooseFont.

"c" specifies the foreground colour of the string, and if the
~txSolid~:392 constant is added to "c", the background of the string
is drawn to, according to ~TextBkColour~:381.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~ChooseFont~:310
  ~DrawStr~:321
  ~DrawChar~:320
  ~DrawText~:323

%323
 DrawText (procedure)     ~(TGText Unit)~:300
 
Draw a text string using the current TextStyle.

 Declaration:
  procedure PutText(x,y:Integer; s:String; c:LongInt);

 Remarks:
DrawText draws a proportional spaced text string "s" according to the current
~TextStyle~:382, the colour "c" and the font specified by ~CurFont~:380.

Currently, the bold style is not supported, it has to be done manually.

 Restrictions:
Must be in graphics mode.

 See Also:
  ~ChooseFont~:310
  ~PutChar~:320
  ~PutStr~:321
  ~tsXXX-constants~:391

 Sample Code:

  {DrawText.PAS}

  {Sample code for the DrawText function.}

  uses TGProcs, TGDriver, TGText;

  begin
    SetMode(vm640x480x16);
    ChooseFont('Main',16);
    TextStyle := tsCentre + tsTtoB + tsSolid;
    TextBkColour := 7;
    DrawText(10,0,480,'Vertically Centred with grey background',0);
    Readkey;
    SetMode(vmOriginal);
  end.


%330
 DrawTransStr (procedure)     ~(TGText Unit)~:300
 

%331
 DrawRotStr (procedure)     ~(TGText Unit)~:300
 

%332
 DrawScaleStr (procedure)     ~(TGText Unit)~:300
 

%370
 TFontSet (type)     ~(TGText Unit)~:300
 

 PFontSet = ^TFontSet;
 TFontSet = record
   FontName : String[40];  - Name of Font file
   FileName : String[8];   - File name of font file
   FontType : Word;        - Type of font
   DataSize : Word;        - Size of Data in bytes
   Data     : Pointer;     - character width & definitions
   ID       : Integer;     - Numerical ID of font
   Next     : PFontSet;    - pointer to next font in list
 end;

 See Also:
  ~CurFont~:380
  ~TFontSet.Data format~:305
  ~FontType contants~:390

%380
 CurFont (variable)     ~(TGText Unit)~:300
 

%381
 TextBkColour (variable)     ~(TGText Unit)~:300
 

%382
 TextStyle (variable)     ~(TGText Unit)~:300
 
The TextStyle variable contains information on how ~DrawText~:323 puts the
text string on the screen.

 Declaration:
  TextStyle : Word;

  15                            0
 Ŀ
    RotDirUIndSIBY-JX-J
 

  "X-J" and "Y-J" are the Justification bits (0-3)
   for each axis:
     0 - left (top) justified (default).
     1 - centred.
     2 - right (bottom) justified.
     3 - full justification.
  "B" is the bold text bit (4).  If set, the text
     is fattened according to the size of the letter
     to give an accurate illusion of boldening.
  "I" is the italic text bit (5).  If set, the
     text is slanted slightly (1 pixel in 3).
  "S" is the solid background bit (6).  If set,
     the background of the string is solid, not
     transparent, the colour set by ~BkColour~:214.
  "Ind" are the indent bits (7,8):
     0 - no indentation (default).
     1 - light indentation
     2 - heavy indentation
     3 - outdent.
  "U" is the underline bit (9).  If set, all
     characters following a ^ is underlined.
  "Dir" are the direction bits (10,11):
     0 - left to right (normal).
     1 - top to bottom.
     2 - right to left.
     3 - bottom to top.
  "Rot" are the rotation bits (12,13) for the
   characters:
     0 - upright.
     1 - rotated anticlockwise 90.
     2 - rotated 180.
     3 - rotated clockwise 90.

The styles are represented by several ~tsXXX constants.~:391

%383
 TextSpace (variable)     ~(TGText Unit)~:300
 

%390
 Font-Type constants     ~(TGText Unit)~:300
 

  fntTGF
  fntTTF

%391
 Text-Style constants     ~(TGText Unit)~:300
 
These are the ~TextStyles~:382 used by ~DrawText~:323:

  Constants    Value  Description
 
  tsLeft       $0000  Left justified text
  tsCentre     $0001  Centred text
  tsRight      $0002  Right justfied text
  tsFull       $0003  Full justified text
  tsTop        $0000  Top of text is at y (or x)
  tsMiddle     $0004  Middle of text is at y
  tsBottom     $0008  Bottom of text is at y
  tsBody       $000C  Bottom of "body" of text is at y
  tsBold       $0010  Make text bold
  tsItalic     $0020  Italicize text
  tsSolid      $0040  Make solid background (BkColour)
  tsIndent     $0080  Indent text (typically grey surface)
  tsLtIndent   $0100  Lightly indents text
  tsOutdent    $0180  Outdent text (opposite of indent)
  tsUnderline  $0200  Underline letters following a caret (^)
  tsLtoR       $0000  Draw text from left to right (normal)
  tsTtoB       $0400  Draw text from top to bottom (vertical)
  tsRtoL       $0800  Draw text from right to left (backwards)
  tsBtoT       $0C00  Draw text from bottom to top
  tsRot0       $0000  Draw letters upright (normal)
  tsRot90      $1000  Draw letters rotated 90 anticlockwise
  tsRot180     $2000  Draw letters rotated 180 (upside down)
  tsRot270     $3000  Draw letters rotated 270

The default is left justified, top alignment, left to right direction
and 0 rotation.

DrawText currently does not support tsBold and tsUnderline.

Also, tsItalic is not supported if the characters are rotated by an
angle other than 0.

%392
 txSolid (constant)     ~(TGText Unit)~:300
 

%393
 BIOSFont (constant)     ~(TGText Unit)~:300
 


%400
 TGColour Unit
 

The TGColour unit includes a range of procedures for colour manipulation
in various formats.  Included is support for palette control, colour model
conversions and BNGui colour control.

 Functions and Procedures:
  ~SetStandardPalette~:410
  ~StandardColour~:411

  ~SetRGBPalette~:412
  ~SetHSIPalette~:413
  ~SetPalette~:414
  ~GetPalette~:415
  ~FadeIn~:416
  ~FadeOut~:417
  ~CyclePalette~:418
  ~GreyScale~:419

  ~PackRGB~:430
  ~PackHSI~:431
  ~PackYUV~:432
  ~UnPackRGB~:435
  ~UnPackHSI~:436
  ~UnPackYUV~:437

  ~RGBtoHSI~:440
  ~RGBtoHLS~:441
  ~RGBtoCMYK~:442
  ~RGBtoYUV~:443
  ~HSItoRGB~:444
  ~HSItoCMYK~:445
  ~HLStoRGB~:446
  ~CMYKtoRGB~:447
  ~CMYKtoHSI~:448
  ~YUVtoRGB~:449

 Types:
  ~TColour~:460
  ~TPalette~:461

 Constants:
  ~Gamma23~:470
  ~Gamma13~:471

 Variables:
  ~FadeSteps~:480
  ~CurPalette~:481

 See Also:
  ~TGColour Info~:409

%410
 SetStandardPalette (procedure)     ~(TGColour Unit)~:400
 
Sets a standard palette to be used in BNGui applications.

 Declaration:
  procedure SetStandardPalette;

 Remarks:
In 16 colour mode, the standard palette uses all 16 entries, and the
colours are similar to the standard BIOS palette.

In 256 colour mode, the standard palette uses the first 40 entries.  The
first 16 are the same as in the 16 colour mode version, plus 4 more.  The
last 20 are darker versions of the first 20, used for shadowing of windows,
dialogs, etc.

In other colour modes, no palette exists and therefore does nothing.

 See Also:
  ~StandardColour~:411
  ~SetRGBPalette~:412
  ~SetHSIPalette~:413
  ~SetPalette~:414

%411
 StandardColour (function)     ~(TGColour Unit)~:400
 
Returns the actual data colour for a GUI standard colour.

 Declaration:
  function StandardColour(c:Byte):LongInt;

 Remarks:
Standard returns the value required for the current video mode for
BNGui's standard colours.  The value returned depends on the current video
mode, with the 16 colour modes only having 16 standard colours, while the
other modes have 20 standard (system) colours.

The standard 20 colours are:

  Value  Colour
 
    0    Black
    1    Dark Blue
    2    Dark Green
    3    Dark Cyan
    4    Dark Red
    5    Dark Magenta
    6    Dark Yellow
    7    Light Grey
    8    Dark Grey
    9    Blue
   10    Green
   11    Cyan
   12    Red
   13    Magenta
   14    Yellow
   15    White
        
   16    Light Blue
   17    Light Green
   18    Light Red
   19    Light Yellow

 See Also:
  ~SetStandardPalette~:410

%412
 SetRGBPalette (procedure)     ~(TGColour Unit)~:400
 
Sets a standard RGB palette for 256 colour modes.

 Declaration:
  procedure SetRGBPalette;

 Remarks:
This procedure sets a RGB palette using the last 216 entries in the 256
colour palette.  Each R, G & B value has six values.  ~PackRGB~:430 converts
the RGB values (ranging from 0 to 255) into matching 256 colour
palette entry.

 Restrictions:
Must be in 256 colour graphics mode.

 See Also:
  ~SetStandardPalette~:410
  ~SetHSIPalette~:413
  ~SetPalette~:414

%413
 SetHSIPalette (procedure)     ~(TGColour Unit)~:400
 
Set a standard HSI palette for 256 colour modes.

 Declaration:
  procedure SetHSIPalette(which:Byte);

 Remarks:
Sets one of 7 HSI palettes (shown below) using the last 216 palette entries
in the 256 colour palette entry.  ~PackHSI~:431 converts separate HSI values
(ranging from 0 to 255) into the 256 colour palette entry.

  which  Hues  Sat  Int
 
    1      9    6    4
    2      9    4    6
    3     12    6    3
    4     12    3    6
    5     18    4    3
    6     18    3    4
    7     24    3    3

 Restrictions:
Must be in 256 colour graphics mode.

 See Also:
  ~SetStandardPalette~:410
  ~SetRGBPalette~:412
  ~SetPalette~:414

%414
 SetPalette (procedure)     ~(TGColour Unit)~:400
 
Sets a range of palette entries.

 Declaration:
  procedure SetPalette(pal:~TPalette~:461; first,last:Word);

 Remarks:
Sets the "pal" entries from "first" to "last" into the 256 colour palette.

It does work in 16 colour mode, but only certain entries alter the 16
colours.

 See Also:
  ~GetPalette~:415
  ~SetStandardPalette~:410
  ~SetRGBPalette~:412
  ~SetHSIPalette~:413

%415
 GetPalette (procedure)     ~(TGColour Unit)~:400
 
Gets a range of palette entries.

 Declaration:
  procedure GetPalette(var pal:~TPalette~:461; first,last:Word);

 Remarks:
Sets the "pal" entries from "first" to "last" from the 256 colour palette.

 See Also:
  ~SetPalette~:414
  ~SetStandardPalette~:410
  ~SetRGBPalette~:412
  ~SetHSIPalette~:413

%416
 FadeIn (procedure)     ~(TGColour Unit)~:400
 
Fades part of the 256 colour palette from black to normal.

 Declaration:
  procedure FadeIn(pal:~TPalette~:461; first,last:Byte);

 Remarks:
Fades part of the 256 colour palette in from black to the palette specified
by "pal" in ~FadeSteps~:480 iterations.  Only palette entries "first" to
"last" are affected.

 See Also:
  ~FadeOut~:417
  ~CyclePalette~:418
  ~SetPalette~:414

%417
 FadeOut (procedure)     ~(TGColour Unit)~:400
 
Fades part of the 256 colour palette from normal to black.

 Declaration:
  procedure FadeOut(pal:~TPalette~:461; first,last:Byte);

 Remarks:
Fades part of the 256 colour palette out from the palette specified by
"pal" to black in ~FadeSteps~:480 iterations.  Only palette entries "first"
to "last" are affected.

 See Also:
  ~FadeIn~:416
  ~CyclePalette~:418
  ~SetPalette~:414

%418
 CyclePalette (procedure)     ~(TGColour Unit)~:400
 
Rotates part of the 256 colour palette.

 Declaration:
  procedure CyclePalette(var pal:~TPalette~:461; first,last:Byte;
                         step:ShortInt);

 Remarks:
Rotates part of "pal" from "first" to "last" and sets it in the colour
palette.  The palette is rotated one "step", only being set once.

 See Also:
  ~FadeIn~:416
  ~FadeOut~:417
  ~SetPalette~:414

%419
 GreyScale (procedure)     ~(TGColour Unit)~:400
 
Sets part of the palette to it's intensity only (no colour).

 Declaration:
  procedure GreyScale(first,last:Byte);

 Remarks:
Sets part of the 256 colour palette from "first" to "last" to it's grey
scale value.  The weightings for each primary colour are:
  Red   - 30%
  Green - 60%
  Blue  - 10%

 See Also:
  ~SetPalette~:414
  ~SetRGBPalette~:412

%430
 PackRGB (function)     ~(TGColour Unit)~:400
 

%431
 PackHSI (function)     ~(TGColour Unit)~:400
 

%432
 PackYUV (function)     ~(TGColour Unit)~:400
 

%435
 UnPackRGB (procedure)     ~(TGColour Unit)~:400
 

%436
 UnPackHSI (procedure)     ~(TGColour Unit)~:400
 

%437
 UnPackYUV (procedure)     ~(TGColour Unit)~:400
 

%440
 RGBtoHSI (procedure)     ~(TGColour Unit)~:400
 

%441
 RGBtoHLS (procedure)     ~(TGColour Unit)~:400
 

%442
 RGBtoCMYK (procedure)     ~(TGColour Unit)~:400
 

%443
 RGBtoYUV (procedure)     ~(TGColour Unit)~:400
 

%444
 HSItoRGB (procedure)     ~(TGColour Unit)~:400
 

%445
 HSItoCMYK (procedure)     ~(TGColour Unit)~:400
 

%446
 HLStoRGB (procedure)     ~(TGColour Unit)~:400
 

%447
 CMYKtoRGB (procedure)     ~(TGColour Unit)~:400
 

%448
 CMYKtoHSI (procedure)     ~(TGColour Unit)~:400
 

%449
 YUVtoRGB (procedure)     ~(TGColour Unit)~:400
 

%460
 TColour (type)     ~(TGColour Unit)~:400
 

%461
 TPalette (type)     ~(TGColour Unit)~:400
 

%470
 Gamma23 (constant)     ~(TGColour Unit)~:400
 

%471
 Gamma13 (constant)     ~(TGColour Unit)~:400
 

%480
 FadeSteps (variable)     ~(TGColour Unit)~:400
 

%481
 CurPalette (variable)     ~(TGColour Unit)~:400
 

%409
 TGColour Information
 
Included is the setting of a standard palette for 16 and 256 colour modes.

In 16 colour mode, the palette is almost the same as the BIOS palette but
the brown is dark yellow, and the two greys are slightly lighter.

In 256 colour mode, the first 16 colours are the same as in 16 colour mode,
the next 4 are saturated shades of red, green, blue and yellow.  The next
20 are darker versions of the first 20 colours, and the last 216 are
arranged in an RGB format, each primary consisting of 6 shades from black
to full intensity, gamma corrected for the monitor.

HSI & YUV standard palettes are also available for use instead of the RGB
model.

Colour model conversions are also included, support RGB, HSI, HLS, CMYK &
YUV models with conversion to and from each.

Also, for plotting on the screen, the current colour model palette values
can be are converted to a packed LontInt form for passing to BNGraph
procedures for 16, 256, 32k, 64k and 16M colour modes.

One last feature of this unit are a few procedures to control 256 colour
palettes: Set/Get, Fading, Cycling and GreyScaling.

 For the uninitiated...
 
HSI stands for Hue, Saturation and Intensity (a generic colour model):
  (also called HSV (value) or HSB (brightness))
   Hue is what we "think" of as the colour
    (like orange, purple, etc).  The hue is
    represented by an angle between 0 and 360
    degrees.  Red is at 0, green at 120 and
    blue at 240 and other colours in between
    these primaries.
   Saturation describes the amount of white
    in the colour.  for example, the brown in
    dark chocolate is very saturated (ie.
    doesn't have much white in it), while milk
    chocolate is the same hue, but is less
    saturated (ie. has more white in it).
   Intensity describes the brightness of the
    colour.  for example, an orange in the sun
    has a higher intensity colour than the
    orange in the shade.
   This is used as it is more the way we
    perceive colour (even though our eyes
    perceive RGB values only).  We see the
    colour, hue, which is the frequency of the
    light, Intensty is luminance or brightness
    of the light, and saturation as the purity
    of the light, bold primaries are very pure
    (highly saturated) while pastels are not.

HLS stands for Hue, Lightness and Saturation, and is similar to the HSI
model.  I cannot explain much about it, refer to the HSI model explanation
above.  It is provided for those who prefer this model to the HSI model.
(Windows Control panel Colour selection uses this model, with all values
between 0 and 240).

CMYK stands for Cyan, Magenta, Yellow and blacK.  This colour format is used
by printers, used colour mixing called "subtractive colour mixing" (the
opposite colour mixing used by "additive" RGB mixing used in monitors).
   Cyan and Magenta on paper produces Blue,
    for example.
   Magneta and Yellow produces Red.
   Cyan and Yellow produces Green.
   Black is used for contrast in printing
    as CMY only usually cannot produce a
    "black" but is rather brownish/greyish.

YUV is used in the transmission of colour television (similar to YIQ).
   Y is the intensity of the colour.
   U & V are the "chroma" values of the colour.
    U has the quantity of Red minus intensity (Y).
    V has the quantity of Blue minus intensity.
    This is format was derived and used for
    two main reasons...
      - to maintain compatibility with old
        black and white TVs.
      - only require 3 and not 4 signals
        (Green can be calculated from the
        Y, U & V values), therefore minimizing
        bandwidth used for the television signal.
    This format is support here because video
    frame grabbers tend to support this format
    (as it is used by TV), and the same image
    data can be represented in YUV more
    efficiently than RGB signals.  The eye is
    less responsive to colour than black & white
    changes, and the chroma info requires less
    bits to maintain a full picture (chroma data
    typically use half or a quarter of the number
    of bits used for the Y data).

%500
 TGMemory Unit
 
The TGMemory unit provides a range of functions for conventional and
extended/expanded memory management.  Currently, they are only an addition
to the existing heap functions and not a replacement (but may occur in the
future).

The common and useful XMS and EMS memory functions are supported including
a Exec function to execute DOS applications while freeing almost all of the
memory used by the application by swapping the applications code, data and
heap into XMS, EMS or a file (trying in that order).

 Conventional memory functions:
  ~LowMemory~:510
  ~MemAlloc~:511
  ~MemAllocSeg~:512
  ~SetMemTop~:513

  ~LowMemSize constant~:570

  ~SwapExec~:520

 XMS memory functions:
  ~IsXMS~:530
  ~GetXMSVersion~:531
  ~QueryFreeXMS~:532
  ~AllocEMB~:533
  ~FreeEMB~:534
  ~MoveEMB~:535
  ~LockEMB~:536
  ~UnlockEMB~:537
  ~GetEMBInfo~:538
  ~ReAllocEMB~:539

 EMS memory functions:
  ~IsEMS~:550
  ~GetEMSVersion~:551
  ~GetEMSStatus~:552
  ~GetPageFrameAddress~:553
  ~GetPageCount~:554
  ~AllocPages~:555
  ~MapPages~:556
  ~FreePages~:557

%570
 LowMemSize (variable)    ~(TGMemory)~:500
 

 Declaration:
  LowMemSize : Word = 4096 div 16;

 Remarks:
Sets the size of the safety pool in 16-byte paragraphs. The default value is
the usual pratical minimum, but it can be increased to suit your
application.

 See also:
  ~LowMemory~:510

%510
 LowMemory (function)    ~(TGMemory)~:500
 

 Declaration:
  function LowMemory:Boolean;

 Remarks:
Returns True if memory is low, otherwise False.  True means that a memory
allocation call (for example, by a VScreen) was forced to "dip into" the
memory safety pool.

The size of the safety pool is defined by the LowMemSize variable.

 See also:
  ~LowMemSize~:570

%511
 MemAlloc (function)    ~(TGMemory)~:500
 

 Declaration:
  function MemAlloc(size:Word):Pointer;

 Remarks:
Allocates "size" bytes of memory on the heap and returns a pointer to the
block.  If a block of the requested size cannot be allocated, a value of nil
is returned.

As opposed to the New and GetMem standard procedures, MemAlloc will not
allow the allocation to dip into the safety pool.  A block allocated by
MemAlloc can be disposed using the FreeMem standard procedure.

 See also:
  ~MemAllocSeg~:512

%512
 MemAllocSeg (function)    ~(TGMemory)~:500
 

 Declaration:
  function MemAllocSeg(size:Word):Pointer;

 Remarks:
Allocates a segment-aligned memory block.  Corresponds to MemAlloc, except
that the offset part of the resulting pointer value is guaranteed to be
zero.

 See also:
  ~MemAlloc~:511

%513
 SetMemTop (procedure)    ~(TGMemory)~:500
 

 Declaration:
  procedure SetMemTop(memtop:Pointer);

 Remarks:
Sets the top of the application's memory block. The initial memory top
corresponds to the value stored in the HeapEnd variable. SetMemTop is
typically used to shrink the application's memory block before executing a
DOS shell or another program, and to expand the memory block afterward.

%520
 SwapExec (function)    ~(TGMemory)~:500
 
Executes a specified program with a specified command line.

 Declaration:
  function SwapExec(Path,CmdLine:String):Integer;

 Remarks:
SwapExec moves all heap, code, data and stack into XMS, EMS or a disk file
and frees up almost all the memory for the program to execute in.
The function returns an error code according to the success of executing
the program (0 = successful).

%530
 IsXMS (function)    ~(TGMemory)~:500
 
Returns whether an XMS memory manager is available or not.

 Declaration:
  function IsXMS:Boolean;

 Remarks:
If an XMS memory manager (such as Himem.sys) is present IsXMS returns True,
else it returns False.

 See Also:
  ~GetXMSVersion~:531
  ~QueryFreeXMS~:532

%531
 GetXMSVersion (function)    ~(TGMemory)~:500
 

 Declaration:
  function GetXMSVersion:Word;

%532
function QueryFreeXMS(var free,total:Word):Byte;

%533
function AllocEMB(size:Word; var handle:Word):Byte;

%534
function FreeEMB(handle:Word):Byte;

%535
function MoveEMB(len:LongInt; shandle:Word; soffset:LongInt;
                              dhandle:Word; doffset:LongInt):Byte;

%536
function LockEMB(handle:Word; var loca:LongInt):Byte;

%537
function UnlockEMB(handle:Word):Byte;

%538
function GetEMBInfo(handle:Word; var lock,freehandles:Byte; var size:Word):Byte;

%539
function ReAllocEMB(handle:Word; newsize:Word):Byte;

%550
function IsEMS:Boolean;
         { Returns True if EMS memory is available }

%551
function EMSVersion(var ver:Byte):Byte;
         { Gets the version number of the EMS handler. }

%552
function GetEMSStatus:Byte;
         { Returns the status of the memory manager }

%553
function GetPageFrameAddress(var addr:Word):Byte;
         { Gets the segment address of the page frame (returns status) }

%554
function GetPageCount(var free,total:Word):Byte;
         { Gets the free & total page count and returns the status }

%555
function AllocPages(var handle:Word; numpages:Word):Byte;
         { Allocates the specified number of pages required (one page equals
           16K bytes of memory), and returns a handle to it, and returns the
           status of the memory managers after the call }

%556
function MapPages(handle,logical,physical:Word):Byte;
         { Maps the logical page to the physical page in the page frame and
           returns the status.  If logical is FFFFh, the page is unmapped. }

%557
function FreePages(handle:Word):Byte;
         { Frees the pages previously allocated, and returns the status }


%600
 TGVScrns Unit
 

The BNVScrns unit provides a set of procedures and functions for creating
and using "VScreens" that reside in conventional and XMS memory.  For
screens requiring memory greater than 64k, XMS memory will be used if it
is available, and a 64k window in conventional memory for access to the
XMS VScreen.

In the near future, EMS will also be used, and would be used in preference
to XMS memory (faster, and no conventional memory requirements).

 Procedures and Functions:
  ~AllocVScreen~:610
  ~FreeVScreen~:611

  ~VScreenSize~:620
  ~SetVScreen~:621
  ~ResetVScreen~:622

  ~GetVScreen~:630
  ~PutVScreen~:631
  ~PutTransVScreen~:632

%610
 AllocVScreen (function)     ~(TGVScrns Unit)~:600
 

%611
 FreeVScreen (procedure)     ~(TGVScrns Unit)~:600
 

%620
 VScreenSize (procedure)     ~(TGVScrns Unit)~:600
 
Returns the number of bytes needed to store an area for a Virtual RAM Screen.

 Declaration:
  procedure VScreenSize(w,h:Integer):LongInt;

 Remarks:
VScreenSize returns the number of bytes needed to store the area specified
by "w" and "h" into memory using a VScreen.

It is suggested to call this function before allocating memory for
a VScreen, or use AllocVScreen instead.

 SeeAlso:
  ~SetVScreen~:621
  ~ResetVScreen~:622
  ~AllocVScreen~:610

 Sample Code:

%621
 SetVScreen (procedure)     ~(TGVScrns Unit)~:600
 

 Declaration:
  procedure SetVScreen(w,h:Word; buf:Pointer);

 Remarks:

 See Also:
  ~VScreenSize~:620
  ~ResetVScreen~:622
  ~AllocVScreen~:610

%622
 ResetVScreen (procedure)     ~(TGVScrns Unit)~:600
 

 Declaration:
  procedure ResetVScreen;

 Remarks:

 See Also:
  ~SetVScreen~:621
  ~VScreenSize~:620
  ~FreeVScreen~:611

%630
 GetVScreen (procedure)     ~(TGVScrns Unit)~:600
 

 Declaration:
  procedure GetVScreen(x,y:Integer);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutVScreen~:631
  ~SetVScreen~:621
  ~AllocVScreen~:610

%631
 PutVScreen (procedure)     ~(TGVScrns Unit)~:600
 

 Declaration:
  procedure PutVScreen(x,y:Integer);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutTransVScreen~:632
  ~GetVScreen~:630
  ~SetVScreen~:621
  ~AllocVScreen~:610

%632
 PutTransVScreen (procedure)     ~(TGVScrns Unit)~:600
 

 Declaration:
  procedure PutVScreen(x,y:Integer);

 Remarks:

 Restrictions:
Must be in graphics mode.

 See Also:
  ~PutVScreen~:631
  ~GetVScreen~:630
  ~SetVScreen~:621
  ~AllocVScreen~:610


%700
 TGImage Unit
 

This unit will support the transparent loading and displaying of graphic
image files including the following:

 .TGI
 .PCX
 .BMP
 .ICO
 .GIF
 .TIF
 .TGA
 .LBM

 .FLI
 .FLC

%800
 TGMouse Unit
 

The TGMouse unit is a stand alone unit (independant of ~TGEvents~:900) that
supports 32x32 monochrome mouse cursors in SVGA resolutions.

It provides a minimal framework for mouse event handling, but does provide
a procedure hook for other mouse handling code to be called automatically
for advanced mouse operations.

The unit also provides support for shape sensitive screen areas, where the
mouse cursor shape changes automatically.  They are simply set by specifying
a region of the screen, and the cursor shape associated with that part of
the screen.

If the active driver that is being used supports hardware cursors, that will
be used instead of the standard software mouse cursor, resulting in a large
increase in speed (as the mouse doesn't have to be re-drawn every time it
moves, or hidden when drawing occurs on the screen).

One last feature of the TGMouse unit, is that it if a ~VScreen~:600 is
active, the mouse will still continue to be drawn properly on the physical
screen, so all drawing can occur in the VScreen without interrupting normal
mouse operations (so doesn't have to be hidden or frozen).

 See:
  ~TGMouse Procedures and Functions~:801
  ~TGMouse Constants, Variables and Types~:802

%801
 TGMouse Procedures and Functions
 
These are the functions and procedures that currently make up the
~TGMouse~:800 unit:

 ~ResetMouse~:810
 ~EnableMouseEvent~:811
 ~SetMouseLimits~:812

 ~MouseStatus~:815

 ~HideMouse~:820
 ~ShowMouse~:821
 ~FreezeMouse~:822
 ~ThawMouse~:823
 ~SetHideMouse~:824

 ~LoadCursor~:830
 ~SetMouseCur~:831
 ~SetMouseColours~:832

 ~AddCurRegion~:840
 ~DelCurRegion~:841
 ~FrontCurRegion~:842
 ~ModifyCurRegion~:843

%802
 TGMouse Constants, Variables and Types
 

 Variables:
  ~MouseAvail~:880
  ~MouseEvent~:881
  ~MouseProc~:882

 Types:
  ~TMouse~:890
  ~TMouseProc~:891

%805
 { Mouse.PAS }

 { Program to demonstrate the use of the SVGA mouse support }

 uses TGProcs, TGDriver, TGMouse;

 var
   cursor : TMouse;

 begin
   { initialization }
   if not MouseAvail then
     Abort('Error:  This program requires the use of a mouse');

   if not LoadCursor('Arrow.BNC',cursor) then
     Abort('Error:  Arrow.BNC not found');

   if not SetMode(vm640x480x256c) then
     Abort('Error:  Cannot set graphics mode 640 x 480, 256 colours');

   { show mouse pointer }
   SetMouseLimits(0,0,ModeInfo.Width-1,ModeInfo.Height-1);
   SetMouseCur(cursor);
   EnableMouseEvent;

   Readkey; { wait until a key is pressed }

   SetMode(vmOriginal);
 end.

%806
 { MsRegion.PAS }

 { Program to demonstrate the use of
   automatic mouse cursor shape control }

 uses
   TGProcs, TGDriver, TGraph, TGMouse, TGColour;

 var
   msArrow, msMove, msIBar, msWait,
   msOut, msNS, msWE, msNESW, msNWSE : TMouse;

 begin
   { Load all the mouse cursor shapes }
   LoadCursor('Wait.BNC',msWait);
   LoadCursor('Arrow.BNC',msArrow);
   LoadCursor('Move.BNC',msMove);
   LoadCursor('IBeam.BNC',msIBar);
   LoadCursor('SizeNS.BNC',msNS);
   LoadCursor('SizeWE.BNC',msWE);
   LoadCursor('SizeNESW.BNC',msNESW);
   LoadCursor('SizeNWSE.BNC',msNWSE);
   LoadCursor('OutBound.BNC',msOut);

   { Initialize screen, colours and mouse }
   if not SetMode(vm1024x768x256c) then begin
     Writeln('Couldn''t set video mode');
     Halt;
   end;
   SetStandardPalette;
   SetMouseLimits(0,0,ClipRect.xh,ClipRect.yh);
   SetMouseColours(StandardColour(15),0);

   { Draw screen }
   FillScr(StandardColour(19));
   DrawLine(640,0,640,480,StandardColour(12));
   DrawLine(0,480,1023,480,StandardColour(12));
   DrawFrame(100,100,500,400,StandardColour(1)+btThin,1,1);
   DrawRect(103,103,497,397,0);
   DrawButton(104,104,496,130,StandardColour(7)+btThin,1);

   { Setup cursor regions }
   SetMouseCur(msArrow); { Enable SVGA mouse }
   AddCurRegion(msWait,640,0,1023,479);
   AddCurRegion(msOut,0,480,1023,767);
   AddCurRegion(msArrow,0,0,639,479);
   AddCurRegion(msNWSE,99,99,130,130);
   AddCurRegion(msNWSE,470,370,501,401);
   AddCurRegion(msNESW,99,370,130,401);
   AddCurRegion(msNESW,470,99,501,130);
   AddCurRegion(msWE,99,131,501,369);
   AddCurRegion(msNS,131,99,469,401);
   AddCurRegion(msMove,104,104,496,130);
   AddCurRegion(msIBar,104,131,496,396);

   { Enable mouse events and wait for a key to be pressed }
   EnableMouseEvent;
   ReadKey;
   SetMode(vmOriginal);
 end.

%807
 { VDesktop.PAS }

 { Program to demonstrate hooking the mouse procedure }

 uses
   TGProcs,TGDriver,TGraph,TGMouse;

 var
   OrgMouseProc : TMouseProc;
   VDeskCoords  : record
                    sx,sy        : Integer;
                    x1,x2,y1,y2  : Integer;
                  end;

 {$F+}
 procedure MouseInt(var ev,but,x,y:Integer);
 var
   displaychange : Boolean;
 begin
   displaychange := False;
   if (@OrgMouseProc <> nil) then OrgMouseProc(ev,but,x,y);
   with VDeskCoords do begin
     if (x > x2) then begin
       Inc(x1,x - x2);
       x2 := x1 + sx;
       displaychange := True;
     end;
     if (x < x1) then begin
       x1 := x;
       x2 := x1 + sx;
       displaychange := True;
     end;
     if (y > y2) then begin
       Inc(y1,y - y2);
       y2 := y1 + sy;
       displaychange := True;
     end;
     if (y < y1) then begin
       y1 := y;
       y2 := y1 + sy;
       displaychange := True;
     end;
     if displaychange then SetDisplayStart(x1,y1);
   end;
 end;
 {$F-}

 var
   cursor : TMouse;
   i      : Integer;

 begin
   if (CardInfo.Memory < 16) then
     Abort('The video card needs at least 1M of video memory');
   if not LoadCursor('arrow',cursor) then
     Abort('ARROW.TGC was not found');
   SetMode(vm640x480x256c);

   { Setup screen parameters }
   with VDeskCoords do begin
     sx := ModeInfo.Width - 1;
     sy := ModeInfo.Height - 1;
     x1 := 0;
     y1 := 0;
     x2 := sx;
     y2 := sy;
   end;
   SetLineLength(1160);
   ModeInfo.Height := 900;   { Set 1160 x 900 desktop }
   SetClipArea(0,0,ModeInfo.Width-1,ModeInfo.Height-1);

   { Draw screen - grid with 50 pixel spacing and border }
   FillScr(0);
   for i := 0 to (ClipRect.xh div 50) do
     DrawLine(i*50,0,i*50,ClipRect.yh,4);
   for i := 0 to (ClipRect.yh div 50) do
     DrawLine(0,i*50,ClipRect.xh,i*50,4);
   DrawFrame(0,0,ClipRect.xh,ClipRect.yh,btNoFill,1,1);

   { Hook into the mouse handler and setup the mouse }
   @OrgMouseProc := @MouseProc;
   @MouseProc := @MouseInt;
   SetMouseLimits(0,0,ClipRect.xh,ClipRect.yh);
   SetMouseCur(cursor);
   EnableMouseEvent;

   ReadKey;  { Wait for a key to be pressed }

   SetMode(vmOriginal);
 end.

%820
 HideMouse (procedure)     ~(TGMouse unit)~:800
 
Hides the mouse cursor for drawing.

 Declaration:
  procedure HideMouse;

 Remarks:
The mouse cursor is initially visible after the call to ~SetMouseCur~:831.
HideMouse hides the mouse and decrements the internal "hide counter".

ShowMouse will increment this counter, and show the mouse cursor when the
counter becomes zero.  Thus, calls to HideMouse and ShowMouse can be nested,
but must also always be balanced.

HideMouse should be called whenever drawing occurs on the actual screen
(but is not required when drawing to a VScreen, or when SetHideMouse is
used).

 See Also:
  ~ShowMouse~:821
  ~SetHideMouse~:824

  ~FreezeMouse~:822
  ~ThawMouse~:823

%821
 ShowMouse (procedure)     ~(TGMouse unit)~:800
 
Reveals the mouse cursor that was previously hidden.

 Declaration:
  procedure ShowMouse;

 Remarks:
ShowMouse increments the "hide counter" previously decremented by HideMouse,
and makes the mouse cursor visible if counter becomes zero.

 See Also:
  ~HideMouse~:820

  ~FreezeMouse~:822
  ~ThawMouse~:823

%822
 FreezeMouse (procedure)     ~(TGMouse unit)~:800
 
Stops a mouse from being redrawn (and visibly moved).

 Declaration:
  procedure FreezeMouse;

 Remarks:
The mouse cursor is initially "thawed" (that is, it is redrawn whenever it
moves) after the call to ~SetMouseCur~:831.  FreezeMouse "freezes" mouse
redrawing and decrements the internal "freeze counter".

ThawMouse will increment this counter, and thaw the mouse cursor when the
counter becomes zero.  Thus, calls to FreezeMouse and ThawMouse can be
nested, but must also always be balanced.

 See Also:
  ~ThawMouse~:823

  ~HideMouse~:820
  ~ShowMouse~:821
  ~SetHideMouse~:822

%823
 ThawMouse (procedure)     ~(TGMouse unit)~:800
 
Restarts mouse cursor redrawing when it is moved.

 Declaration:
  procedure ThawMouse;

 Remarks:
ThawMouse increments the "freeze counter" previously decremented by
FreezeMouse, and if the counter becomes zero, mouse cursor redrawing
will occur when the mouse is moved.

 See Also:
  ~FreezeMouse~:822

  ~HideMouse~:820
  ~ShowMouse~:821
  ~SetHideMouse~:822

%824
 SetHideMouse (procedure)     ~(TGMouse unit)~:800
 
Set region where mouse disappears when it enters it.

 Declaration:
  procedure SetHideMouse(xl,yl,xh,yh:Integer);

 Remarks:
SetHideMouse sets a region of the screen, typically where drawing occurs,
that if the mouse cursor enters it, the cursor is automatically hidden.

Using this procedure instead of the Hide/ShowMouse combination can make
drawing operations faster (time taked to hide then show the mouse), and
also reduce unrequired flicker when the mouse cursor doesn't have to be
hidden when drawing.

To reset the region (and disable automatic mouse hiding), send
-1 as the coordinates.

 See Also:
  ~HideMouse~:820
  ~ShowMouse~:821

%830
 LoadCursor (function)     ~(TGMouse unit)~:800
 
Loads a mouse cursor shape from a .TGC file.

 Declaration:
  function  LoadCursor(name:String; var cur:~TMouse~:890):Boolean;

 Remarks:
LoadCursor loads a mouse cursor image file into the "cur" record.  If it
succeeds in loading the file, LoadCursor returns True, else it returns
False if it was not able to load the cursor file.

 See Also:
  ~SetMouseCur~:831
  ~AddCurRegion~:840

  ~Mouse.PAS~:805

%831
 SetMouseCur (procedure)     ~(TGMouse unit)~:800
 
Sets the mouse cursor image on the screen.

 Declaration:
  procedure SetMouseCur(cur:~TMouse~:890);

 Remarks:
SetMouseCur sets the mouse cursor image on the screen.  If it is being called
for the first time (when the program starts up), the cursor image is also
revealed.

If the cursor is hidden (and has been called before), the cursor is not
revealed.  If the cursor is visible when this is called, the cursor image
on the screen is instantly changed without any flicker (so can be used for
an animated mouse cursor).

 See Also:
  ~LoadCursor~:830
  ~AddCurRegion~:840

  ~Mouse.PAS~:805

%832
 SetMouseColours (procedure)     ~(TGMouse unit)~:800
 
Sets the mouse cursor colours.

 Declaration:
  procedure SetMouseColours(fc,bc:LongInt);

 Remarks:
SetMouseColours changes both the foreground (typically white) and the
background (typically black) colours of the mouse cursor.  The colour
is mode sensitive like all the TGraph functions, so the ~PackRGB~:430 or
~StandardColour~:411 functions can be used to set the colour independant of
the graphics mode.

 See Also:
  ~SetMouseCur~:831

%812
 SetMouseLimits (procedure)     ~(TGMouse unit)~:800
 
Sets the area on the screen where the mouse moves.

 Declaration:
  procedure SetMouseLimits(xl,yl,xh,yh:Word);

 Remarks:
SetMouseLimits defines the rectangle in which the mouse cursor moves in,
and cannot move out of that region.  This has to be called after the mode
is set.

 See Also:
  ~EnableMouseEvent~:811
  ~SetMouseCur~:831

  ~Mouse.PAS~:805

%810
 ResetMouse (function)     ~(TGMouse unit)~:800
 
Resets the mouse hardware and driver.

 Declaration:
  function  ResetMouse:Boolean;

 Remarks:
ResetMouse resets the mouse hardware and driver and sets the mouse cursor
position to (0,0).  It is called automatically on start-up and does not
have to be called within the program.  The only real use for this function
is if the program shells to DOS, and has to be called when the program
returns.

 See Also:
  ~MouseAvail variable~:880

%811
 EnableMouseEvent (procedure)     ~(TGMouse unit)~:800
 
Activates the TGMouse inbuilt mouse event handler.

 Declaration:
  procedure EnableMouseEvent;

 Remarks:
EnableMouseEvent has to be called when the program starts up (preferably
after everything has been setup) to enable the SVGA mouse cursor handler.

A procedure hook is provided so custom procedures can hook into mouse
handler to provide automatic mouse functions, such as mouse coordinates,
virtual desktops, etc.  The ~TGEvents~:900 unit hooks into the mouse
handler to provide the mouse events.

The mouse handler also updates the ~MouseEvent~:881 variable.

 See Also:
  ~MouseProc~:882
  ~TMouseProc~:891

  ~SetMouseLimits~:812
  ~SetMouseCur~:831
  ~AddCurRegion~:840

  ~Mouse.PAS~:805

%815
 MouseStatus (procedure)     ~(TGMouse unit)~:800
 
Returns the mouse status.

 Declaration:
  procedure MouseStatus(var x,y,b:Integer);

 Remarks:
MouseStatus returns the position of the mouse cursor on the screen, and
the state of each of the mouse buttons.

 See Also:
  ~MouseEvent variable~:881

%840
 AddCurRegion (procedure)     ~(TGMouse unit)~:800
 
Adds a "cursor shape sensitive screen region".

 Declaration:
  procedure AddCurRegion(cur:~TMouse~:890; xl,yl,xh,yh:Integer);

 Remarks:
The mouse handler in TGMouse provides a feature that allows the areas of
the screen to be assigned a mouse cursor shape.  All the regions are
added to the top of a linked list, so the first region on the list has
the highest priority.  This allows regions to be nested, and new regions
to be added on top, overriding older regions.

When ever the mouse cursor enters a region in the list, the cursor shape
is changed automatically.  Whenever a new region is added, and the mouse
cursor is already in that region, the cursor shape is updated.

Generally, if this method of cursor shape control is used, the entire
screen should be set to a default cursor image, and has to be set first
(so it is at the end of the list, and has the lowest priority).

 See Also:
  ~SetMouseCur~:831
  ~LoadCursor~:830
  ~DelCurRegion~:841
  ~FrontCurRegion~:842
  ~ModifyCurRegion~:843

  ~MsRegion.PAS~:806

%841
 DelCurRegion (procedure)     ~(TGMouse unit)~:800
 
Deletes a previously added cursor region.

 Declaration:
  procedure DelCurRegion(xl,yl,xh,yh:Integer);

 Remarks:
If a region that was previously added (by AddCurRegion) is not needed
anymore, the region can be deleted from the list.

If the cursor is in the region that is deleted, the cursor image is updated
to the next cursor image in the region.

 See Also:
  ~AddCurRegion~:840
  ~FrontCurRegion~:842
  ~ModifyCurRegion~:843

  ~MsRegion.PAS~:806

%842
 FrontCurRegion (procedure)     ~(TGMouse unit)~:800
 
Puts an already existing cursor region to the front of the list.

 Declaration:
  procedure FrontCurRegion(xl,yl,xh,yh:Integer);

 Remarks:
If a region in the list has to go to the front of the list (like a window
is selected to the top of the desktop), this moves an existing cursor
region to the front of the list, giving the region the highest priority.

If the cursor is in the region, the cursor is immediately updated.

 See Also:
  ~AddCurRegion~:840
  ~DelCurRegion~:841
  ~ModifyCurRegion~:843

  ~MsRegion.PAS~:806

%843
 ModifyCurRegion (procedure)     ~(TGMouse unit)~:800
 
Modifies and existing cursor region to a new region.

 Declaration:
  procedure ModifyCurRegion(oxl,oyl,oxh,oyh,nxl,nyl,nxh,nyh:Integer);

 Remarks:
If a region is to be moved and/or resized, ModifyCurRegion modifies an
existing region to the new boundaries.

The old boundarys to be changed are specified by (oxl,oyl) and (oxh,oyh) and
the new boundarys are specified by (nxl,nyl) and (nxh,nyh).

The mouse cursor is immediately updated.

 See Also:
  ~AddCurRegion~:840
  ~DelCurRegion~:841
  ~FrontCurRegion~:842

  ~MsRegion.PAS~:806

%880
 MouseAvail (variable)     ~(TGMouse unit)~:800
 
States whether a mouse is available or not.

 Declaration:
  MouseAvail : Boolean;

 Remarks:
If a mouse (and driver) exists on the system, MouseAvail is True, else if no
mouse and driver exists, MouseAvail is False.

A mouse and driver is required for the TGMouse procedures to work properly.

The program should not modify this variable.

 See Also:
  ~ResetMouse~:810

%881
 MouseEvent (variable)     ~(TGMouse unit)~:800
 
State of last mouse event.

 Declaration:
  MouseEvent : record
                 Event,MsX,MsY,ButState : Integer;
               end;

 Remarks:
When the mouse event handler is enabled in TGMouse, every time a mouse event
occurs (such as a mouse button press or release, or the mouse is moved),
this variable is updated automatically with the mouse status, and the event
that triggered the handler.

MouseEvent.Event contains the last event that occured. MouseEvent.MsX and
MouseEvent.MsY contains the position of the mouse when the last event
occured.  MouseEvent.ButState contains the status of the mouse buttons
when the event occured.

The centre mouse buttons (if they exist) do not trigger a mouse event, but
if they exist, the status of the button is contained in ButState.

The Event field contains five valid bits:
  0 - mouse movement event
  1 - left button press
  2 - left button release
  3 - right button press
  4 - right button release

The first bit (bit 0) of ButState is the status of the left mouse button,
the second bit (bit 1) is the status of the right mouse button, and if a
third mouse button exists, bit 2 contains the status of the mouse button.

 See Also:
  ~EnableMouseEvent~:811

  ~TGEvents unit~:900

%882
 MouseProc (variable)     ~(TGMouse unit)~:800
 
A procedure variable to allow custom procedures to be called by the mouse
event handler.

 Declaration:
  MouseProc : ~TMouseProc~:891;

 Remarks:
MouseProc provides a hook for procedures that need to be executed from a
mouse event.  The event, x and y coordinates and button status are passed
to the handler.  The handler should save the state of the existing
MouseProc when it is installed, and call the old MouseProc if it is not
nil.

A few applications where this is useful is for automatic updating of the
mouse coordinates on the screen, a large virtual desktop that automatically
scrolls when the mouse moves of the edge of the actual screen, etc.

The TGEvents mouse handler uses this hook to implement the mouse event side
of the handler.

 See Also:
  ~EnableMouseEvent~:811

  ~TGEvents unit~:900

  ~VDesktop~:807

%890
 TMouse (type)     ~(TGMouse unit)~:800
 
Structure for mouse cursor images.

 Declaration:
  TMouse = record
    Image : Pointer;
    hx,hy : Byte;
  end;

 Remarks:
The mouse cursor images are loaded into a TMouse structure.  The TMouse
record itself only occupies 6 bytes, the image itself is loaded into the
heap.

The Image pointer points to the 32x32 mouse image.  The first 128 bytes in
the image is the monochrome background mask.  If the bit is set, the pixel
is black (the default colour), otherwise it is transparent (an inverted
AND mask).  The second 128 bytes of the image is the foreground mask.
The bit is XORed with the existing pixel.

The hx and hy fields are the hot-spot of the cursor (the active point within
the image).  The hot-spot coordinates are relative to the upper left corner
of the mouse cursor image.

 See Also:
  ~LoadCursor~:830
  ~SetMouseCur~:831
  ~AddCurRegion~:840

%891
 TMouseProc (type)     ~(TGMouse unit)~:800
 
The structure for the ~MouseProc~:882 event handler.

 Declaration:
  TMouseProc = procedure(var event,button,x,y:Integer);

 Remarks:
Any new mouse handlers that are to be hooked into the mouse event chain has
to have a similar parameter list (the names can be different).

 See Also:
  ~VDesktop.PAS~:807

%900
 TGEvents Unit
 

The TGEvents unit provides a full featured TRUE event handler.  That is, it
collects all mouse and keyboard events into one common queue (which is
allocated at run-time into the heap, without using precious data segment
space), as the events occur.

The event structure also supports message events for a full featured GUI
application.

The mouse event part of the event handler automatically generates events
for both left and right mouse buttons separately, and the events include:
 - mouse movement events
 - press and release events
 - dragging events (where the mouse is moved
     while a button is held down)
 - double-clicking events
 - auto-repeat events (when the mouse button
     is held down - say in a scroll bar)

If several of the above events occur simultaneously, all the events that
occured are passed, as each event occupies a separate bit in the event
record.

The keyboard event part of the handler generates events for all of the keys
on the keyboard (except Shift, Ctrl, Alt and the Locks), including F11, F12,
PrtScrn, Pause, etc.  Also, the standard Alt-KeyPad character generation
method is supported.

One other feature is a special Alt pressed event, where the Alt key is
pressed and released without any other keys being pressed in the meantime,
which can be used to activate a menu bar.

One final, and unique feature of this event handler is inbuilt support for
screen saver activation and deactivation events!  By setting a variable,
the time for a screen saver to activate can range from less than a second
up to one hour, or not at all (the default).  When a mouse or key event
occurs, and the screen saver is active, a screen saver deactivate event
is issued.

 See:
  ~TGEvents Procedures and Functions~:901
  ~TGEvents Constants, Variables and Types~:902


Other Tech Notes:

The handler takes almost complete control of the standard keyboard functions,
so BIOS and DOS ReadKey functions cannot be used in conjuction with this
handler unless the handler is released (by calling RestoreVectors).  This
also means that Ctrl-Break will not work, nor will Ctrl-Alt-Del.

 Ŀ
  If a program crashes on you while this 
  event handler is active, a program can 
    be aborted at any time by pressing   
             Ctrl-Alt-Break              
 

%901
 TGEvents Procedures and Functions
 
These are the functions and procedures that currently make up the
~TGEvents~:900 unit:

 ~EventAvail~:910
 ~GetEvent~:911
 ~PutEvent~:912
 ~ClearEvent~:913

 ~RestoreVectors~:920
 ~SetVectors~:921

%902
 TGEvents Constants, Variables and Types
 

 Variables:
  ~DoubleEnabled~:970
  ~DoubleDelay~:971
  ~RepeatDelay~:972
  ~CursorDelay~:973
  ~CursorState~:974
  ~ScrSaveTime~:975
  ~KeyUpEnabled~:976

 Constants:
  ~evXXX~:980

 Types:
  ~TEvent~:990

%910
 EventAvail (function)     ~(TGEvents unit)~:900
 
Returns whether there is a event in the queue or not.

 Declaration:
  function  EventAvail : Boolean;

 Remarks:
EventAvail returns True if there is an event in the event queue ready to
be handled, or False if no event is waiting to be handled.

 See Also:
  ~GetEvent~:911
  ~PutEvent~:912
  ~ClearEvent~:913

%911
 GetEvent (procedure)     ~(TGEvents unit)~:900
 
Gets the next event from the event queue.

 Declaration:
  procedure GetEvent(var ev:~TEvent~:990);

 Remarks:
GetEvent gets the next event from the event queue.  If there are no events
in the queue, it returns an "evNothing" event.

 See Also:
  ~EventAvail~:910
  ~PutEvent~:912
  ~ClearEvent~:913

  ~evXXX contants~:980

%912
 PutEvent (function)     ~(TGEvents unit)~:900
 
Inserts an event into the start of the queue.

 Declaration:
  function PutEvent(ev:~TEvent~:990):Boolean;

 Remarks:
PutEvent inserts an event into the start of the queue, and is the next
event that will be fetched by GetEvent.  It returns True if the event
was successfully inserted into the queue, or False if the queue is full
and the event could not be inserted.

 See Also:
  ~EventAvail~:910
  ~GetEvent~:911
  ~ClearEvent~:913

%913
 ClearEvent (procedure)     ~(TGEvents unit)~:900
 
Clears the event variable "ev".

 Declaration:
  procedure ClearEvent(var ev:~TEvent~:990);

 Remarks:
ClearEvent clears the fields of the passed "ev" variable.  All is cleared
to zero (evNothing) to indicate a handled event in the application.

The event field does not have to be cleared before calling GetEvent.

 See Also:
  ~EventAvail~:910
  ~GetEvent~:911
  ~PutEvent~:912

%920
 RestoreVectors (procedure)     ~(TGEvents unit)~:900
 
Restores the interrupt vectors that are changed by TGEvents.

 Declaration:
  procedure RestoreVectors;

 Remarks:
RestoreVectors restore the keyboard and timer interrupt vectors that are
altered when the program starts up (by SetVectors).  It does not have to
be called when the program exits as it is called automatically when the
program exits.

This is used when shelling to DOS or a similar Exec style function is
called, and should be called before the Exec program starts.

 See Also:
  ~SetVectors~:921

%921
 SetVectors (procedure)     ~(TGEvents unit)~:900
 
Sets the interrupt vectors required by TGEvents to function.

 Declaration:
  procedure SetVectors;

 Remarks:
SetVectors MUST only be called after a call to RestoreVectors.  It also MUST
not be called when the program starts up as it is called automatically on
program start-up.

This is used when shelling to DOS or a similar Exec style function is
called, and is called after the Exec program returns.

It modifies the keyboard and timer interrupt vectors to internal interrupt
handlers.

 See Also:
  ~RestoreVectors~:920

%970
 DoubleEnabled (variable)     ~(TGEvents unit)~:900
 
Specifies whether double clicking is enabled or not.

 Declaration:
  DoubleEnabled : Boolean = True;

 Remarks:
If DoubleEnabled is set to True (the default), double clicking is enabled
in the mouse handler.  If it is set to False, double clicking events will
not occur.

 See Also:
  ~DoubleDelay~:971

  ~evXXX constants~:980

%971
 DoubleDelay (variable)     ~(TGEvents unit)~:900
 
Specifies the time in which a mouse button is to be double clicked.

 Declaration:
  DoubleDelay : Word = 6;

 Remarks:
When double clicking is enabled, the maximum time between two mouse button
presses (to make the double click) is set by the DoubleDelay variable.

The time is specified in multiples of 0.055 seconds, the default is 6 which
is equivalent to 0.33 seconds (or a third of a second).

 See Also:
  ~DoubleEnabled~:970

  ~evXXX constants~:980

%972
 RepeatDelay (variable)     ~(TGEvents unit)~:900
 
Specifies the rate at which a mouse button "auto repeat" event occurs.

 Declaration:
  RepeatDelay : Word = 2;

 Remarks:
When a mouse button is held down, after RepeatDelay * 4 cycles (a cycle
equals 0.055 seconds), an evAClk event occurs, and evAClk events continue
while the mouse button is held down every RepeatDelay cycles.

The default is 2, so after 0.44 seconds, an evAClk event occurs, and while
the mouse button is held down, an evAClk event occurs every 0.11 seconds.

This event is useful for scroll bars.

 See Also:
  ~evXXX constants~:980

%973
 CursorDelay (variable)     ~(TGEvents unit)~:900
 
Specifies the rate at which the ~CursorState~:974 variable changes.

 Declaration:
  CursorDelay : Word = 4;

 Remarks:
The CursorDelay and CursorState variables are used for a graphics text
cursor flashing control, and is included in this unit because the unit
hooks into the timer interrupt, so is convenient to include it here.

The CursorState variable toggles its state every CursorDelay cycles, where
a cycle equals 0.055 seconds.

The default rate is 4 cycles, so the CursorState variable toggles every
0.22 seconds (4.5 times per second).  The rate can easily be customized
by altering CursorDelay (the smaller, the faster).

%974
 CursorState (variable)     ~(TGEvents unit)~:900
 
Specifies the state of the graphics text cursor.

 Declaration:
  CursorState : Boolean = False;

 Remarks:
The CursorDelay and CursorState variables are used for a graphics text
cursor flashing control, and is included in this unit because the unit
hooks into the timer interrupt, so is convenient to include it here.

The CursorState variable toggles its state every CursorDelay cycles, where
a cycle equals 0.055 seconds.

The default rate is 4 cycles, so the CursorState variable toggles every
0.22 seconds (4.5 times per second).  The rate can easily be customized
by altering CursorDelay (the smaller, the faster).

%975
 ScrSaveTime (variable)     ~(TGEvents unit)~:900
 
Specifies the time before the screen saver event occurs.

 Declaration:
  ScrSaveTime : Word = 0;

 Remarks:
A screen saver control is inbuilt into the TGEvents unit.  ScrSaveTime
states the time before the screen saver event is issued.

A time of zero disables the screen saver, and any other value is the
time in multiples of 0.055 seconds.  This allows times from less than a
second (not suggested!) up to one hour.  The value is the time in seconds
multiplied by 18.2.

Here are some examples for common times (in minutes):

  Time  Value
 
    2    2184
    5    5461
   10   10923
   30   32768
   60   65535

 See Also:
  ~evXXX constants~:980

%976
 KeyUpEnabled (variable)     ~(TGEvents unit)~:900
 
Specified whether key release events are generated or not.

 Declaration:
  KeyUpEnabled : Boolean = False;

 Remarks:
If KeyUpEnabled is True, the keyboard event handler generates key release
events (evKeyUp) when a key is released.  It does not process the Shift,
Caps Lock and Num Lock states like it does with the key press events.
Also, the numeric keypad release events only states numbers, regardless
of the state of Num Lock.  The keypad returns the same code as the numbers
across the top of main keyboard.

If it is False, as is the default, no key release events are generated at
all.

The main application for key release events is in game programming as
multiple key press detection can be used with this event handler.

 See Also:
  ~GetEvent~:911

  ~evXXX constants~:980

%980
 Event constants     ~(TGEvents unit)~:900
 
The ~TEvent~:990.What field indicates what event occured, and the constants
representing each of the events are as follows:

  Constants    Value  Meaning
 
  evNothing    $0000  No event is available
                     
  evMouse      $07FF  Mask for all following mouse events
  evMove       $0001  Mouse has moved, no buttons pressed
  evLtPrs      $0002  Left button is pressed down
  evRtPrs      $0004  Right button is pressed down
  evLtRel      $0008  Left button is released
  evRtRel      $0010  Right button is released
  evLtDrg      $0020  Mouse has moved while left button is pressed
  evRtDrg      $0040  Mouse has moved while right button is pressed
  evLtDbl      $0080  Left button is double clicked
  evRtDbl      $0100  Right button is double clicked
  evLtAClk     $0200  Auto repeat when left button is held down
  evRtAClk     $0400  Auto repeat when right button is held down
                     
  evScrnSave   $0800  Event to (de)activate a screen saver
                     
  evKey        $3000  Mask for all key events
  evKeyDown    $1000  Key is pressed
  evKeyUp      $2000  Key is released
                     
  evMessage    $C000  Mask for all message events
  evCommand    $4000  Message for a single item
  evBroadCast  $8000  Message for all items in an application
                     
  evScrnSave   $0800  Event to (de)activate a screen saver


The event mask bits are defined as follows:

    evMessage
      
          evKey
            
                    evMouse
                                                 
 ͻ
 msb                                          lsb
 ͼ
                                                
                                                 evMove
                                              evLtPrs
                                           evRtPrs
                                        evLtRel
                                     evRtRel
                                  evLtDrg
                               evRtDrg
                            evLtDbl
                         evRtDbl
                      evLtAClk
                   evRtAClk
               
                evScrnSave
            
             evKeyDown
          evKeyUp
      
       evCommand
    evBroadCast

 See Also:
  ~GetEvent~:911

%990
 TEvent (type)     ~(TGEvents unit)~:900
 
The structure (a variant record) for all event handling:

 TEvent = record
   What : Word;         - The actual event
   case Word of
     evNothing : ();
     evMouse   : (
         MsX, MsY : Integer; - Mouse Location when mouse event occured
         ButState : Byte;    - Mouse Button Status when mouse event occured
         MsShift  : Byte);   - Key shift state when mouse event occured
     evKey     : (
         case Integer of
           0 : (KeyCode : Word);    - Combination shift & key press
           1 : (Key     : Char;     - ASCII value for key pressed
                Shift   : Byte));   - Shift state when key was pressed
     evMessage : (
         Command : Word;
         case Word of
           0 : (InfoPtr  : Pointer);
           1 : (InfoLong : LongInt);
           2 : (InfoWord : Word);
           3 : (InfoInt  : Integer);
           4 : (InfoByte : Byte);
           5 : (InfoChar : Char));
     evScrnSave : (
         SaverState : Boolean);     - State to put screen saver in
 end;

 See Also:
  ~GetEvent~:911
  ~PutEvent~:912
  ~ClearEvent~:913

%INDEX

Abort                   11
AByte                   84
AChar                   85
AInt                    87
AllocVScreen            610
ALongInt                88
ArcCoords               284
AWord                   86
BIOSFont                393
BkColour                282
BlockSize               247
BorderFill              243
btXXX                   272
CardInfo                160
CharHeight              312
CharWidth               311
ChooseFont              310
ClipRect                162
CMYKtoHSI               448
CMYKtoRGB               447
ColdBoot                28
ConvexPoly              248
CurFont                 380
CurPalette              481
CyclePalette            418
Delay                   16
Dithering               274
doXXX                   270
DrawArc                 237
DrawBezier              241
DrawButton              252
DrawCentreStr           322
DrawChar                320
DrawCircle              230
DrawEllipse             233
DrawFrame               253
DrawLine                214
DrawOp                  280
DrawPixel               212
DrawPoly                244
DrawRect                223
DrawRel                 220
DrawRotStr              331
DrawRoundRect           227
DrawScaleStr            332
DrawSector              239
DrawSEllipse            236
DrawStr                 321
DrawText                323
DrawTo                  219
DrawTransStr            330
ExePath                 24
FadeIn                  416
FadeOut                 417
FadeSteps               480
fpXXX                   273
FilledCircle            231
FilledEllipse           234
FilledPoly              245
FilledRect              224
FilledRoundRect         228
FilledSector            240
FillPattern             283
FillScr                 210
FillViewPort            211
FloodFill               242
fntXXX                  390
FreeVScreen             611
Gamma13                 471
Gamma23                 470
GetActivePage           119
GetBlock                248
GetCardInfo             101
GetDisplayStart         113
GetKey                  22
GetLineLength           111
GetMode                 104
GetModeInfo             102
GetPalette              415
GetPixel                213
GetRBank                109
GetSplitScreen          115
GetVisualPage           121
GetVScreen              630
GetWBank                108
GetX                    221
GetY                    222
GreyScale               419
HLStoRGB                446
HSItoCMYK               445
HSItoRGB                444
IPos                    45
kbXXX                   90
KeyPressed              15
lsXXX                   271
LineStyle               281
Lower                   46
ModeInfo                161
MoveRel                 218
MoveTo                  217
NoExt                   25
NoSound                 18
PackHSI                 431
PackRGB                 430
PackYUV                 432
PByte                   80
PInt                    82
PLongInt                83
Processor               12
Protected               13
PutBlock                249
PutStyleBlock           251
PutTransBlock           250
PutTransVScreen         632
PutVScreen              631
PWord                   81
ReadKey                 14
ResetVScreen            622
RGBtoCMYK               442
RGBtoHLS                441
RGBtoHSI                440
RGBtoYUV                443
RScan                   47
Scan                    48
ScreenOff               42
ScreenOn                41
SetActivePage           118
SetClipArea             116
SetDisplayStart         112
SetHSIPalette           413
SetLineLength           110
SetMode                 103
SetPalette              414
SetRBank                107
SetRGBPalette           412
SetRWBank               105
SetSplitScreen          114
SetStandardPalette      410
SetTypematicRate        23
SetViewPort             117
SetVisualPage           120
SetVScreen              621
SetWBank                106
ShadowRect              226
Sound                   17
StandardColour          411
StrDel                  52
StrIns                  50
SetLIns                 51
TCardInfo               150
TColour                 460
tsXXX                   391
TextBkColour            381
TextSpace               383
TextStyle               382
TextWidth               313
TFontSet                370
PFontSet                370
TG                      2
TGProcs_Unit            10
TGDriver_Unit           100
TGraph_Unit             200
TGText_Unit             300
TGColour_Unit           400
TGMemory_Unit           500
TGVScrns_Unit           600
TGImage_Unit            700
TGMouse_Unit            800
TGEvents_Unit           900
ThickArc                238
ThickCircle             232
ThickEllipse            237
ThickLine               215
ThickRect               225
ThickRoundRect          229
TModeInfo               151
TPalette                461
TPattern                291
TPoint                  290
TRect                   152
Turbo_Graphics          2
txSolid                 392
UnPackHSI               436
UnPackRGB               435
UnPackYUV               437
Upper                   49
vmXXX                   170
VScreenSize             620
WarmBoot                29
YUVtoRGB                449
MultiTasker             30
TimeSlice               31
PreventSwitching        32
ResumeSwitching         33
MultiTaskerVersion      34
mtskXXX                 30
LowMemory               510
MemAlloc                511
MemAllocSeg             512
SetMemTop               513
LowMemSize              570
SwapExec                520
IsXMS                   530
GetXMSVersion           531
QueryFreeXMS            532
AllocEMB                533
FreeEMB                 534
MoveEMB                 535
LockEMB                 536
UnlockEMB               537
GetEMBInfo              538
ReAllocEMB              539
IsEMS                   550
GetEMSVersion           551
GetEMSStatus            552
GetPageFrameAddress     553
GetPageCount            554
AllocPages              555
MapPages                556
FreePages               557
ResetMouse              810
EnableMouseEvent        811
SetMouseLimits          812
MouseStatus             815
HideMouse               820
ShowMouse               821
FreezeMouse             822
ThawMouse               823
SetHideMouse            824
LoadCursor              830
SetMouseCur             831
SetMouseColours         832
AddCurRegion            840
DelCurRegion            841
FrontCurRegion          842
ModifyCurRegion         843
MouseAvail              880
MouseEvent              881
MouseProc               882
TMouse                  890
TMouseProc              891
EventAvail              910
GetEvent                911
PutEvent                912
ClearEvent              913
RestoreVectors          920
SetVectors              921
DoubleEnabled           970
DoubleDelay             971
RepeatDelay             972
CursorDelay             973
CursorState             974
ScrSaveTime             975
evXXX                   980
TEvent                  990
DrawAngleLine           256
DrawHDivider            254
DrawVDivider            255
KeyUpEnabled            976

%END
