flat assembler
Message board for the users of flat assembler.

Index > DOS > keyboard handling

Author
Thread Post new topic Reply to topic
phunk



Joined: 27 Feb 2005
Posts: 2
phunk
i'm having a little bit of trouble getting keyboard handling to work, but here's what i have so far:

Code:
        org     0x100
        use16

getkp:  in      al,     0x60
        or      al,     0x82
        out     0x61,   al
        and     al,     0x7F
        out     0x61,   al
        mov     dl,     al
        shr     al,     3
        cmp     al,     0x01
        jz      gotkp
        jmp     getkp

gotkp:  mov     ah,     0x02
        int     0x21
        jmp     getkp
    


most of the stuff i saw from example code, so i'm not sure of exactly what it does. all i know is that for some reason it isn't working. can anyone give me some insight?
Post 01 Mar 2005, 19:33
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
hello,
i have made functions that use keyboard directly,
your code is not clear for me Smile
i have attached a keyboard information doc too, from ports.list

Code:
org $100
;cli
mainloop:
call clearkey

call readkeyboard

push ax
mov bl,1
mov bh,1
mov ch,15
mov dx,ax
call writehexnibbles80x25z
pop ax

cmp al,1
jne mainloop
;sti
int 20h

readkeyboardrealtime:
.wait: in al,$64
       bt ax,0
jnc .wait
in al,$60
ret

readkeyboard:
in al,$60
ret

waitkeyboardchange: ; does not wait busy, (windows and other) uses al,bl
in al,$60; because buffer ready bit is cleared after reading
mov bl,al
.wait2:
in al,$60
cmp al,bl
jz .wait2
ret

clearkey:   ;Clears keystroke buffer directly ( $0040:$001A := $0040:$001C )
push ds
push es
 mov ax,$40
 mov es,ax
 mov ds,ax
 mov di,$1a
 mov si,$1c
 movsw
pop es
pop ds
ret

writehexnibbles80x25z: ; EDX = 32 bit input bl=x bh=y ch=color ( writes 8 nibbles from input )
push es                ; does not remove leading zeroes
mov ax,$b800
mov es,ax
xor ax,ax
xchg al,bh
mov di,ax
shl di,2
add di,ax
shl di,4
add di,bx
shl di,1
mov cl,8
.roll1:
rol edx,4
mov al,dl
and al,$f
cmp al,10
sbb al,69h
das
mov ah,ch
stosw
dec cl
;or cl,cl
jnz .roll1
pop es
ret

    


if you don't need that performance, just use bios function readkey, or keycheck, i have posted some bios routines to this board, made with help by interrupt list

basic read keyboard is
Code:
readkeyboard:
in al,$60
ret
    

this is all rigth if you don't care about busy (in most cases you should)

i don't know why i couldn't find so accurate descriptions anywhere,
i had to play lego from my info files to make these work all right


Description: Keyboard Port description
Download
Filename: keyboard.rar
Filesize: 7.87 KB
Downloaded: 308 Time(s)

Post 02 Mar 2005, 01:38
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
keyboard handling was well described in PCGPE (PC games programming encyclopedia) if i recall right. There are some special issues with shifts and pause/sysrq/scrolllock keys (they send more than one scan) also extended keys (gray ones) send some prefix before real scan code, which is E0 or E2 or something. Just look for some good description
Post 02 Mar 2005, 09:04
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Cas



Joined: 26 Feb 2004
Posts: 82
Location: Argentina
Cas
If you're willing to make a keyboard routine, maybe my old "Support" project will be useful to you. It is a timer+keyboard handler TSR, with source and all. Take a look.


Description: Support 1.50
Download
Filename: Sup150.zip
Filesize: 20.57 KB
Downloaded: 281 Time(s)


_________________
Ā«Earth is my country; science is my religionĀ» - Christian Huygens
Post 05 Apr 2005, 04:33
View user's profile Send private message Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.