From: "Damian Yerrick" Newsgroups: comp.os.msdos.djgpp Subject: Re: How to empty the keyboard buffer Date: Fri, 8 Oct 1999 16:15:01 -0500 Organization: Rose-Hulman Institute of Technology Lines: 40 Message-ID: <7tln1u$6so$1@solomon.cs.rose-hulman.edu> References: NNTP-Posting-Host: 137.112.205.146 X-Trace: solomon.cs.rose-hulman.edu 939417470 7064 137.112.205.146 (8 Oct 1999 21:17:50 GMT) X-Complaints-To: news AT cs DOT rose-hulman DOT edu NNTP-Posting-Date: 8 Oct 1999 21:17:50 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: > That might be because of the rest(1000) call. How much time does it > wait? (I don't know much about ALlegro.) If it waits enough time, the > keyboard buffer could become full. void delay(int t); delay() is a function (in the standard C library IIRC) that programs the internal timer to wait t milliseconds. On the PC, that comes out to 1193n PC ticks. Back in the days before Allegro, when programming the Sound Blaster was too much of a pain in the *** to be attempted by anyone but professionals, many games used the PC speaker and used delay() to set the length of a note. In fact, the Borland C++ library reference actually listed sound() and delay() together. void rest(int t); rest() is the same as delay() except it uses Allegro's timer interface instead of programming your system's timer directly. rest(n) also waits t milliseconds. Which should I use? It depends on if you've called install_timer() or not. Under Windows, install_timer() reprograms the timer to generate an interrupt every five milliseconds, i.e., 200 Hz. This timer programming is incompatible with delay(), which expects the timer to still be programmed at 18.2 Hz. That's why Shawn and the gang added the rest() function. (No, i.e. does not stand for the web browser Infernal Exploder.) Damian Yerrick http://come.to/yerrick