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 > $d013 sync ??
2009-08-21 14:21
andym00

Registered: Jun 2009
Posts: 45
$d013 sync ??

Okay, be nice, I've been away from the C64 for over 20 years and I thought this would be easy having seen it mentioned once on here... I cobbled this together a few weeks ago, and now when I've just tried it out again I'm getting variable results, regards getting to a stable clock cycle..
		lda #16		
		sta $dc01
		lda #0
		sta $dc01
		lda $d013
		lsr		
		lsr		
		adc	#17+13	
		lsr		
		sta bm + 1	
bm:		bne *		
		!for .count, 30 {
			nop
		}
		bcs +	; if carry set 3 cycles, if clear 2 cycles..

Okay, so maybe it might be out by a constant amount of cycles, but it's all over the place..
Does this technique actually work (by creating a button press to trigger the light-pen) or have I misunderstood from what little tidbits have been mentioned here ?
I examined a load of demos and don't see much messing with $d013, so I'm guessing maybe I've got the wrong end of the stick, but this should work in theory right ?
I only want it for stablising some CIA IRQs, and I know there's other ways to do it, but this just seemed like something I should give a go, but it's borked :)
2009-08-21 15:45
chatGPZ

Registered: Dec 2001
Posts: 11386
here is a working routine (used this last time over 10 years ago, forgot how exactly it works =P)

.scope
         lda $d019
         sta $d019
         ldx #$ff
         ldy #$00
         stx $dc00
         sty $dc02
         stx $dc03
         stx $dc01
         sty $dc01
         stx $dc01
         lda $d013
         stx $dc02
         sty $dc03
         stx $dc01
         ldx #$7f
         stx $dc00
         lsr a
         lsr a
         lsr a
         sta timeout+1
         bcc timing
timing:  clv
timeout: bvc timeout
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop

         rts

.endscope
2009-08-21 18:08
Graham
Account closed

Registered: Dec 2002
Posts: 990
The $D013 sync has a major disadvantage: If you press space, it does not work. Better synchronize via double IRQ.
2009-08-21 19:38
algorithm

Registered: May 2002
Posts: 705
Thats interesting

I assume that this is inside the IRQ and that things would sync properly at the end of the routine? Would sprites affect the syncing of this somewhat. Double IRQ is always a better approach, but the above seems somewhat cleaner.
I would not think it would be that much of an issue to not press spacebar (unless it is a 'press space' to continue' demo)
2009-08-22 00:26
chatGPZ

Registered: Dec 2001
Posts: 11386
ofcourse the syncing is affected by sprites... and also by badlines (or what ever else disturbs the timing)
2009-08-22 09:05
Graham
Account closed

Registered: Dec 2002
Posts: 990
I don't think that inverting the CIAs keyboard matrix direction to cheat the VIC into thinking the lightpen has triggered is somewhat "clean" :)

Btw it would be interesting to know who invented this routine. I've first seen it in 64'er magazine issue 11/88.
2009-08-22 09:21
Radiant

Registered: Sep 2004
Posts: 639
I think I've seen stable rasters referred to as "lightpen rasters" in some early demo; perhaps that was the first known method of stabilizing?
2009-08-22 10:38
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
I've first seen it in 64'er magazine issue 11/88.


hannes sommer .... (and the routine above is exactly his, copied from said 64er =))
2009-08-22 14:05
andym00

Registered: Jun 2009
Posts: 45
Thanks Groepaz, that works a treat, and I hunted high and low for that original article from Hannes curious to see how he originally wrote it.. Now I know :)
I just wanted a nice clean way to setup CIAs at startup to the exact cycle I wanted, and if the users presses space then woe betide them ;)
I only wanted to try this way because I never had done before and I liked the idea of it..
2011-07-12 07:47
ready.

Registered: Feb 2003
Posts: 441
I am coding a full screen sprite mux, showing sprites on char screen+upper+lower border (not the side boreders) and I need to have a stable raster even in the lower border area where $d011 MSB is at 1.

I think this $d013 stabilizing code is much more handy than double-irq for working in the raster area over $0ff to $137, since you don't need to care about setting $d011. Usually double-irq method just calls for inc $d012, for triggering stable irq on next line, but this does not work in the lower border.
2011-07-12 10:02
Radiant

Registered: Sep 2004
Posts: 639
Of course it works in the lower border. The only time it doesn't work is if you're putting the initial IRQ on line $ff - then you need to set $d011 as well. Workaround: don't do that. Other than that, inc $d012 will work just as fine in the lower border as anywhere else on the screen.
 
... 6 posts hidden. Click here to view all posts....
 
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
Mike
LKP/CFN
kbs/Pht/Lxt
Aomeba/Artline Desig..
zscs
Lazycow
TheRyk/MYD!
t0m3000/hf^boom!^ibx
Case/Padua
St0rmfr0nt/Quantum
MWR/Visdom
Chesoner/House Designs
katon/Lepsi De
The Syndrom/TIA/Pret..
Youth
Guests online: 132
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 NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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