Welcome, Guest. Please login or register.

Author Topic: Using timer.device in C (VBCC)  (Read 4240 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline NovaCoder

Re: Using timer.device in C (VBCC)
« on: June 29, 2011, 01:02:16 AM »
Hiya,

My startup code was actually listed in the original EAB thread, you could have just copied that?

Code: [Select]

void startup() {
    // Create the timer.
    timerRequest = CreateTimer(UNIT_ECLOCK);
}
 
struct timerequest *CreateTimer(ULONG theUnit)
{
    ULONG Error;
    struct timerequest *TimeReq;
    if (!(TimerPort=CreatePort(NULL,0))) {
        return NULL;
    }

    if (!(TimeReq = (struct timerequest*)(CreateExtIO(TimerPort,sizeof(struct timerequest)))))
    {
        DeletePort(TimerPort);
        return NULL;
    }

    Error = OpenDevice(TIMERNAME, theUnit, (struct IORequest*)(TimeReq), 0);
    if (Error!=0)
    {
        DeleteExtIO((struct IORequest*)(TimeReq));
        DeletePort(TimerPort);
        return NULL;
    }
    TimerBase=(struct Library*)(TimeReq->tr_node.io_Device);

    return(TimeReq);
}


I used the following declarations:

Code: [Select]

#include

    // Amiga Timer.
    struct Device *TimerBase;
    struct timerequest *timerRequest;
    struct timeval startTime;
    ULONG  timerUnit;


Seems to work ok for me using the 3.9 NDK :)
Life begins at 100 MIPS!


Nice Ports on AmiNet!