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 > Horizontal d020 scroller
2015-02-04 21:15
xIII

Registered: Nov 2008
Posts: 210
Horizontal d020 scroller

I'm still learning ... and again I could use some advice.
I coded a d020 scroller that actually works :p

I'm having trouble with the stability (the scroller is jittering ?). I used the double IRQ routine but I just cannot get the timing correct.

If there's a coder out there who wants to help me by taking a look at the code, send me a msg with your email and I'll send you the kickasm code.

thanks.
2015-02-05 14:53
Oswald

Registered: Apr 2002
Posts: 5094
*if* the double irq is working you must have only 1 cycle jitter left. do this with the 1 cycle jitter:

lda $d012
sta $d020

by adding/removing nops bit $xx, etc. find the place (right edge of screen) where d020 color flickers, then you found the place where the raster counter is 'flickering' between two lines.

there you have to add this line:

lda $d012
cmp $d012 ;<- place of lda $d012 of prev code in timing
beq next
next

this adds +1 cycle when needed.

sometimes it was bne next, but never tought about it why, just hacked the code mindlessly. :o)
2015-02-05 14:57
Ninja

Registered: Jan 2002
Posts: 411
Double-check if all indexed addressing modes do not cross a page border. Also check if all branch instructions do not cross a page border. Especially the latter can easily slip through, so most people have a macro checking this for branches in timing sensitive code.
2015-02-05 21:47
xIII

Registered: Nov 2008
Posts: 210
Oswald: good tip. Double IRQ routine seems to be OK, this is confirmed by Flavioweb who was so kind to take a look at the code.

Flavio explained the problem and I'm trying to work out a solution.

I'm not sure if I understood it all very well but it seems that it has something to to with delaying cycles every frame.
2015-02-06 10:59
Flavioweb

Registered: Nov 2011
Posts: 463
Code is stable and works as it should.
The "glitch" is caused by a not complete "scroll" routine that, for now, -move- chars simply updating the "sta" for bgcolor in an "hardcoded" way, without modify the starting cycle for each frame.
This mean that the minimum step is 4 cycles, so 32 pixels, and this cause a poor scroll movement.
XIII should implement an "intermediate cycles delay" code, to cover 4 steps, each with 1 cycle difference from previous, to achieve a more "smooth" scroll fx.
I suppose this can be done with some self-modify code, that update itself, accordingly with a step-counter.
Same as is done with normal scroll routine, but done with cycles and for only 4 steps instead of 8...
I think is more simple to code that explain it...
2015-02-06 18:01
xIII

Registered: Nov 2008
Posts: 210
I came up with this routine:

		ldx timer1    // 3-2-1-0					2
		dex			// 2-1-0-ff					2
		bpl *+2			// taken-taken-taken-not	3-3-3-2
		dex			// 1-0-ff-fe				2
		bpl *+2			// taken-taken-not-not		3-3-2-2
		dex			// 0-ff-fe-fd				2
		bpl *+2			// taken-not-not-not		3-2-2-2
					// ------------------------>17-16-15-14


Later in the code:

		dec timer1
		bmi resettimer1 and do scroll
		jmp endirq



This helped for a smoother scoll but it still is not smooth enough.
2015-02-07 04:55
Flavioweb

Registered: Nov 2011
Posts: 463
You used this code just before "line1"?
Keep in mind that minimum "resolution" possible is 8 pixels, but this should give a decent scroll movement...
Ps: you have a mail. Give a look.
2015-02-09 21:32
xIII

Registered: Nov 2008
Posts: 210
Found this routine in Krestage which also does the trick (code is a little modified to my needs):

self_mod:	
		cmp ($00),y
	    jmp line1_entry                      // 59
    
delay:
		ldx timer1
		lda cycle,x
		sta self_mod
		rts

cycle: .byte $d1,$c9,$c5,$d5
2015-02-10 06:17
Flavioweb

Registered: Nov 2011
Posts: 463
Ok.
Nice way to do it.
With cycles in correct sequence, it should work as well...
2015-02-10 07:14
Oswald

Registered: Apr 2002
Posts: 5094
use this:

	sta timeit+1
timeit        bpl timeit+2
	.byte $a9,$a9,$a9,$a9,$a9,$a9,$24,$ea


by changing how far bpl jumps (sta timeit+1), you can change in a cycle exact way how much cycle is wasted. trick is that the last few bytes alternatively translate into bit $ea, or lda #$24 nop, giving one by one increments of extra cycles as you go.

code snippet from a 4x4 irq by ninja.
2015-02-10 13:40
Bitbreaker

Registered: Oct 2002
Posts: 508
take care of having a cia detection if you do things by timer though.
2015-02-12 10:05
Krill

Registered: Apr 2002
Posts: 2980
Quoting Bitbreaker
take care of having a cia detection if you do things by timer though.
This is why i prefer VIC rasterline interrupt + jitter correction via reading a CIA timer (which does not require handling different CIA revisions), rather than having CIA timer interrupts. Unless the former is not feasible for some reason.
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
Jammer
csabanw
Flex/Artline Designs
Chrx/Design/Chaos
Guests online: 99
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 Triad  (9.3)
5 Censor Design  (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.06 sec.