Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Productions > VIC interrupts
2002-12-29 09:28
Cybernator

Registered: Jun 2002
Posts: 154
VIC interrupts

Can anyone tell me: In which cycle the VIC is, when a raster interrupt occurs? (on normal line, badline, if there're sprites...)

Any help is appreciated.
 
... 2 posts hidden. Click here to view all posts....
 
2002-12-29 20:36
yago

Registered: May 2002
Posts: 332
Quote: Can anyone tell me: In which cycle the VIC is, when a raster interrupt occurs? (on normal line, badline, if there're sprites...)

Any help is appreciated.


Well, switch the screen off,
and within the irq,change the border color twice.
Now you can see, where the raster interrupt occurs.

Or did I misunderztood ya?

For the details with sprites etc, the VIC-Article has also
some ASCII-Diagrams.

Zed Yago
--
If everything is worth money
money is worth nothing
2002-12-30 07:06
Stryyker

Registered: Dec 2001
Posts: 465
If you did read the 2 texts you would of found it is the first cycle of a line (VIC Article). The IRQ sequence takes 7 cycles (64doc), pushing SR, PC (16 bits), getting IRQ vector etc. I'm unsure how you counted by the INC or STx commands are 6 cycles for non indexed absolute.
2002-12-30 08:38
CyberBrain
Administrator

Posts: 390
Just a little add-on..

As far as i remember the cpu also 'waits' for the instruction currently being run to finish, before it starts the IRQ sequence (it can't break in the middle of an instruction), so you can't be sure your code will start excatly on the 8th cycle of the rasterline.

(the slowest opcode on the C64 is BRK which takes 7 cycles, so if you're unlucky (or whatever you wanna call it) i think it could start on the 8+(7-1)=14th cycle, and if you're lucky it will start on the 8th cycle (well... the extream case - why would you use BRK for anything?))

But all this is what accurate IRQ-interrupts are made for...
(just don't remember how they work)

NOTE!! This is just what i remember, but i think it's correct - if not, somebody gimme a kick!! (pretty interesting topic - allmost forgot all these thinx)
2002-12-30 09:05
QuasaR

Registered: Dec 2001
Posts: 145
Hi there!
In a C=Hacking was once written an article about a stable raster interrupt. The clue was you had to do a RAM-access in the mainloop (like INC $somewhere) and put the last line of the first (or any sprite, I guess..) sprite to the rasterline you wanna have the IRQ and voila you get a really stable IRQ. The author also wrote why this "bug" occurs and I think it explains the cyles VIC is using then, too.
2002-12-30 09:11
Puterman
Account closed

Registered: Jan 2002
Posts: 188
Getting a stable interrupt by using a sprite + inc only works if you're not doing anything outside the interrupt handler. Otherwise you'll have to use the double interrupt method, which is documented in several places on the net.
2002-12-30 10:05
CyberBrain
Administrator

Posts: 390
As far as i remember there was a third way too... I think i called it "$D011 Crash" in the past :) - don't know if that was the official name :)

Again taken compleately from my memory, but it was something like this (if it's wrong please correct me):

1] Make the IRQ start on a non-badline (but on the screen - not in the border)
2] In the middle of this line change $D011 so that the line becomes a badline.
3] Wee.. The VIC will take over for some cycles like it allways does on a badline, and the cpu will regain control at excatly the same cycle every time.
4] (remember to change $D011 back at some point, so that the rasterline on which the IRQ starts won't be a bad line next time - coz' then it won't work as i wrote under 1])

This method ofcause makes the screen look a little fucked up around the rasterline on which you made the $D011-crash, but that can be hidden. :)

The best method is ofcause putermans! (but this one is pretty easy to code)
2002-12-30 13:22
Cybernator

Registered: Jun 2002
Posts: 154
CyberBrain: If you generate a badline somewhere in the middle, this would produce DMA Delay, right? If I'm correct, the misalignment continues for the rest of the screen, not just one rasterline. Though, it's nice a trick.

I've started this topic because of some problems I have with stable rasters (the double interrupt technique). I get the main idea. Now, when it comes to compare the rasterline (cmp $d012) this should happen in cycle 60, right? Because "cmp $d012" takes 4 cycles, and the actual read access to $d012 will happen in the last (the 4th) cycle of the op-code. Because the raster will be off my most of 1 cycle, the comparement will either happen in cycle 63 of the current rasterline, or in the next line. When I've used sprites (8 of them on a line) this didn't work. Of course, because VIC needs additional cycles to fetch the sprite pointers. According to "Pal timing" by Marko, the last free cycle (in this case) is 56. So cmp should go into cycle 53, right? In CCS, I've noticed what I was expecting. CMP would go in two different rasterlines, but the rasters were unstable again. When I've moved the cmp back for 3-4 cycles, it worked. Yes, my routine works, but I need to know what the heck is going on.

Puterman: You said I can find docs about this tech. at more places. I only know about the C=Hacking mag. Will you drop some more links? (in case it's not the same doc by Marko).

And finaly the sprite + inc method: I think I understand the principle. But I think that Pasi has made some mistakes. He said the INC does not need the bus during cycle 5 of the op-code. According to "64doc" the processor makes a write access. Since Pasi used INC and DEC, this means that we have two write cycles (from the INC) and then three read cycles (from the DEC). This opcodes should execute somewhere when the VIC needs to fetch the sprite pointer. During the 'Bus Request Pending' it can only execute the write cycles and stops on first read cycle (the DEC). So DEC will execute after the VIC has finished fetching the sprite pointer. (This is the way I understand the trick. Plz correct me if I'm wrong).
2002-12-30 13:54
Puterman
Account closed

Registered: Jan 2002
Posts: 188
Cybernator: I think there's some example code at http://www.ffd2.com/fridge/.
2002-12-30 17:01
CyberBrain
Administrator

Posts: 390
@cybernator: damn, i must have messed those 2 up then. It's been too long.. Gotta check my sources.
2002-12-31 12:24
Stryyker

Registered: Dec 2001
Posts: 465
I never thought of using $D011 method. The DMA delay issue doesn't always happen as easy as it seems. I had to do it in a FLD gap (idle gfx state). Another method is to use the CIA timer registers. I haven't figured out how they get it started. Lightpen X register can be used. It got messed up if space was pressed. Maybe some DDR of $DD02/$DD03 might fix that. I use the simpler double interrupt with first padded with NOPs.

With 8 sprites on screen check the timing charts - you need to simply shift the read forward some bytes. C= Hacking has it. I think 64doc or some other Marko text had it. I did plan to do this in a disk magazine but the coder who was to write about the methods I don't know has been very busy. I know in the past some writes to memory have made getting an interrupt stable a nightmare. Some effort and it'll all work out fine. Don't try to be too complex. If Singles Collection volume 2 was released then you would see a very simple double interrupt with $D012 comparing for the scroller stretcher.
Previous - 1 | 2 - 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
Viti/Hokuto Force
CA$H/TRiAD
jmin
radius75
Oxbow/Xenon
Guests online: 83
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

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