preventing music restart after title screen

Raftronaut

Member
I am trying to use my title screen music in my introduction cut scenes. Currently, when the start button is pressed it brings me to my first cutscene screen loaded with the same Title Screen music. However, the music restarts after the transition. Is there a way to prevent the music from restarting after the Title Screen if the song selected is the same?

I posted this question on the facebook forums earlier in the week. Dale Coop provided great insight as always.

Citing the following lines near 68 of HandleStateChanges.asm (located in your Basic\System folder).
Code:
;; check the song... if the same we don't restart it:
	PlaySong temp
	LDA temp
	STA currentSong

be changed to the following:
Code:
	;; check the song... if the same we don't restart it:
	LDA temp
	CLC
	CMP currentSong
	BEQ +
	;; else play the song:
	PlaySong temp
	LDA temp
	STA currentSong
	+

However the start screen still restarts the music upon pressing the start button after I change the script.

Any suggestions?
 

dale_coop

Moderator
Staff member
How is your GameStart script (the script executed when pressing the START button) could you share it?
 

Raftronaut

Member
Good call! I had not thought to check the input script for the command

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PART 1: Prepare the game for a state change.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  LDA #STATE_START_GAME
  STA change_state
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PART 2: If a sound is playing and you want it to stop,
;; or if you'd like to play a sound effect to designate
;; the button press, you can do that here;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  ;StopSound
  ;PlaySound #$00, $00
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PART 3: Turn on sprites;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  LDA #%10000000
  STA gameHandler ;; turn sprites on
  RTS

I see we have these lines here clearly causing a problem:
Code:
  ;StopSound
  ;PlaySound #$00, $00

Should I simply remove those? Or is there is there better way to comment out?

Please pardon my ASM terminology, my understanding is slowly coming along :)
 

dale_coop

Moderator
Staff member
Those lines seem already commented out (a ";" before the code), so they will be ignored by the compilator.
Your script looks completely fine.

Could you share the whole HandleStateChanges.asm ?

Also could you share a screenshots of your special screen > Start screen
and a screenshot of the "screen details" dialog of the first screen of your cutscene?
 

Raftronaut

Member
Here is the entire HandleStateChanges.asm:
Code:
HandleStateChanges
	LDA change_state
	BNE fireAStateChange
	;; no state change to fire
	rts
fireAStateChange:
	
	CMP #STATE_START_GAME
	BEQ doStartGame
	JMP notStartGame
doStartGame:

;;;;;;;=========================================
;;;;; HERE IS WHAT HAPPENS WHEN THE GAME STARTS:
;;;;;===========================================
	;;;;; 1) First, load the main game state, the 
			LDA #%11000000
				;7 = active
				;6 = 8 or 16 px tiles
			ORA #GS_MainGame
			STA update_screen
			LDA #$02	;; dale_coop: fix for starting screen in the Underworld.
			SEC
			SBC #START_LEVEL
			STA update_screen_details ;; load from map 1

			LDA #START_ON_SCREEN
		;	LDA continueScreen

			STA currentNametable
			STA newScreen
			STA currentScreen ;currentScreen
			STA xScroll_hi
			STA nt_hold
			
			LDA newScreen
			STA currentScreen
			LSR
			LSR
			LSR
			LSR
			LSR
			STA screenBank
			;; ignores this if is special
			;; adds 08 if it is map 2
			LDA #HUD_TILE_OFFSET
			STA update_screen_hud_offset
			
			LDA #HUD_ATT_OFFSET
			STA update_screen_att_offset
			
			LDA #HUD_COL_OFFSET
			STA update_screen_col_offset
			
	;;;;;; 2) Second, create the player in the correct starting position.
		
		CreateObject continuePositionX, continuePositionY, playerToSpawn, #$00, currentNametable ;; change this to name?
		TXA
		STA player1_object
		
	LDA screenTypeAndSongNumber
	AND #%00001111
	STA temp
	

;; check the song... if the same we don't restart it:
	LDA temp
	CLC
	CMP currentSong
	BEQ +
	;; else play the song:
	PlaySong temp
	LDA temp
	STA currentSong
	+
	
			
	
;;;;=======================================
;;;; END START GAME
;;;======================================	
	LDA #$00
	STA change_state
	RTS
	
notStartGame:
	CMP #STATE_WIN_GAME
	BEQ doWinGame 
	JMP notWinGame
doWinGame:

	LDA #%10000000
				;7 = active
				;6 = 8 or 16 px tiles
	ORA #GS_Win
	STA update_screen
	

	JSR DeactivateAllObjects
	JSR DrawAllSpritesOffScreen
	LDA #%00
	STA gameHandler ;; turn off drawing sprites
	
;	LDA #$00
;	LDx #$00
;turnOffAllObjects:
;	STA Object_status,x
;	STA Object_x_hi,x
;	inx
;	CPX #TOTAL_MAX_OBJECTS
;	BNE turnOffAllObjects
	;; other possibilities go here.
	
	LDA #$01 ;; win screen
	STA newScreen
	LDA #$00
	STA update_screen_hud_offset
	STA update_screen_att_offset
	STA update_screen_col_offset
	LDA #%00000000 ;; special screen
	STA update_screen_details
	

	;; load hud
	;LoadChrData #$1d, #$1c, #$00, #$40, textTiles
	LDA #WIN_SCREEN_SONG
	STA currentSong
	PlaySong #WIN_SCREEN_SONG
	LDA #$00
	STA change_state
	
notWinGame:
	RTS
 

Raftronaut

Member
dale_coop said:
Also could you share a screenshots of your special screen > Start screen
and a screenshot of the "screen details" dialog of the first screen of your cutscene?

I am not sure what you mean by this, I attached the screen details of the 1st screen I am using currently, but I am not sure what I can share regarding screen shots of : "special screen > Start screen"
Is this script file?
 

Attachments

  • cutscene screen 1.PNG
    cutscene screen 1.PNG
    58.2 KB · Views: 2,904

dale_coop

Moderator
Staff member
Your Start Screen is set to play song_introtomorrow too, right?
(I checked your script... I even tested it... working as expected)
 

Raftronaut

Member
That is really weird!

Unless, Could it be that I am editing HandleStateChanges.asm from the wrong folder?

here is where my script is that I am editing:
Nesmaker_4_1_5 > GameEngineData > Routines > Basic > System > HandleStateChanges

Is this correct?
 

dale_coop

Moderator
Staff member
Yes, it is that one.
Weird... I will continue tomorrow. Now, I will go follow the Awards (byte-off) that will start soon (somewhere on FB / Youtube... the link will be share in a few minute now). After that I go to sleep (it's already 2am here ;))
 

Raftronaut

Member
Well thank you again for all the great help today Mr.8-bit hero! :)

Congrats. I am very happy to see your contributions recognized by the community. You're the best
 

dale_coop

Moderator
Staff member
Thank you, Raftronaut.
The show was awesome! And I was so suprised to see the musical show ;) Congrats too!

About your issue(s), would you mind sending me your project (zipped)? I could check and tell how to fix it? (in fact, more precisely, i'd need the project .MST file, the GraphicAssets and the GameEngineData folders).
 

Raftronaut

Member
Hey Dale,

I actually found something, Out of frustration I changed my title screen to a new song. I will call it song X here, then mistakenly set my 1st screen to a screen I had mistakenly set at song X as well. When I exported and tested there was no break in the music between title screen and screen 1 when transitioning from song X to Song X. So for some reason it only appears to be happening on the previous song (i'll call it song Y). I ran out of time to do more tests after making this discovery so I hope to test further and report back.

However, in the meantime I discovered that going with a traditional title screen theme X transition into cutscene them Y actually works much better than I'd imagined. That also gives me the added benefit of being able to control exactly how long the introduction theme plays in the cutscene before launching the player into the action, rather than leaving it up to the player to hit the start button, often resulting in some very non-musical transitions.

So I don't think I need to continue with this particular function after my happy-accident here. I would be more than happy to share my project with you if you would find it interesting, though I would hate to waste your time if I am not going to be using the feature after all. Though, I will certainly do more tests with "Song Y" and post my results in case anyone finds it helpful.
 

dale_coop

Moderator
Staff member
Glad you found something. No problem.
If you need help on something, I will never be very far from here.

See ya
 

Raftronaut

Member
dale_coop said:
If you need help on something, I will never be very far from here.
OH, I'll certainly need more help going forward, I have a laundry list of things I am trying to fix and/or implement before I can start buttoning up version 2.0 of my demo.

I'd like to get some bugs removed to provide a more playable experience in my demo before setting out to finish it completely.

Thanks again for ALL you do here, I look forward to talking more with you in the future.

All the best
 

Raftronaut

Member
WOW, Determined that Song X transitions JUST FINE from title to screen1. Song X to Song Y transitions fine as well. However, When I set my title screen to SONG Y and my screen1 to Song Y it results in the song restarting at the screen transition.

I have no idea how to explain this, like I said before, I like the song x to y transition enough to keep it, so there is no reason to continue looking into this problem for me. Though I did do some quick experiments in famitracker so determine if something was wrong with my song. I noticed that SONG Y starts with two channels muted with the (-) command, since this command causes glitches when used in SFX, I decided to try switching that (-) to a BLANK instrument instead hoping that wouldn't trigger the song restart, annnnnnnd it didn't work and I am totally clueless as to why it doesn't work with only the one particular song.....

I am baffled, but through the process discovered a transition I ultimately like better!
 

Razzie.P

Member
I was searching for a way to have songs play continously and found this thread. How can this be accomplised using the "maze" module? I don't see HandleStateChanges.asm anywhere in the scripts, unless I'm overlooking it. Currently, game loads the new song each time a screen is loaded. When I have the settings to "no change" it seems to glitch and makes a nasty screech. I'd like to do something simliar to what you've done, having the music continue (instead of restarting with every screen) until I've set it to change.

Thanks for the help!
 

dale_coop

Moderator
Staff member
The "HandleStateChanges.asm" file is directly in your Routines\Basic\System folder. Even if this script is not listed in "Project Settings > Script Settings", this script is used by the NESmaker engine (one of the main scripts of the core).
 

Razzie.P

Member
Thank you! That did seem to allow the music to play continously from "Title" to "Screen 1." Any idea where this can be altered to allow for the same behaviour for the rest of the game's screens? For example, to have a song start on Screen 1, then continue (not restart) on Screen 2, then 3, etc?
 

dale_coop

Moderator
Staff member
You want to restart the song each time you change screen? (even if it's the same song)

How/when to you change screen in your game? When you win the current level?
If you are using a player victory object that is warping you to the next screen/level, it should already be the case (if I remember well the Timer_WarpNextScreen script reset the music)...
 
Top Bottom