Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > looking for rom independent keyboard read routine
2010-04-24 07:07
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.
2010-04-24 07:11
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..
2010-04-24 07:12
Oswald

Registered: Apr 2002
Posts: 5094
I see there's already like 3 topics on this here :) should have searched first. thanks :)
2010-04-24 08:36
Mace

Registered: May 2002
Posts: 1799
Yeah, shoo!
2010-04-24 10:01
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
2010-04-24 14:09
Ed

Registered: May 2004
Posts: 173
I made some halfhearted attempt in my unfinished gfx editor. However it has some bugs.

2010-04-24 16:28
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.
2010-04-24 17:14
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)|
+----+----------------------+------------+------------+------------+------------ +------------+------------+------------+------------+
2010-04-24 17:22
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

2010-04-24 18:42
Oswald

Registered: Apr 2002
Posts: 5094
nice codebase material, thanks :)
2010-04-24 19:38
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
macx
LordCrass
Guests online: 90
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.061 sec.