Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clearing the keyboard buffer

Status
Not open for further replies.

kismetlafiete

Programmer
Oct 13, 2004
8
US
My classmate and I are working on a pong game for our final project in our assembly class this semster... it's completely finished, the one problem we have is getting the input. We use the 16h interrupt (ah = 0) to see if a key was pressed in order to move a paddle. The problem comes after that... we tried to call 16h (ah = 1) after checking and hoped it would just clear it for us since a key was pressed already, but it waits for the key to be pressed again(although it does clear it).
If we remove the call to 16h (ah = 1), it never stops reading that the key was pressed. So we basically need a way to do the following:

1) was a keypressed?
2) decide which one it was
3) take the appropriate action
4) clear the key state(without pausing the program) to avoid looping.

we can do it all except for #4, so any help?
 
If there is an edit button here I couldn't find it. Anyway, I wrote the values for ah above incorrectly... when ah = 1, the bios will not wait; when it is 0, it will wait for a key to be pressed.
 
21h DOS function 0Ch can be used to flush the keyboard buffer -so I read anyway....

Code:
mov ah,0c
mov al,0
int 21h

Regards


Jakob
 
I couldnt get it to work with ah=0ch, but it did point me in the right direction to find that

mov ah,08h
int 21h

works like a charm. Thanks for your help!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top