A92: Re: keyb matrix


[Prev][Next][Index][Thread]

A92: Re: keyb matrix




Hi Raphaël !
In order to read all keys directly from the matrix, you should first get rid
of the auto-int 1-7 at the beginning of the program. (speeds program up, no
indicators like 2nd,Shift, Alpha,Busy...) Due to the fact you have asked for
a ClearScreenRoutine I have included one for gray4lib and one for standard
black & white programs. Everytime you want to read keys, call the Getkey
Routine first. It loads the actual setting of the keyboard into the keystat
memory adress. The Keyboard Routine then checks wether a specific key has
been pressed or not.

Klaus Lukaschek
lukas1@xpoint.at

Program:
- - - - - - - -
ClearScreen:
movem.l d0-d1/a0,-(a7)
clr.l    d0
move.l #959,d1
lea LCD_MEM,a0
ClearScreenLoop:
move.l d0,(a0)+
dbra d1,ClearScreenLoop
movem.l (a7)+,d0-d1/a0
rts
ClearGrayScreen:
movem.l d0/a0-a1,-(a7)
move.l #959,d0
move.l gray4lib::plane1,a0
move.l gray4lib::plane0,a1
RepClr:
clr.l (a0)+
clr.l (a1)+
dbra d0,RepClr
movem.l (a7)+,d0/a0-a1
rts

Getkey:
movem.l d0-d1/a0,-(a7)
lea keystat(pc),a0
move.w #$FFFE,d0
move.w #9,d1
GetKeys:
move.w d0,$600018
nop
nop
nop
nop
nop
nop
nop
nop
nop
move.b $60001B,(a0)+
rol.w #1,d0
dbra.w d1,GetKeys
movem.l (a7)+,d0-d1/a0
rts

Keyboard:

bsr Getkey
btst.b #3,keystat    ;checks if bit 3 of keystat row 0 is active=pressed(1)
or inactive=notpressed(0)  (89:Right)
beq Routine1
btst.b #1,keystat    ;checks if bit 1 of keystat row 0 is on or off
(89:Left)
beq Routine2
btst.b #5,keystat+5    ;checks if bit 5 of keystat row 5 is on or off
(89:X)
beq Routine3
btst.b #4,keystat       ;checks if bit 4 of keystat row 0 is on or off
(89:2nd)
beq Routine4
btst.b #0,keystat+6    ;checks if bit 0 of keystat row 6 is on or off
(89:ESC)
beq End

...
;Other code or calls
...
bra Keyboard
End:
rts

AutoInt_1:
rte
AutoInt_2:
rte
AutoInt_3:
rte
AutoInt_4:
rte
AutoInt_5:
rte
AutoInt_6:
rte
AutoInt_7:
rte

_main:
move.l #$700,d0
trap #1
bclr.b #2,$600001
move.l $64,oldint1
move.l $68,oldint2
move.l $6C,oldint3
move.l $70,oldint4
move.l $74,oldint5
move.l $78,oldint6
move.l $7C,oldint7
move.l #AutoInt_1,$64
move.l #AutoInt_2,$68
move.l #AutoInt_3,$6C
move.l #AutoInt_4,$70
move.l #AutoInt_5,$74
move.l #AutoInt_6,$78
move.l #AutoInt_7,$7C
bset.b #2,$600001
trap #1
;activate gray4lib if you want
bsr    ClearScreen            ;if no gray4lib active(only black & white,
standard)
bsr    ClearGrayScreen    ;if gray4lib active
...
;other code
....
bsr    Keyboard                ;this is the main_loop of the program
;deactivate gray4lib if you want
move.l #$700,d0
trap #1
bclr.b #2,$600001
move.l oldint1,$64
move.l oldint2,$68
move.l oldint3,$6C
move.l oldint4,$70
move.l oldint5,$74
move.l oldint6,$78
move.l oldint7,$7C
bset.b #2,$600001
trap #1
rts

oldint1 dc.l 0
oldint2 dc.l 0
oldint3 dc.l 0
oldint4 dc.l 0
oldint5 dc.l 0
oldint6 dc.l 0
oldint7 dc.l 0
keystat    ds.b    10
end

-----Ursprüngliche Nachricht-----
Von: Raphaël HUCK <philhuck@club-internet.fr>
An: assembly-92@lists.ticalc.org <assembly-92@lists.ticalc.org>
Datum: Sonntag, 27. September 1998 19:43
Betreff: A92: keyb matrix


>
>How do I use the keyboard matrix instead of flib::idle_loop ?
>Thank you.
>
>MP <philhuck@club-internet.fr> <http://mp.i-france.com>
>



Follow-Ups: