experimental: add keyboard driver code from RETRO9 source tree
FossilOrigin-Name: 927feb4f3388f1a26bce75079f18a112b72d3379ab83155da8ae66a4a37c215d
This commit is contained in:
parent
a49e02ea3f
commit
0fe48073a5
1 changed files with 47 additions and 0 deletions
|
@ -49,6 +49,53 @@ getchar:
|
|||
|
||||
section .text
|
||||
|
||||
key:
|
||||
xor eax,eax ; clear eax
|
||||
.a: in al,64h ; Is any data waiting?
|
||||
test al,1 ; Is character = ASCII 0?
|
||||
jz .a ; Yes? Try again
|
||||
in al,60h ; Otherwise, read scancode
|
||||
xor edx,edx ; edx: 0=make, 1=break
|
||||
test al,80h ; Is character = HEX 80h?
|
||||
jz .b ; Skip the next line
|
||||
inc edx ; Update edx
|
||||
.b: and al,7Fh ; Filters to handle
|
||||
cmp al,39h ; the ignored keys
|
||||
ja .a ; We just try another key
|
||||
mov ecx,[board] ; Load the keymap
|
||||
mov al,[ecx+eax] ; Get the key ASCII char
|
||||
or al,al ; Is is = 0?
|
||||
js .shift ; No, use CAPITALS
|
||||
jz .a ; Ignore 0's
|
||||
or dl,dl ; Filter for break code
|
||||
jnz .a ; Ignore break code
|
||||
; dup
|
||||
; call sys_emit
|
||||
; ret
|
||||
jmp .done
|
||||
.shift: mov ecx,[edx*4 + .shifts] ; Load the CAPITAL keymap
|
||||
mov [board],ecx ; Store into BOARD pointer
|
||||
jmp .a ; And try again
|
||||
.done:
|
||||
ret
|
||||
|
||||
section .data
|
||||
.shifts dd shift,alpha
|
||||
board dd alpha
|
||||
alpha:
|
||||
db 0,27,"1234567890-=",8 ;00-0E
|
||||
db 9,"qwertyuiop[]",10 ;0F-1C
|
||||
db 0,"asdfghjkl;'`" ;1D-29
|
||||
db -1,"\zxcvbnm,./",-1,"*",0,32,-2 ;2A-3A
|
||||
shift:
|
||||
db 0,27,"!@#$%^&*()_+",8 ;00-0E
|
||||
db 9,"QWERTYUIOP{}",10 ;0F-1C
|
||||
db 0,'ASDFGHJKL:"~' ;1D-29
|
||||
db -1,"|ZXCVBNM<>?",-1,"*",0,32,-2 ;2A-3A
|
||||
|
||||
|
||||
section .text
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; This code is based on the video driver for FTS/Forth. Samuel
|
||||
; Falvo II has kindly granted permission for me to redistribute
|
||||
|
|
Loading…
Reference in a new issue