| |
xIII
Registered: Nov 2008 Posts: 210 |
Stable Raster routine
A long time ago I coded a small routine which shows some rasterbars moving on the screen (Transparent Rasterbars). I got some help from my mates in WOW with this stable raster routine.
I know that the NOPs are there for cycle timing but I don't understand how it works :(
Can someone explain me how this works?
;--------------------------------------------------
; stable raster routine ?
;--------------------------------------------------
irq INC $D019 ; 6 cycles
LDY #$19 ; 2 cycles
INY ; 2 cycles
INY ; 2 cycles
STY $D011 ; 4 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
LDY #$00 ; 2 cycles
jump01 LDX #$F8 ; 2 cycles
LDA rastertable,Y ; 4+ cycles
jump03 STA $D020 ; 4 cycles
STA $D021 ; 4 cycles
INY ; 2 cycles
INX ; 2 cycles
BEQ jump01 ; 2++ cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
NOP ; 2 cycles
LDA rastertable,Y ; 4+ cycles
CPY #$80 ; 2 cycles
BCS clearrastertbl ; 2++ cycles
NOP ; 2 cycles
NOP ; 2 cycles
CLC ; 2 cycles
BCC jump03 ; 2++ cycles
; ---------------
; 94-102 cycles |
|
... 6 posts hidden. Click here to view all posts.... |
| |
lft
Registered: Jul 2007 Posts: 369 |
http://linusakesson.net/programming/vic-timing/victiming.pdf
Study this chart. Starting anywhere on cycle 15-54 (corresponding to the large red box), you go from non-badline to badline by writing to $d011. This jumps sideways into the red box. As signified by the red colour in the chart, this stalls the CPU, and it will resume execution again at cycle 55. Thus, you stabilise the raster by going from an unknown cycle (within a range) to a known cycle.
Hope this helps! |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
your routine relies on a special "auto" stabilizing effect but it also has a graphical glitch as a sideeffect on the line executed.
the one by TWW starts a raster interrupt, then starts a 2nd raster irq while the first is executing nops, this is done so that an irq interrupting nops will only have 1 cycle jitter. finally the "critical" instruction removes the final jitter. (if the raster counter is on the same line adds 1 more cycle, if its on the next line it doest, because the final jitter is exactly between two raster lines) |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
It's also possible to mix up both things:
Use the dma stabilization trick to setup a cia timer, then use the "inverted timer" trick to stabilize your irq code.
Imho is the simplest way to have a stable raster code without side effects (like fli bug). |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
the double irq thing is much simpler IMHO. but you should be able to do both, of course =) |
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
@xIII/WOW: for simple rasterbars effect you don't need stable rasters. you can use delay table or better
a compact raster routine which take 63 cycles for
normal line/21 cycles for bad line. good luck |
| |
xIII
Registered: Nov 2008 Posts: 210 |
Dr J.: I usually use a delay table, at least I understand how that works ;)
Thanks everyone for the replies and especially for the links and the PDF ! |
| |
HCL
Registered: Feb 2003 Posts: 728 |
Checkout Uncensored for a stable raster routine.. even rotating :) Haha, i just couldn't resist :P. |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
hcl, haha |
| |
Smasher
Registered: Feb 2003 Posts: 520 |
that part with rotating rasters caused the biggest "WOOOOOW!" in the whole democompo! :) (ok, offtopic & I dont care) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
despite that i wouldnt call this drunken mess exactly stable at all! =P |
Previous - 1 | 2 - Next |