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

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#98952)
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
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99539)
I totally need a version of this that'll let me combine VRC6 NSFs! :o

Is there any way around the FDS RAM usage?
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99540)
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.

Quote:
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.)
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99541)
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...
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99543)
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.
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99547)
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.)
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99696)
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.
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#99756)
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).
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#100408)
Thank you! :mrgreen: This worked for my Stinkoman NSFs!

Edit: Here! :o
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#101545)
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.
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#101612)
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)
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#101656)
I probably made some stupid mistakes I think I realized some of them later on I will fix it. Sorry...!
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#101657)
It's okay - I figured out a way to sort my tracks. :mrgreen: <- green, snivy tomfoolery going on with my submission
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#103543)
hows development on this coming along? still very interested in updates!
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#105539)
bump for updates. still interested in this project
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#160179)
I would like to recommend an affordable tool that can combine multiple .nsf file with another NSF files i.e. NSF Merge tool. This Lotus Notes Mail Merge tool will offer users two options to combine NSF data files i.e. Merge & Join. Give a try to its FREE version from [BLAM]
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#160186)
Not that kind of NSF. You're talking Notes Storage Facility; we're talking NES Sound Format. And we don't mean National Salvation Front, National Science Foundation, National Sanitation Foundation, Nonstop Forwarding, non-sufficient funds, or thiazyl fluoride either.
Re: CombiNSF v0.1 -- combine multiple .NSF to one .NSF file
by on (#160191)
Seems like spam, you should probably censor that URL.