Welcome, Guest. Please login or register.

Author Topic: how to use timer.device's EClock unit's higher LONG  (Read 2580 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
how to use timer.device's EClock unit's higher LONG
« on: May 10, 2005, 05:31:08 PM »
Hey. Does anyone knows how to use the EClockVal structure's (which is returned by ReadEClock()) ev_hi element ? The RKM Devices has an example but doesn't use the full 64 bit value (only uses ev_lo).
The goal is to calculate elapsed time whith good precision. And by the way, I suppose 64bits correspond to a way big amount of time, why use that instead of the VBlank unit for big intervals, since the RKM states that the VBlank unit can have higher precision then MicroHz or Eclock for big time intervals.

[EDIT] I meant the higher long not the higher byte.
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« Reply #1 on: May 10, 2005, 06:56:47 PM »
lol! yes... but if I subtract two ev_hi's and divide the result by the tics per second to obtain the fracctions of a second that passed between both readings do I have to multiply the result by a FFFF ? I'm just confused, first time I mess with doubles that.

[EDIT]
So maybe I just declare a double variable and assign it the result of each reading and the compiler will do the rest ?


[EDIT] I meant the higher long not the higher byte.
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« Reply #2 on: May 10, 2005, 07:27:55 PM »
@Trev

Ahh, thanks.. just what I was needing. I was actually confused thinking that the returned 64bit value would be a double or something (I know a double is still probably needed to get the result of the division...). I'll now of course read it...
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« Reply #3 on: May 12, 2005, 07:10:25 PM »
I was gonna make a routine in assembler to do it, started checking the VBCC docs to see how to interface to asm (how can you access a variable that's in your C code from assembler when using inline assebler, anyone ?) and stumbled across the long long type, apparently only supported by more recent C standarts (ISO99 or something, what's the difference anyway is ISO incompatible with ANSI ?)...

So it goes like this: just use some casting to assign the EClockVal *ptr function argument to a long long, repeat the same when doing the second reading (to a different variable of course), use C's ordinary substraction to substract the 2nd reading from the 1st one and divide the obtained value by the returned ticks per seoncd, and finally cast the result to a double to obtain the fraccions of a second that passed (wich I don't think the RKM should refer as fracctions since from what I understand can be much more than a second..).

Will that work as easy as it seems ? :-)
\\"We made Amiga, they {bleep}ed it up\\"