Support extended keyboards in console.asm

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@602 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-06-15 20:37:56 +00:00
parent faaff5006a
commit 5a5df81896
2 changed files with 71 additions and 20 deletions

View File

@ -15,6 +15,7 @@
config.sys parser. config.sys parser.
* distinguish between the builtin DOS version and the settable * distinguish between the builtin DOS version and the settable
DOS version. DOS version.
* console.asm now accepts extended scancodes (modified by Bart)
+ Changes Bart + Changes Bart
* flip some slashes in drivers/*.asm * flip some slashes in drivers/*.asm
(enables cross-assembly on Linux) (enables cross-assembly on Linux)

View File

@ -35,7 +35,7 @@ segment _IO_FIXED_DATA
global ConTable global ConTable
ConTable db 0Ah ConTable db 0Ah
dw _IOExit dw ConInit
dw _IOExit dw _IOExit
dw _IOExit dw _IOExit
dw _IOCommandError dw _IOCommandError
@ -47,13 +47,41 @@ ConTable db 0Ah
dw ConWrite dw ConWrite
dw _IOExit dw _IOExit
PRT_SCREEN equ 7200h CTL_PRT_SCREEN equ 7200h
CTL_P equ 10h CTL_P equ 10h
segment _LOWTEXT segment _LOWTEXT
uScanCode db 0 ; Scan code for con: device uScanCode db 0 ; Scan code for con: device
kbdType db 0 ; 00 for 84key, 10h for 102key
;
; (taken from nansi.sys)
;
global ConInit
ConInit:
; Jam special test code into keyboard buffer
mov ah,5
mov cx,0ffffh
int 16h
; Try to read special test code from keyboard buffer
mov cx, 10h
kbdLoop:
; Get keystroke using extended keyboard read
mov ah, 10h
int 16h
; Is it our special test code?
cmp ax, 0ffffh
; Yes; Set flag saying that the extended keyboard BIOS is supported
je kbdExtended
loop kbdLoop
jmp short kbdSimple
kbdExtended:
mov byte[cs:kbdType],10h
kbdSimple:
jmp _IOExit
; ;
; Name: ; Name:
; ConRead ; ConRead
@ -86,9 +114,10 @@ ConRead2:
; Read a character from the keyboard. ; Read a character from the keyboard.
; ;
; Description: ; Description:
; This subroutine reads a character fromthe keyboard. It also handles ; This subroutine reads a character from the keyboard. It also handles
; a couple of special functions. It converts the print screen key to ; a couple of special functions.
; a control-P. It also accounts for extended scan codes by saving off ; It converts ctrl-printscreen to a control-P.
; It also accounts for extended scan codes by saving off
; the high byte of the return and returning it if it was non-zero on ; the high byte of the return and returning it if it was non-zero on
; the previous read. ; the previous read.
; ;
@ -96,12 +125,15 @@ ConRead2:
KbdRdChar: KbdRdChar:
xor ax,ax ; Zero the scratch register xor ax,ax ; Zero the scratch register
xchg [cs:uScanCode],al ; and swap with scan code xchg [cs:uScanCode],al ; and swap with scan code
; now AL is set if previous key was extended,
; and previous is erased in any case
or al,al ; Test to see if it was set or al,al ; Test to see if it was set
jnz KbdRdRtn ; Exit if it was, returning it jnz KbdRdRtn ; Exit if it was, returning it
mov ah, [cs:kbdType]
int 16h ; get keybd char in al, ah=scan int 16h ; get keybd char in al, ah=scan
or ax,ax ; Zero ? or ax,ax ; Zero ?
jz KbdRdChar ; Loop if it is jz KbdRdChar ; Loop if it is
cmp ax,PRT_SCREEN ; Print screen? cmp ax,CTL_PRT_SCREEN ; Ctrl-Print screen?
jne KbdRd1 ; Nope, keep going jne KbdRd1 ; Nope, keep going
mov al,CTL_P ; Yep, make it ^P mov al,CTL_P ; Yep, make it ^P
KbdRd1: KbdRd1:
@ -114,26 +146,31 @@ KbdRdRtn:
global CommonNdRdExit global CommonNdRdExit
CommonNdRdExit: CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes
mov al,[cs:uScanCode] ; Test for last scan code mov al,[cs:uScanCode] ; Test for last scan code
; now AL is set if previous key was extended,
or al,al ; Was it zero ? or al,al ; Was it zero ?
jnz ConNdRd2 ; Jump if there's a char waiting jnz ConNdRd2 ; Jump if there's a char waiting
mov ah,1 mov ah,1
add ah,[cs:kbdType]
int 16h ; Get status, if zf=0 al=char int 16h ; Get status, if zf=0 al=char
jz ConNdRd4 ; Jump if no char available jz ConNdRd4 ; Jump if no char available
or ax,ax ; Zero ? or ax,ax ; Zero ?
jnz ConNdRd1 ; Jump if not zero jnz ConNdRd1 ; Jump if not zero
mov ah,[cs:kbdType]
int 16h ; get status, if zf=0 al=char int 16h ; get status, if zf=0 al=char
jmp short CommonNdRdExit jmp short CommonNdRdExit
; if char was there but 0, fetch and retry...
; (why do we check uScanCode here?)
ConNdRd1: ConNdRd1:
cmp ax,PRT_SCREEN ; Was print screen key pressed? cmp ax,CTL_PRT_SCREEN ; Was ctl+prntscrn key pressed?
jne ConNdRd2 ; Jump if not jne ConNdRd2 ; Jump if not
mov al,CTL_P mov al,CTL_P
ConNdRd2: ConNdRd2:
lds bx,[cs:_ReqPktPtr] ; Set the status lds bx,[cs:_ReqPktPtr] ; Set the status
mov [bx+0Dh],al mov [bx+0Dh],al ; return the ASCII of that key
ConNdRd3: ConNdRd3:
jmp _IOExit jmp _IOExit
@ -144,21 +181,28 @@ ConNdRd4:
global ConInpFlush global ConInpFlush
ConInpFlush: ConInpFlush: ; *** flush that keyboard queue
call KbdInpChar call KbdInpChar ; get all available keys
jmp _IOExit jmp _IOExit ; do not even remember the last one
KbdInpChar: KbdInpChar: ; *** get ??00 or the last waiting key after flushing the queue
mov byte [cs:uScanCode],0 xor ax,ax
mov byte [cs:uScanCode],al
KbdInpCh1: KbdInpCh1:
mov ah,1 mov ah,1
add ah,[cs:kbdType]
int 16h ; get status, if zf=0 al=char int 16h ; get status, if zf=0 al=char
jz KbdInpRtn ; Jump if zero jz KbdInpRtnZero ; Jump if zero
xor ah,ah ; Zero register ; returns 0 or the last key that was waiting in AL
mov ah,[cs:kbdType]
int 16h ; get keybd char in al, ah=scan int 16h ; get keybd char in al, ah=scan
jmp short KbdInpCh1 jmp short KbdInpCh1
; just read any key that is waiting, then check if
; more keys are waiting. if not, return AL of this
; key (which is its ASCII). AH (scan) discarded!
KbdInpRtnZero: mov ah,1 ; if anybody wants "1 if no key was waiting"!
KbdInpRtn: KbdInpRtn:
retn retn
@ -221,26 +265,32 @@ _int29_handler:
; ;
global ConInStat global ConInStat
ConInStat: ConInStat:
mov ah,0 ; just in case ...
mov al,[cs:uScanCode] ; Test for last scan code mov al,[cs:uScanCode] ; Test for last scan code
or al,al ; Was it zero ? or al,al ; Was it zero ?
jnz ConCharReady ; Jump if there's a char waiting jnz ConCharReady ; Jump if there's a char waiting
; return previously cached ext char if any
mov ah,1 mov ah,1
add ah,[cs:kbdType]
int 16h ; get status, if zf=0 al=char int 16h ; get status, if zf=0 al=char
jz ConNoChar ; Jump if zero jz ConNoChar ; Jump if zero
; if no key waiting, return AL=0 / "none waiting"
or ax,ax ; Zero ? or ax,ax ; Zero ?
jnz ConIS1 ; Jump if not zero jnz ConIS1 ; Jump if not zero
; if non-zero key waiting, take it
mov ah,[cs:kbdType]
int 16h ; get status, if zf=0 al=char int 16h ; get status, if zf=0 al=char
jmp short ConInStat jmp short ConInStat
; if zero key was waiting, fetch 2nd part etc. (???)
ConIS1: ConIS1:
cmp ax,PRT_SCREEN ; Was print screen key pressed? cmp ax,CTL_PRT_SCREEN ; Was ctl+prntscrn key pressed?
jne ConIS2 ; Jump if not jne ConIS2 ; Jump if not
mov al,CTL_P mov al,CTL_P
ConIS2: ConIS2:
lds bx,[cs:_ReqPktPtr] ; Set the status lds bx,[cs:_ReqPktPtr] ; Set the status
mov [bx+0Dh],al mov [bx+0Dh],al ; return the ASCII of the key
ConCharReady: ConCharReady:
jmp _IOExit ; key ready (busy=0) jmp _IOExit ; key ready (busy=0)
ConNoChar: ConNoChar: