我正在制作一个汇编程序,该程序根据所按下的键在屏幕上移动像素。
根据here,修改重复延迟的方法正在使用
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
这是完整的代码
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
除了键盘重复延迟使像素移动一次,然后停止250毫秒,然后重新开始连续移动而没有问题外,它工作正常。如何消除重复延迟?
此延迟(以及重复率)可以在BIOS选项中配置。如果要绕过它,则不应使用BIOS功能,而应直接访问keyboard controller。
使用您的代码
mov bh, 00h ;repeat delay: 250ms <-- this has to be 0
试图设置重复延迟的值,值0
表示250ms,这是可以在BIOS /通过BIOS中断设置的最小值。您可以在Ralph Brown's interrupt list上进行验证。