| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
Mixing multiple effects is messing up stuff
I am doing a small and very lowtech demo but I seem to be confused about the raster timing - probably like any other C64 newbie out there(?).
I know(?) this is related to the raster interrupt I am using plus my routines and that everyone will shout out "learn to code before you do a demo" and you are right but I really need some directions or hints here as I cannot get my head around this problem. I have read a lot on the C64 Codebase and here in the forum but still I don't get it (no hope for me!?).
I am trying to get a static (not moving) rasterbar below a 2x2 scroll plus some music - this must be "demo programming day 1". I have done each part individually and they work but together they are screwing up things (of course!?). Well, the music and the 2x2 scroll I can get working but introducing the raster gets ne problems.
What I have is a rasterbar... fired up at raster pos #$80 (as an example). A few lines below I am starting my scroll and this is totally messing up things... the scroll is veeery slow and shifting between the 2x2 charset and the system charset and when playing music I can hear it is slowing down to 1/4 of the normal pace or alike. This must be because the rasters are overlapping but how can I overcome this?
This is not a matter of getting the rasterbars looking nice but a more fundamental problem I think - then the prettyness of the bars will be a problem for later on.
If anyone would explain me how or point me to a fool-proof-dummy-guide on how I might can solve this I would really appreciate it as I am getting really frustrated now and I don't see any solutions for it (though there obvioulsy is one). |
|
| |
Stainless Steel
Registered: Mar 2003 Posts: 966 |
wrap your routines in inc/dec $d020 to visualize the rasterusage in the frame and adjust accordingly. |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
Post a link to your code and someone may be able to make a quick peek into the code and give some advice on obvious improvements or comments on errors in your way of understanding how things work on the c64. |
| |
terric Account closed
Registered: Feb 2009 Posts: 47 |
What Stainless and Frantic sad and ---->
It sounds like you are firing the irq at line 70 and
tries to play music and scroll until raster 80.
This may not be rastertime enough for your routines and music.
Instead i suggest fire-off irq at raster 80, make the rasterbar, scroll the scroll and play the music at last.
terric |
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
I have put my code here, http://cobrakid.dk/asm/mydmo1-asm.txt - this one here is actually working (with HEAVY flickers but that's not my concern for now) as it doesn't take correct rasterbar position into consideration. If I change this in the main section:
lda #$03
sta $d020
jsr raster ; show raster
lda #$00
sta $d020 to this (this has the rasterbar in the correct pos):
lda #$7a
w1 cmp $d012
bne w1
lda #$03
sta $d020
jsr raster ; show raster
lda #$00
sta $d020 .. then everything is going crazy - due to overlapping raster lines.
I have also tried to put this in to multiple interrupts with this:int1
..mycode.. (raster+music)
lda #<int2
sta $0314
lda #>int2
sta $0315
jmp $ea81
int2
..mycode.. (scroll2x2)
lda #<int1
sta $0314
lda #>int1
sta $0315
lda #$ff
sta $d019 ; clear irq
jmp $ea81 .. but I am not sure I fully understand this as it still looks to be running sequentially to me (not correct irq routine probably?)? Isn't it just setting the IRQ addr to either one of the labels - it doesn't state when it should fire it off?
I hope I can get some hints to solve this - thanks a lot in advance. |
| |
ready.
Registered: Feb 2003 Posts: 441 |
try to avoid this:
lda #$7a
w1 cmp $d012
bne w1
instead use:
lda #$7a
w1 cmp $d012
bcs w1
since if you have a bad line you don't always see $d012 incrementing by one, but it increments by 2.
not sure this will help, but give it a try.
|
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
@ready - this actually helped... at least the music is playing normally and the scroll is moving on top of the rasterbar. The scroll is though now a hardscroll (not smooth) and the charset is the system charset but I suspect I am messing up the $d016 and $d018 registers(?).
OK, so to understand this, then BCS will continue if the carry flag is set... which means if it has surpassed the value? |
| |
ready.
Registered: Feb 2003 Posts: 441 |
glad it worked!
Subtraction:
x-y=z, carry=1 if y>x; carry=0 if y<=x
remeber how you did the subtraction in first grade, by hand? the carry works exactly like that!
example given:
carry 1
100-
98=
----
002
|
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
OK, I get it - this is also translated into (lda=x, cmp=y): lda #122
w1 cmp $d012 ($d012=#121)
bcs w1
(this one loops 2 times)
---
lda #122
w1 cmp $d012 ($d012=#122)
bcs w1
(this one loops 1 time)
---
lda #122
w1 cmp $d012 ($d012=#123)
bcs w1
(this one continues right away) OK, I get the idea, that I need to check for bad-lines also when polling $d012. |
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
Now I just solved this so everything is stable and looks good. The only thing I don't fully understand is the double-interrupt. Here is my code:int1
jsr raster ; starts at pos #$7a
lda #<int2
sta $0314
lda #>int2 ; start the
sta $0315 ; second IRQ
jmp $ea81
int2
jsr scroll2x2 ; awaits raster pos #$82
jsr $1003 ; play music afterwards
lda #<int1
sta $0314
lda #>int1
sta $0315
lda #$ff
sta $d019 ; clear our irq
jmp $ea81 1) Why shouldn't I clear the IRQ in "int1"?
2) Does this generates two IRQs or is it just running sequentially? I may be misunderstanding this.
3) Is this stable because of pure luck(!) or because I have moved the scroll and music into its own IRQ and thereby they get their own timing?
4) Can I have many more interrupts... fx. "int3" for a second scroll (if the timing mess up things having it in "int2")? |
| |
ready.
Registered: Feb 2003 Posts: 441 |
could you please post all your code for us to understand? What is "jsr raster" doing?
and I don't see why you shouldn't clear the IRQ flag in irq1. |
... 21 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 | 4 - Next |