| |
PopMilo
Registered: Mar 2004 Posts: 146 |
How to properly setup $fffe interrupt ?
Good day to you all, I have a bit of a problem so... :
I found some old code of mine on an old tape and transfered it to PC and want to compile it using tass and try it on CCS64 or VICE. Im sure code worked 15 years ago, but now... :)
So why this happens...
"sei
...
lda #<irqsr
ldx #>irqsr
sta $fffe
stx $ffff
...
cli"
I watched this code in VICEs debbuger and imidiatelly when sta $fffe is done there is NO change in $fffe ?
same with $ffff
So when cli goes, my prg just goes to $ff48 and my interupt routine is never executed...?
So I would be very gratefull if someone can write just some small piece of code that makes my routine go off in regular timed intervals (5-20 times a second...).
I read some other posts but cant get it to work...
thanks... |
|
| |
Radiant
Registered: Sep 2004 Posts: 639 |
You need to swap out KERNAL by poking the appropriate value to $01 first. See Mapping the C64 or so. |
| |
Wanderer Account closed
Registered: Apr 2003 Posts: 478 |
SEI
LDA #$35
STA $01
etc.
If you plan to use Kernal routines, remember to copy $E000-$FFFF) into itself so that when you switch it out, you don't crash. |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
Tryed that out... still something is wrong. Must be something in the rest of code...
I dont need kernel. Just VIC in bank 0, turn off basic and kernel, dont even need charset, got my own.
Code is 18Kb so I need time to look it up.
If you could supply just that: How to set up timed interrupt every now and then :), what to put in $01, $dc0d, $dd0d, $dc00 ? ...
p.s. This game is something you have never seen on C64 :) I got to fix it... |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
When using $fffe interrupts, you also have to preserve the registers yourself. So, do pha txa pha tya pha at the beginning of your interrupt routine, and you should be set. |
| |
Scout
Registered: Dec 2002 Posts: 1570 |
Here you go:
*=$0810
sei
lda #<irq
ldy #>irq
sta $fffe
sty $ffff
lda #<brkirq
ldy #>brkirq
sta $fffa
sty $fffb
lda #$7f
sta $dc0d
sta $dd0d
lda #$00
sta $d012
lda #$1b
sta $d011
lda #$01
sta $d019
sta $d01a
lda #$35
sta $1
cli
jmp *
irq:
pha
txa
pha
tya
pha
inc $d020
asl $d019
pla
tay
pla
tax
pla
brkirq:
rti
|
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
YES!!! After three evenings starring in code finally got it!!!
Am little puzzled, what was wrong at first place but who cares it works!
Your code did it (and the fact that I realised what the main loop was acctually doing ... it was written 14 years ago)
Thank you guys...
p.s. will upload code for all of you to admire when the graphics is done (Its a game but I salvaged only code, and the graphics file is gone so have to do some drawing (4 sprites and 5 chars :)and then youll see what was all about) |
| |
Scout
Registered: Dec 2002 Posts: 1570 |
Quote: YES!!! After three evenings starring in code finally got it!!!
Am little puzzled, what was wrong at first place but who cares it works!
Your code did it (and the fact that I realised what the main loop was acctually doing ... it was written 14 years ago)
Thank you guys...
p.s. will upload code for all of you to admire when the graphics is done (Its a game but I salvaged only code, and the graphics file is gone so have to do some drawing (4 sprites and 5 chars :)and then youll see what was all about)
Yay!
But that's what we're here for, right?
---
-= Silicon Ltd. =-
http://forum.siliconlimited.com
Commodore 64 Scenemusic Podcast
http://8bitmayhem.blogspot.com/ |
| |
TDJ
Registered: Dec 2001 Posts: 1879 |
I think that HEMA should first-release this game |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
The code lacks an LDA $DC0D and LDA $DD0D to clear the timer irq flags. You might encounter occassional crashes due to that. |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
I did used
bit $dcod
bit $ddod
in previous attempts. No noticable difference though...
|
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Just wait 1 frame in the sei block and see how your IRQ gets triggered immediately after the cli. Clearing the timer flags IS needed. |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
I read info on those memory locations, and its all there. Just cant see what was wrong in the first place. Must be kind of mistake that sits there infront of your eyes and you are just blind to see it...
I knew this when I was younger :(
Am out of shape... But am just going into it again! :)
|
| |
TDJ
Registered: Dec 2001 Posts: 1879 |
Quote: I read info on those memory locations, and its all there. Just cant see what was wrong in the first place. Must be kind of mistake that sits there infront of your eyes and you are just blind to see it...
I knew this when I was younger :(
Am out of shape... But am just going into it again! :)
Heh, I remember when I started playing football again after 9 years .. "I used to be much better at this but I guess it will come back".
Guess what? Never happened .. ;)
(on the other hand, when I returned to coding in 2000, I actually found out after a while that I had improved - ofcourse being a professional developer has something to do with that)
(and yes, this means that I was an even worse coder before than I am right now)
(I should really stop talking like this) |
| |
V-12
Registered: Nov 2003 Posts: 206 |
you don't need to set $fffa/b :) |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
@Murdock
Its just one of those "just to be sure ..." situations :)
Its all done now, interrupts work the rest of game is the problem... But Ill never get better if I dont try hard first. :)
@The Dark Judge:
Well I think I am more experienced coder now then before, but in wrong things :) (book keeping apps and stuff like that ... AND ALL I WANTED TO DO WHEN I WAS YOUNG WAS CODE GRAPHIC EFFECTS AND GAMES !!! :)
Life... |
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
Quote: you don't need to set $fffa/b :)
As long as no one presses restore (and you haven't triggered the CIA 2 timer then not read $DD0D). |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
Restore was the reason why I used it... |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
learn one lesson
its called _K_E_R_N_*A*_L
not kernel |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
"According to early Commodore 'myth' and reported by writer/programmer Jim Butterfield among others, the word KERNAL is an acronym (or maybe more likely, a backronym) standing for Keyboard Entry Read, Network, And Link, which in fact makes good sense considering its role. There's also, however, a theory that the word originated as a misspelling of the word "kernel"[1] by some unknown Commodore employee. Misspelling or not, Berkeley Softworks later used it when naming the core routines of its GUI OS for 8-bit home computers: the GEOS KERNAL..."
Ok. Lesson learned. :)
|
| |
yago
Registered: May 2002 Posts: 333 |
Here is Scouts IRQ-Setup with symbolic names, and acknowledge of unwanted CIA-Irqs.
The acknowledging is really necessary, otherwise Murphys Law will hit you when you show it!
How doke() works and the values for the symbolic names should be clear when looking at the previous Code.
#include <kernel/c64.inc>
#include <macros/util.mac>
.org $0810
sei
doke(irq_vec,irq)
doke(brk_vec,brk)
lda#%01111111
sta cia1.icr
sta cia2.icr
lda cia1.icr
lda cia2.icr
lda#0
sta vic.raster
lda#$1b
sta vic.cr1
lda#1
sta vic.irq
sta vic.irqmask
lda#pla.RAMIO
sta pla.dr
cli
jmp *
.scope irq {
pha txa pha pya pha
;actual routines come here
inc vic.border
asl vic.irq
pla tay pla tax pla
rti
}
.scope brkirq {
rti
}
Possible Enhancements: Debug-Code for brk_irq (should never be called!) and checking if VIC-Irq is really responsible for the Irq.
Its also nice to setup the NMI, either as "will even not trigger when Restore is hit" or as another useful Timer.
|
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quote: learn one lesson
its called _K_E_R_N_*A*_L
not kernel
The KERNAL is the C64's KERNEL.
A KERNEL is not necessarily the C64's KERNAL.
So using both is correct for C64 people. |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
Actually I have never seen people calling the KERNAL a kernel until these days :) |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
Well, by any CS definition, it is an operating system kernel. So I don't see why it would be wrong to call it as such. It's a kernel, named KERNAL. :-) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
kernAl is the OS itself.
kernel is a system core.
there's some difference ehm ?
check any programming guide, and C= docs, its called kernal, period. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
sei
lda #$7f
sta $dc0d ;turn off timer irq
lda #$01
sta $d01a ;request raster irq from vic
lda #raster
sta $d012 ;raster position low
lda #rasterhi&$1b
sta $d011 ;raster position hi&char mode
lda #<irq
sta $fffe ;irq routine addy low byte
lda #>irq
sta $ffff ;irq routine addy high byte
lda $dc0d ;ack any pending timer irq
lda $dd0d ;at cia #2 too
lda #$35
sta $01 ;turn off kern_A_l
cli
jmp *
irq pha
txa
pha
tya
pha
lsr $d019
;do stuff
pla
tay
pla
tax
pla
rti
done. |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
OK guys, you have been extremely helpfull, and my prog is now fully functional except it doesnt work just the way it should :)
Interrupts are working great, graphics is ok, I just have some logical mistakes in my code that need to be fixed...
Thanks! |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
Quote: kernAl is the OS itself.
kernel is a system core.
there's some difference ehm ?
check any programming guide, and C= docs, its called kernal, period.
IMHO, a modern KERNEL does everything what the C64's KERNAL does, and more. And calling the KERNAL the C64's system core (KERNEL) is appropriate since there's also the BASIC interpreter and user front-end running on top of it. |
| |
Monte Carlos
Registered: Jun 2004 Posts: 359 |
This initialisation all lack an lsr $d019 just before the cli.
If you acknowledge any timer irq you have to do it for raster irq, too. You don't know in which rasterline your irq-init routine is executed. In the worst, but most unlikely case you get an irq request just before setting up the new irq.
After the cli the first raster-irq immediately starts in any rasterline which is not good, when using some vic trickery.
Monte
|
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
monte, good point |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
Quote: I think that HEMA should first-release this game
Why HEMA ? What is HEMA ? :(
Is it demo group ?
is it a joke :) No offence intended... :)
p.s. Monte thanks... |
| |
TDJ
Registered: Dec 2001 Posts: 1879 |
Quote: Why HEMA ? What is HEMA ? :(
Is it demo group ?
is it a joke :) No offence intended... :)
p.s. Monte thanks...
Hema is the #1 crack/release group these days. Groups like Onslaught & Triad have nothing on them! |
| |
PopMilo
Registered: Mar 2004 Posts: 146 |
Ok :)
|