CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

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

Moderator: Moderators

zzo38
Posts: 1063
Joined: Mon Feb 07, 2011 12:46 pm

CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by zzo38 » Sun Sep 02, 2012 6:01 pm

CombiNSF is a program to combine multiple .NSF into one .NSF file.

Currently the following restrictions apply (to method 1, currently the only method available):
  • The source files must not use bankswitching.
  • You may not combine NTSC and PAL files together unless some files are compatible with both NTSC and PAL, and the other files (if any) are NTSC-only, or PAL-only, but not both.
  • The only expansion chips usable are Namco 163 and MMC5. (The reason is that others will conflict with FDS RAM. If the input uses FDS, then it might use $6000-$7FFF, and this program requires that memory for its own use, so FDS cannot be used in the input either.)
  • The output will use Famicom Disk System, so the output of this program cannot be given as input to this program. (The FDS audio is not used; but the memory range $6000-$7FFF will be used, four bytes of which are being used as RAM, although these four bytes of RAM are also used as instruction operands!)
  • The output will use bankswitching, which is another reason that the output cannot be given as input to this program.
Method 1 uses up 3 clock cycles of the play routine, unless all the inputs have the same play address in which case it does not use up any clock cycles.

Download: http://zzo38computer.org/nes_program/combinsf.zip
Last edited by zzo38 on Tue Sep 18, 2012 12:38 am, edited 1 time in total.
[url=gopher://zzo38computer.org/].[/url]

jrlepage
Posts: 24
Joined: Wed Apr 04, 2012 2:15 am

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by jrlepage » Fri Sep 14, 2012 12:13 pm

I totally need a version of this that'll let me combine VRC6 NSFs! :o

Is there any way around the FDS RAM usage?

zzo38
Posts: 1063
Joined: Mon Feb 07, 2011 12:46 pm

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by zzo38 » Fri Sep 14, 2012 12:18 pm

Thanks for the suggestion; I too want it to be able to combine NSFs using any expansion chips; however, I am unsure how to implement this. I have some ideas (execution tracing to decide what area of ROM and RAM is unused and can be used for the combiner), and if you have any other ideas you can tell those to me as well, please. (This can be called "method 2"; the current version is "method 1", and method number zero is reserved to try each method until one of them does not result in an error, and use that one.)

Do you know what other features the VRC6 NSFs use? Bankswitching? NTSC/PAL? Multiple songs in the input files? Do they ever execute code from RAM?

Perhaps if you know what kind of algorithms can be used too; I posted my ideas above, but don't know if there is some better way.
Is there any way around the FDS RAM usage?
Probably if the execution tracing I wrote about above is done, then it could work without FDS. (The current method is very simple and has to be careful not to overwrite the rest of the song.)
[url=gopher://zzo38computer.org/].[/url]

jrlepage
Posts: 24
Joined: Wed Apr 04, 2012 2:15 am

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by jrlepage » Fri Sep 14, 2012 12:20 pm

I'm afraid I know bugger all about any sort of programming, so I wouldn't be able to help. :<

I can tell you the files I need to merge use bankswitching and that they have the NTSC flag only (no dual NSFs). That's all I can say, I'm afraid. I am but a musician...

User avatar
rainwarrior
Posts: 7804
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by rainwarrior » Fri Sep 14, 2012 12:47 pm

NSFPlay intentionally blocks FDS ram writes from conflicting locations if other expansions are enabled, so VRC6/VRC7/5B should not cause a problem for that player.

All bets are off for other players. Implementations of FDS RAM for NSF players differs widely.

zzo38
Posts: 1063
Joined: Mon Feb 07, 2011 12:46 pm

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by zzo38 » Fri Sep 14, 2012 2:07 pm

jrlepage wrote:I'm afraid I know bugger all about any sort of programming, so I wouldn't be able to help. :<

I can tell you the files I need to merge use bankswitching and that they have the NTSC flag only (no dual NSFs). That's all I can say, I'm afraid. I am but a musician...
Then, if this idea of execution tracing is used, it would also have to trace all bankswitching and then recompile the program to use different bank numbers! If the bank numbers are being calculated, or the bank numbers are being used for things other than bank numbers, then it would have to add instructions, and might interfere if exact CPU clock timing is required.

Another simpler idea (probably not relevant to what you are doing, though): If no more than one input file uses bankswitching: Set a high bank number used for the init routine which sets up everything and calls the input file's init routine (it could copy a part of itself into RAM and execute there before switching the initial banks). If the play addresses differ, then it should also ensure no input files use MMC5 ExRAM, so that the jump to play routine could be stored there.
rainwarrior wrote:NSFPlay intentionally blocks FDS ram writes from conflicting locations if other expansions are enabled, so VRC6/VRC7/5B should not cause a problem for that player.

All bets are off for other players. Implementations of FDS RAM for NSF players differs widely.
Yes I know, the implementation can differ widely and that the specification says about those things. (If you know you are using it only with players that block FDS RAM writes from conflicting locations, you could modify CombiNSF to ignore that error.)

(My hardware implementation (not yet built) does not block writes, as this is simpler; however it does have flags to: write-protect FDS RAM, mute VRC6 audio, mute VRC7 audio, and mute Sunsoft 5B audio. Famicom Disk System audio, MMC5 audio, and Namco 163 audio cannot be muted in this way.)

If you want to know about CombiNSF working you can look at the source-codes! Even modify if you like to do so; it is designed that methods can be added, and method 0 to try each method until finding one which is not error. (If anyone send a patch, I might add it; if I figure out the algorithms myself, I will program them myself.)
[url=gopher://zzo38computer.org/].[/url]

elsh
Posts: 13
Joined: Tue Jul 07, 2009 4:02 pm
Location: Grand Rapids, MI
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by elsh » Sun Sep 16, 2012 4:26 pm

you chould make a thread over at the chipmusic.org forums, im sure there a lot of people who would help out with this. especially neil baldwin.

zzo38
Posts: 1063
Joined: Mon Feb 07, 2011 12:46 pm

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by zzo38 » Mon Sep 17, 2012 2:17 pm

I now have idea to make method 2, with these restrictions:
  • No more than one source file can use bankswitching.
  • You may not combine NTSC and PAL files together unless some files are compatible with both NTSC and PAL, and the other files (if any) are NTSC-only, or PAL-only, but not both.
  • No input files can use MMC5 unless the play routine addresses for all input files are the same.
  • If any input file uses FDS, then none of the input files without FDS can use VRC6, VRC7, and Sunsoft.
  • The output will use bankswitching and MMC5.
  • The play routines for the input files must exceed $5C0A.
  • Method 2 uses up 3 clock cycles of the play routine, unless all the inputs have the same play address in which case it does not use up any clock cycles.
I intend also to add an option, for both method 1 and method 2, which tells it to ignore some of these restrictions, and continue anyways (possibly resulting in an invalid .NSF but this is your fault for selecting this option in cases when it doesn't work).
[url=gopher://zzo38computer.org/].[/url]

User avatar
Jedi QuestMaster
Posts: 603
Joined: Thu Sep 07, 2006 1:08 pm
Location: United States
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by Jedi QuestMaster » Fri Sep 28, 2012 11:10 am

Thank you! :mrgreen: This worked for my Stinkoman NSFs!

Edit: Here! :o

User avatar
Jedi QuestMaster
Posts: 603
Joined: Thu Sep 07, 2006 1:08 pm
Location: United States
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by Jedi QuestMaster » Mon Oct 22, 2012 1:42 am

Is there a file size limit?

I'm putting together 5 NSFs & can't get them all to play. None of them use expansion chips.

Edit: It seems if I use a Famitracker NSF, the next track won't play. :? Two of my tracks are from Famitracker. :cry:

Edit: Let me make sure neither of them use bankswitching mind tricks.

Edit: Nope.

User avatar
Jedi QuestMaster
Posts: 603
Joined: Thu Sep 07, 2006 1:08 pm
Location: United States
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by Jedi QuestMaster » Mon Oct 22, 2012 10:25 pm

The hell? :?

Just found out this doesn't work with NotsoFatso or FCEUltra or anything else except FCEUX & NEStopia.

Is this because it uses the FDS chip? I want to be able to submit this to Famicompo 9.

(it works on VirtuaNSF)

zzo38
Posts: 1063
Joined: Mon Feb 07, 2011 12:46 pm

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by zzo38 » Tue Oct 23, 2012 4:21 pm

I probably made some stupid mistakes I think I realized some of them later on I will fix it. Sorry...!
[url=gopher://zzo38computer.org/].[/url]

User avatar
Jedi QuestMaster
Posts: 603
Joined: Thu Sep 07, 2006 1:08 pm
Location: United States
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by Jedi QuestMaster » Tue Oct 23, 2012 4:27 pm

It's okay - I figured out a way to sort my tracks. :mrgreen: <- green, snivy tomfoolery going on with my submission

elsh
Posts: 13
Joined: Tue Jul 07, 2009 4:02 pm
Location: Grand Rapids, MI
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by elsh » Tue Nov 27, 2012 10:00 am

hows development on this coming along? still very interested in updates!

elsh
Posts: 13
Joined: Tue Jul 07, 2009 4:02 pm
Location: Grand Rapids, MI
Contact:

Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file

Post by elsh » Fri Jan 04, 2013 6:54 pm

bump for updates. still interested in this project

Post Reply