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
2008-10-06 17:44
chatGPZ

Registered: Dec 2001
Posts: 11386
if i recall correctly, put 4 sprites on same Y position, put rasterirq on same position, then do a few INC there and the irq will be magically stable after one line or so :)
2008-10-06 17:55
tlr

Registered: Sep 2003
Posts: 1790
With 8 sprites and INC/DEC or DEC/INC $d016 timed to 46 cycles it will syncronize automatically in a few lines.
This was frequently used to implement sideborder stuff in the early days when double IRQ stable rasters weren't as common.
2008-10-06 17:59
Zaz
Account closed

Registered: Mar 2004
Posts: 33
If you know what kind of instructions will be used when the interrupt triggers, it becomes easier. E.g. if your non-interrupt code does this:
forever:
           jmp forever

the variance should be 0-3 cycles, right?
2008-10-06 18:01
chatGPZ

Registered: Dec 2001
Posts: 11386
with a mainloop like this you dont need a irq in the first place =D
2008-10-06 18:05
Barbarossa

Registered: May 2007
Posts: 31
When I use more sprites or more INC/DEC's I can probably get it to work, but how can the following code from C=hacking work then? It only uses one sprite and one INC.

irq:
lda #$13 // open the bottom border (top border will open too)
sta $d011
nop
bit $11
ldy #111 // reduce for ntsc ?
inc dummy // do the timing with a sprite
bit $ea // wait a bit (add a nop for ntsc)
loop3:
lda tech,y // do the x-shift
sta $d016
...

The raster is stable from loop3.
2008-10-06 18:06
Barbarossa

Registered: May 2007
Posts: 31
Quote: If you know what kind of instructions will be used when the interrupt triggers, it becomes easier. E.g. if your non-interrupt code does this:
forever:
           jmp forever

the variance should be 0-3 cycles, right?


LOL, yeah unfortunately it isn't that simple.
2008-10-06 18:22
Oswald

Registered: Apr 2002
Posts: 5094
try this instead:

http://codebase64.org/doku.php?id=base:double_irq

shortly: the first irq it initiates a 2nd one, while the 1st irq executes nops the 2nd one will hit => only 1 cycle jitter left which is ironed by watching $d012 wether its in the current or the next line.
2008-10-06 18:31
chatGPZ

Registered: Dec 2001
Posts: 11386
somehow i get the impression that he knew that already when he explicitly asked about how to do it with sprites (which indeed can be better in some cases)
2008-10-06 18:31
Danzig

Registered: Jun 2002
Posts: 440
Quote: If you know what kind of instructions will be used when the interrupt triggers, it becomes easier. E.g. if your non-interrupt code does this:
forever:
           jmp forever

the variance should be 0-3 cycles, right?


not to forget the magic "jsr *" resulting in stable raster.
2008-10-06 20:46
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: not to forget the magic "jsr *" resulting in stable raster.

I see a corrupt stack... Please enlighten me. :D
 
... 22 posts hidden. Click here to view all posts....
 
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
Peacemaker/CENSOR/Hi..
Soya/Fairlight
Andy/AEG
megasoftargentina
BYB/Hokuto Force
t0m3000/hf^boom!^ibx
Conjuror
kbs/Pht/Lxt
zscs
XmikeX
Brataccas/HF
rexbeng
Guests online: 146
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 Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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