home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 1986 by Manx Software Systems */
-
- #include <exec/types.h>
- #include <exec/lists.h>
- #include <devices/timer.h>
-
- extern struct MsgPort *CreatePort();
-
- static struct timerequest t, ut;
- static initted_time = 0;
-
- init_time()
- {
- if (OpenDevice(TIMERNAME, (long)UNIT_VBLANK, &t, 0L)) {
- return(0);
- }
- initted_time++;
- if (OpenDevice(TIMERNAME, (long)UNIT_MICROHZ, &ut, 0L)) {
- return(0);
- }
- initted_time++;
- if ((t.tr_node.io_Message.mn_ReplyPort = CreatePort(0L, 0L)) == NULL)
- {
- return(0);
- }
- initted_time++;
- if ((ut.tr_node.io_Message.mn_ReplyPort = CreatePort(0L, 0L)) == NULL)
- {
- return(0);
- }
- initted_time++;
- return(1);
- }
-
- uninit_time()
- {
- switch (initted_time)
- {
- case 4:
- DeletePort(ut.tr_node.io_Message.mn_ReplyPort);
- case 3:
- CloseDevice(&ut);
- case 2:
- DeletePort(t.tr_node.io_Message.mn_ReplyPort);
- case 1:
- CloseDevice(&t);
- case 0:
- break;
- }
- initted_time = 0;
- }
-
- wait_milli()
- {
- ut.tr_node.io_Command = TR_ADDREQUEST;
- ut.tr_time.tv_secs = 0;
- ut.tr_time.tv_micro = 1500;
- DoIO(&ut);
- }
-
-
- long
- get60hz()
- {
- unsigned long hz;
-
- t.tr_node.io_Command = TR_GETSYSTIME;
- DoIO(&t);
- hz = t.tr_time.tv_secs*60 +
- (t.tr_time.tv_micro + (1000000/60)/2) / (1000000/60);
- return(hz);
- }
-
-
-