Author: Christophe Theron
Date: 01:14:40 10/08/99
Go up one level in this thread
On October 08, 1999 at 03:48:59, Dave Gomboc wrote:
>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
>
>If you want to write portable code, you'd better stay away from kbhit()!! What
>the heck is that? Some non-portable relic, that is for sure.
>
>Check out "cin.peek()" if you're using C++. I don't use straight C anymore, so
>ask a C hacker if you're using straight C.
>
>Dave
I use kbhit() in the text mode interface, which is only a developpement tool
used (currently) under DOS and Windows.
On another system I would just add a #if to call another function. I don't care
if that piece of code (text mode interface) is not smoothly portable.
The engine uses a callback function to call the interface (text or graphical),
and the interface checks for user input. Then returns the appropriate
information to the engine. So the core of the portable engine is free from that
"check user input" problem (or "write search results" problem).
It may have other portability problems, I will see as they happen.
Christophe
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.