home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / tsr4c.zip / CLOCKIC.C < prev    next >
Text File  |  1992-03-17  |  3KB  |  82 lines

  1. /*****************************************************************
  2.     TINY CLOCK  -  INITIALIZATION/DISPOSABLE CODE
  3.       (c) Copyright 1992 by Omega Point, Inc.
  4. ******************************************************************/
  5. #include "cr.h"
  6.  
  7. #ifdef K1        /** Use LIM if PDK-1 is available */
  8. #include "lm.h"
  9. #endif
  10.  
  11. #define STK_SZ (64)        /* TSR Stack: 64 words */
  12. word isr_stk[STK_SZ+1];
  13.  
  14.  
  15. extern popclock();    /* Main TSR entry, called by scheduler */
  16.  
  17. /******** Disposable messages in CLOCKID.C **************/
  18.  
  19. extern char sms[];          /* Signon screen                 */
  20. extern char attrc[],attrm[]; /* Screen attributes used for signon */
  21. extern char already[];       /* Message when already loaded      */
  22. extern char unloaddone[];
  23. extern char unloadnot[];
  24. extern word init_data_end;   /* Marker for end of disposable data */
  25.  
  26.  
  27. /********************************************************************
  28.  This main gets called only once on program load, after that it is
  29.  discarded 
  30. *********************************************************************/
  31.  
  32. main()
  33. {  int i;
  34.    char *a;
  35.    
  36.      if (second_load())    /* Check if TSR already loaded */
  37.        {
  38.        i=str_pos('-',cmd_line);
  39.        if (i && ((cmd_line[i]|0x20)=='r'))
  40.          {
  41.      if(remove_tsr())        /* Remove TSR from memory */
  42.        dspf(unloaddone);        /* Inform about unloading */
  43.      else
  44.        dspf(unloadnot);
  45.      }
  46.        else dspf(already);        /* Otherwise show Help message */
  47.        mv_crs();            /* Reposition real cursor */
  48.        return(1);            /* Exit with errorlevel 1 */
  49.        }
  50.  
  51.  /***** Display Signon Screen *****/
  52.  
  53.      clr_scr();
  54.      a = color ? attrc:attrm;    /* Select proper screen attributes */
  55.      crs_x=20; crs_y=7;        /* Location to put signon box      */
  56.      dspf(sms,a);        /* Show the screen                 */
  57.  
  58.      crs_x=0; crs_y=scr_len-2;    /* Move to the bottom of screen    */
  59.      mv_crs();            /* Place real cursor there         */
  60.      crs_y=0;            /* Top line used to display clock  */
  61.  
  62.  
  63. #ifdef DBG   /********** Debug mode via -DDBG compiler switch ***********/
  64.  
  65.      popclock();    /* The TSR can be debugged as a regular program */
  66.  
  67. #else         /**********  INIT TSR MODE  ********************************/
  68.  
  69.      idata_end=&init_data_end;        /* This enables init data disposal. */
  70.      icode_beg=main;            /* This enables init code disposal. */
  71.      stay_resident(isr_stk,STK_SZ*2);    /* Enable resident mode             */
  72.      install_tsc(popclock,2*STK_SZ,1);    /* Install tiny scheduler           */
  73. #ifdef K1                /* Usable only with PDK1            */
  74.      move_to_lim(1,1,MOVE_BOTH);    /* Move TSR to LIM if available     */
  75. #endif
  76.      add_tsc_event(8L);        /* Add event to timer, 8 ticks from now  */
  77.                 /* Popclock will be called by scheduler  */
  78.      return(0);            /* Set errorlevel to 0                   */
  79.  
  80. #endif
  81. }
  82.