Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user eightbitswide ! (Registered 2024-12-24) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Stable rasters, again...
2004-07-20 08:05
Trash

Registered: Jan 2002
Posts: 122
Stable rasters, again...

I'm really no newbie at this and I've got a few ideas for some new parts I want to put together but I can't seem to get my rasters stable.

Here's the code, what am I doing wrong?

(Only tested in Vice since my C128 and C64 ain't allowed in the livingroom according to my better half)

* = $0900
;-------------------------------------------------------------------------
rasterrow = $fb
;-------------------------------------------------------------------------
sei
lda #$7f
sta $dc0d
lda #<stableraster
sta $fffe
lda #>stableraster
sta $ffff
lda #rasterrow
sta $d012
lda #$1b
sta $d011
lda #1
sta $d01a
sta $d019
cli
jmp *
;-------------------------------------------------------------------------
stableraster
lda #rasterrow ;2
cmp $d012 ;6
beq newrow ;8 / 9
dec $d012 ;14
bit $ea ;17
nop ;19
adc #1 ;21
cmp $d012 ;
beq *+2 ;
;-------------------------------------------------------------------------
inc $d019 ;Trigger a new interrupt
jsr maincode ;
jmp $ea81 ;done
;-------------------------------------------------------------------------
newrow
inc $d012 ;
inc $d019 ;Trigger a new interrupt
cli
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea ; 16 * 2 = 32
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea ; 16 * 2 = 32
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea ; 16 * 2 = 32
jmp *-48
;-------------------------------------------------------------------------
maincode
inc $d020
dec $d020
rts
 
... 10 posts hidden. Click here to view all posts....
 
2004-07-20 20:43
Trash

Registered: Jan 2002
Posts: 122
Quote: Now we're talking stable rasters - anyone knows if there's a way to do it if you're not just jumping to * outside the irq, but doing something else that takes more cycles/command? And preferrably a way that doesn't waste too many additional rasterlines ofcourse.

I've got an idea that involves NMI-interrupts, in theory all you need for that idea isto do it this way:

1. Find out which timerchip you're working with (it's my understanding that there are two versions out and that they differ a cycle when interrupting)
2. Stable your rasters the usual way (double irq or whatever)
3. Point a timer interrupt at the code above
4. Prepare the interrupt so it corresponds to the exakt number of cycles your C64 invokes in a screen
5. Start the interrupt so it occurs exactly when you want it to

That could work!

The Dark Judge:
No, what I need is a big house with a playroom for just me :-)
2004-07-20 21:20
trident

Registered: May 2002
Posts: 91
Quote: Now we're talking stable rasters - anyone knows if there's a way to do it if you're not just jumping to * outside the irq, but doing something else that takes more cycles/command? And preferrably a way that doesn't waste too many additional rasterlines ofcourse.

Is that really a problem with the double-IRQ method? The first IRQ should work with any normal amount of cycle jitter and the second IRQ occurs in the midst of NOPs and isn't affected. In any case, it is always possible to do a tripple-IRQ where the first IRQ just invokes a jmp * loop.
2004-07-21 07:35
Oswald

Registered: Apr 2002
Posts: 5094
Trash: your idea wont work, as even NMI has to wait the current instruction to be finished before it can jump to it's routine.

The nicest way is to have an nmi timer count the horizontal cycles of each rasterline. So it runs 0-63 all the time in synch with the VIC. Now when your raster irq starts, you just poll the timer to see how much cycles you are off, and then add the needed delay with a self modded beq/bne. (check reflex's 4x4 routines for example, they use this method)
2004-07-21 09:14
Ninja

Registered: Jan 2002
Posts: 411
Oswald: NMI timer count? Any timer will do :)

The fastest way for a stable raster is probably Double-Timer. Most convenient... way too much ;) Most seem to like Double-IRQ or IRQ+Timer, though.

I give away sources, if someone is interested...
2004-07-21 09:22
Oswald

Registered: Apr 2002
Posts: 5094
ninja:Yeah any timer, just in my mind nmi and timer is connected in a strange way .)
2004-07-21 11:00
Cruzer

Registered: Dec 2001
Posts: 1048
Guess the double irq would work with more instability aswell. Didn't really get it at first actually. :-) I wasn't aware that you could interrupt and interrupt with another interrupt. I have always used two d012-compares to get the raster stabilized.
2004-08-11 04:32
Fungus

Registered: Sep 2002
Posts: 686
Sure you can interrupt an IRQ. or even an NMI.

Just CLI in your irq/nmi routine (as the processor sets this flag when any irq/nmi condition occurs).

This is even used as a protection sometimes.

I like that timer/irq method. But doubel irq is most trustworthy when it comes right down to it. It works weather your on pal or ntsc (provided enough nops are there) , doesnt matter what vic chip revision (pal or ntsc), or CIA revision (pal or ntsc).

www.ffd2.com/fridge/stableraster.txt

;)


2004-08-11 09:22
JackAsser

Registered: Jun 2002
Posts: 2014
I prefer the timer approach since 63-timer value + some offset is actually the X-position of the rasterbeam. This gives you the opportunity to create auto adjusting timing such as when removing the sideborder which requires exact timing plus using an unknown number of sprites flying around which screws up the timing.

/JackAsser
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
Isildur/Samar
iAN CooG/HVSC
MWR/Visdom
MaD ][/Starship
Bieno/Commodore Plus
Guests online: 125
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 X-Mas Demo 2024  (9.5)
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 Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Facet  (9.4)
5 Shine  (9.4)

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