Mail Archives: djgpp/1997/04/20/10:06:16
On 17 Apr 1997, Flynn wrote:
> I've some problems clearing the key buffer ring. In watcom I used:
>
>
> static short * const KeyBufferFirst=(short * const)0x41a;
> static short * const KeyBufferLast=(short * const)0x41c;
>
> *KeyBufferFirst=*KeyBufferLast;
>
> but in DJGPP it doesn't work....
Others already have told you why it doesn't work. But I would like to
point out that this is just plain wrong: this code will break even in
Watcom on systems where keyboard enhancer is installed. Many keyboard
enhancers replace the brain-damaged 15-character BIOS keyboard buffer
with a larger one, which is of course at different address in memory.
Your code will fail miserably in such cases.
I suggest to do it the usual way:
#include <conio.h>
while (kbhit ())
getch ();
This clears the keyboard buffer, no matter what TSR has taken over
Int 16h. It might be slower, but how many times per second do you
need to clear the keyboard buffer, anyway?
- Raw text -