From: michael DOT mauch AT gmx DOT de (Michael Mauch) Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro and timer routines Date: Thu, 23 Oct 1997 19:22:17 +0200 Organization: Gerhard-Mercator-Universitaet -GH- Duisburg Lines: 42 Message-ID: <34516509.19929574@news.uni-duisburg.de> References: <62mosa$nb5$1 AT postern DOT mbnet DOT mb DOT ca> NNTP-Posting-Host: ppp102.uni-duisburg.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Thu, 23 Oct 1997 06:10:27 GMT, bigphil AT merlin DOT magic DOT mb DOT ca (Mark Phillips) wrote: > What allegro routine do I use to make the computer pause for less than > one millisecond? rest() is the only function i know and its lowest > denomination is one millisecond. please help me out. The libc function uclock() has a resolution of approx. 980 nanoseconds, you can use it for a usleep()-like function (see below). IIRC you may not use allegro timers together with uclock(), because the allegro timers change the timer chip mode just like uclock() does. If your program is going to be run under Windows/Win95, search the DJGPP mail archives for (one of the oldest occurrences of) "puclock()", because uclock() can't work there. usleep() does not provide 1 ms delay, because it is based on clock() which in turn has a resolution of 55 ms. You can use a homebrew version of usleep(), e.g.: #include #include "puclock.h" unsigned int pusleep(unsigned int _useconds) { uclock_t stop_time = puclock() + _useconds * (uclock_t)UCLOCKS_PER_SEC / 1e6; while (puclock() < stop_time) { __dpmi_yield(); } return 0; } If you don't need it to run in Windows/Win95, you can change puclock() into uclock() and #include instead of "puclock.h". (Hmm, also the __dpmi_yield() doesn't make much sense if you don't use any kind of multi-tasker, so you can just leave it off, IMHO.) Regards... Michael