Marcel Vander Mierde
Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Reading function/cursor keys
"Osmo Ronkanen" <ronka...@cc.helsinki.fi> schreef in bericht news:8i0uu8$j96$1@kruuna.Helsinki.FI... Quote> In article <NTR05.171440$Qp2.442...@afrodite.telenet-ops.be>, > Marcel Vander Mierde <Marcel.Vander.Mie...@pandora.nospam.be> wrote: > >This is my point of view - so if I'm wrong, please correct me. > >Apparently, every key or keycombination fills the keyboardbuffer with > >two bytes (a word?), probably to fill up the 16 bits. When pressing a > >special key or keycombination the second byte will get the (hex)value > >00. This is what I can deduct from reading all those 'special key' > >codes. > >If the compiler reads the buffer he will first read the second byte. > >when a 00 is met, he 'knows' another byte is{*word*154} around and will > >not clear the buffer until asked to do so, > >however when the second byte does not equal 00, a 'normal' key is > >pressed and the buffer will be cleared automatically (?). > >As I stated before, this is my humble opinion, so if anyone knows more > >about this: > >I'm always willing to learn. > >Hope this helped a Bit, > I do not know what you are talking about. The internal representation > of the keyboard buffer is not relevant. What Readkey does is it uses Int > 16h, ah=0 to read a scancode, ASCII code pair. It returns the ASCII > code. If the ASCII code is zero, then it stores the scan code into an > internal buffer. The next time it is called it checks the buffer if > there is scancode available and if there is it is returned instead. > Here are Pascal versions of readkey and keypressed: > const scancode:char=#0; > function readkey:char; > var rg:registers; > begin > if scancode>#0 then begin > readkey:=scancode; > scancode:=#0; > exit; > End; > rg.ah:=0; > intr($16,rg); > readkey:=chr(rg.al); > if rg.al=0 then scancode:=chr(rg.ah); > End; > function keypressed:boolean; > var rg:registers; > begin > if scancode>#0 then keypressed:=true > else begin > rg.ah:=1; > intr($16,rg); > keypressed:=rg.flags and fzero=0; > End; > End; > Note that the buffer where the scancode is store is internal to CRT, it > has nothing to do with the BIOS keyboard buffer. > Osmo
Osmo, thanks for clarifying things up for me, I saved your answer to my harddisk (as I do with many others), so I can learn from it. As I said in my posting, my "guess" was a deduction from the things I knew and saw. Still, I'm stuck with the same question as Frederic, what is the meaning of this high byte for a "normal" key, or isn't there a meaning at all? Marcel -- Please remove the *.NoSpam* entry from my eMail address when replying. It's meant to keep Spam and Advertising out, not friends. Please test my new web pages http://users.pandora.be/marcel.van.der.mierde/ still under heavy construction
|