home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 142_01 / clock.c < prev    next >
Text File  |  1985-03-10  |  2KB  |  55 lines

  1. /*
  2.             clock.c    
  3.     FDC - I Clock for Monitor version 4.0c
  4.         Alan Coates, 1 Oct 1984
  5.         Hi Tech C Compiler
  6.  
  7.     FDC-I stores a real time clock, which is not battery backed up,
  8.     at a location SEC which can be located from the monitor using 
  9.     the monitor routine RTSEC.  The location of RTSEC varies with the 
  10.     version of the monitor. Version 4.0c has a base page of F8, and 
  11.     locates RTSEC at F839H.  This in turn gives SEC at F7A9H.  Rather
  12.     than look this all up each time the program is run, I define it
  13.     as SECADR below.  If a different monitor version is used, you can
  14.     get the address of SEC using DDT to examine the location jumped
  15.     to by the instruction at BP39.
  16.  
  17.  */
  18. #include <stdio.h>    /* "libc.h" if using Aztec compiler    */
  19.  
  20. /* Hazeltine screen control codes - octal values! CLS merely clears the screen
  21.    using the (switch selectable) lead-in tilde plus FS, while CURPOS places 
  22.    the cursor at x,y - the last two digits after lead-in, DC1.  The location 
  23.    should not be in the display area of the clock, since the cursor spends
  24.    most of each second here. Hence the \t in the printf format.
  25. */
  26.  
  27. #define CLS    "\176\034"
  28. #define CURPOS    "\176\021\025\027"    
  29.  
  30. #define SECADR  0xF7A9        /* Address given by RTSEC in FDC Monitor */
  31.  
  32. static char *month[] =    { "  ", "Jan", "Feb", "March", "April", "May", "June",
  33.                 "July", "Aug", "Sept", "Oct", "Nov", "Dec"};
  34.  
  35.  
  36. main()
  37.     {
  38.     char lastsec, *sec, *min, *hr, *day, *mno,  *yr;
  39.  
  40.     sec = (char *)SECADR;    /* cast to avoid HiTech warning message! */
  41.     min = sec + 1;        /* other locations as in FDC-I manual    */
  42.     hr  = sec + 2;
  43.     yr  = sec + 3;
  44.     day = sec + 4;
  45.     mno = sec + 5;
  46.     printf("%s %s", CLS, CURPOS);    /* or wherever you use the clock */
  47.     for (;;)            /* break out with ^C    */
  48.         {
  49.         if (lastsec != *sec)    /* dont update unless secon changed */
  50.         printf("\t%2d  %s  %04d\t %02d:%02d:%02d %s", *day, 
  51.         month[*mno], 1900 + *yr, *hr, *min, lastsec=*sec, CURPOS);
  52.     }
  53.     exit(0);            
  54. }
  55.