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 > how to delay a routine from starting?
2008-12-30 17:39
FillmoreC
Account closed

Registered: Dec 2008
Posts: 7
how to delay a routine from starting?

Lets say I turned the screen black then started music, but i have scroller that I want to delay starting until a certain part of the music. how can I do that.

sort of like

lda #$00
sta $d020
sta $d021
jsr $1000
sei

then set the interupt up and all that

then

irq asl $d019
jsr $1003
jsr scroll
jmp $ea82

scroll
wait until into of the music is done
then scroll
rts




2008-12-30 17:43
Burglar

Registered: Dec 2004
Posts: 1105
use enough spaces at the beginning of the scrolltext?

or you could count frames...
2008-12-30 18:20
Conrad

Registered: Nov 2006
Posts: 849
One way would be to read various memory locations of the music player, particularly the memory dump of where temporary track + sequence data is stored. Though you'll need to look at the music player specifications and code first.

Say for example the track read position indexes are temporarily stored from $1400-$1402. At each frame you could read the contents of $1400 to check what pattern list position track 1 is currently at. If the value meets a specific value to compare, trigger the start of scroller from there.

example code:
  lda #$00
  sta $d020
  sta $d021
  jsr $1000

  ; Init scroller trigger check to 0
  lda #0
  sta triggerscroll+1

  sei
  ; set up irq, blablabla

... ...

irq
  asl $d019
  jsr $1003

  lda $1400    ; Track 1 pattern list position buffer
  cmp #$04     ; Track 1 pattern list position to check for.
  bne *+7
  lda #1
  sta triggerscroll+1      

triggerscroll
  lda #0
  beq *+5
  jsr scroll

  jmp $ea82


... or what Burglar said if you want to make life easier.
2008-12-30 18:22
Honesty

Registered: Jan 2003
Posts: 121
Just make a plain counter... decreasse some byte until its zeros and then enabble the scrolla...
2008-12-30 22:21
Radiant

Registered: Sep 2004
Posts: 639
Frame counting is the best way of doing normal music sync. If you need to do more advanced stuff (like time some action to a particular instrument during a longer period) you can dive into the music player, but for most tasks it is overkill.
2008-12-31 11:02
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
delay .byte 7

init
lda #7 (delay)
sta delay
rts

interrupt routine
jsr not-every-frame-routine
rts

not-every-frame-routine
dec delay
beq go-on
rts

go-on
lda #7
sta delay
(routine to run at x frames, go here)
rts

2008-12-31 11:05
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
using the CLOCK, you can make a counter that counts to exactly 1 minute and 40 seconds, then set a bit/byte to 0, which means your routine will start.

irq:
lda execute
beq doit
(do rest of stuff in irq)

doit
...
...
...
rts
2008-12-31 23:30
Stainless Steel

Registered: Mar 2003
Posts: 966
Or what i like to do is to make the jsr $scrollroutine be a bit $scrollroutine initially.
When the delay routine hits its value it sets the bit to jsr on the scroller and a bit to the delay routine.
2009-01-01 05:16
Hate Bush

Registered: Jul 2002
Posts: 466
use timingmarks if your musicplayer supports them. if not, let's have one more
2009-01-02 17:19
FillmoreC
Account closed

Registered: Dec 2008
Posts: 7
Quote: delay .byte 7

init
lda #7 (delay)
sta delay
rts

interrupt routine
jsr not-every-frame-routine
rts

not-every-frame-routine
dec delay
beq go-on
rts

go-on
lda #7
sta delay
(routine to run at x frames, go here)
rts



This only slows the scroll down in speed. I need the scroll not to go for like maybe 5 -10 seconds then start scrolling for the rest of the demo.
2009-01-02 18:51
JackAsser

Registered: Jun 2002
Posts: 2014
frameCount: .word 0
startScroller: .byte 0

frameTrigger = 7*50 ; 7 seconds
frameCountLo = frameCount+0
frameCountHi = frameCount+1

irq_handler:
   jsr doMusic

   ; Update frameCount
   inc frameCountLo
   bne :+
      inc frameCountHi
   :

   ; If frameCount == frameTrigger then startScroller=1
   lda frameCountHi
   cmp #>frameTrigger
   bne :+
      lda frameCountLo
      cmp #<frameTrigger
      bne :+
         inc startScroller
   :

   ; If startScroller !=0 then doScroller
   lda startScroller
   beq :+
      jsr doScroll
   :

   ; exit IRQ
 
... 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
Scan/House Designs
Sillicon/Unreal
Airwolf/F4CG
Andy/AEG
Guests online: 89
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.6)
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 Sprite Bukkake 2  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Dawnfall V1.1  (9.5)
6 Rainbow Connection  (9.5)
7 Morph  (9.5)
8 Libertongo  (9.5)
9 Onscreen 5k  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Musicians
1 Mutetus  (9.7)
2 Jeroen Tel  (9.7)
3 Rob Hubbard  (9.6)
4 Linus  (9.6)
5 Jammer  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.06 sec.