Author: Ed Schröder
Date: 22:20:03 10/07/99
Go up one level in this thread
On October 07, 1999 at 23:17:55, Christophe Theron wrote: >On October 07, 1999 at 22:08:38, Ratko V Tomic wrote: > >>> I have discovered on my K5 computer that calling the keyboard input >>> too often slows down the program considerably. Even in pure DOS >>> (the Windows scheduling algorithm has nothing to do with the problem). >> >>In DOS and Windows all kinds of code (BIOS, DOS, network drivers, schedulers, >>screen blankers and other TSRs) attach to the interrupt 0x16 (kbd interrupt), >>which makes the overhead erratic. The quickest way to check kbd for DOS >>programs, bypassing any such overhead in plain DOS or in DOS Box under >>Windows, is to check the keyboard buffer pointers, i.e. in C you can >>declare a pointer: >> >> short far *kbd=0x41a; >> >>Then you can test for key present using a macro: >> >> #define anykey() (kbd[0]!=kbd[1]) >> >>which evaluates true if (and only if) there is a key in the buffer. Even >>the 16-bit Windows programs can use this via predefined selectors which >>cover BIOS data area (imported value representing BIOS data selector >>is named __0040H). The overhead is minimal and predictable. > > >Yes, I know. But the problem is that I want to write portable code. Tiger is >completely written in C and I don't want to rely on knowledge about the system, >unless it is absolutely necessary. > >In this case, polling the keyboard with the standard kbhit() function, if done >with a long enough time interval, is harmless. So I favour this solution. > > > Christophe I heard that kbhit() is a killer running NT. True? Ed
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.