home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / tsr / tp4_tsr / tp4_tsr.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1988-09-03  |  4.0 KB  |  130 lines

  1. {$B+}                {Boolean 'lazy evaluation' on - avoids potential bugs}
  2. {$M 1024,0,3072}     {This is sure to vary dependent on your application.
  3.                       See note below regarding screen 'save' and 'restore'}
  4.  
  5. PROGRAM TP4_TSR;
  6.  
  7. {This has been shamelessly filtched from THELP4, a TSR program originally
  8. written by Glenn Wood of the Greenville PC Club of Greenville, Texas and
  9. updated by John Sloan, AlphaOmega Computer Services, Devon, Alberta.
  10. There are no guarantees that this will work as I am definitely >>NOT<< a
  11. TSR expert, but for the few programs that I have required to have 'terminate
  12. and stay resident' abilities this 'TSR shell' has worked adequately.
  13.  
  14.                                                E. J. Drinkwater (3/9/88) }
  15.  
  16. Uses
  17.   Crt,
  18.   {WinTTT,}                            {'uncomment' if required}
  19.   Dos;
  20.  
  21. const
  22.   EntryChar       = 19;                { ALT 'R' - can be changed }
  23.   Entry_comm      = 'ALT ''R''';       { to be changed as required }
  24.   KybdInt         = $16;
  25.   Prog_name       = 'Test Program';     {Insert the name of your program here}
  26.  
  27. var
  28.   UserInt    : byte;
  29.   exitcode   : word;
  30.   reg        : Registers;
  31.   Vector1,
  32.   Vector2    : Pointer;
  33.  
  34. {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
  35.  
  36. procedure main_prog;
  37.  
  38. begin
  39.  
  40. {
  41.  
  42.  ** insert your main program in here as a procedure for the TSR shell **
  43.  
  44.   Note : make sure you insert all your program 'types', 'constants',
  45.   'variables' etc. to this TSR shell's listing in the appropriate places
  46.   and ensure that all your own procedures are inserted before this 'main_prog'
  47.   procedure.
  48.                                                                               }
  49.  
  50.  
  51. end;
  52.  
  53.  
  54. {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
  55.  
  56. procedure ProcessInt(Flags,cs,ip,ax,bx,cx,dx,si,di,ds,es,bp:word);
  57.  
  58. Interrupt;
  59.  
  60. begin
  61.  
  62. Reg.ax:=ax;
  63.  
  64. If Reg.ah <> 0 then
  65.   Begin
  66.      Intr(UserInt,reg);
  67.      ax:=reg.ax;
  68.      Flags:=reg.flags
  69.   end
  70.   else
  71.   begin
  72.     Intr(UserInt,reg);
  73.     ax:=reg.ax;
  74.     Flags:=reg.flags;
  75.     if (reg.ah = EntryChar) and (reg.al = $00) then
  76.     begin
  77.       reg.ax := $0300;
  78.       reg.bx := $0;
  79.       {savescreen(1);}        {**}      
  80.       main_prog;
  81.       {restorescreen(1);}     {**}      
  82.       {disposescreen(1);}     {**}
  83.  
  84. { ** these three lines are procedures in the 'Technojock's Turbo Toolkit'
  85.      that enable the screen, prior to calling the TSR, to be saved to
  86.      memory and then restored accurately after exit from the TSR.  These
  87.      procedures are contained in  the WINTTT.TPU unit and eat up memory
  88.      in order to perform the save correctly.  Therefore, if required,
  89.      'uncomment' these lines, add WINTTT to the uses section, and alter
  90.      the  'M' compiler directive at the top of the listing to allow for
  91.      extra memory for a 'page of screen'.}
  92.       
  93.     end;
  94.   end;
  95. end;
  96.  
  97. { Program installation }
  98.  
  99. Var Signature:^longint;
  100.  
  101. begin
  102.   userint:=$60;                              {start checking at first user int}
  103.   Repeat
  104.      GetIntVec(userint,Vector1);
  105.      GetIntVec(Kybdint,Vector2);
  106.   Signature:=Vector2;
  107.   If Signature^ = $52515350 then             {use push instructions at beginning of}
  108.      Begin                                   {ProcessInt as signature to detect if it}
  109.         write(' ',Prog_name,' appears to be already Installed!');
  110.         exitcode:=3;                         {signal exit}
  111.         writeln;
  112.      End
  113.   Else
  114.   If (Meml[Seg(Vector1):Ofs(Vector1)] = $00000000) or
  115.      (Meml[Seg(Vector1):Ofs(Vector1)]=$F000F815) then {accomodate PCjr}
  116.   begin
  117.     writeln('Installing ',Prog_name,' as TSR --  Press < ',Entry_comm,' > to run.');
  118.     writeln('');
  119.     GetIntVec(Kybdint,Vector2);
  120.     SetIntVec(UserInt,Vector2);
  121.     SetIntVec(KybdInt,@ProcessInt);
  122.     keep(exitcode);
  123.   end;
  124.   userint:=userint+1;
  125.   Until (exitcode = 3) or (UserInt > $67);
  126.   If exitcode <> 3 then  writeln('User Interupts in use -- can''t install ',Prog_name,'.')
  127. end.
  128.  
  129.  
  130.