home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 290.dms / in.adf / quickrif.source / clock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-31  |  1.2 KB  |  75 lines

  1. /* Copyright (C) 1986 by Manx Software Systems */
  2.  
  3. #include    <exec/types.h>
  4. #include    <exec/lists.h>
  5. #include    <devices/timer.h>
  6.  
  7. extern struct MsgPort *CreatePort();
  8.  
  9. static struct timerequest t, ut;
  10. static initted_time = 0;
  11.  
  12. init_time()
  13. {
  14. if (OpenDevice(TIMERNAME, (long)UNIT_VBLANK, &t, 0L)) {
  15.     return(0);
  16. }
  17. initted_time++;
  18. if (OpenDevice(TIMERNAME, (long)UNIT_MICROHZ, &ut, 0L)) {
  19.     return(0);
  20. }
  21. initted_time++;
  22. if ((t.tr_node.io_Message.mn_ReplyPort = CreatePort(0L, 0L)) == NULL)
  23.     {
  24.     return(0);
  25.     }
  26. initted_time++;
  27. if ((ut.tr_node.io_Message.mn_ReplyPort = CreatePort(0L, 0L)) == NULL)
  28.     {
  29.     return(0);
  30.     }
  31. initted_time++;
  32. return(1);
  33. }
  34.  
  35. uninit_time()
  36. {
  37. switch (initted_time)
  38.     {
  39.     case 4:
  40.         DeletePort(ut.tr_node.io_Message.mn_ReplyPort);
  41.     case 3:
  42.         CloseDevice(&ut);
  43.     case 2:
  44.         DeletePort(t.tr_node.io_Message.mn_ReplyPort);
  45.     case 1:
  46.         CloseDevice(&t);
  47.     case 0:
  48.         break;
  49.     }
  50. initted_time = 0;
  51. }
  52.  
  53. wait_milli()
  54. {
  55. ut.tr_node.io_Command = TR_ADDREQUEST;
  56. ut.tr_time.tv_secs = 0;
  57. ut.tr_time.tv_micro = 1500;
  58. DoIO(&ut);
  59. }
  60.  
  61.  
  62. long
  63. get60hz()
  64. {
  65.     unsigned long hz;
  66.  
  67.     t.tr_node.io_Command = TR_GETSYSTIME;
  68.     DoIO(&t);
  69.     hz = t.tr_time.tv_secs*60 + 
  70.         (t.tr_time.tv_micro + (1000000/60)/2) / (1000000/60);
  71.     return(hz);
  72. }
  73.  
  74.  
  75.