Test function:
Code: Select all
Test:
.loop:
call GameKeys
cmp al, 0x1 ; esc pressed?
je .done ; yes, we're done
mov dx, ax
call PrintHex
call BR
jmp .loop
.done:
ret
Code: Select all
GameKeys:
mov ah, 1 ; non-blocking
int 0x16 ; read key
; ah = bios scancode
mov al, 0
cmp ah, 0x48 ; UP
je .up
cmp ah, 0x50 ; DOWN
je .down
cmp ah, 0x4B ; LEFT
je .left
cmp ah, 0x4D ; RIGHT
je .right
cmp ah, 0x1 ; ESC
je .escape
cmp ah, 0x39 ; SPACE
je .space
ret
.escape:
mov al, 0x1
ret
.space:
mov al, 0x2
ret
.up:
mov al, 0x3
ret
.down:
mov al, 0x4
ret
.left:
mov al, 0x5
ret
.right:
mov al, 0x6
ret