I'm writing a game for the IBM PC (running MS-DOS), complete with fancy cutscenes. Unfortunately, though, the keys pressed during those fancy cutscenes are carried out once the fancy cutscene has finished, leading to the player's inevitable death.
I solved this problem by clearing the BIOS's keyboard buffer just after the cutscene finishes, using this subroutine:
proc ClearKeyboardBuffer
ClearKeyboardBuffer_loop:
mov ah, 01h
int 16h ; is there a key pressed
jz ClearKeyboardBuffer_ret ; if not, return
mov ah, 00h
int 16h ; "handle" the key
jmp ClearKeyboardBuffer_loop
ClearKeyboardBuffer_ret:
ret
endp ClearKeyboardBuffer
It seems a bit brute-force, though, and takes up many precious bytes that could be better spent containing content. I expected there to be a BIOS call for this or something, but I couldn't find one.
Are there any better (faster and/or shorter) ways to stop the program from paying attention to keys pressed during the cutscene?