home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Spanish Scene 4
/
SpanishScene4.iso
/
Programas
/
DavidBarbion_Ind
/
backclock_V232c.lha
/
BackClock
/
sources
/
timer.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-05
|
2KB
|
57 lines
/*****************************************************************************
*
* Nom: timer.c
* Desc: handle timer
*
*
* version : $VER: timer.c 1.11 (05.06.99)
*
*****************************************************************************
*/
#include <proto/exec.h>
#include <devices/timer.h>
#include <exec/io.h>
#include "utils.h"
#include "timer.h"
#include <clib/rtracker_protos.h>
#include <pragmas/rtracker_pragmas.h>
extern struct Library * RTrackerLibrary ;
int initTimer(idWin * prj) {
// retourne TRUE si initialisation ok
int ret = FALSE ;
prj->timerok = FALSE ; // ok (pour le refermer)
if ((prj->trport = NewCreateMsgPort()) != NULL) {
// creation port message ok
if ((prj->treq = (struct timerequest *)NewCreateIORequest(prj->trport, sizeof(struct timerequest))) != NULL) {
// creation ioreq ok
if (!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest*)prj->treq, 0)) {
// ouverture timer ok
ret = TRUE ;
prj->timerok = TRUE ;
}
}
}
return ret ;
}
void closeTimer(idWin * prj) {
if (prj->timerok)
CloseDevice((struct IORequest*)prj->treq) ;
if (prj->treq)
NewDeleteIORequest((struct IORequest*)prj->treq) ;
if (prj->trport)
NewDeleteMsgPort(prj->trport) ;
}
void runtimer(idWin * prj, long seconds) {
/* lance le timer
*/
if (prj->timerok) {
prj->treq->tr_time.tv_secs = seconds ;
prj->treq->tr_time.tv_micro = NULL ;
prj->treq->tr_node.io_Command = TR_ADDREQUEST ;
SendIO((struct IORequest *)prj->treq) ;
}
}