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 > Mixing multiple effects is messing up stuff
2011-11-08 22:29
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).
 
... 21 posts hidden. Click here to view all posts....
 
2011-11-09 01:26
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.
2011-11-09 06:27
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
2011-11-09 10:29
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.
2011-11-09 10:47
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.
2011-11-09 11:32
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?
2011-11-09 11:45
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
2011-11-09 12:05
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.
2011-11-09 12:55
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")?
2011-11-09 13:03
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.
2011-11-09 13:12
Cobrakid

Registered: Oct 2011
Posts: 23
Full code here, http://cobrakid.dk/asm/mydmo2-asm.txt

When clearing the IRQ in "int1" I get into the same problems as in the beginning - everything goes 1/4 of the normal speed.
Previous - 1 | 2 | 3 | 4 - 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
REBEL 1/HF
Retroluzzer/Quantum
zscs
Act-Otl/Outlaws
rexbeng
Guests online: 95
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 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.04 sec.