amead@s.psych.uiuc.edu (alan mead) (11/11/90)
If I understand the original post (how does the BIOS kbd buffer work?) correctly, it is not a difficult subject (but neither am I an expert on the buffer let-alone all of BIOS). I posted a way to poke characters into the keyboard buffer. I will repost if there is interest (it solved the problem of not haveing a "chain" function in TP like there is in GWBASIC). My info comes from Yester's _Using Turbo Pascal_ and _Turbo Pascal Advanced Techniques_ by Ohlsen & Stoker. The BIOS (I guess) uses a 32 byte circular buffer (a queue) for KBD input. An ASCII and a "scan code" value are placed into the buffer for each keystroke (ie for each depression--no info is available here about releaseing keys). Thus each keystroke is a word, not a byte. Since the buffer is circular and thus LILO (~FIFO) instead of LIFO, there is no starting and ending place. There are instead a head and a tail. The head lives at $0040:$001A and the tail at $0040:$001C (the queue starts at $0040:001E--right?). As I understand it, one word is always wasted in this manner: When the head and the tail have the same value, the buffer is empty(thus the tail points to the next available word of the buffer). When the 15th word (keystroke) has been entered, the tail points to the word directly before the one that the head points to. Thus the buffer cannot be lengthened (if this happened, the tail would coincide with the head again and BIOS would think that the buffer was empty). So my questions are 1) what is the mechanism that reads the buffer and moves the head (I wonder about this when I see utilities that increase the size of the buffer and 2) I believe I can enter 16 keystrokes before the computer "beeps" at me--why? It is ironic that this post appears now, since I am codeing a similar system for (text mode) mouse input so that I have been giving the matter some thought. I posted some mouse routines a short time ago, and I have been thinking about how they might be improved. Have they been of any use? Has anyone suggestions? Thanks. Hope this helps, -alan mead : mead@uxh.cso.uiuc.edu
zhou@brazil.psych.purdue.edu (Albert Zhou) (11/11/90)
It is possible to extend the keyboard buffer. I found $40:$80 contains the beginning address of the keyboard buffer (the default is $40:$1E, of course), and $40:$81 the end. However, you have to know which area in the segment of $40 is unused so that you can set a new keyboard buffer to there. After my original posting, I have tried to send a 10-character string to the buffer at $40:$1E, and at the same time set $40:$1A to be $40:$1E (the buffer head) and set $40:$1B to be $40:$32 (that's $1E+20 because 10 characters take 20 bytes). I haven't got desired result. The 10-character string was output on the screen, but followed by dozens of strange characters (probably some ^G since it kept beeping). What's the problem?