Author: Robert Hyatt
Date: 19:26:52 10/07/99
Go up one level in this thread
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. That might not be exactly what a chess program wants. IE most of us read in a whole move (line including 0x0a) at one time. The above would mean you have to read in char by char, handle backspaces, and so forth, inside the program, and be sure to wait until the 0x0a is read signifying the <return> key way hit. Best solution is to dump dos. :) it is unsafe anyway, since there is no memory protection and those TSR's are not always well-behaved...
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.