On Fri, 11 Aug 2000, Lionel Pinkhard wrote:
> Thanks for the help! I seem to have one more problem with the time:
>
> My game expects the time to be returned in the system timer's format, how
> would I be able to convert tv.tv_usec to this format? The way the game is
> programmed, makes it VERY hard to rewrite the game's timing routines,
> without rewriting the entire game, but the game uses a procedure which
> returns the system timer, so just converting the number in this
> procedure would be the easiest. :-)
Yes. Ralf Brown says that INT 1Ah, AH=0 returns the number of clock ticks
as approx. 18.2 per sec or 1800B0h (1573040) per 24 hrs.
ticks = (tv.tv_usec + tv.tv_sec * 1000000) * 1573040 / (24*60*60*1000000);
This gives an integer overflow. To avoid, use doubles, "long long" or
simplify.
E.g. ticks = (tv.tv_usec/10000 + tv.tv_sec * 100) * 182 / 1000;
(but there are more accurate ways; it depends how many decimals of the
18.2... you need. I guess you don't need more for game playing).
Bart