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

  1. /* CLOCK... a program to set the hardware clock on the AST
  2.      Six Pack Card at address's 2c0 thru 2cA.  
  3.           by Ben R. Wert 01-84 */
  4.  
  5. #include "stdio.h"
  6.  
  7. int num,a,innum,outnum;
  8. int sec,minutes,hour,mday,month,wday,year,nibble,last;
  9. int  ch;
  10.  
  11. gettime()  
  12. {
  13.      month     = inp(0x2c7);
  14.      mday      = inp(0x2c6);
  15.      wday      = inp(0x2c5);
  16.      hour      = inp(0x2c4);
  17.      minutes   = inp(0x2c3);
  18.      sec       = inp(0x2c2);
  19.      year      = inp(0x2ca);
  20.      nibble    = inp(0x2c8);
  21.      last      = inp(0x2c9);
  22. }
  23.  
  24. showtime()
  25. {
  26.      printf("\nYear\tMonth\tDate\tDay\tHour\tMinutes\tSeconds\n");
  27.  
  28.      printf("%x \t %x \t %x \t %x \t %x \t %x \t %x\n", year,month,mday,
  29.           wday,hour,minutes,sec);
  30.  
  31. }
  32.  
  33. main()
  34. {
  35.     scr_clr();
  36.  
  37.      gettime();
  38.  
  39.      showtime();
  40.  
  41.      printf("\nDo you wish to change the settings?...y/n  ");
  42.      ch = toupper(getchar());
  43.  
  44.      if (ch == 'Y') 
  45.      {
  46.           putchar('\n');
  47.           printf("Enter last digit of year ");
  48.                scanf("%x",&year);
  49.           printf("\nEnter current month ");
  50.                scanf("%x",&month);
  51.           printf("\nEnter current day ");
  52.                scanf("%x",&mday);
  53.           printf("\nEnter the # of weekday ");
  54.                scanf("%x",&wday);
  55.           printf("\nEnter current hour ");
  56.                scanf("%x",&hour);
  57.           printf("\nEnter current minutes ");
  58.                scanf("%x",&minutes);
  59.           printf("\nEnter current seconds ");
  60.                scanf("%x",&sec);
  61.         
  62.       outp(0x2ca,year);
  63.           outp(0x2c7,month);
  64.           outp(0x2c6,mday);
  65.           outp(0x2c5,wday);
  66.           outp(0x2c4,hour);
  67.           outp(0x2c3,minutes);
  68.           outp(0x2c2,sec);
  69.      }
  70.  
  71.      putchar('\n');
  72.      putchar('\n');
  73.      gettime();
  74.      showtime();
  75.      exit();
  76. }
  77.