Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
60 user(s) are online (48 user(s) are browsing Forums)

Members: 1
Guests: 59

tekmage, more...

Support us!

Headlines

Report message:*
 

How to allocate TimeRequest

Subject: How to allocate TimeRequest
by billyfish on 2020/5/17 18:05:32

Hi all

I'm trying to allocate a struct TimeRequest object and copying the code from the a2d.c example code from here, yet it fails to allocate the object using AllocSysObjectTags(). Is it something stupid that I'm doing??? I'm basically just after getting the ITimer interface so is there another way to do it?

cheers

billy

// a2d.c
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/datetime.h>
#include <devices/timer.h>

// Note these three libraries are opened by newlib startup code.
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>

#include <proto/timer.h>

struct TimerIFace *ITimer NULL;

int main()
{
    
struct TimeRequest *tr IExec->AllocSysObjectTags(ASOT_IOREQUEST,
    
ASOIOR_Sizesizeof(struct TimeRequest),
    
ASOIOR_ReplyPortNULL,
        
TAG_END);

  if (
tr != NULL)
  {
    if (!(
IExec->OpenDevice("timer.device"UNIT_VBLANK, (struct IORequest *)tr0) ))
    {
            
struct Library *TimerBase = (struct Library *) tr->Request.io_Device;
      
ITimer = (struct TimerIFace*)IExec->GetInterface(TimerBase"main"1NULL);

      if (
ITimer != NULL)
      {
        
struct TimeVal tv;
        
ITimer->GetSysTime(&tv);

        
IDOS->Printf("GetSysTime():t%d %dn"tv.Secondstv.Microseconds);

        
struct ClockData clockdata;
        
IUtility->Amiga2Date(tv.Seconds, &clockdata);

        
IDOS->Printf("Amiga2Date():  sec %d min %d hour %dn",
          
clockdata.secclockdata.minclockdata.hour);

        
IDOS->Printf("               mday %d month %d year %d wday %dn",
                    
clockdata.mdayclockdata.monthclockdata.yearclockdata.wday);

        
int32 seconds IUtility->CheckDate(&clockdata);

        
IDOS->Printf("CheckDate():t%ldn"seconds);

        
seconds IUtility->Date2Amiga(&clockdata);

        
IDOS->Printf("Date2Amiga():t%ldn"seconds);

                
IExec->DropInterface((struct Interface*)ITimer);
      }

      
IExec->CloseDevice((struct IORequest *)tr);
    }

        
IExec->FreeSysObject(ASOT_IOREQUESTtr);
    }
    else
    {
        
IDOS->Printf ("Failed to allocate TimeRequestn");
    }

  return 
RETURN_OK;
}


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project