Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - tsr() terminate a program that remains resident http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 tsr()               Terminate a program that remains resident
------------------------------------------------------------------------------
 Declaration
   tsr.hdr

 Syntax
   proc tsr extern
   param value ulong nMemSize

 Arguments
   nMemSize is the amount of memory to keep beyond the minimum
   size required for the TSR application.

 Return
   None.

 Description
   The tsr() function terminates a program and remains resident. If the
   tsr() procedure returns, then it was unable to make the program
   resident. If tsr() exits, then the procedure specified by the
   procentry() function is active.

   The memory reserved by the nMemSize parameter serves as a safety
   measure; its optimal value depends on the runtime memory use of the
   application.

   The total amount of memory required by a TSR application results from the
   following factors:

   TSR size = ExeImage + Stack + Buffer + nMemSize, where

   ExeImage is the amount of memory required for the .exe file.

   Stack is the size of the runtime stack which is set via the -S
   compiler switch, and defaults to 16 Kbytes.

   Buffer is a 16 Kbytes internal buffer reserved for database operations.

   nMemSize is the parameter to the tsr() function.

 Example
   #define EXAMPLE_SYSTEM
   #include example.hdr

   #define ID_CLOCK 200
   
   proc Clock static
   @ 0, __max_col - 7 ?? time()         // display time in every second
   endproc
   
   proc Unload static
   unloadtsr()                          // unload TSR when Ctrl-Z pressed
   endproc
   
   proc Test_tsr
   if .not. chkinstalled( ID_CLOCK )    // check if already loaded
      if tsrinstall( ID_CLOCK )         // install multiplex ID
         if procentry( Unload, "<Ctrl><Z>", TSR_CALL_ANY ) // install unloader
            if timerentry( Clock, 1, TSR_TIME_SECS, TSR_CALL_ANY ) // install
               ? "TSR clock installed. Press Ctrl-Z to unload."
               tsr( 1024 )              // terminate and stay resident
            endif
         endif
      else
         ? "TSR clock could not be loaded"
      endif
   else
      ? "TSR clock already loaded"
   endif
   endproc

   proc main
   Test_tsr()
   endproc

See Also: procentry() tsrinstall()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson