| |
stunt Account closed
Registered: Jul 2006 Posts: 48 |
Scan the keyboard
Guys,
Right now i'm still using kernal routine $ffe4 to scan the keyboard, but ofcourse I'd rather avoid using kernal routines. So Scout suggested me inastead to scan the keyboard matrix ($dc00 and $dc01) directly.
Now i have:
keyscanloop
lda $dc00 ; row
and #%00100000
bne continu
lda $dc01 ; collumn
and #%00000001
bne continu
jmp keyispressed
continu
jmp keyscanloop
keyispressed
...
But this doesnt seem to be working.
What am i doin wrong?
Stunt |
|
| |
Soren
Registered: Dec 2001 Posts: 547 |
you store a value in one of the adresses
and read from the other and do a compare.
To put it short :)
|
| |
Soren
Registered: Dec 2001 Posts: 547 |
example
lda #$xx
sta $dc00
lda $dc01
cmp #$yy
more or less..
|
| |
stunt Account closed
Registered: Jul 2006 Posts: 48 |
ok, thanks jeff,
now i tried:
scankey
lda #%00010000 ; row for character '0'
sta $dc00
lda $dc01
cmp #%00001000 '; collumn for character '0'
bne scankey
lda #07
sta 53280
So I want to change border colour to yellow when key '0' is pressed. But still it doenst work.
(For the values i used the matrix on http://sta.c64.org/cbm64kbdlay.html (very handy link that scout gave me).Did i pick the right values for key '0'?)
Stunt
|
| |
enthusi
Registered: May 2004 Posts: 677 |
no, you either mixed row/column or got the bit-order wrong
bit 0 = #%00000001 |
| |
Soren
Registered: Dec 2001 Posts: 547 |
the bits of the key(s) to check for has to be off.
so to check for 0 (zero)
do this:
loop lda #%11101111
sta $dc00
lda $dc01
cmp #%11110111
bne loop
rts
|
| |
stunt Account closed
Registered: Jul 2006 Posts: 48 |
yes it's working now!!!!!!
thx!
O and another 1 question, what if i want to scan for 2 keys pressed at same time, for example scan for 'f8', which is f7+shift?
thx
Stunt |
| |
Soren
Registered: Dec 2001 Posts: 547 |
That gets a bit tricky, as there is both left shift and right shift/shiftlock.
But there is a neat adress, $028d which can be used to check for shift/CTRL/Commodore
when it has value 01, a shift key is pressed, 02 -> commodore key is pressed. 04 -> ctrl is pressed.
And you can combine those values.
so possible you could first check for f7 by using dc00 and dc01, and then check if shift is pressed by using address $028d.
|
| |
stunt Account closed
Registered: Jul 2006 Posts: 48 |
@ jeff: u rock. f8 is now working also :)) |
| |
enthusi
Registered: May 2004 Posts: 677 |
well 028d aint very helpful when you code the KB-scan to get rid of the kernal. sorry for being all negative and of little use. |
| |
stunt Account closed
Registered: Jul 2006 Posts: 48 |
@ enthusi:
Please explain.
And please also tell me what is your solution then to read shift+key?
Stunt
|
... 6 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 - Next |