| |
Oswald
Registered: Apr 2002 Posts: 5094 |
looking for rom independent keyboard read routine
I'm lazy, anyone can help me out? I'd need shift+crsrs + return aswell, not just alphanumeric stuff.
thanks. |
|
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
The one in C= Hacking regarding "three key rollover" is ROM independent, and if you don't want that fancy roll-over stuff, it is easy to modify:
http://codebase64.org/doku.php?id=magazines:chacking6#three-key.. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
I see there's already like 3 topics on this here :) should have searched first. thanks :) |
| |
Mace
Registered: May 2002 Posts: 1799 |
Yeah, shoo! |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
i should post the one i made for my tracker loooooong ago on codebase. if i only knew where i have the source for that.... =P |
| |
Ed
Registered: May 2004 Posts: 173 |
I made some halfhearted attempt in my unfinished gfx editor. However it has some bugs.
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
who can make a faster/better one ? :) here's one from the top of my head, unrolled style:
lda #%11111110
sta $dc00
ldy $dc01
ldx table,y
ldy row/col key table,x
cpy pressedinthisrow/col
beq ;do somekindoffdebounce?
sty pressedinthisrow/col
next row/col
"table" translates 0111111 => 0, 101111 => 1, 11011111=2, for indexing a byte table. more than 2 zero bits would give $ff (dont need that except for shift,etc) for a bmi error check. Then I'd do a pinpoint scan for shifts/c=, etc. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
here is a crude table I made for this kind of routine a while back (Don't remeber where i got this info (maybee 3 key rollover or the ref. manual). Maybee it could be of some use...
$dc00 is used for selecting one of eight the scan rows as folows and the $dc01 value is then peeked:
+----+----------------------+--------------------------------------------------- ----------------------------------------------------+
| | | Peek from $dc01 (code in paranthesis): |
|row:| $dc00: +------------+------------+------------+------------+------------+------------+- -----------+------------+
| | | BIT 8 | BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 |
+----+----------------------+------------+------------+------------+------------ +------------+------------+------------+------------+
|1. | #%11111110 (254/$fe) | DOWN ($ )| F5 ($ )| F3 ($ )| F1 ($ )| F7 ($ )| RIGHT ($ )| RETURN($ )|DELETE ($ )|
|2. | #%11111101 (253/$fd) |LEFT-SH($ )| e ($05)| s ($13)| z ($1a)| 4 ($34)| a ($01)| w ($17)| 3 ($33)|
|3. | #%11111011 (251/$fb) | x ($18)| t ($14)| f ($06)| c ($03)| 6 ($36)| d ($04)| r ($12)| 5 ($35)|
|4. | #%11110111 (247/$f7) | v ($16)| u ($15)| h ($08)| b ($02)| 8 ($38)| g ($07)| y ($19)| 7 ($37)|
|5. | #%11101111 (239/$ef) | n ($0e)| o ($0f)| k ($0b)| m ($0d)| 0 ($30)| j ($0a)| i ($09)| 9 ($39)|
|6. | #%11011111 (223/$df) | , ($2c)| @ ($00)| : ($3a)| . ($2e)| - ($2d)| l ($0c)| p ($10)| + ($2b)|
|7. | #%10111111 (191/$bf) | / ($2f)| ^ ($1e)| = ($3d)|RGHT-SH($ )| HOME ($ )| ; ($3b)| * ($2a)| £ ($1c)|
|8. | #%01111111 (127/$7f) | STOP ($ )| q ($11)|COMMODR($ )| SPACE ($20)| 2 ($32)|CONTROL($ )| <- ($1f)| 1 ($31)|
+----+----------------------+------------+------------+------------+------------ +------------+------------+------------+------------+
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
this is what i use if all i need is simple keychecking (one key at a time, no extras)
minikey:
lda #$0
sta $dd03 ; port b ddr (input)
lda #$ff
sta $dd02 ; port a ddr (output)
lda #$00
sta $dc00 ; port a
lda $dc01 ; port b
cmp #$ff
beq nokey
; got column
tay
lda #$7f
sta nokey2+1
ldx #8
nokey2:
lda #0
sta $dc00 ; port a
sec
ror nokey2+1
dex
bmi nokey
lda $dc01 ; port b
cmp #$ff
beq nokey2
; got row in X
txa
ora columntab,y
sec
rts
nokey:
clc
rts
columntab:
.repeat 256,count
.if count = ($ff-$80)
.byte $70
.elseif count = ($ff-$40)
.byte $60
.elseif count = ($ff-$20)
.byte $50
.elseif count = ($ff-$10)
.byte $40
.elseif count = ($ff-$08)
.byte $30
.elseif count = ($ff-$04)
.byte $20
.elseif count = ($ff-$02)
.byte $10
.elseif count = ($ff-$01)
.byte $00
.else
.byte $ff
.endif
.endrepeat
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
nice codebase material, thanks :) |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
Yes, hehe.. sigh.. I felt obliged to put this stuff there, so I did:
http://codebase64.org/doku.php?id=base:reading_the_keyboard
...but I would indeed appreciate if people could just throw the code itself up there at once instead of posting it here, and just post a link to the code from here to there, or so... :) |
... 30 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 | 4 - Next |