Article View: comp.sys.ibm.pc.misc
Article #9142Re: Problem trying to write fast keyb reading
From: Adam Goldberg
Date: Thu, 11 Apr 1991 19:44
Date: Thu, 11 Apr 1991 19:44
40 lines
2367 bytes
2367 bytes
mgvalen@cs.vu.nl (Valent MG) writes: >To everybody. >I have a question or 3 (surprise !). >I'm trying to write a (fast) game in Turbo C on an AT, so I want >the keyboard-reading to happen as fast as possible. The fastest way >is, I think, using inportb(0x60). The problem now is, that the >keyboard-buffer fills up, and because I'm not emptying it, I get the >buffer-full interrupt & bell. >I could solve this by using getch() after each key-hit, but that >slows down the (fast) reading quite a lot. >So my questions are: > - is there a way to turn that buffering off (and in this way > , also the checking if the buffer is full)? > (In this case, I'll probably miss a few key-hits, > but that doesn't matter.) Sure you could turn it off...redirect the keyboard interrupt vector to point to just an IRET -- but (below) > - or some simpel way to check how full the buffer is, and > when necessary, emptying the buffer by clearing some bit > (and perhaps give an acknowledgement) ? > - am I totally wrong and should I do the keyboard-reading > completely different (and what is that better solution) ? The problem with reading the keyboard via an inportb() function is that you're reading the scan code, not the ASCII code. Further, if you really want fast, you could look into intercepting the keyboard interrupt yourself and calling the BIOS interrupt routine yourself, then dealing with the key when you return...or you could xlate the scan code yourself...ugh -- +-----------------------------------------------------------------------------+ ! Adam Goldberg ! "It's simple! Even a PASCAL ! ! cs352a41@cs.iastate.edu <= this one ! programmer could do it!" ! +-----------------------------------------------------------------------------+
Technical Details
Message-ID:
<cs352a41.671399089@zippy>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.iastate.edu!cs352a41References:
<9633@star.cs.vu.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.iastate.edu!cs352a41 From: cs352a41@cs.iastate.edu (Adam Goldberg) Newsgroups: comp.sys.ibm.pc.misc Subject: Re: Problem trying to write fast keyb reading Keywords: fast keyboard reading Message-ID: <cs352a41.671399089@zippy> Date: 11 Apr 91 19:44:49 GMT References: <9633@star.cs.vu.nl> Sender: news@news.iastate.edu (USENET News System) Organization: Iowa State University, Ames IA Lines: 41