Does anyone know of any tutorials on how to make a keyboard handler for a game in assembly? All it has to do is set the appropriate byte in a 256 byte array to 1 when its pressed and 0 when its not pressed.
Printable View
Does anyone know of any tutorials on how to make a keyboard handler for a game in assembly? All it has to do is set the appropriate byte in a 256 byte array to 1 when its pressed and 0 when its not pressed.
Ok, i found a tutorial on how to write a handler in c, so i tried to follow it and do it in asm. I got a problem though. When i press a key, it sets the appropriate byte in the array to 1, but when i let go, it doesnt set it back to 0. Heres the code...
_keys is of course the 128 byte array. Anything would be helpful.Code:new9 proc
in al, 60h
mov bl, al
xor bh, bh
mov al, 20h
out 20h, al
mov al, bl
and al, 80h
jz short keyoff
sub bl, 80h
mov _keys[bx], 1h
jmp short endkey
keyoff: mov _keys[bx], 0h
endkey: iret
new9 endp
I think you have "and al,80" when you mean "test al,80" - you are deleting the keycode