| |
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?!?
|
|
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
I always used the kernal to read the keyboard for such stuff.. there are 2 routines for that
- scnkey: you must call this one from your irq routine, this one scans the keyboard for pressed keys
- getin: and this one gives you the petscii codes of the pressed keys
so it will look like this
irq:
blah
...
jsr scnkey
...
blah
main prog:
jsr getin
cmp #"<crsr left>"
beq left
cmp #"<crsr up>"
beq up
...
etc
its the same as in basic :) you dont have to check for shift seperately. |
| |
yago
Registered: May 2002 Posts: 332 |
The getin method is new to me (and a good Idea).
If you want to use the commodore keyboard read,
you need to end one of your irqs with
JMP $EA31
The other irqs should be ended with
JMP $EA81
Please note that the kernel must be switched in, so you need to change irq-vector at $314 instead of $fffe.
Have Fun,
Zed Yago
PS: Please correct me, if sth is wrong, written out of my head!
|
| |
Krill
Registered: Apr 2002 Posts: 2839 |
If i have to only check some keys for cursor control, i never use the kernel. Direct access of the key matrix is faster and it doesnt interfere with joy 1 input like the kernel input routine does due to poor coding. There is a way to have keyboard, joy 1 and joy 2 input simultaneously, if you use the data direction registers wisely (basically, put the negated $dc00 value to $dc02) to prevent joy 1 from interfering with the keyboard input. |
| |
Testicle Account closed
Registered: Sep 2002 Posts: 131 |
ah, jmp $ea31 solves my problem! :-)
usually i use either $ea7e or $ea81 to end my raster-irq, but i actually never knew the differences.
can somebody tell me?
and: when is it useful to use $fffe/$ffff as irq-vectors?
|
| |
cadaver
Registered: Feb 2002 Posts: 1153 |
When you want to use RAM behind Kernal, or want to save CPU cycles. |
| |
Krill
Registered: Apr 2002 Posts: 2839 |
Quote: ah, jmp $ea31 solves my problem! :-)
usually i use either $ea7e or $ea81 to end my raster-irq, but i actually never knew the differences.
can somebody tell me?
and: when is it useful to use $fffe/$ffff as irq-vectors?
A look into the kernel using a monitor usually helps answering those questions... :b and the kernel is for weenies... *states* ;) |
| |
yago
Registered: May 2002 Posts: 332 |
Quote: A look into the kernel using a monitor usually helps answering those questions... :b and the kernel is for weenies... *states* ;)
There are also some excellent Books about the cbm-kernel, which explain the routines and zp-addresses.
I agree, IMHO nowaday PC-Demos are not "real" Demos, because they use DirectX etc.
|
| |
Seven
Registered: Jan 2002 Posts: 201 |
yeah! and they use C instead of assembly! damn them! |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
krill: oh well, then Im a weenie :)) but why would I sit down and code a keyboard scan routine, if its just about 2 jsr ? :)
$ea31 will call several kernal routines, cursor blinking, scnkey and the likes..
$ea81 is just: pla tay pla tax pla rti
$ea7e is a bit better with lda $dc0d in front of the earlier :) |
| |
Testicle Account closed
Registered: Sep 2002 Posts: 131 |
@Oswald: yes, i looked at the kernel and saw the differences. now i've got another question: is it necessary to end a raster-irq-routine with jmp $ea7e (or whatever) or can i directly use "rti" instead? i'm not sure, if the three missing pla's (from jmp $ea7e/81) would do any harm?
well, ofcourse i could give it (the "rti" i mean) a try, but then i would probably not know, if it really works or if it was just pure chance that nothing went wrong...
|
... 18 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |