home *** CD-ROM | disk | FTP | other *** search
- {$B+} {Boolean 'lazy evaluation' on - avoids potential bugs}
- {$M 1024,0,3072} {This is sure to vary dependent on your application.
- See note below regarding screen 'save' and 'restore'}
-
- PROGRAM TP4_TSR;
-
- {This has been shamelessly filtched from THELP4, a TSR program originally
- written by Glenn Wood of the Greenville PC Club of Greenville, Texas and
- updated by John Sloan, AlphaOmega Computer Services, Devon, Alberta.
- There are no guarantees that this will work as I am definitely >>NOT<< a
- TSR expert, but for the few programs that I have required to have 'terminate
- and stay resident' abilities this 'TSR shell' has worked adequately.
-
- E. J. Drinkwater (3/9/88) }
-
- Uses
- Crt,
- {WinTTT,} {'uncomment' if required}
- Dos;
-
- const
- EntryChar = 19; { ALT 'R' - can be changed }
- Entry_comm = 'ALT ''R'''; { to be changed as required }
- KybdInt = $16;
- Prog_name = 'Test Program'; {Insert the name of your program here}
-
- var
- UserInt : byte;
- exitcode : word;
- reg : Registers;
- Vector1,
- Vector2 : Pointer;
-
- {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
-
- procedure main_prog;
-
- begin
-
- {
-
- ** insert your main program in here as a procedure for the TSR shell **
-
- Note : make sure you insert all your program 'types', 'constants',
- 'variables' etc. to this TSR shell's listing in the appropriate places
- and ensure that all your own procedures are inserted before this 'main_prog'
- procedure.
- }
-
-
- end;
-
-
- {-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}
-
- procedure ProcessInt(Flags,cs,ip,ax,bx,cx,dx,si,di,ds,es,bp:word);
-
- Interrupt;
-
- begin
-
- Reg.ax:=ax;
-
- If Reg.ah <> 0 then
- Begin
- Intr(UserInt,reg);
- ax:=reg.ax;
- Flags:=reg.flags
- end
- else
- begin
- Intr(UserInt,reg);
- ax:=reg.ax;
- Flags:=reg.flags;
- if (reg.ah = EntryChar) and (reg.al = $00) then
- begin
- reg.ax := $0300;
- reg.bx := $0;
- {savescreen(1);} {**}
- main_prog;
- {restorescreen(1);} {**}
- {disposescreen(1);} {**}
-
- { ** these three lines are procedures in the 'Technojock's Turbo Toolkit'
- that enable the screen, prior to calling the TSR, to be saved to
- memory and then restored accurately after exit from the TSR. These
- procedures are contained in the WINTTT.TPU unit and eat up memory
- in order to perform the save correctly. Therefore, if required,
- 'uncomment' these lines, add WINTTT to the uses section, and alter
- the 'M' compiler directive at the top of the listing to allow for
- extra memory for a 'page of screen'.}
-
- end;
- end;
- end;
-
- { Program installation }
-
- Var Signature:^longint;
-
- begin
- userint:=$60; {start checking at first user int}
- Repeat
- GetIntVec(userint,Vector1);
- GetIntVec(Kybdint,Vector2);
- Signature:=Vector2;
- If Signature^ = $52515350 then {use push instructions at beginning of}
- Begin {ProcessInt as signature to detect if it}
- write(' ',Prog_name,' appears to be already Installed!');
- exitcode:=3; {signal exit}
- writeln;
- End
- Else
- If (Meml[Seg(Vector1):Ofs(Vector1)] = $00000000) or
- (Meml[Seg(Vector1):Ofs(Vector1)]=$F000F815) then {accomodate PCjr}
- begin
- writeln('Installing ',Prog_name,' as TSR -- Press < ',Entry_comm,' > to run.');
- writeln('');
- GetIntVec(Kybdint,Vector2);
- SetIntVec(UserInt,Vector2);
- SetIntVec(KybdInt,@ProcessInt);
- keep(exitcode);
- end;
- userint:=userint+1;
- Until (exitcode = 3) or (UserInt > $67);
- If exitcode <> 3 then writeln('User Interupts in use -- can''t install ',Prog_name,'.')
- end.
-
-