Adding Play/Pause + colour flicker - VegaPlay

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

I've been able to compile my own VegaPlay ROM but there are things about the program which I felt were needed just to make it more interesting than just a collection of NSF files.

I wanted to have the screen be more visually appealing. I've made a custom background and it looks nice but it's still static and I was wanting to make them flash different colours just to make it more lively. I also wasn't a fan of how the track instantly changes as soon as you scroll up or down. I'd rather have it like in FamiCompo or have the currently playing track play while you move the cursor and only stop to change when you press A or something. So a way to pause/play and select new song.

I tried looking at LogoNES to see how flickering colours could work. I've also looked at the files and how they work for the past 2 evenings and I'm really just breaking the program more than anything.

I know that when it says something like "BEQ EndDrawChk" it sends the message to "EndDrawChk" and begins its cycle. However I don't know what the difference between those CEQ, GRA, PEL phrases mean and what they do alongside the $4000 or $45 $c10.

If any of you guys are like pros at this kind of stuff It'd be awesome if you could tell me how to code this out or explain how some areas work so I could do it myself.

Thanks.
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by lidnariq »

CanYouNot wrote:I was wanting to make them flash different colours
The NES provides relatively strict requirements on just how much background data you can upload at a time. Without going into that complexity, you should probably limit yourself to:
1- palette updates (including color rotation) and
2- sprites
only.
pause
Given the structure of NSFs... you can only pause if you are either willing for
1- the notes to be left on while it's paused, or
2- if you're ok with having any sustained notes not being restarted when you unpause, or
3- Some notes incorrectly being on when you unpause


Also, because of the structure of NSFs, you may be limited on memory available for your not-music. I don't actually remember how much memory Famitracker's driver uses, though.

Did you see this older thread? It's only a little polish, but it is a little.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by tepples »

lidnariq wrote:
CanYouNot wrote:pause
Given the structure of NSFs... you can only pause if you are either willing for
1- the notes to be left on while it's paused, or
2- if you're ok with having any sustained notes not being restarted when you unpause, or
3- Some notes incorrectly being on when you unpause
Or 4- Figuring out how to convince a particular music engine to restart the note correctly when you unpause. For example, if you silence the channels by writing $00 to all envelope registers ($4000, $4004, $4008, and $400C) and leaving $4015 alone, and then you scribble $FF over the RAM locations where an engine stores "previous period high byte" values that it uses for avoiding phase resets, it may restart the note.

(suppresses urge to make a "polish" pun)
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

Given the structure of NSFs... you can only pause if you are either willing for
1- the notes to be left on while it's paused, or
2- if you're ok with having any sustained notes not being restarted when you unpause, or
3- Some notes incorrectly being on when you unpause


Also, because of the structure of NSFs, you may be limited on memory available for your not-music. I don't actually remember how much memory Famitracker's driver uses, though.
If we can't pause the audio, then there's surely a way to stop the audio when say you press START and when you press it again it plays whatever track is highlighted from the beginning?
What would go after these commands?

Code: Select all

CheckStart:
	LDA #%00001000
	AND JustPressed
	BEQ CheckDown
    
Because I think those first 3 lines are for when the ROM begins and it checks through all the buttons?

I'm also looking at it's colour flicker function and trying to see how I could implement it into VegaPlay.
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by rainwarrior »

For pausing a playing NSF, I'd recommend writing $00 to $4015 to silence all channels, and then when resuming write $0F to it to re-enable them before continuing. (Edit: Oh, sorry, just noticed Tepples arleady suggested this above. Futher commentary below though.)

This is not a perfect method: any playing DPCM sample will not survive the pause, and some NSF engines might have not resume their sound until the next note, or may even have problems with writing to $4015 silencing a channel permanently, but in my experience most of them do pretty well with this technique.
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

rainwarrior wrote:For pausing a playing NSF, I'd recommend writing $00 to $4015 to silence all channels, and then when resuming write $0F to it to re-enable them before continuing. (Edit: Oh, sorry, just noticed Tepples arleady suggested this above. Futher commentary below though.)

This is not a perfect method: any playing DPCM sample will not survive the pause, and some NSF engines might have not resume their sound until the next note, or may even have problems with writing to $4015 silencing a channel permanently, but in my experience most of them do pretty well with this technique.
yeah alright then.

I don't think I'll have it be a pause function then, it seems like it sort of ruins it a bit. I think I'll resort to a Stop/Play function somehow and the colour flicker thing.
Is the code for stopping/playing simple though?
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by rainwarrior »

Stopping is the same as pausing, really. Write $00 to $4015 to silence, and stop executing PLAY every frame.

Restarting means to run the NSF INIT function again before you resume executing PLAY once per frame. (You also need to zero out the RAM areas it uses before calling INIT, and initialize some other things, information here. VegaPlay should already have a function that does all this before it calls the NSF's INIT though, so just re-use that.)


I don't think it "ruins" the track to use the pause/resume method I suggested, though. In the vast majority of cases it sounds quite natural. I called it imperfect simply because it's not entirely foolproof.

In the music compilation ROMs I've made, it was sufficient for almost all tracks I've encountered. For the one or two oddball tracks that didn't unpause cleanly I just added some special code for that track. Depends on the engine, though, and I don't believe any of the problem tracks were using contemporary versions of Famitracker, which is what you're using, right?
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

When I think I've gotten it to work, it says that the line '.ORG $fffa' is a value out of range.
Does this mean the file is too big? I've tested the compiler by using a NSF with only 2 tracks and it still says it.
Unless there's a limit to how big the .asm can be.

So why is it saying ORG fffa is a value out of range?

Code: Select all

;       ----------------------------------------------------

	.ORG $fffa              ; vectors
	.DW NMI
	.DW Reset
	.DW IRQ
Sorry if this is real obvious and I'm just doing everything wrong guys. I'm not good at programming but I'm trying to understand this.
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by lidnariq »

That error means you've put too much code to fit in the remaining 1.5 KiB that the first .org statement at the top of the file left for you.

I tentatively think you could get away with just removing the .org $fa00, and then you'll have the same 32762-byte pool for the entire including NSF and your graphical updates, not a fixed division.
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

lidnariq wrote:That error means you've put too much code to fit in the remaining 1.5 KiB that the first .org statement at the top of the file left for you.

I tentatively think you could get away with just removing the .org $fa00, and then you'll have the same 32762-byte pool for the entire including NSF and your graphical updates, not a fixed division.
I removed the .org $fa00 and it compiled, however the ROM crashes when I attempt to run it.

I'll just include the .asm so you can see where the problem may lie, which I feel like would be more than I think.
Attachments
vegaplay.asm
(11.43 KiB) Downloaded 213 times
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by rainwarrior »

You removed the .org $fffa, not the .org $fa00. The former is critical for placing the vectors.
User avatar
CanYouNot
Posts: 17
Joined: Sun May 15, 2016 7:20 am
Location: Cambridge, UK
Contact:

Re: Adding Play/Pause + colour flicker - VegaPlay

Post by CanYouNot »

Okay I just looked over the asm file and I've gotten ridden of uneeded strings and all that.
I've fixed some errors I've found.

It compiles which is good and the select button is able to do the colour flicker thing.
The music plays too! However the screen isn't aligned right. The colours align with the music!? that's so cool!
However the image not being in the right place kind of annoys me but I also kind of like it. Just because of the glitchy look,

But I can't change song. Probably a mistake in the coding the up down buttons.

I'll share the .asm
Attachments
VegaPlay.asm
(11.01 KiB) Downloaded 212 times
-------------Social Media----------------------------
Twitter: https://twitter.com/thom_hex2a03
Facebook: https://www.facebook.com/hexospherenes/
~~~~~~Music to be found~~~~~~~~~~~~~
Bandcamp: https://hexosphere.bandcamp.com/
Soundcloud: https://soundcloud.com/hexosphere/
Post Reply