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 > Raster line cycle 0 != cycle where raster irq is triggered?
2012-04-03 10:34
Flavioweb

Registered: Nov 2011
Posts: 447
Raster line cycle 0 != cycle where raster irq is triggered?

I'm writing a raster irq routine where using this loop
lda #rasterline
cmp $d012
bne *-3

and the polling raster method to set up cia timer for raster stabilization.
During my debug section, on pal machine, i noticed that after my polling routine, if i put code to reach rasterline-after-polling+1 on 4th cycle of a lda $d012, i need 64 cycles in total.
This is perfect: 63 cycles of current line + 1 cycle in new line.
But if i try, on the line where raster irq is triggered, to reach next line, i have to use only about 56 cycles, but from raster trigger line+2 to +3 i must use 63 cycles in total again.
No code outside irq, of course.
Also taking care about 3 cycles jitter of an endless loop, this mean that first cycle of first opcode in irq routine isn't executed near first cycle of rasterline, but about 5-6 cycles after.
Or isn't it?
 
... 1 post hidden. Click here to view all posts....
 
2012-04-03 12:53
Flavioweb

Registered: Nov 2011
Posts: 447
so it's correct if i say that on rasterline where irq is triggered, there are only 56 cycles available,
and from these cycles we need to subtract also the jitter before first opcode of irq routine it's executed?
2012-04-03 13:30
Frantic

Registered: Mar 2003
Posts: 1628
Yes, I suppose you could put it that way if you like. Jitter is separate from the cycles consumed by the IRQ stack pushing etc that Graham mention.
2012-04-03 14:26
Flavioweb

Registered: Nov 2011
Posts: 447
ok. I understand.
I know that those 2 delays are caused by 2 different things.
I just wanted to know if this 7 cycles delay i found using my routine exist, or i caused it by wrong coding...
But seems that exist...
=)
2012-04-03 15:37
MagerValp

Registered: Dec 2001
Posts: 1059
The IRQ is triggered on cycle 0 (naturally depending on which cycle you define as 0… :), it then takes 2-9 cycles for the current instruction to finish executing, then it takes 7 cycles for the CPU to save status and PC registers and jump to the IRQ vector. This leaves you 47 cycles left on the rasterline where the IRQ was triggered.
2012-04-03 20:55
Flavioweb

Registered: Nov 2011
Posts: 447
Quote: The IRQ is triggered on cycle 0 (naturally depending on which cycle you define as 0… :), it then takes 2-9 cycles for the current instruction to finish executing, then it takes 7 cycles for the CPU to save status and PC registers and jump to the IRQ vector. This leaves you 47 cycles left on the rasterline where the IRQ was triggered.

My definition of "cycle 0" in a PAL system is "that cycle after wich there are other 62 cycles before reaching new raster line".
Said this, in your post you consider a jitter of 9 cycles, that include also illegal opcodes, right?
So: 9+7 (worst case) = 16 = 63-16 = 47.
9 cycles "before" those "47" are jitter, so they may be or not be, but the "7 cycles for the CPU to save status and PC registers and jump to the IRQ vector" are -fixed-.
So 47+9 = 56 and assuming a minimum of 2 cycles of jitter, at maximun (best case) 54 cycles are available on line where IRQ is triggered.
Concluding:
best case 54 cycles
worst case 47 cycles available on raster trigger line.
what i thought is correct?
2012-04-04 06:19
MagerValp

Registered: Dec 2001
Posts: 1059
No, 2-9 cycles of delay means 7 cycles of jitter, and does not consider illegal opcodes.
2012-04-04 06:46
Flavioweb

Registered: Nov 2011
Posts: 447
Quote: No, 2-9 cycles of delay means 7 cycles of jitter, and does not consider illegal opcodes.

...mumble...mumble...
How do you reach the '47 cycles' available?
Irq triggered on cycle 0
7 cycles jitter in worst case
7 cycles for saving etc...
63 - 14 = 49 availables.
What are others 2 cycles used for?
2012-04-04 07:04
Fresh

Registered: Jan 2005
Posts: 101
You need to consider delays: the jitter is 7 but the delay, as Magervalp's written, is 2-9. Add to this the delay of 7 due to IRQ call and you get a total of 9-16 cycles which, in turn, means you get 47 (worst case, delay of 16) to 54 (best case delay of 9) free cycles per line (no badline, no sprites).
2012-04-04 07:33
Flavioweb

Registered: Nov 2011
Posts: 447
these 2 cycles then come from the fact that cpu goes to irq if it is triggered almost before last 2 cycles of currently executed opcode, otherwise also next opcode is executed...
right?
2012-04-04 07:42
Fresh

Registered: Jan 2005
Posts: 101
Yes, you can consider a fixed delay of 2 cycles due to the way 6510 schedules interrupts in the execution flow.
Once an irq is called 2 cycles are *always* skipped then it depends on where the cpu finds itself and you get the overmentioned 0-7 delay. As MaverValp's stated you may consider 0-8 with illegal opcodes (DCP x indexed IIRC).
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
Scrap/Genesis Project
Alakran_64
X2themax
csabanw
Unlock/Padua/Albion
Guests online: 86
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 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (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 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Elwix  (9.1)
5 A Life in Hell  (9.1)

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