| |
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.... |
| |
MagerValp
Registered: Dec 2001 Posts: 1082 |
It'd just crash with a bare RTI, as in the beginning of the IRQ routine you have PHA TXA PHA TYA PHA. You have to restore them before exiting.
|
| |
Ninja
Registered: Jan 2002 Posts: 418 |
Krill: Well, I think some troubles are unavoidable using Joy1 and Keyboard even with data-direction registers. If the joy is pressed up and so the line is low, how can you check if e.g. "DEL" is pressed at the same time? |
| |
Testicle Account closed
Registered: Sep 2002 Posts: 131 |
@MagerValp: ah, understand! thanks! :-) |
| |
Oswald
Registered: Apr 2002 Posts: 5127 |
testicle:
the kernal irq at its start pushes a,x,y regs to the stack on top of the return address, if you dont pull those values out, the code will continue to run un some random location, instead of the correct return addy...
ofcourse you can have your own irq routine, just
turn back the kernal when you want to use it, and jsr it..
(when not in irq we have $35 in $01, using fffe/ffff as vectors)
irq pha
txa
pha
tya
pha
...
lda #$36
sta $01
jsr kernal
lda #$35
sta $01
pla
tay
pla
tax
pla
rti
sorry, if this is was too straightforward 2 you :) |
| |
Digger
Registered: Mar 2005 Posts: 448 |
@Oswald: Hmmm, I've tried your last example with JSR $ffe4 but it just returns $00 all the time, what am I doing wrong? Cheers! |
| |
JackAsser
Registered: Jun 2002 Posts: 2038 |
@digger: necro-poster of the year! Congrats! :)
For custom keyscan I recommend Codebase and TLR’s routine. |
| |
Oswald
Registered: Apr 2002 Posts: 5127 |
Quote: @Oswald: Hmmm, I've tried your last example with JSR $ffe4 but it just returns $00 all the time, what am I doing wrong? Cheers!
ffe4 is getin, reads a character from the input buffer.
but you also need to call SCNKEY (ff9f) from a raster irq (or with similar frequency), SCNKEY does scan the keyboard and fills up the input buffer.
(2nd post in here I explain same thing :P ) |
| |
Digger
Registered: Mar 2005 Posts: 448 |
@Oswald: Ahhh makes sense, thx!
@JackAsser: Hehe, still within this millennium though. I wanted to avoid any foreign code to save some bytes, since I don't need to read all the keys. Will give it a go. Kernal's SCNKEY seems to take a lot of rastertime actually. |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
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.. |
| |
Krill
Registered: Apr 2002 Posts: 3098 |
Quoting FreshI'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. =) |
Previous - 1 | 2 | 3 - Next |