	Pix2
   Version: 1.4.1
   Released: 24/06/1997 (june)
	Copyright(c) 1997, the authors (see below)

	Thank you for downloading Pix2.  This Game Kernel is designed for use
	with TP7/BP7, and will not compile with earlier versions of those.

	Pix2 is distributed as freeware, as for the included utilities.  You may
	copy the game kernel as much as you want, as long as you don't modify
	the source.  Distributing any parts of the kernel alone is illegal, so
	it is to publish a modified source code.

	You may, though, modify the source code to suit your needs.  If you make
	a descent improvement to the kernel, please tell me about it, so I may
	change the game Kernel.

	You may use Pix2 for either personnal or commercial uses, without any
	basic fees nor royalties.  If you use Pix2 in a commercial game/utility,
	we would like to ear about it, and each author would appreciate getting
	a copy of the game/utility.  Note that it isn't an obligation, but it's
	so less for you!

	To contact me, Jonathan Nicolas, you me either (in order of preference):

	E-Mail me: joun@quebectel.com
	Snail Mail me:
		Jonathan Nicolas
		96 Belles-Feuilles
		Grande-Rivire, PQ
		G0C 1V0
		CANADA
	Phone me:
		(418) 385-3934 (More chances during week-ends)

	Maybe this is not the lateste version of Pix2... If you want to make sure
	it is, and if there's a newer one that you want to download, go to the
	official Pix Game Kernel home page.  The URL is:
		http://www.geocities.com/SiliconValley/Vista/4490

	Good luck!

	The authors so far that worked on Pix2 (in order of work done):
		Jonathan Nicolas, for most of the core work
		Ethan Brodsky, for the SMIX unit
		Jason Morriss, for a lot of help
		Yuri Kirsanov, for the Pix2Cd module


	************************************************************************

	This file contains the description of each functions included in the
	Pix2 Package.

	What it does have:
	- Basic drawing functions
	- Virtual video pages management
	- Sprites, and GetImage/PutImage functionnality
	- Ability to save .P2I files and to load .P2I/.PRI files
	- Functions to write text, with default or custom fonts
	- Mouse handling routines
	- Palette management functions
	- Tiled map engine
	- Small GUI (Graphical User Interface)
	- Sound playing capabilities on the sound blaster.  Mixes up to 8
	  sounds at the same time.
	- Keyboard handling
	- Joystick management
	- CD-ROM control for music
	- A timer module
	- Hability to store images in XMS

	To come:
	Pix2 is an always-evoluting game kernel, so changes are always been made.
	New features that should be included soon:
	- MID or MOD player
	- Ported to C/C++
	- Help file that integrates into the TP/BP IDE

	Well, much more is needed, but that's the essential, and those that
	will come vey soon.  So stay tuned!

	************************************************************************

	Don't forget to check Pix2Main.Pas for some more info, and an history
	of the Pix2 Game Kernel.

	This file can be used as a reference for all of the Pix2's functions.
	I am currently working on a tutorial and a tips&tricks part that will
	be released very soon.

	************************************************************************

	Functions/Types/Variables definition:


	I haven't written examples for those functions, just follow your instinc
	and try out!  For more info, check the Pix2Demo (PIX2DEMO.PAS).  If you
	need any more help, just write me at joun@quebectel.com
	If you don't have e-mail, see above how to contact me.

	I haven't written useless functions/types neither.  I only write
	documentation for what's useful to you, the user.

-----------------------------------------------------------------------------
RGB=Record
	R,G,B:Byte;
End;
PixPaletteP=^PixPalette;
PixPalette=Array[0..255] Of RGB;
PixPalType=(PIXPALVAR,CURRENT,SPECIFIEDVAR,NOWHERE);

	For palette management functions

-----------------------------------------------------------------------------
PixSprite=Object
	X,Y:Integer;
	Img:Array[1..20,1..20] Of Pointer;
	NbFrm,CurFrm:Array[1..20] Of Byte;
	CurSet:Byte;
	Way:Byte;
	Constructor Init;
	Procedure AddFrame(NSet:Byte;NImg:Pointer);
	Procedure NewSet(NSet:Byte);
	Procedure Draw;
	Function Step:Boolean;
	Function StepRev:Boolean;
	Function PingPong:Boolean;
   Destructor Done;
End;

   This is an object for a basic sprite.  It's only provided for convinience
   because I used this in some games.  I guess you'll be able to figure out
   by yourself how it works.  If you need help, just e-mail me!

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Main module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Function PixOpen(NbPages:Byte):Boolean;

	This function initiates all the Pix2 stuff and sets video mode.  The
	NbPages argument specifies how much virtual video pages you want.
	Normally, you have 1 or 2.  The real VGA page isn't counted here, so
	specifying a 0 doesn't open any virtual pages.

	If there was enough memory, PixOpen returns True, else it returns False.

-----------------------------------------------------------------------------
Procedure PixClose;

	This closes VGA Mode 13h and returns to text mode.  It also free up
   memory that was used by virtual pages.

-----------------------------------------------------------------------------
Procedure PixScreen(InfoStr:String);

	You must be in text mode for that.  It clears the screen, place a blue
   line on top with PIX -> Written to the top, followed with the content
   of the InfoStr string.  It then place the cursor 2 lines below, so that
   you can use WriteLn to write explaination.  For an example, try using
   PixSelPage with an out-of-range page number.

-----------------------------------------------------------------------------
Procedure PixSelPage(NewPage:Byte);

	Used to select which page is being written to.  By default, you write
   on page 0, so all things are apparent to screen.  If another page is
   selected, things that you draw will not be shown on screen.

-----------------------------------------------------------------------------
Procedure PixWaitVSync;

	This waits for a Vertical retrace to occur.  You generally call this
   just before PixDump.

-----------------------------------------------------------------------------
Procedure PixSetClip(X1,Y1,X2,Y2:Integer);

	This sets the clipping rectangle for all of Pix2's functions.  Note that
   the (X1,Y1) is top-left, (X2,Y2) is bottom-right, and that values are
   inclusive.  By default, clipping is set to (0,0,319,199), so it clips
	withing the screen bounds.

-----------------------------------------------------------------------------
Procedure PixGetClip(Var X1,Y1,X2,Y2:Integer);

   This returns the current clipping rectangle's coordinates into the four
   specified variables.

-----------------------------------------------------------------------------
Procedure PixFillPage(Col:Byte);

	This fills the current page with the color in the Col variable.

-----------------------------------------------------------------------------
Procedure PixPutPixel(X,Y:Integer;Col:Byte);

	This puts a pixel at (X,Y) of color Col on the current page.

-----------------------------------------------------------------------------
Procedure PixHLine(X1,X2,Y:Integer;Col:Byte);

	This draws an horizontal line from (X1,Y) to (X2,Y) of color Col on the
   current page.

-----------------------------------------------------------------------------
Procedure PixVLine(Y1,Y2,X:Integer;Col:Byte);

	This draws a vertical line from (X,Y1) to (X,Y2) of color Col on the
   current page.

-----------------------------------------------------------------------------
Procedure PixBox(X1,Y1,X2,Y2:Integer;Col:Byte);

	This draws a square box from (X1,Y1) to (X2,Y2) of color Col on the
   current page.

-----------------------------------------------------------------------------
Procedure PixFilledBox(X1,Y1,X2,Y2:Integer;Col,ColIn:Byte);

	Same as PixBox, except that it fills the box with color ColIn.

-----------------------------------------------------------------------------
Procedure PixLine(X1,Y1,X2,Y2:Integer;Col:Byte);

	This draws a line from (X1,Y1) to (X2,Y2) of color Col on the current
   page.

-----------------------------------------------------------------------------
Function PixGetPixel(X,Y:Integer):Byte;

	This returns the color of the pixel at (X,Y) on the current page.

-----------------------------------------------------------------------------
Procedure PixDump;

	This copies the current page to page 0, that is the screen. This is
   the same as PixCopyPage({current page},0).

-----------------------------------------------------------------------------
Procedure PixCopyPage(Source,Dest:Byte);

	This copies one page to another (Source to Dest).

-----------------------------------------------------------------------------
Procedure PixSetRGB(Col,R,G,B:Byte);

	This sets the Red,Green and Blue value of color Col from the palette.

-----------------------------------------------------------------------------
Procedure PixGetRGB(Col:Byte;Var R,G,B:Byte);

	This gets the Red,Green and Blue value of color Col from the palette.

-----------------------------------------------------------------------------
Procedure PixSetPalette(Pal:PixPaletteP);

	This sets the entire palette with Pal.

-----------------------------------------------------------------------------
Procedure PixGetPalette(Pal:PixPaletteP);

	This gets then entire palette in variable Pal.

-----------------------------------------------------------------------------
Procedure PixBlackOutPalette(Pal:PixPaletteP);

	This sets all palette's entry to 0 (black).

-----------------------------------------------------------------------------
Procedure PixResetPalette(Pal:PixPaletteP);

	This sets the palette Pal with the default palette.

-----------------------------------------------------------------------------
Procedure PixFadeOutPalette(Pal:PixPaletteP);

	This fades the palette Pal one step.

-----------------------------------------------------------------------------
Procedure PixFadeInPalette(Pal:PixPaletteP;Goal:PixPaletteP);

	This fades in the plaette Pal one step to Goal.

-----------------------------------------------------------------------------
Procedure PixRotatePalette(Pal:PixPaletteP;From,Too:Byte);

	This rotates the palette from From to Too.

-----------------------------------------------------------------------------
Procedure PixRotatePaletteRev(Pal:PixPaletteP;From,Too:Byte);

	Same as PixRotatePalette, but does it in reverse order.

-----------------------------------------------------------------------------
Function PixSavePalette(FName:String;Pal:PixPaletteP):Boolean;

	This saves the palette Pal in file FName.  If no extension was specified,
   .PAL is added.

-----------------------------------------------------------------------------
Function PixLoadPalette(FName:String;Pal:PixPaletteP):Boolean;

   This loads the palette in FName to Pal.  If no extension was specified,
   .PAL is added.

-----------------------------------------------------------------------------
Function PixGetImage(Var P:Pointer;X1,Y1,X2,Y2:Integer;Alloc:Boolean):Boolean;

	This gets the image from the current page into variable P from (X1,Y1)
   to (X2,Y2).  If Alloc was set to True, PixGetImage will take care about
   allocating memory for the sprite.  If set to false, be sure enough
   memory was allocated.  To calculate this, do this:
   	MemReq=(X2-X1+1)*(Y2-Y1+1)+4

-----------------------------------------------------------------------------
Procedure PixPutImage(P:Pointer;X1,Y1:Integer;Trans:Boolean);

	This puts the pre-loaded or Getted image from variable P on the current
   page at position (X1,Y1).  If Trans was set to true, black pixels will
   not be drawn.  This is ideal for a sprite.

-----------------------------------------------------------------------------
Procedure PixSaveImage(P:Pointer;FName:String;WPal:PixPalType;Pal:PixPaletteP);

	This saves the image in pointer P to file FNAme.  If no extension was
   specified, .P2I is used.  Each P2I file contains a full palette that can
   be saved with this function.  Valid entries for WPal are:
   	PIXPALVAR: Saves the palette that is in the PixPal variable (see below)
      CURRENT: Saves the current palette
      SPECIFIEDVAR: Saves the palette from variable Pal
      NOWHERE: Says you don't matter.  It will save the PixPal var.
   If you use SPECIFIEDVAR for WPal, specify the palette in variable Pal,
   else just give nil for Pal.

-----------------------------------------------------------------------------
Procedure PixLoadImage(Var P:Pointer;FName:String;WPal:PixPalType;Pal:PixPaletteP);

	This loads the image from file FName to variable P.  This function takes
   care about allocating memory for the image.  If no extension was specified,
   .P2I is used.  Each P2I file contains a full palette that can be loaded
   with this function.  See PixSaveImage for valie entries for WPal and Pal.

-----------------------------------------------------------------------------
Procedure PixLoadPri(Var P:Pointer;FName:String);

	This loads a .PRI file (Actually this looks like .P2I, but it saves a raw
   image, so the actual pointer is saved.  No palettes are saved in this.
   This was used in original Pix, and I make it here again because it's
   small, fast and easy.  It's also used for mouse pointers.  If no
   extension was specified, .PRI is used, and the function takes care
   of allocating memory for the image.

-----------------------------------------------------------------------------
Procedure PixDeAllocImage(Var P:Pointer);

	This free up the memory used by an image, wheter allocated by you,
   PixGetImage,PixLoadImage or PixLoadPri.

-----------------------------------------------------------------------------
Function PixIntToStr(Num:LongInt):String;

	Converts the integer Num and returns the result.

-----------------------------------------------------------------------------
Function PixStrToInt(S:String):LongInt;

	Converts the string S and returns the result.  If the string didn't
   consist of a number, 0 is returned.
-----------------------------------------------------------------------------
PixPal:PixPalette;

   A free palette variable, set with the default palette by PixOpen.  You may
   use this as you like, but remember, palette functions requires a palette
   pointer!!! So pass it as @PixPal.


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Text module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Procedure PixLoadFont(FName:String);

	This loads a custom font and makes it current.  If no extension was
   specified, .FNT is used.

-----------------------------------------------------------------------------
Procedure PixSaveFont(FName:String);

	This saves the current font in file FName.  If no extension was specified,
   .FNT is used.  You generally don't use this.

-----------------------------------------------------------------------------
Procedure PixLoadDefaultFont;

	If you loaded a custom font, this functions sets the current font with
   the default small font like at Pix2's startup.

-----------------------------------------------------------------------------
Procedure PixLoadROMFont;

	This loads the font from ROM and make it current.

-----------------------------------------------------------------------------
Procedure PixWrite(X,Y:Integer;Col:Byte;St:String);

	This writes a string St at (X,Y) of color Col on the active page with
   current font.

-----------------------------------------------------------------------------
Procedure PixWriteCenter(Y:Integer;Col:Byte;St:String);

	This writes a string St of color Col at vertical position Y centered
   within the screen.

-----------------------------------------------------------------------------
Procedure PixWriteS(X,Y:Integer;Col,SCol:Byte;St:String);

	Same as PixWrite, but produces a shadow of color SCol to the string.

-----------------------------------------------------------------------------
Procedure PixWriteCenterS(Y:Integer;Col,SCol:Byte;St:String);

	Same as PixWriteCenter, but produces a shadow of color SCol to the string.

-----------------------------------------------------------------------------
Function PixLength(St:String):Word;

	This returns the length of the string St with the current font.

-----------------------------------------------------------------------------
Function PixHeight(St:String):Byte;

	This returns the height of the string St with the current font.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Mous module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Function PixResetMouse:Boolean;

	Don't call this, it is called by PixOpen.

-----------------------------------------------------------------------------
Function PixGetButNum:Integer;

	Returns the number of button on your mouse.

-----------------------------------------------------------------------------
Function PixMouseIdle:Boolean;

	Call this to update the MouseX,MouseY,MouseB1 and MouseB2 variables.

-----------------------------------------------------------------------------
Procedure PixShowMouse;

	This makes the mouse cursor visible.  Be sure to call PixLoadCursor first.

-----------------------------------------------------------------------------
Procedure PixHideMouse;

	This removes the mouse cursor from the screen.

-----------------------------------------------------------------------------
Procedure PixDrawMouse;

	Don't call this.

-----------------------------------------------------------------------------
Procedure PixLoadCursor(CurFile:String;NHX,NHY:Integer);

	This loads the cursor from file CurFile, which must be a .PRI.  If you
   don't speicfy any extension, .PRI is used.  NHX and NHY are the
   cursor's hotspot, i.e. where the mouse actually points.  Top-left is
   (0,0).

-----------------------------------------------------------------------------
Procedure PixDeAllocCursor;

	Free up memory used by the pointer.

-----------------------------------------------------------------------------
MouseX,MouseY:Integer;

   Location of the mouse pointer.

-----------------------------------------------------------------------------
MouseB1,MouseB2,MouseB3:Boolean;

	True if the corresponding button is down.

-----------------------------------------------------------------------------
MouseVisible:Boolean;

   True if mouse is on screen.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Snd module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Function PixInitSound(BaseIO:Word;IRQ,DMA,DMA16:Byte;Smp:Word;Sh:Boolean):Boolean;

Use this to initialize the sound card on port BaseIO, with irq IRQ, and
dmas DMA and DMA16.  If you specify 0 as BaseIO, it auto-detects the sound
card.  Smp is the sampling rate, usually 22000 KHz.  If Sh is true, sharing
is applied, so only one handle is allocated in the XMS instead of one per
sound.
If sound card initialization (and maybe auto-detection) is successful, the
function returns True, or else returns false.

-----------------------------------------------------------------------------
Procedure PixCloseSound;

Shuts down the sound system.

-----------------------------------------------------------------------------
Function PixOpenSoundResFile(FName:String):Boolean;

This opens a sound resource file, generated by SNDLIB.EXE, from Ethan
Brodsky.

-----------------------------------------------------------------------------
Procedure PixCloseSoundResFile;

Closes a pre-opened sound resource file.

-----------------------------------------------------------------------------
Type
      PixSound=Object
		Dta:PSound;
		Idx:Word;
		Constructor Init(NIdx:Word);
		Function Load(FName:String):Boolean;
		Function Play(Rpt:Boolean):Boolean;
		Procedure Stop;
		Destructor Done;
	End;

This is the actual sound object.
First, use Init, with an unique index as the parameter, to keep track of the
sound. Actually, it's used to stop it later.
Next, use Load with RAW file name.  Use WAV2RAW to convert a WAV file to the
RAW format.  If you previously opened a resource file, specify the KEY you
used instead.  See SMIX130.DOC for more info.
Now just call Play to play the sound.  If Rpt is true, the sound auto-repeats.
Later, if you want the sound to stop, call Stop.
Finally, call Done to free up the memory used by the sound.

Example:
Uses Pix2,Crt;

Var
   S:PixSound;

Begin
   PixInitSound(0,0,0,0,22050,False);
   S.Init(1);
   S.Load('TEST.RAW');
   S.Play(True);
   Repeat Until KeyPressed;
   ReadKey;
   S.Done;
   PixCloseSound;
End.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Gui module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
PixButton=Object
	X1,Y1,X2,Y2:Integer;
   Cap:String;
   Pressed,Clicked,Wahoo:Boolean;
   Constructor Init(nX1,nY1,Wd,Hg:Integer;nCap:String);
   Procedure Draw;
   Function Idle:Boolean;
   Function Check:Boolean;
End;

   A simple & cute push button.  First use Init to specify top-left position,
   Width and Height, and Caption of the button.
   Next, call Draw to display it on the active page.
   Then, call Idle to let it check if an even has occured, such as a press
   or release.  If Idle returns true, it must be re-drawn.  You generally
   remove the mouse pointer from the screen, call draw and put the mouse
   back when this returns true.
   Finnaly, call Check to know wheter the button has been pressed and then
   released.

-----------------------------------------------------------------------------
PixCheckBox=Object
	X1,Y1:Integer;
   Cap:String;
   Pressed,Clicked,Check:Boolean;
   Constructor Init(nX1,nY1:Integer;nCap:String;Default:Boolean);
   Procedure Draw;
   Function Idle:Boolean;
End;

	It's much like PixButton, except for the constructor, where you don't
   specify width and height, and Default is set wheter you want the checkbox
   be checked or not at default.
   The Check variable is set to true if the box is checked.

-----------------------------------------------------------------------------
Procedure PixDrawPanel(X1,Y1,X2,Y2:Integer);

	This draws a panel that looks much like a window from (X1,Y1) to (X2,Y2).

-----------------------------------------------------------------------------
PixGuiCol1,PixGuiCol2,PixGuiCol3:Byte;

   GUI colors.  If you change those, PixGuiCol1 is the dark color,
   PixGuiCol2 is the medium color (interior), and PixGuiCol3 is the light
   color.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Map module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
   PixTileMap=Object
		MWd,MHg,TWd,THg,NumTil:Integer;
      Tiles:Array[0..255] Of Pointer;
      Map:Array[0..199,0..199] Of Byte;
      ScX,ScY,Wd,Hg:Integer;
   	Constructor Init(nScX,nScY,nWd,nHg:Integer);
      Procedure NewMap(nMWd,nMHg,nTWd,nTHg:Integer);
      Procedure Draw(VirX,VirY:Integer);
      Procedure Save(FName:String);
      Procedure Load(FName:String);
      Destructor Done;
   End;

   This is the acutal Tiled map variable.

   To use a tiled map, it's easy.

   First, use PixMapEd to create a map.

   Then, create a PixTileMap variable.
   Call it's constructor Init.
   nScX and nScY specify to top-left position of the virtual page where the
   map is going to be drawn.  nWd and nHg are the width and height the the
   map must AT LEAST draw.  Note the the map will be larger than the specified
   width and height, and will draw to the left and to the top of nScX and
   nScY in order to make the specified portion of the map drawn.  You
   generally use PixSetClip before drawing the map.

   Now, you may load a map using Load, where FName is the file name.  If
   you don't specify any extension, .PTM is used.

   Well done!  Now just use Draw to display it. VirX and VirY specify the
   virtual position.  (0,0) displays the map starting with tile 0 and 0 to
   the top-left position.  Specify (8,0) displays the map starting from the
   top, but half of the first tile isn't seen.

   That's all folks!

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Cd module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
 PixCDRom=object                  { Main object                            }
  CDError    : Byte;              { Check this var to see if error occured }
  VolSize    : LongInt;           { Size of CD in sectors.                 }
  DskInfo    : DiskInfo;          { Information about disk.                }
  Position   : CDPos;             { Current CD position                    }
  CDReady    : Boolean;           { Readyness flag, used by unit           }
  Status     : CDState;           { Status of CD-ROM                       }
  Constructor  Init;              { Call this to initialize CD-ROM         }
  Procedure    Play(Track:Byte);  { Starts playing the track               }
  Procedure    Stop;              { Stops playing                          }
  Procedure    Pause;             { Pause playing. Call again to resume    }
  Procedure    ErrorMsg(Var MsgNum:Byte); { Call this to see error info    }
  Procedure    GetCDPos;                  { Returns current CD position    }
  Procedure    ChangeDisk;                { Ejects or loads disk           }
  Function     GetKey:Byte;               { Reads key without waiting      }
  Function     IsDoorOpen:Boolean;        { Checks if CD-ROM door open     }
  Function     IsMediaChg:Boolean;        { Checks if media was changed    }
  Destructor   Done;                      { Call this when you're done     }
end;

   I think that Yuri's comments beside each function describes quite well
   how to use this ;)

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Joy module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Type
	PixJoystick=Record
		X,Y:Word;
		B1,B2:Boolean;
		Up,Down,Left,Right:Boolean;
		CalX1,CalY1,CalX2,CalY2:Word;
	End;

   This is the type definition for the Joystick.  X and Y are the real
   joystick's coordinates.  B1 and B2 are true if the corresponding button
   is down.  Up, Down, Left and Right if the joystick is in the corresponding
   direction (WORKS ONLY IF JOYSTICK CALIBRATED!!!).  Don't use the 4 words.

-----------------------------------------------------------------------------
Function PixAutoCalibJoy(WJoy:Byte):Boolean;

   This is a calibration function.  You must be in text mode (PixOpen not yet
   called), because it draws a calibration screen that let the user calibrate
   it's joystick.  You may personnalize this function.  WJoy is the joystick
   number (1 or 2) to calibrate.

-----------------------------------------------------------------------------
Procedure PixReadJoy(WJoy:Byte);

   This updates the joystick's data for joystick number WJoy.  You must call
   this before using the joystick's coordinates/buttons to make sure that
   the values are right.  WJoy is the joystick number to read (1 or 2).

-----------------------------------------------------------------------------
Function PixDetectJoy(WJoy:Byte):Boolean;

   Returns true if a joystick is attached.  WJoy is the joystick number to
   check (1 or 2).

-----------------------------------------------------------------------------
Var
	Joy:Array[1..2] Of PixJoystick;

   This is the actual joystick variables.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
              Functions/Procedures for the Pix2Kbd module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Procedure PixInstallKey;

   Installs the Pix2 new keyboard handler.  BEWARE: ONCE THAT THIS IS
   INSTALLED, NO OTHER INPUT FUNCTIONS SUCH AS READKEY/READ/READLN THAT
   USES THE KEYBOARD WILL WORK!!!  If you forget to call PixRemoveKey, don't
   worry it's automatically called upon exit.  Once this has been
   called, you can use other Pix2Kbd's functions and the Key[] array.

-----------------------------------------------------------------------------
Procedure PixRemoveKey;

   This removes the Pix2 keyboard handler, allowing you to use other
   keyboard functions.  YOU MUST CALL THIS BEFORE EXITING YOUR PROGRAM!

-----------------------------------------------------------------------------
Procedure PixWaitForKey(WKey:Byte);

   This function doesn't return until the key number WKey has been pressed
   and released.  See below for more info about key numbers.

-----------------------------------------------------------------------------
Function PixWaitAnyKey:Byte;

   This functions waits for the user to press any key and to release it.
   The function returns the key's number.  See below for more info about
   key numbers.

-----------------------------------------------------------------------------
Var
	Key:Array[1..255] Of Boolean;

   This is the key array.  To check wheter a key is up or down, just check
   the corresponding key number's in the Key array.  See below for more info
   about key numbers.

-----------------------------------------------------------------------------
	CtrlAltDelEnabled:Boolean;

   If this is set to true, Pix2 will handle the Ctrl+Alt+Del and reboot the
   computer.  If it is set to false, it doesn't care about it.  By default
   this is false.  Note that if you use Windows 95, this is useless because
   Windows95 handles it first.

-----------------------------------------------------------------------------
   Key number:
      Each key have a scan code.  Those scan codes are used with Pix2Kbd.
      Here's a list of all keys that can be checked and used in
      PixWaitForKey, and returned by PixWaitAnyKey.  Note that the key
      constants represents the US keyboard configuration and may not
      work on foreign keyboards!
Const
  keySysReq      = $54;  keyCapsLock    = $3A;  keyNumLock     = $45;
  keyScrollLock  = $46;  keyLeftCtrl    = $1D;  keyLeftAlt     = $38;
  keyLeftShift   = $2A;  keyRightCtrl   = $9D;  keyAltGr       = $B8;
  keyRightShift  = $36;  keyEsc         = $01;  keyBackspace   = $0E;
  keyEnter       = $1C;  keySpace       = $39;  keyTab         = $0F;
  keyF1          = $3B;  keyF2          = $3C;  keyF3          = $3D;
  keyF4          = $3E;  keyF5          = $3F;  keyF6          = $40;
  keyF7          = $41;  keyF8          = $42;  keyF9          = $43;
  keyF10         = $44;  keyF11         = $57;  keyF12         = $58;
  keyA           = $1E;  keyB           = $30;  keyC           = $2E;
  keyD           = $20;  keyE           = $12;  keyF           = $21;
  keyG           = $22;  keyH           = $23;  keyI           = $17;
  keyJ           = $24;  keyK           = $25;  keyL           = $26;
  keyM           = $32;  keyN           = $31;  keyO           = $18;
  keyP           = $19;  keyQ           = $10;  keyR           = $13;
  keyS           = $1F;  keyT           = $14;  keyU           = $16;
  keyV           = $2F;  keyW           = $11;  keyX           = $2D;
  keyY           = $15;  keyZ           = $2C;  key1           = $02;
  key2           = $03;  key3           = $04;  key4           = $05;
  key5           = $06;  key6           = $07;  key7           = $08;
  key8           = $09;  key9           = $0A;  key0           = $0B;
  keyMinus       = $0C;  keyEqual       = $0D;  keyLBracket    = $1A;
  keyRBracket    = $1B;  keySemicolon   = $27;  keyTick        = $28;
  keyApostrophe  = $29;  keyBackslash   = $2B;  keyComma       = $33;
  keyPeriod      = $34;  keySlash       = $35;  keyInsert      = $D2;
  keyDelete      = $D3;  keyHome        = $C7;  keyEnd         = $CF;
  keyPageUp      = $C9;  keyPageDown    = $D1;  keyArrowLeft   = $CB;
  keyArrowRight  = $CD;  keyArrowUp     = $C8;  keyArrowDown   = $D0;
  keyKeypad0     = $52;  keyKeypad1     = $4F;  keyKeypad2     = $50;
  keyKeypad3     = $51;  keyKeypad4     = $4B;  keyKeypad5     = $4C;
  keyKeypad6     = $4D;  keyKeypad7     = $47;  keyKeypad8     = $48;
  keyKeypad9     = $49;  keyKeypadComma = $53;  keyKeypadStar  = $37;
  keyKeypadMinus = $4A;  keyKeypadPlus  = $4E;  keyKeypadEnter = $9C;
  keyCtrlPrtScr  = $B7;  keyShiftPrtScr = $B7;  keyKeypadSlash = $B5;

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
				  Functions/Procedures for the Pix2Tmr module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
var
	ticks : longint absolute $0040:$006C;

	number of ticks since midnight, constantly updated.  This is always
	updated at 18.2 times a sec no matter what the clock rate is set at.

-----------------------------------------------------------------------------
	clock : array[0..15] of word;

	16 clock counters.  Each are decremented at every timer interrupt.
	They do not loop, and will stop at 0.}

-----------------------------------------------------------------------------
procedure PixSetRate(freq:word);

   Sets the rate of the clock.  The actual real-time clock will remain
   intact no matter what rate is set (or at least it'll be as close as
   possible ;)
   freq = number of interupts per second (18 is normal clock [almost] if you
   want a normal clock counter it is better to use the procedure below to
   restore the timer)

-----------------------------------------------------------------------------
procedure PixRestoreTimer;

	Restores the actual BIOS 18.2 timer.  Removes my custom timer handler.
	This will be called automatically when your program stops, but it wont
	hurt anything if you do call it.

-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
				  Functions/Procedures for the Pix2Xms module
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

	Before describing XMS functions, I'll explain how I implemented the XMS
	handling so that you better understand how to use it.

	First, when someone allocates memory in XMS, you must specify the size
	of the block in Kb.  Also, there's a restricted number of handles (A
	handle is like an allocated block of memory, much like a pointer, but
	in limited number).  So, if you have many tiny images, each one would
	take one handle and 1k of memory, and that's not really useful.  So,
	here's what I've done.

	Pix2Xms takes care about allocating as much space as you want and there's
	available in XMS memory into a single handle, which is used internally
	by Pix2Xms.  Next, when you load an image or a PRI, or when you get an
	image from the screen, it's stored in this big handle, and an offset
	relative to the begining of the block is stored in the PixXmsImage
	structure (as long as the image's size).  With this structure, you
	can put the image.

	To avoid messing too much with that, I haven't made a de-allocation
	procedure.  If images must come and go, just use regular functions.

	So, you may allocate as much memory as you want (of course if it's
	available), and store all images in it.  So here's the explaination
	of each functions.

	If you run Windows 95, there's no problem (Well I think!).  But if you
	run in DOS, the TP/BP IDE takes up all the XMS memory, so you won't have
	any for you.  To override that, type the folowing line before entering
	the IDE:

	SET DPMIMEM=MAXMEM x

	Where x is the number of Kb you want to IDE to take.  For example, if you
	have 15mb free and want 10 for you, type:

	SET DPMIMEM=MAXMEM 5000

	This way you'll avoid problems!

	Since most of the functions works about the same, you can just change
	your source code with a search/replace and everything will go in XMS.

-----------------------------------------------------------------------------
  Type
	PixXMSImage=Record
		Offset:LongInt;
		Size:Word;
	End;

	This is the structure used instead of a pointer in the XMS image routines.
	Pix2Xms uses it internally to retreive where in the block of XMS memory
	the image is stored.  The size is the real image's size, to speed up
	the XMS transfer process.  Normally you'll do just like the pointer and
	don't touch what's in it.

-----------------------------------------------------------------------------
Function PixCheckXMS:Boolean;

	This checks wheter XMS is installed.  Return true if you can use the XMS.

-----------------------------------------------------------------------------
Function PixGetFreeXms:Word;

	This returns the amount of available memory in the XMS.  This is a good
	practice to check that before allocating memory!

-----------------------------------------------------------------------------
Function PixAllocXms(NumK:Word):Boolean;

	This allocates the block of memory.  It returns true if there was enough
	XMS to allocate the whole block.  NumK is the number of Kb you want in
	the block.  Make it large enough to include all of your images, but not
	too much to avoid the game from working on low-memory computers.  You
	should call PixFreeXms before leaving the program to free up this memory,
	buf if you forget, Pix2Xms will do that for you when you leave the
	program.

-----------------------------------------------------------------------------
Procedure PixFreeXms;

	This free up the memory allocated with PixAllocXms.  If you don't call
	this, the memory will be automatically freed up by Pix2Xms.

-----------------------------------------------------------------------------
Function PixGetImageXms(Var I:PixXMSImage;X1,Y1,X2,Y2:Integer):Boolean;

	This works exactly as PixGetImage, except that you specify a
	PixXMSImage instead of a pointer, and there's no "Alloc" variable, since
	this function always takes new space.  Return true if everything went
	all right.

-----------------------------------------------------------------------------
Procedure PixPutImageXms(I:PixXMSImage;X,Y:Integer;Trans:Boolean);

	This works exactly as PixPutImage, except that you specify a
	PixXMSImage instead of a pointer.  Apart that, everything is the
	same.

-----------------------------------------------------------------------------
Procedure PixSaveImageXms(I:PixXMSImage;FName:String;WPal:PixPalType;Pal:PixPaletteP);

	Same as PixSaveImage, with a PixXMSImage instead of a pointer.

-----------------------------------------------------------------------------
Function PixLoadImageXms(Var I:PixXMSImage;FName:String;WPal:PixPalType;Pal:PixPaletteP):Boolean;

	Same as PixLoadImage, with a PixXMSImage instead of a pointer.

-----------------------------------------------------------------------------
Function PixLoadPriXms(Var I:PixXMSImage;FName:String):Boolean;

	Same as PixLoadPri, with a PixXMSImage instead of a pointer.

-----------------------------------------------------------------------------
Function PixFreeMemXms:LongInt;

	This returns the number of bytes available in your allocated block.
	You can check this before loading large image if you think you haven't
	allocated enough space.

-----------------------------------------------------------------------------
EXAMPLE
-------------
I've decided to include an example for the XMS routines:

Uses
	Pix2Main,Pix2Xms,Crt;

Var
	I:PixXmsImage;

Begin
	If Not PixCheckXms Then
	Begin
		WriteLn('Oh oh! No XMS!!!');
		Exit;
	End;
	If PixGetFreeXms<2000 Then
	Begin
		WriteLn('You need 2000k of free XMS memory to run this!');
		Exit;
	End;
	PixAllocXms(2000); { 2000k is way more than the regular 500k limit!!! }
	If Not PixLoadPriXms(I,'TEST.PRI') Then
	Begin
		WriteLn('Was unable to load TEST.PRI');
		Exit;
	End;
	PixOpen(0);
	PixPutImageXms(I,0,0,False);
	ReadKey;
	PixClose;
	PixFreeXms;
End.
