From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: exact timing and allegro timers Date: Tue, 8 Jul 1997 21:07:37 +0100 Organization: None Distribution: world Message-ID: References: <199707041814 DOT LAA21998 AT adit DOT ap DOT net> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 42 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Nate Eldredge writes: >You wrote >>So I did timer (using allegro) at 100hz and measuerd intervals to 1/100 sec >>but increasing timer 400Hz efectivly degrades speed of computer. >>So this way us unusable anymore. > >Sorry, I think that's the facts of life. If your timer routine is going to >go that often, it *is* going to eat up significant CPU time. Only thing I >can think of is to make your timer handling routine more efficient. Or find some other way of measuring the time. The Allegro routines were designed for generating interrupts (to run multiple tasks in the background), not for measuring elapsed time, and they aren't really appropriate for the latter. I can think of a few possibilities: - Find some other source of timing information. I believe the Pentium chip has a clock register, but I've never used it and have no idea if it would be useful for this. - Change the Allegro timer module to use the RTC instead of the PIT, so that uclock() would still work. This would drastically reduce the precision of the Allegro timers, so it would probably be best done as a special mode, like the current Windows-friendly fixed interval version of the code. Again, I've never used the RTC so I don't know how practical this would be, but in theory it ought to work. - Write a uclock() type function that integrates with the current Allegro timer code. The current uclock() reads the BIOS tick counter to get an 18.2th of a second resolution, and then reads elapsed time from the PIT to fill in the low bits of the result. It would be possible to do something similar with the Allegro timer, if you modified the interrupt handler to maintain a tick counter similar to the BIOS one, and made the polling function smart enough to handle variable lenghts between each interrupt. The trouble is that it doesn't seem to be possible to read the PIT counter under Win95, so this method wouldn't work properly in a DOS box. My feeling is that if something won't run reliably on every platform, it isn't worth bothering with... -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ Beauty is a French phonetic corruption of a short cloth neck ornament.