Search code examples
assemblyinputkeyboarddosx86-16

Is there a way to set keyboard repetition delay to zero in assembly?


I'm making an assembly program that move a pixel on the screen depending of the key pressed.

According to here the way to modify the repetition delay is using

mov ah, 03h 
mov al, 05h ;set typematic rate/delay
mov bh, 00h ;repeat delay: 250ms <-- this has to be 0
mov bl, 00h ;typematic rate: 30
int 16h

This is the entire code

cmp [keypress], 'a'
je left
cmp [keypress], 'A'
je left
cmp [keypress], 'd'
je right
cmp [keypress], 'D'
je right
jmp endMove
left:
    dec xpos
    jmp endMove
right:
    inc xpos
    jmp endMove
endMove:
call drawPixel
input:
mov keypress, 0
mov ah, 01h
int 16h
jnz animLoop
mov ah, 00h
int 16h
mov keypress, al
jmp animLoop

It works fine except for the keyboard repetition delay that makes the pixel moving once, then stops for 250 ms and then restart moving continuously without problems. How can i remove the repetition delay?


Solution

  • This delay (and also the repeat rate) can be configured in the BIOS options. If you want to bypass it, you shouldn't use BIOS functions but rather access the keyboard controller directly.

    In your code

    mov bh, 00h ;repeat delay: 250ms <-- this has to be 0
    

    trying to set the value for the repeat delay, the value 0 stands for 250ms, the minimum that can be set in the BIOS/via the BIOS interrupt. You can verify this on Ralph Brown's interrupt list.