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
2004-07-20 08:18
Stryyker

Registered: Dec 2001
Posts: 468
Walk through it remembering the CPU will delay somehting like 1 cycles then it executes your code. On top of that it could be delayed by an opcode when the IRQ happens. They delay could be up to 6 or so cycles.

Did you read the VIC Artikle (sic)? From this and CBM Hackers you should learn enough to create a stable raster. Maybe you could walk us through your code and reasons/logic so we can correct you. $D012 is only the Y position. So by the time your code executes it could be anywhere along the line - hence why people have various methods. I personally use the double IRQ method. It creates a 1 cycle jitter which is normally easy to fix.
2004-07-20 08:22
Trash

Registered: Jan 2002
Posts: 122
This IS the double IRQ-method, just modified to be small and simple to use.
When you get to the label 'newrow', I create the one-cycle-delay by executing a bunch of nops ($ea). So in practice both of us are using the same routine, but my version seems to have a flaw somewhere :-(
2004-07-20 08:33
Ninja

Registered: Jan 2002
Posts: 411
So, what happens? Small jitter, heavy flickering (I am too lazy to type it in ;))? From a glimpse, following suggestions:

After 'LDA #$7F, STA $Dx0D', always do 'LDA $Dx0D' to clear the latch.

You change the vector $FFFE/F (is $01 set to $35?) and return from interrupt with $JMP $EA81. Should give you nice stack problems :)
2004-07-20 08:46
Oswald

Registered: Apr 2002
Posts: 5094
at first you should add before cli:

lda #$35
sta $01
lda $dc0d
lda $dd0d

second:

uhh this code is a mess.. the same routine for 2 purpose :)

test this code wether its at the right X position on the screen:

cmp $d012 ;
beq *+2 ;

by changing it to:

lda $d012
sta $d020

(remove all other d020 writes)

now adjust timing until the border keeps flashing, then you found the timing for the cmp.

third thing:

jmp $ea81 will do something like: pla tay pla tax pla rti, but you havent saved anything to the stack at the start of the irq!! so use a rti instead.


2004-07-20 10:20
Trash

Registered: Jan 2002
Posts: 122
Thanks for your help, now all I have to do is remember how bankswitching worked, but that I'll do on my own.

Oh, the when finished looks like this, just so noone else will bug you about unstable rasters :-):
* = $0801
.byte $0c, $08, $00, $00, $9e, $20, $32, $33
.byte $30, $34, $00, $00, $00, $00, $00, $00

* = $0900
;-------------------------------------------------------------------------
rasterrow = $4d
;-------------------------------------------------------------------------
sei
lda #$7f
sta $dc0d
lda $dc0d
lda #rasterrow
sta $d012
lda #$1b
sta $d011
lda #1
sta $d01a
sta $d019
lda #$35
sta $01
lda #<stableraster
sta $fffe
lda #>stableraster
sta $ffff
cli
jmp *
;-------------------------------------------------------------------------
stableraster
lda #rasterrow
cmp $d012
beq newrow
dec $d012
inc $d019 ; Trigger a new interrupt
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea, $ea
.byte $ea, $ea, $ea, $ea, $ea, $ea
adc #1
cmp $d012
beq * + 2
;-------------------------------------------------------------------------
jsr maincode ;
rti ; 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
rts
2004-07-20 14:00
Oswald

Registered: Apr 2002
Posts: 5094
We're glad we could help :) But I guess everyone likes to do his own routine, even with help, so probably this wasnt the last topic about it :)
2004-07-20 15:38
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Don't do cmp xx for D012, it's a waste if time, instead just write a new D012 and new intvector, then it skips to that line immediately. Last int then points to the first (0314/15 fffe/ff)
2004-07-20 18:38
Trash

Registered: Jan 2002
Posts: 122
Well, since that time is going to be wasted anyway I'll figured I could use it to trigger the next interrupt and it seems to work without any problems. So I'll problably keep the code as it is now since it's quite compact, works fine and it fit my purposes.
2004-07-20 19:49
Cruzer

Registered: Dec 2001
Posts: 1048
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.
2004-07-20 19:58
TDJ

Registered: Dec 2001
Posts: 1879
"(Only tested in Vice since my C128 and C64 ain't allowed in the livingroom according to my better half)"

I think you need a better better half more than you need stable rasters :)
 
... 8 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
Guests online: 87
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 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.16 sec.