[SOLVED] Delay Music

Discussion in 'Discussion & Q&A' started by Arsen, Mar 12, 2017.

Thread Status:
Not open for further replies.
  1. Arsen

    Arsen Active Member In Limbo

    Joined:
    May 16, 2014
    Messages:
    39
    Hello, everyone. So I was trying to make boss music for example not started instantly. I'm currently using Sonic 1 "Hivebrain Disassembly" . I just want to know how to delay orders.

    Code:
            move.b    #$E0,d0
            bsr.w    PlaySound_Special ; fade out music
            ; Delay for 3 seconds for example
            move.w    #$8C,d0
            bsr.w    PlaySound    ; play boss music
    Thanks for the help.

    EDIT: As Otterboi said you can't just add delay, otherwise everything will freeze. So you have to do by following:

    Thank you so much for this information.
     
    Last edited by a moderator: Mar 12, 2017
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I'm afraid it isn't that simple, you could delay for 3 seconds inbetween those two sections there, but EVERYTHING would virtually freeze. What you need to do, is allow everything to continue but run a counter that counts upwards/downwards and avoid playing the theme until it has reached its final count.
    Code:
    off_6E4A:	dc.w Resize_GHZ3main-off_6E4A
    		dc.w Resize_GHZ3boss-off_6E4A
    		dc.w Resize_GHZ3end-off_6E4A
    You'll need another subroutine for this, so insert like so:
    Code:
    off_6E4A:	dc.w Resize_GHZ3main-off_6E4A
    		dc.w Resize_GHZ3boss-off_6E4A
    		dc.w Resize_GHZ3delay-off_6E4A
    		dc.w Resize_GHZ3end-off_6E4A
    Now, at the moment, you'll have this inside "Resize_GHZ3boss" further down:
    Code:
    loc_6ED0:
    		move.w	#$8C,d0
    		bsr.w	PlaySound	; play boss theme
    		move.b	#1,($FFFFF7AA).w ; lock	screen
    		addq.b	#2,($FFFFF742).w
    		moveq	#$11,d0
    		bra.w	LoadPLC		; load boss patterns
    So, firstly, changing the 8C to an E0 so it plays the fadeout first, you'll see that It's the "addq.b #2,($FFFFF742).w" which is responsible for running "Resize_GHZ3end" on the next frame, but now that you've inserted "Resize_GHZ3delay", that will be ran next, so we need to create that routine, just above "Resize_GHZ3end:" like so:
    Code:
    Resize_GHZ3delay:
    		subq.w	#$01,($FFFFFF90).w		; decrease delay timer
    		bgt.s	locret_6EE8			; if it's still running, branch
    		addq.b	#2,($FFFFF742).w		; increase routine counter to "Resize_GHZ3end"
    		move.b	#$8C,d0				; set boss BGM ID to play
    		bra.w	PlaySound			; ''
    As you can see, this subtracts 1 from a RAM space, counting down, as long as it's above 0000 still, it'll branch to "locret_6EE8" which simply returns, so if you set that word of RAM to say 3 seconds inside "Resize_GHZ3boss", which is 3 x 60 frames, like so:
    Code:
    loc_6ED0:
    		move.w	#$E0,d0
    		bsr.w	PlaySound			; play fade out
    		move.b	#1,($FFFFF7AA).w ; lock	screen
    		addq.b	#2,($FFFFF742).w
    		move.w	#60*3,($FFFFFF90).w		; <- set time before playing the boss theme
    		moveq	#$11,d0
    		bra.w	LoadPLC		; load boss patterns
    Then it'll start off as 180 (60 x 3), and each frame it comes into "Resize_GHZ3delay" routine, it'll subtract 1 from it, changing it to 179, then return. It'll do it again, 178, then 177, then 176, and so on, until it reaches 0.
     
    Last edited: Mar 12, 2017
    redhotsonic, FATA-, M.N.K. and 5 others like this.
Thread Status:
Not open for further replies.