Non-textbox based pause

User avatar
Razzie.P
Posts: 79
Joined: Thu Jun 13, 2019 3:51 am

Re: Non-textbox based pause

Post by Razzie.P » Fri Aug 30, 2019 1:12 am

Works great. Thanks! I don't think I would have figured that out on my own anytime soon.

I'm not familiar with discord. Guess it's time to check that out and see what useful info is happening on there.
User avatar
dale_coop
Posts: 4100
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Non-textbox based pause

Post by dale_coop » Fri Aug 30, 2019 9:03 am

Glad it worked ;)

Discord is more for direct tchat... talking... helping each others. I am new there, but it's fun.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
Raftronaut
Posts: 266
Joined: Mon Sep 03, 2018 4:47 pm

Re: Non-textbox based pause

Post by Raftronaut » Mon Sep 09, 2019 4:52 pm

dale_coop wrote:
Thu Aug 29, 2019 8:25 am
As Kasumi epxlained somewhere (on the Discord channel maybe), for pausing the music...
Modify the MainASM.asm script, under the "skipNMIstuff:", you will find this block of code:

Code: Select all

	LDA currentBank
	STA prevBank
	LDY #BANK_MUSIC  ;; switch to music bank
	JSR bankswitchY
	soundengine_update  
	LDY prevBank
	JSR bankswitchY	
Comment those 7 lines, like this:

Code: Select all

	; LDA currentBank
	; STA prevBank
	; LDY #BANK_MUSIC  ;; switch to music bank
	; JSR bankswitchY
	; soundengine_update  
	; LDY prevBank
	; JSR bankswitchY	
And just after them, add this block of code:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PAUSE MUSIC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #BANK_MUSIC  ;; switch to music bank
	JSR bankswitchY

	LDA isPaused
	BEQ unpause_music
	JSR pause_song
	JMP post_pause_music_handle
unpause_music:
	JSR resume_song
post_pause_music_handle:
	soundengine_update  
	LDY prevBank
	JSR bankswitchY   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	


Ooooh, this has been fairly low on my priority list, but it certainly has been on my mind to do something with. Pausing the music completely would probably the BEST thing to do with the music while paused... however.... I had a discussion with Kasumi about the Mother soundtrack and how the DPCM drums are muted whenever a sub-menu is opened.. (Maybe this is due to CPU usage) it creates a really unique aspect to the sound design, whenever you close a sub-menu the Drums kick back in and you are launched back into the action! This might be of use to other Nesmakers as well, which is why I bring it up. Kasumi mentioned that GGsound has the capability to Mute up to two channels independently... I had thought it would be interesting to try something like this, and MUTE my drums and melody when the game is paused, then when unpaused the player would feel thrown back into the action...

Kasumi dropped this code on me, but I am still too inexperienced to understand how to put it to use:

Code: Select all

ldx #1;Square 2
    lda stream_flags,x
    ora #STREAM_SILENCE_SET
    sta stream_flags,x

    lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x
Does anyone have any insight as to whether or not this will work?

If so, I Imagine it could be used in all many different scripts for cool sound tricks, like muting melody when displaying text boxes, Or this pause screen application, or muting sound channel during certain enemy AI actions, or an Ice bomb that temporarily mutes the drums or something....Seems like playing with the lack of sound could be used creatively here...
Space Raft 2.0 Demo: [url] http://nesmakers.com/viewtopic.php?f=52&t=2867 [/url]

Chiptune: [url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Re: Non-textbox based pause

Post by Mugi » Mon Sep 09, 2019 5:22 pm

well, Kasumi generally knows what he's talking about so i'd assume it does work, although i havent looked at the sound flags myself to verify if these are correct.

basically it should work if you put this into the pause script for the pause function, and an opposite function (to unmute the channels) into the unpause function.
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
Raftronaut
Posts: 266
Joined: Mon Sep 03, 2018 4:47 pm

Re: Non-textbox based pause

Post by Raftronaut » Mon Sep 09, 2019 8:12 pm

Mugi wrote:
Mon Sep 09, 2019 5:22 pm
well, Kasumi generally knows what he's talking about so i'd assume it does work, although i havent looked at the sound flags myself to verify if these are correct.

basically it should work if you put this into the pause script for the pause function, and an opposite function (to unmute the channels) into the unpause function.
Any idea what the label would be for the Noise channel? The script shows square 2, in this case would it simply be: noise?
Space Raft 2.0 Demo: [url] http://nesmakers.com/viewtopic.php?f=52&t=2867 [/url]

Chiptune: [url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Re: Non-textbox based pause

Post by Mugi » Tue Sep 10, 2019 3:57 am

well the channels go in order as far as i know,
0: square 1
1: square 2
2: triangle
3: noise

kasumi's script loads 1 in X

Code: Select all

ldx #1 ;Square 2
again, going off my head here, i really didnt dig that much into the sound driver since my parallaxer made it impossible for me to use DPCM and i had no reason to mess with it anymore :P
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
Raftronaut
Posts: 266
Joined: Mon Sep 03, 2018 4:47 pm

Re: Non-textbox based pause

Post by Raftronaut » Wed Sep 11, 2019 8:45 pm

LOL, off topic but I love the idea of Parallax being a proper noun or verb..

"what are you up to?" "Oh, not much... just... Parallaxing"
Space Raft 2.0 Demo: [url] http://nesmakers.com/viewtopic.php?f=52&t=2867 [/url]

Chiptune: [url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
Mugi
Posts: 697
Joined: Thu Dec 27, 2018 8:30 pm

Re: Non-textbox based pause

Post by Mugi » Thu Sep 12, 2019 4:51 am

Raftronaut wrote:
Wed Sep 11, 2019 8:45 pm
"what are you up to?" "Oh, not much... just... Parallaxing"

this shall henceforth be my signature :P
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
Raftronaut
Posts: 266
Joined: Mon Sep 03, 2018 4:47 pm

Re: Non-textbox based pause

Post by Raftronaut » Thu Sep 12, 2019 2:38 pm

HAHAHA happy to be of assistance ;)
Space Raft 2.0 Demo: [url] http://nesmakers.com/viewtopic.php?f=52&t=2867 [/url]

Chiptune: [url] https://soundcloud.com/user-634230995-350638590 [/url]
User avatar
Kasumi
Posts: 261
Joined: Fri Mar 09, 2018 11:13 pm

Re: Non-textbox based pause

Post by Kasumi » Sat Sep 14, 2019 5:04 pm

Raftronaut wrote:
Mon Sep 09, 2019 4:52 pm
Kasumi dropped this code on me, but I am still too inexperienced to understand how to put it to use:

Code: Select all

ldx #1;Square 2
    lda stream_flags,x
    ora #STREAM_SILENCE_SET
    sta stream_flags,x

    lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x
Does anyone have any insight as to whether or not this will work?
Yes, it works.

Anyway, there's not much to getting it to work. Every frame you run the above code, Square 2 won't play. With ldx #0, every frame you run the above code, Square 1 won't play. To mute both in place of pausing using the code dale_coop posted above, you'd do:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PAUSE MUSIC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #BANK_MUSIC  ;; switch to music bank
	JSR bankswitchY

	LDA isPaused
	BEQ unpause_music
	ldx #0;Square 1
    lda stream_flags,x
    ora #STREAM_SILENCE_SET
    sta stream_flags,x

    lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x

    ldx #1;Square 2
    lda stream_flags,x
    ora #STREAM_SILENCE_SET
    sta stream_flags,x

    lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x
unpause_music:
post_pause_music_handle:
	soundengine_update  
	LDY prevBank
	JSR bankswitchY   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
There's no need to "unsilence", because the engine seems to do it every note. So if you want something silenced, set STREAM_SILENCE_SET that frame, and if you don't want something silenced, do nothing.

It doesn't work with the triangle or the noise channels because only square_1_play_note and square_2_play_note respect the flag. (DPCM also seems to respect it, but I haven't tested.) The engine is capable of pausing, but not pausing all channels breaks playback (the ones you don't pause continue to play, so when the paused ones are resumed, the channels are out of sync.) It may be simple to make noise and channel respect the flag:

Replacing this code in ggsound.asm seems to allow the triangle channel to be muted in the same way, but I don't yet know if it's actually a good way to do it. I'd need to look deeper into GGSound.

Note: There are multiple pieces of similar looking code in ggsound.asm. You want the one under the triangle_play_note label.

Code: Select all

@pitch_already_loaded:
    lda stream_flags,x
    and #STREAM_SILENCE_TEST
    bne @silence_until_note
@note_not_silenced:

    ;Load volume offset.
    ldy stream_volume_offset,x

    ;Load volume value for this frame, but hard code flags and duty for now.
    lda (sound_local_word_0),y
    cmp #ENV_STOP
    beq @volume_stop
    cmp #ENV_LOOP
    bne @skip_volume_loop

    ;We hit a loop opcode, advance envelope index and load loop point.
    iny
    lda (sound_local_word_0),y
    sta stream_volume_offset,x
    tay

@skip_volume_loop:

    lda #%10000000
    ora (sound_local_word_0),y
    sta stream_channel_register_1,x

    inc stream_volume_offset,x
    jmp @done_volume
@volume_stop:
@silence_until_note:
    lda stream_channel_register_1,x
    and #%10000000
    sta stream_channel_register_1,x
@done_volume:
    ;Load pitch offset.
    
(Copy the above. Select everything between and including @pitch_already_loaded and ;Load pitch offset. Paste, which will replace what's there with this new code)

Then triangle can be muted with

Code: Select all

ldx #2;Triangle
    lda stream_flags,x
    ora #STREAM_SILENCE_SET
    sta stream_flags,x
    
    lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x
Noise channel probably requires a similar modification.

Edit: Oh. Seems you don't need the

Code: Select all

lda stream_channel_register_1,x
    and #%11110000
    sta stream_channel_register_1,x
For any of the channels.
Probably a leftover from trying to mute the other channels that don't respect the flag.
Post Reply