home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / clock.zip / CLKTIM.C < prev    next >
Text File  |  1987-01-03  |  2KB  |  65 lines

  1. /***************************************************** CLKTIM.C
  2.  * NAME:    CLKTIM
  3.  *
  4.  * FUNCTION:    Get current time.
  5.  *
  6.  * EXAMPLE:    CLKTIM();
  7.  *
  8.  * INPUTS:    Time obtained from system call.
  9.  *
  10.  * OUTPUT:    placed into global definitions
  11.  *
  12.  **************************************************************
  13.  * 11/22/86 -RBM- original implementation
  14.  **************************************************************/
  15. #define XTRNALGLOBALS 1        /* globals externally defined    */
  16. #include "E:CLKGBL.H"        /* setup global storage */
  17.  
  18. #define  DBUGON   0         /* 0=debug off, 1=debug on    */
  19.  
  20. /**************************************************************
  21.  * BEGIN ROUTINE
  22.  **************************************************************/
  23.  
  24. CLKTIM()
  25. {
  26. static int doscall = SYSINTR;    /* system interrupt #                   */
  27.  
  28. if (DBUGON == 0)
  29.     {
  30.     /*---- setup "lasts" -----------*/
  31.     lasthr = thishr;
  32.     lt24hr = th24hr;
  33.     lastmn = thismn;
  34.     lastsc = thissc;
  35.  
  36.     while (lastsc == thissc)
  37.         {/*--- repeat continuously until time changes ---*/
  38.         /*--- get true system time ---*/
  39.         sreg.ax = GETTIME;
  40.         csysint (doscall, &sreg, &rreg);
  41.         thishr = rreg.cx / 256;
  42.         thismn = rreg.cx & 0X00FF;
  43.         thissc = rreg.dx / 256;
  44.         };
  45.  
  46.     /*--- convert to 12 hour clock ----*/
  47.     th24hr = thishr;
  48.     if (thishr > 12) thishr -= 12;
  49.  
  50.     }
  51. else
  52.     {/*--- debugging, fake system time ----*/ 
  53.     lasthr = thishr;
  54.     lastmn = thismn;
  55.     lastsc = thissc;
  56.     if (++thissc >= 60)
  57.     { thissc=0;
  58.       if (++thismn >= 60) 
  59.         {thismn=0;
  60.          if (++thishr >= 12) thishr=0;
  61.         };
  62.     };
  63.     };
  64. }                /***** end of routine ******/
  65.