
UNIT TPlus;
{$S-}
INTERFACE

USES Crt,Dos;

TYPE String1  = STRING [1];
     String2  = STRING [2];
     String6  = STRING [6];
     String11 = STRING [11];
     String65 = STRING [65];
     String80 = STRING [80];
     AnyStr   = STRING [255];

     DisplayPointer = ^DisplayArray;
     DisplayArray = ARRAY [1..50] OF ARRAY [1..80] OF ARRAY [1..2] OF BYTE;

     InterventionProc = Procedure;
     BorderStyle = Byte;


CONST
      EscKey      =  1;
      EnterKey    = 28;
      PageUpKey   = 73;
      PageDnKey   = 81;
      ArrowUpKey  = 72;
      ArrowDnKey  = 80;
      ArrowLfKey  = 75;
      ArrowRtKey  = 77;
      SpaceBarKey = 57;
      F1Key       = 59;
      F2Key       = 60;
      F3Key       = 61;
      F4Key       = 62;
      F5Key       = 63;
      F6Key       = 64;
      F7Key       = 65;
      F8Key       = 66;
      F9Key       = 67;
      F10Key      = 68;
      TabKey      = 15;
      ShiftTabKey = 150;


      LBracket : CHAR = '[';
      RBracket : CHAR = ']';

      StartScanOff : Byte = $20;
      StopScanOff  : Byte = $00;

      NoLine     = 0;
      ThinLine   = 1;
      FatLine    = 2;
      DoubleLine = 3;
      DoubleTop  = 4;
      DoubleSide = 5;

      TPBorders : ARRAY [0..5] OF String [10] = ('          ',
						 'ÚÄ¿³ÙÄÀ³´Ã',
						 'ÜÛÜÛßÛßÛÝÞ',
						 'ÉÍ»º¼ÍÈº¹Ì',
						 'ÕÍ¸³¾ÍÔ³¹Ì',
						 'ÖÄ·º½ÄÓº´Ã');



VAR SType       : CHAR;

    BackGroundColor : INTEGER;
    ForeGroundColor : INTEGER;
    ShadeColor      : BYTE;
    TPHandle    : INTEGER;
    Display     : DisplayPointer;
    TPMaxXw     : INTEGER;
    TPMaxYw     : INTEGER;
    TPMinXw     : INTEGER;
    TPMinYw     : INTEGER;

    IStartLine, IStopLine : INTEGER;

    Computer_Type,
    Major_DOS_Version,
    Minor_DOS_Version,
    Active_Video,
    Alternate_Video,
    Display_Mode,
    Ega_Memory,
    Number_Of_Disks,
    Number_Of_Printers,
    Number_Of_Serial_Adapters : BYTE;
    System_Ram,
    Available_Ram,
    Extended_System_Ram : INTEGER;



    MousePresent : Boolean;


    UserMapRoutine : InterventionProc;
    UserMapScan : Byte;
    UserMapAscii : Char;
    UserMapCursor : Integer;
    UserMapExit : Boolean;

PROCEDURE FastWrite (Msg : AnyStr;
		     FgColor, BgColor, SCursor : INTEGER);


PROCEDURE NewLine;
PROCEDURE FastString (Msg : AnyStr;
		      SCursor : INTEGER);
PROCEDURE FastAtt (Msg : AnyStr;
		   FgColor, BgColor, SCursor : INTEGER);
PROCEDURE ChangeAtt (Len, FgA, BgA : INTEGER);
PROCEDURE ChangeBatt (Len, BgA : INTEGER);
PROCEDURE GetAtt (VAR FgA, BgA : INTEGER);
PROCEDURE FastRead (XPos, YPos, Length : INTEGER;
		    Msg : AnyStr);
PROCEDURE ClearScn;
PROCEDURE ClearScnHome;
PROCEDURE ClearWindow;
PROCEDURE ClearWindowHome;
PROCEDURE SnapShot (Option : INTEGER);
PROCEDURE NestSnap (Option : INTEGER;
		    VAR SaveArea);
PROCEDURE NestSnapWindow (Option : INTEGER;
			  VAR Savearea;
			  StartX,Starty,EndX,EndY: INTEGER);
PROCEDURE DrawFrame (Border : BorderStyle;
		     UpperLeftX, UpperLeftY,
		     LowerRightX, LowerRightY : INTEGER);
PROCEDURE WindowFrame (Border : BorderStyle;
		       x1, y1,
		       x2, y2 : INTEGER;
		       Title  : String80);
PROCEDURE ScreenType (VAR SType : CHAR);
PROCEDURE ScreenOff;
PROCEDURE ScreenOn;
PROCEDURE CursorOff;
PROCEDURE CursorOn;
PROCEDURE CursorNormal;
PROCEDURE GetCursor (VAR StartLine, StopLine : INTEGER);
PROCEDURE SetCursor (StartLine, StopLine : INTEGER);
PROCEDURE FindCursor (VAR Xpos, Ypos : INTEGER);
PROCEDURE FindCursorF (VAR Xpos, Ypos : INTEGER);
PROCEDURE MoveCursor (Xpos, Ypos : INTEGER);
PROCEDURE MoveCursorF (Xpos, Ypos : INTEGER);
PROCEDURE GetPage (VAR PageNum : INTEGER);
PROCEDURE SetPage (PageNum : INTEGER);
PROCEDURE Cva (    FgA, BgA : INTEGER;
	       VAR AByte    : BYTE);
PROCEDURE Exa (VAR FgA, BgA : INTEGER;
		   AByte    : BYTE);
PROCEDURE MoveScreen (VAR FromArea, ToArea;
			  Length : INTEGER);
PROCEDURE FMoveScreen (VAR FromArea, ToArea;
			   Length : INTEGER);
PROCEDURE TMoveScreen (VAR FromArea, ToArea;
			   Length : INTEGER);
PROCEDURE CMoveScreen (VAR FromArea, ToArea;
			   Length : INTEGER);
PROCEDURE AMoveScreen (VAR FromArea, ToArea;
			   Length : INTEGER);
PROCEDURE Above25 (OnOff : BOOLEAN);
PROCEDURE Above25Clear (OnOff : BOOLEAN);
PROCEDURE Bright;
PROCEDURE Blink;
PROCEDURE ReadKb (VAR Scan : BYTE;
		  VAR ASCII : String1);
PROCEDURE ReadKbC (VAR Scan : BYTE;
		  VAR ASCII : CHAR);
PROCEDURE ReadKbLeave (VAR Scan : BYTE;
		  VAR ASCII : String1);
PROCEDURE ShowKb (VAR Scan : BYTE;
		  VAR ASCII : String1;
		  VAR Image : String6);
PROCEDURE PauseKb;
PROCEDURE ClearKb;
FUNCTION KeyStruck : BOOLEAN;
PROCEDURE RamWindow (VAR VarName);
PROCEDURE CritError;
PROCEDURE CritErrorPass;
PROCEDURE SetColorsN (Foreground, Background : INTEGER);
PROCEDURE ReverseOn;
PROCEDURE ReverseOff;
PROCEDURE MenuMaker (    Option : CHAR;
			 Fg, Bg : INTEGER;
			 LBracket, RBracket : CHAR;
			 SearchItem : CHAR;
		     VAR Item, Position : INTEGER;
		     VAR SaveArea);
PROCEDURE RMenuMaker (    Sx, Sy, Ex, Ey : INTEGER;
			  Option : CHAR;
			  Fg, Bg : INTEGER;
			  LBracket, RBracket : CHAR;
			  SearchItem : CHAR;
		      VAR Item, Position : INTEGER;
		      VAR SaveArea);
PROCEDURE MenuPick (    Sx, Sy, Ex, Ey : INTEGER;
			LBracket, RBracket : CHAR;
		    VAR Item     : INTEGER;
			Fg, Bg   : INTEGER;
			NumItems : INTEGER;
			ItemsPerLine : INTEGER);
Procedure WMenuMaker(    sx,sy,ex,ey : integer;
			 option      : char;
			 fg,bg       : integer;
			 lbrac,rbrac : char;
			 search      : string65;
		     var item,
			 position    : integer;
		     var savearea;
		     var scan        : byte;
		     var ascii       : string1;
			 OneColumn   : Boolean);
PROCEDURE System_Resources;
PROCEDURE CreateF (    Path : String65;
		   VAR Attribute, Handle, Error : INTEGER);
PROCEDURE DeleteF (    Path  : String65;
		   VAR Error : INTEGER);
PROCEDURE OpenF (    Path : String65;
		 VAR Access, Handle, Error : INTEGER);
PROCEDURE WriteF (VAR Handle : INTEGER;
		  VAR Area;
		  VAR RecLen : WORD;
		  VAR Error  : INTEGER);
PROCEDURE ReadF (VAR Handle : INTEGER;
		 VAR Area;
		 VAR RecLen : WORD;
		 VAR Error  : INTEGER);
PROCEDURE PointF (VAR Handle: INTEGER;
		  VAR RecLen: WORD;
		  VAR RecNum,
		      POption,
		      Error : INTEGER);
Procedure PointD (VAR Handle : INTEGER;
		  VAR DispIn, DispOut : LONGINT;
		  VAR Option, Error : INTEGER);
PROCEDURE CloseF (VAR Handle, Error : INTEGER);
PROCEDURE DupHandle (    OldHandle : INTEGER;
		     VAR NewHandle : INTEGER;
		     VAR ErrorCode : INTEGER);
PROCEDURE MkDirN (    Path  : String65;
		  VAR Error : INTEGER);
PROCEDURE RmDirN (    Path  : String65;
		  VAR Error : INTEGER);
PROCEDURE ChgDirN (    Path  : String65;
		   VAR Error : INTEGER);
PROCEDURE CurDisk (VAR Disk : CHAR);
PROCEDURE CurDirN (VAR Path  : String65;
		   VAR Drive : CHAR;
		   VAR Error : INTEGER);
PROCEDURE ChangeN (    Path : String65;
		   VAR Option, Attribute, Error : INTEGER);
PROCEDURE VolumeGet (    ID : CHAR;
		     VAR Volume : String11);
PROCEDURE VolumeSet (    ID : CHAR;
		     VAR Volume : String11);
FUNCTION LoadDir : String65;
FUNCTION FileExists (PathName : String65) : BOOLEAN;
FUNCTION SizeOfFile (PathName : String65) : LONGINT;
FUNCTION SizeOfOpenFile (Handle : INTEGER) : LONGINT;
FUNCTION EnviroPath (VarName : STRING) : STRING;
FUNCTION FindPath (FileName : String65) : String65;
PROCEDURE SelectDisk (VAR Disk : CHAR);
PROCEDURE Screeches;
PROCEDURE Birds;
PROCEDURE ClockSound;
PROCEDURE Machinery1;
PROCEDURE Chirps;
PROCEDURE CrashAndBurn;
PROCEDURE Generator1;
PROCEDURE DialBusyPhone;
PROCEDURE RandomSounds;
PROCEDURE InvadersSaucer;
PROCEDURE Siren1;
PROCEDURE DrippingSpigot;
PROCEDURE Train;
PROCEDURE Siren2;
PROCEDURE ElectronicSounds;
PROCEDURE Screeches2;
PROCEDURE Machinery3;
PROCEDURE Click;
PROCEDURE Zoink;
PROCEDURE WolfWhistle;
PROCEDURE DoorBuzzer;
PROCEDURE Phaser;
PROCEDURE PhoneRing;
PROCEDURE PhotonTorpedo;
PROCEDURE MapField (    Option,
			FType    : CHAR;
			XPos, YPos,
			MsgLine,
			Fg, Bg,
			AFg, ABg : INTEGER;
		    VAR RCode, CPos : INTEGER;
		    VAR Vf, Mask    : String80);
PROCEDURE MapString (    Option       : CHAR;
			 XPos, YPos,
			 MsgLine,
			 Fg, Bg,
			 AFg, ABg     : INTEGER;
		     VAR RCode, CPos  : INTEGER;
		     VAR Vf           : String80;
			 Mask         : String80);
PROCEDURE MapReal   (    Option       : CHAR;
			 XPos, YPos,
			 MsgLine,
			 Fg, Bg,
			 AFg, ABg     : INTEGER;
		     VAR RCode, CPos  : INTEGER;
		     VAR Vf           : REAL;
			 Mask         : String80);
PROCEDURE MapInt (    Option       : CHAR;
		      XPos, YPos,
		      MsgLine,
		      Fg, Bg,
		      AFg, ABg     : INTEGER;
		  VAR RCode, CPos  : INTEGER;
		  VAR Vf           : INTEGER;
		      Mask         : String80);
PROCEDURE MapByte (   Option       : CHAR;
		      XPos, YPos,
		      MsgLine,
		      Fg, Bg,
		      AFg, ABg     : INTEGER;
		  VAR RCode, CPos  : INTEGER;
		  VAR Vf           : BYTE;
		      Mask         : String80);
PROCEDURE MapShortInt (   Option       : CHAR;
			  XPos, YPos,
			  MsgLine,
			  Fg, Bg,
			  AFg, ABg     : INTEGER;
		      VAR RCode, CPos  : INTEGER;
		      VAR Vf           : SHORTINT;
			  Mask         : String80);
PROCEDURE MapWord (   Option       : CHAR;
		      XPos, YPos,
		      MsgLine,
		      Fg, Bg,
		      AFg, ABg     : INTEGER;
		  VAR RCode, CPos  : INTEGER;
		  VAR Vf           : WORD;
		      Mask         : String80);
PROCEDURE MapLongInt (    Option       : CHAR;
			  XPos, YPos,
			  MsgLine,
			  Fg, Bg,
			  AFg, ABg     : INTEGER;
		      VAR RCode, CPos  : INTEGER;
		      VAR Vf           : LONGINT;
			  Mask         : String80);

    { Read or write a byte (8-bit), with hex digits allowed }
PROCEDURE MapHexByte (    Option       : CHAR;
			  XPos, YPos,  {Relative to Turbo Window}
			  MsgLine,
			  Fg, Bg,
			  AFg, ABg     : INTEGER;
		      VAR RCode, CPos  : INTEGER;
		      VAR Vf           : BYTE;
			  Mask         : String80);

    { Read or write a word (16-bit), with hex digits allowed }
PROCEDURE MapHexWord (    Option       : CHAR;
			  XPos, YPos,  {Relative to Turbo Window}
			  MsgLine,
			  Fg, Bg,
			  AFg, ABg     : INTEGER;
		      VAR RCode, CPos  : INTEGER;
		      VAR Vf           : WORD;
			  Mask         : String80);
PROCEDURE ScanMap(    X1,Y1,X2,Y2 : integer;
		      Option : Char ;
		  var X,Y,Item : integer;
		      Marker : Char;
		      RetCode : integer;
		  var Buf);
PROCEDURE MouseInit (VAR Buttons : INTEGER);
PROCEDURE MouseArea (XMin, YMin, XMax, YMax : INTEGER);
PROCEDURE MouseFind (VAR XPos, YPos : INTEGER;
		     VAR BStat      : WORD);
PROCEDURE MouseMove (XPos, YPos : INTEGER);
PROCEDURE MousePress (    Button   : INTEGER;
		      VAR Presses,
			  LastX,
			  LastY    : INTEGER;
		      VAR BStat    : WORD);
PROCEDURE MouseRelease (    Button    : INTEGER;
			VAR Releases,
			    LastX,
			    LastY     : INTEGER;
			VAR BStat     : WORD);
PROCEDURE MouseShowCursor;
PROCEDURE MouseHideCursor;
PROCEDURE MouseMotion (VAR XDist,
			   YDist : INTEGER);
PROCEDURE MouseMickey (XMickey,
		       YMickey  : INTEGER);
PROCEDURE MouseMakeCursor (    XHot,
			       YHot : INTEGER;
			   VAR Masks);
PROCEDURE MouseMakeHardCursor (StartLine,
			       StopLine   : INTEGER);
PROCEDURE MouseMakeSoftCursor (ScreenMask,
			       CursorMask : INTEGER);
PROCEDURE QuerryTime (VAR TIMEHIGH,TIMELOW:WORD);
PROCEDURE ELAPSEDTIME (VAR ELAPHIGH,ELAPLOW:WORD;TIMEHIGH,TIMELOW:WORD);
Function PrinterReady(lpt:byte):boolean;
Procedure PrinterInitialize(lpt:byte);
FUNCTION DelLstSpcs(S :String; Max : Byte) : String;
FUNCTION PadString(S : String; Size : Byte; CharType : Char) : String;
FUNCTION  StrUPCase(Str : String) : String;
FUNCTION Replicate (Count : BYTE;
		    ASCII : CHAR) : AnyStr;
FUNCTION LeftJustify ( Width : BYTE;
		       Str   : AnyStr) : AnyStr;
FUNCTION CenterJustify (Width  : BYTE;
			Center_String : AnyStr) : AnyStr;
FUNCTION RightJustify (Width  : BYTE;
		       Str : AnyStr) : AnyStr;
FUNCTION TokenInStr (    Item : INTEGER;
		     VAR S;
			 Check : CHAR) : STRING;
FUNCTION AddBackSlash (PathName : String65) : String65;
FUNCTION AddFrontPath (PathName : String65) : String65;
FUNCTION PathOnly (Path : String65) : String65;
FUNCTION FileOnly (Path : String65) : String65;
FUNCTION ExtensionOnly (PathName : String65) : String65;
FUNCTION NamePartOnly (PathName : String65) : String65;

