home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / tsr / tp4_tsr / tp4_tsr.lst < prev    next >
Encoding:
File List  |  1988-09-03  |  7.8 KB  |  169 lines

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