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 > Stable raster with just polling for VBL ($D011)
2025-06-23 23:28
Krill

Registered: Apr 2002
Posts: 3098
Stable raster with just polling for VBL ($D011)

I'm on another platform again and find myself needing to set some video registers with cycle-exact accuracy.

Now, there's only a bit to poll that flags a new video frame - no $D012 equivalent to check for current raster line.

Question is how to set up a stable raster timer for a clock-slide in a nice way.

The naive method, of course, being to wait for VBL in a polling loop, with a jitter of 7 cycles, then delay a frame's worth of cycles minus a few cycles, check VBL flag, add or subtract a few cycles around the video frame delay, check for VBL again, etc., and get the variance down to 0 cycles after about 4 or 5 frames.

Are there more elegant methods?
 
... 5 posts hidden. Click here to view all posts....
 
2025-06-24 17:12
Krill

Registered: Apr 2002
Posts: 3098
Quoting chatGPZ
If you have an irq too, maybe some variation of double-interrupt can work within one (or two?) frames?
Hmm, that's a nice idea. Only need to determine a proper point to JMP (3 cycles) back on the NOP desert.
2025-06-25 13:04
Jetboy

Registered: Jul 2006
Posts: 363
Looking forward to see what you are cooking. Sorry, no more ideas than already mentioned.
2025-06-25 14:53
Krill

Registered: Apr 2002
Posts: 3098
Quoting Jetboy
Looking forward to see what you are cooking.
Thanks! :) Come to Deadline! (Hope we'll make it in time.)
2025-06-25 18:33
tlr

Registered: Sep 2003
Posts: 1814
Quote: Quoting chatGPZ
If you have an irq too, maybe some variation of double-interrupt can work within one (or two?) frames?
Hmm, that's a nice idea. Only need to determine a proper point to JMP (3 cycles) back on the NOP desert.


It's a great idea actually! As for the nop's you could just use a timer to busy wait until a few cycles before the next vb, and then do the nop's.
2025-06-25 23:21
Krill

Registered: Apr 2002
Posts: 3098
Quoting tlr
As for the nop's you could just use a timer to busy wait until a few cycles before the next vb, and then do the nop's.
Sure, but there's little difference in outcome, both in time and code size.

And you'd need to know the frame length (not difficult, but still) and not just the length of a rasterline.

(Both are very freely adjustable on that platform, so things like slightly lowering the frame rate are possible - if your effect almost but not quite updates in a single standard 50-Hz-ish frame. :D)
2025-06-26 09:27
Slammer

Registered: Feb 2004
Posts: 449
I'm curious as to how it is used. As it takes frames to do the stabilizing, Perhaps you just do it once and then make sure the timing is constant the rest of the time? (If so, then the simpler stabilizer code the better - doesn't matter if you do it in a couple of frames less if the code gets unecesary complex.)
2025-06-26 09:40
The Human Code Machine

Registered: Sep 2005
Posts: 114
Never did anything for the PET, but my guess is to make it stable once and then setup a timer for a whole frame or a smaller part like a "raster" line and use the common known routines to make it stable.
2025-06-26 09:54
Krill

Registered: Apr 2002
Posts: 3098
Quoting Krill
set up a stable raster timer for a clock-slide
So yeah, only setting up a timer once at init-time, then use it whenever you need to get to a specific beam X position. That part is just like on C-64.
2025-06-26 10:12
tlr

Registered: Sep 2003
Posts: 1814
Quote: Quoting tlr
As for the nop's you could just use a timer to busy wait until a few cycles before the next vb, and then do the nop's.
Sure, but there's little difference in outcome, both in time and code size.

And you'd need to know the frame length (not difficult, but still) and not just the length of a rasterline.

(Both are very freely adjustable on that platform, so things like slightly lowering the frame rate are possible - if your effect almost but not quite updates in a single standard 50-Hz-ish frame. :D)


good point, but you could quite easily measure the frame time for one frame, then do the sync the next frame. Then you don't need to calculate anything to know how many cycles a frame or line is.
2025-06-26 12:59
Krill

Registered: Apr 2002
Posts: 3098
Quoting tlr
good point, but you could quite easily measure the frame time for one frame, then do the sync the next frame. Then you don't need to calculate anything to know how many cycles a frame or line is.
Needless overhead. :) Line length in cycles is a direct register setting, known pretty much by definition. Frame length... is complex and must be measured or computed, yeah... but for no noteworthy gain in this case.

Edit... hmm... but then the double-irq method pretty much demands knowing exact frame length. But either way, no real difference, i guess.
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
Andy/AEG
Sychamis
map/Plush
zscs
Sokrates
Guests online: 499
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Wonderland XIV  (9.5)
9 Uncensored  (9.5)
10 Comaland 100%  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Performers  (9.3)
4 Oxyron  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Black Beard  (9.2)
3 Baracuda  (9.2)
4 hedning  (9.1)
5 Irata  (8.8)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.049 sec.