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 > Sprite synchronisation
2008-10-06 17:36
Barbarossa

Registered: May 2007
Posts: 31
Sprite synchronisation

I am trying to get a stable raster with the help of sprite timing. I've read the articles in C=hacking about it, but it is not explained in full detail there. That is, when I look at the examples Missing Cycles and TechTech, I don't quite get it.

I've tried the timing of those examples in an emulator. I have found out that when the INC ends within the cycles that BA goes low, the intruction ends exactly after the sprite fetch. This would mean that the interrupt cannot be more off than 3 cycles and we all know that we have to deal with 2-9 cycles (7 cycles variance). So how can this trick be stable?

If someone could explain this to me (an article about this in Codebase would be really neat) I would be very grateful.

John
 
... 22 posts hidden. Click here to view all posts....
 
2008-10-06 21:19
chatGPZ

Registered: Dec 2001
Posts: 11386
the theory on how it works is pretty simple... as you probably know sprites steal cycles from the cpu (for details check the vic article). now the basic idea is to execute RMW instructions in the rasterline(s) where said sprites are displayed. the "missing" cycles will force those instructions to get executed in the "gaps" left by the sprites, which in turn will magically stabilize the whole thing. now how many sprites you use and what kind of instructions you execute in what order to stabilize is up to you (there are many ways to make this work).
2008-10-06 22:04
Cybernator

Registered: Jun 2002
Posts: 154
@Barbarossa: As far as I can tell, you know how the method works, but you don't understand how it is possible to achieve this with just a single sprite and a single INC instruction.

This is Pasi Ojala's border routine, no? I think it just happens by accident that the jitter is small. Try scrolling the screen by hold crsr-down for a while and watch that strange flicker in the letters. :)
2008-10-06 22:11
chatGPZ

Registered: Dec 2001
Posts: 11386
yeah with sprites you often get stable behaviour "by accident" ... like tlr said, this was quite common on the old days when coders often didnt quite exactly know what they were doing =)
2008-10-07 00:55
Krill

Registered: Apr 2002
Posts: 2980
I guess the main question here is, is it actually possible to achieve a stable raster within one scanline using only one sprite? I'm skeptical. If so, somebody please explain thoroughly. :)
2008-10-07 05:18
Radiant

Registered: Sep 2004
Posts: 639
Krill: I've done it, but only with deterministic jitter (jmp *). Makes it kinda pointless. :-)
2008-10-07 06:12
Oswald

Registered: Apr 2002
Posts: 5094
hmm maybe it is possible to make faster stabilization with sprites than with cia? :)
2008-10-07 06:49
Radiant

Registered: Sep 2004
Posts: 639
Krill: Of course, if by "within one line" you mean "within the same line as the raster IRQ occurs", then it's impossible (no possible write cycle when BA is low until cycle 59 or something).

Now, if you use timer IRQ's...
2008-10-07 07:52
Barbarossa

Registered: May 2007
Posts: 31
Quote: @Barbarossa: As far as I can tell, you know how the method works, but you don't understand how it is possible to achieve this with just a single sprite and a single INC instruction.

This is Pasi Ojala's border routine, no? I think it just happens by accident that the jitter is small. Try scrolling the screen by hold crsr-down for a while and watch that strange flicker in the letters. :)


Yes, I already noticed that. :-)
But this was on CCS64. I got real sinuses there instead of letters. When I tried it in Vice it was a lot more stable so I blamed the emulator. :-)
I also noticed that the IRQ-entry was always around the same point, which make sense since the only activity in the demo is a blinking cursor. But I thought Pasi would have taken more jitter into account of his routine (I thought it was a universal routine).

@Quasar
I have read that article. My question is based upon it. Although it is clear theoretically. He is not clear in explaining his own program.

So basically it is not possible to get a stable raster with one sprite on one line? You need more than one sprite and several rasterlines.
2008-10-07 08:26
Frantic

Registered: Mar 2003
Posts: 1648
Btw... What IS the *fastest* (and preferablly reasonably generally applicable - with any kind of "main loop" running etc) way of achieving a stable interrupt?

Is it to use a Timer and JMP/branch depending on the value of the timer? Are there other methods which are faster? No?
2008-10-07 08:36
Krill

Registered: Apr 2002
Posts: 2980
Oswald: I don't think so, because that one sprite alone already eats at least 3*21 cycles - if you can use it for your actual raster routine, it may pay off though.. maybe :) But as groepaz already said, with a mainloop like jmp * irq's are pretty much nonsense.

Radiantx: Only if it's a raster irq. Different if it's a timer irq firing somewhere in the middle of a rasterline.

Frantic: According to my experience, the fastest way is a raster irq, followed by an indirect jump through one of the timer registers, with 8 differently timed routines to branch to.
Previous - 1 | 2 | 3 | 4 - 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
marley
Shogoon/Elysium/MSL
rexbeng
Jazzcat/Onslaught
Guests online: 122
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

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