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 > Irq
2003-08-02 22:42
Mihai

Registered: Feb 2002
Posts: 29
Irq

Hy

I am trying to understand some code about intrerupts, it's really simple. IRQ is an intrerupt routine called with the address at ($0314 and $0315). Now in IRQ there are those jumps, JMP $ea31 and Jmp $febc. What do they do and what's the difference between them?

I read something in Programming the C64 but i didn't understood very well.

Thanks,
Mihai
2003-08-03 07:59
Puterman
Account closed

Registered: Jan 2002
Posts: 188
I think there's an article about interrupts in the first issue of C=Hacking, which might be helpful.

ea31 is the BASIC interrupt handler code, which scans the keyboard and does some other stuff. If you're not using that stuff, you'll save quite a lot of time by jumping to ea81 or febc instead (all those routines do is reload the saved register values and do RTI).
2003-08-03 12:48
trident

Registered: May 2002
Posts: 74
Instead of jumping to $ea81, I usually jump to $ea7e instead. The only difference is the "lda $dc0d" instruction at $ea7e, which I believe is used to acknowledge the interrupt when it was caused by a CIA timer. I don't think it really matters in the case of raster interrupts, but I think it is a good habit since it can save a lot of trouble if one would be inclined to convert the raster interrupt into a timer interrupt.
2003-08-03 20:00
Perff
Administrator

Posts: 1664
Perhaps a bit off-topic....

I personally don't use the ROM's interrupt vectors (like $0314) but instead I use the one in $fffa, $fffb (for IRQ) and $fffe, $ffff (for NMI).
You of course then need to code the register-save and recover rutines yourself, but you get access to the 8k of RAM under $e000-$ffff instead of the ?useless? ROM that would be there.

This leads me to a question for all coders.
When you code do you always have the ROM (both basic and kernal or perhaps just the one) enabled or disabled?

Personally I ALWAYS disable it. In that way I get 64k (almost) of RAM and I don't have to worry which zp-addy's I use.
Basically you are in total control of the machine - which I like best. :)
2003-08-03 20:08
Puterman
Account closed

Registered: Jan 2002
Posts: 188
Perff, yes, #$35 to $01, but it seems you're getting a bit rusty, as you say you use $fffe for NMI and $fffa for IRQ. :-)
2003-08-03 20:38
MorGorr
Account closed

Registered: May 2002
Posts: 47
Quote: Perhaps a bit off-topic....

I personally don't use the ROM's interrupt vectors (like $0314) but instead I use the one in $fffa, $fffb (for IRQ) and $fffe, $ffff (for NMI).
You of course then need to code the register-save and recover rutines yourself, but you get access to the 8k of RAM under $e000-$ffff instead of the ?useless? ROM that would be there.

This leads me to a question for all coders.
When you code do you always have the ROM (both basic and kernal or perhaps just the one) enabled or disabled?

Personally I ALWAYS disable it. In that way I get 64k (almost) of RAM and I don't have to worry which zp-addy's I use.
Basically you are in total control of the machine - which I like best. :)


I switch a lot between ROMs, RAM and IO registers, because I like using them all ;-)

I also "switch" between different 0pages or at least different contents for various addresses. Surely not out of convenience and surely not the best way to go, but because I combine compiled basic with a music player and my own asm stuff. Each of these three parts uses 0page addresses, and in the case of the compiled basic, it is hard to find out which addresses are used for what. Buffering certain parts of the 0page was the only way to solve that...
2003-08-03 21:07
Perff
Administrator

Posts: 1664
Quote: Perff, yes, #$35 to $01, but it seems you're getting a bit rusty, as you say you use $fffe for NMI and $fffa for IRQ. :-)


Oups! You got me there!!!
DOH!!!!!!!

;-P
2003-08-03 21:59
cadaver

Registered: Feb 2002
Posts: 1153
It seems for utilities/editors I only switch BASIC-rom off, otherwise both (to get fastest interrupt response). Hmm..thinking of it, Ninjatracker could handle more music if it used the area behind Kernal :)

At one point I also experimented with having everything as RAM in main program ($34 in $01), only using $35 when there's something to be done with IO. On entry/exitpoint of an interrupt, $01 is incremented/decremented, and thus interrupts can work with IO regardless of what the main is doing.. But I always forgot to switch the IO on in the main program as necessary, so I found it best to place graphics under IO area and forget this scheme :)

2003-08-05 09:02
Oswald

Registered: Apr 2002
Posts: 5007
noone really answered the questions so I give it a try:

if an irq occurs the cpu will jump to the address stored at
fffe/ffff (lo/hi). IF the kernal rom is switched on at first the cpu will jump at a routine which will check wether the interrupt was caused a brk or not, if not then it will do a jmp ($0314) wich will lead to the addy $ea31.

now it is a nice thing if u use 0314-15 for irq vector to jump to this routine after u finished ur stuff, so you can have your cursor on, type stuff, etc (as this routine is responsible for all of this, and some other stuff too)

so $ea31 does cursor flash/move, keyboard scan, update ti ti$ etc. and it returns also from the interrupt

you can find on the magic addresses $ea7e $ea81 $febc the followings:

$ea7e: lda $dc0d
$ea81: pla
tay
pla
tax
pla
rti

$febc: same as from $ea81

to drive the irqs on your own, you have to turn off the kernal (lda #$35 sta $01) then put the addy of your routine into fffe/ffff, and save all registers end restore them at the start/end of your routine

something like this

pha
txa
pha
tya
pha
...
your code
...
pla
tay
pla
tax
pla
rti

or if you wanna be smart and fast:

sta a+1
stx x+1
sty y+1

a lda #$00
x ldx #$00
y ldy #$00
rti

happy coding.. :)
2003-10-03 19:39
Falcon
Account closed

Registered: Sep 2003
Posts: 3
Hi folks..

Hrm.. this is not a reply but the topic suits my question...

I am trying to do a little something just 4 the pure fun of it, and my question is soooo simple 4 u codewizzards out there... but it has proven to be a bit of a challenge 4 me... :/

The plan is to do a simple intro, colourwash, flashing, rasterbar n a scroll, to do this im using IRQ's, 1 for the colours(flash, wash, etc), one 4 the rasterbars and one 4 the scroller.

Ive got the custom chars, flash n wash working but as soon as I try to implement one more IRQ things fuck up.

Ive read putermans "int. to demoprg." and that one should use 0314,0315 to "point" to the next IRQ code and from there to the first one, but I cant get it to work prop.

Does any1 have some tips how i should go about or even better, have any asm source code that i could use 4 reference...

I know that theres prob. a better way to code the things i want to.. but this is the way i want to do it.. im a newbee at c64-asm and i want to make things work before i look at efficensy(<-spelling?)


Regards Cyberhawk aka Mandroid
2003-10-03 20:17
cadaver

Registered: Feb 2002
Posts: 1153
How do things fuck up? Anyway, it shouldn't be more complex than this, in this example I assume 3 interrupts chained together, and that raster interrupt is acknowledged (dec $d019 for example) in the beginning of each interrupt's code

At end of interrupt1:

lda #<irq2
sta $0314
lda #>irq2
sta $0315
lda #IRQ2_POSITION
sta $d012
jmp $ea81

End of interrupt2:

lda #<irq3
sta $0314
lda #>irq3
sta $0315
lda #IRQ3_POSITION
sta $d012
jmp $ea81

End of interrupt3:

lda #<irq1
sta $0314
lda #>irq1
sta $0315
lda #IRQ1_POSITION
sta $d012
jmp $ea81

and IRQ1_POSITION < IRQ2_POSITION < IRQ3_POSITION (from top to bottom)
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
Harry Potthead
ΛΛdZ
icon/The Silents, Sp..
skull
jmin
Guests online: 191
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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