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


Forums > C64 Coding > cursor-control.
2003-04-04 07:16
Testicle
Account closed

Registered: Sep 2002
Posts: 131
cursor-control.

well, for a diskmag-system i want the user to be able to use both joystick and/or cursor-keys to choose chapters.

joystick is no problem, but then i tried to implement the cursor-function:

.keyboard lda $c5
cmp #7
beq .leftright
cmp #2
beq .updown
cmp #1
beq .jfire
rts
.leftright lda $028d
and #1
bne .jleft
jmp .jright
.updown lda $028d
and #1
bne .jup
jmp .jdown


first i used this function during the irq, but it didn't work. now i use this function beside my irq-routines, but nothing happens.

do i have to set special registers to get access to the cursor-keys or something like that?!?
 
... 18 posts hidden. Click here to view all posts....
 
2020-04-27 12:43
Fresh

Registered: Jan 2005
Posts: 89
For sure not the most accurate and possibly fast implementation, but it's a bit more reliable than C64 kernal version.
Moreover, I'm far to be a CIA guru, but I'm with ninja: I'm not sure you can 100% avoid joy1/keyboard collisions.
But I'd love to be proved wrong! :)

Here's the code, part of my 1541U2 Mod Player: routine GetKeyJoy, (set GKJtemp to any free location).

https://bitbucket.org/freshness79/mod-player/src/master/keyboar..
2020-04-27 16:48
Krill

Registered: Apr 2002
Posts: 1539
Quoting Fresh
I'm with ninja: I'm not sure you can 100% avoid joy1/keyboard collisions.
If simultaneous JOY1 and keyboard input isn't required, then i guess this can be done.

$DC00 (output) selects keyboard matrix column, then $DC01 (input, also JOY1) reflects pressed keys in the bits corresponding with the keybard matrix row.

Now, if no column is selected ($DC00 set to $ff) and $DC01 reads $ff, then JOY1 isn't active.
Do the required keyboard scans, then re-check if JOY1 still isn't active. Use the scanned keys if so, discard if JOY1 was active.

Oh, and you can also scan keys on the top 3 matrix rows without having to worry about JOY1 interference, as it isn't connected to bits 7..5 of $DC01. =)
2020-04-27 17:34
Groepaz

Registered: Dec 2001
Posts: 9563
You can also do more fun stuff by scanning the keyboard in different ways than the standard way - see https://sourceforge.net/p/vice-emu/code/HEAD/tree/testprogs/CIA.. (this doesnt work very well in any emulator)
2020-04-27 20:26
Fresh

Registered: Jan 2005
Posts: 89
Quoting Krill
If simultaneous JOY1 and keyboard input isn't required, then i guess this can be done.

$DC00 (output) selects keyboard matrix column, then $DC01 (input, also JOY1) reflects pressed keys in the bits corresponding with the keybard matrix row.

Now, if no column is selected ($DC00 set to $ff) and $DC01 reads $ff, then JOY1 isn't active.
Do the required keyboard scans, then re-check if JOY1 still isn't active. Use the scanned keys if so, discard if JOY1 was active.

That's exactly the approach I used in the code I linked in my previous post: I read CIA 1 port B before and after checking keyboard, if both reads are $ff I can consider reliable the keyboard data.
This indeed works but if you use both keyboard and joystick simultaneously, only the status of the latter will be read.
Yes, you can scan a limited number of rows but again, it won't be the 100% I mentioned before either.
2020-04-27 23:28
Krill

Registered: Apr 2002
Posts: 1539
Yes yes, the disclaimers remain valid.

Quoting Fresh
That's exactly the approach I used in the code I linked in my previous post
Which... wasn't quite so obvious from the barely-commented code, to be honest. =) So apologies for stating in prose what your code does in... code. :D
2020-04-28 13:45
Fresh

Registered: Jan 2005
Posts: 89
Quoting Krill
Which... wasn't quite so obvious from the barely-commented code, to be honest.

Ehm... Touchez :D
2020-04-28 14:39
Frantic

Registered: Mar 2003
Posts: 1460
Quote: @digger: necro-poster of the year! Congrats! :)

For custom keyscan I recommend Codebase and TLR’s routine.


@Jackasser: What article do you refer to here?
2020-04-28 14:51
JackAsser

Registered: Jun 2002
Posts: 1725
Quote: @Jackasser: What article do you refer to here?

TWW/CTR ffs. Sorry. :D https://codebase64.org/doku.php?id=base:scanning_the_keyboard_t..
2020-04-28 15:40
Oswald

Registered: Apr 2002
Posts: 4612
3 key rollover is an overkill in most cases. usually you need this for menus or simple navigation, not for a text editor for fast typers :)
2020-04-28 18:25
JackAsser

Registered: Jun 2002
Posts: 1725
Quote: 3 key rollover is an overkill in most cases. usually you need this for menus or simple navigation, not for a text editor for fast typers :)

Indeed. I use that routine in EotB but extended to support c128 keyboard also.
Previous - 1 | 2 | 3 - 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
E$G/HoKuTo FOrCE
Brittle/Demozoo
Peeshaya/Airsomjith ..
Xidex/7-Inch
apprentix
Knight Rider/Excess
Knut Clausen/SHAPE/F..
Båtsman/Latex
cadaver/covertbitops
JCH/Vibrants
Silver Dream !/W.F.M..
Didi/Laxity
Guests online: 65
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.6)
3 Coma Light 13  (9.6)
4 Memento Mori  (9.6)
5 Comaland 100%  (9.6)
6 Unboxed  (9.6)
7 Lunatico  (9.6)
8 The Shores of Reflec..  (9.6)
9 Remains  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Crystal Gazer  (9.5)
2 Dawnfall V1.1  (9.5)
3 Smile to the Sky  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Rewind  (9.5)
6 Instinct  (9.4)
7 Tribute to Ben - Las..  (9.4)
8 In Memoriam BHF  (9.4)
9 Coro(l)na Nuthouse  (9.4)
10 Cuarentenauta  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 PriorArt  (9.4)
4 Oxyron  (9.3)
5 Triad  (9.2)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Horizon  (9.9)
3 Stormbringer  (9.7)
4 The Shadow  (9.6)
5 Fungus  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.05 sec.