🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3606

Re: putting chars back to keyboard buffer...

#3606
From: David Porco
Date: Wed, 11 Nov 1992 22:56
60 lines
2776 bytes
In article <1992Nov10.204616.25750@slate.mines.colorado.edu> iarit@slate.mines.colorado.edu (ARIT ISMAIL) writes:


>Hi,

>I am writing  a small TSR that will put a string back
>to the keyboard buffer. I got some ideas how to use keyboard 'head'
>and 'tail' pointers, but still confused a bit. I understand what the
>'tail' is and how to use it, but 'head' is confusing..
>Does anybody have any 'C' function/idea how to put chars back to
>keyboard buffer without crashing/rebooting the system?
>Any idea/help is appreciated..
>Thanks.
>iarit@slate.mines.colorado.edu

This is kind-of a wierd thing (But aren't all computer concepts).  There 
are basically 4 pointers: Buffer_Start, Buffer_End, Buffer_Head & 
Buffer_Tail.

Buffer_Start is the start of the Keyboard buffer in memory, and Buffer_End
is the end of this buffer.  These are Far pointers at address 0x00400080
and 0x00400082 respectively.  

The Buffer_Head and Buffer_Tail form a sliding/wraparound window within 
this buffer. 

To make a simple illustration... Say an imaginary keyboard buffer started
at address 1 and ended at address 32 (16 ASCII bytes & 16 ScanCode bytes)
Our first window containing the string "HELLO" might look like this:

         00000000011111111112222222222333
Buffer : 12345678901234567890123456789012
         --------------------------------
Data   : H.E.L.L.O.                     (The dots represent the scan codes)
 
In this example Buffer_Head Address=1 and Buffer_Tail Address=11 (Buffer
Tail points to the next available address).

Now for the wierd part:  Lets say our Buffer_Head Address=29 and our
string was "HELLO".  The keyboard buffer would look like this:

         00000000011111111112222222222333
Buffer : 12345678901234567890123456789012
         --------------------------------
Data   : L.L.O.                      H.E.  

The Buffer_Head Address=29 and the Buffer_Tail Address=7.  When the 
keyboard buffer is parsed, the string will be "HELLO" because it is a 
sliding window/wraparound ring.

Whew...

Some info you ought to know:
You can only fit 16 chars in this buffer (16 ASCII codes + 16 Scan Codes),
unless you are up to relocating and expanding the keboard buffer in your
program (not recommended for the weak of heart).
.

Good luck.
.
Technical Details
Message-ID: <lb00197.11@Corlac>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!kronos.arc.nasa.gov!iscnvx!enterprise!news
References: <1992Nov10.204616.25750@slate.mines.colorado.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!kronos.arc.nasa.gov!iscnvx!enterprise!news
From: lb00197@Corlac (David Porco)
Subject: Re: putting chars back to keyboard buffer...
Message-ID: <lb00197.11@Corlac>
Sender: news@enterprise.rdd.lmsc.lockheed.com
Nntp-Posting-Host: 129.197.235.11
Organization: Lockheed
References: <1992Nov10.204616.25750@slate.mines.colorado.edu>
Date: Wed, 11 Nov 92 22:56:47 GMT
Lines: 60