Author Topic: Want to use NSFs or other game music format that stores multiple songs?  (Read 385 times)

Description: Want to be able to play all of those songs from a single file?

0 Members and 1 Guest are viewing this topic.

Offline Gibbering Mouther

The purpose of this guide is to show a clever trick to play any song from a game sound format like NSF.

You will need:

* A hex editor like HxD.
* Knowledge of the format header (I'll use NSF as an example; otherwise you have to find this out on your own)
* Game Maker Pro (8.0 is used for this example)
* S-Winamp or SXMS. S-Winamp is used in this guide. Don't delete the example.
* Winamp plugins: out_wave.dll and NSFPlug (for NSFs; different files will need different input plugins)
* Game music files, obviously. Keep backups because you can easily ruin these files.

Step one: Know the header.

S-winamp or any other winamp plugin doesn't allow you to pick the song (using plugins like NotSoFatso does, but the WAY it does it (via popup) makes it unsuitable for games) in such files. So how do we pick the song while playing the game? Well, at least for NSFs, there's two things to know:

* The header for NSF files contains the number of songs.
* The header for NSF files also contains the number of the first song that plays.

Kevin Horton, the person who designed the NSF format, documented his header well:

0006    1   BYTE    Total songs   (1=1 song, 2=2 songs, etc)
0007    1   BYTE    Starting song (1= 1st song, 2=2nd song, etc)


Step Two: Experimentation and Discovery

In this step, you need to find all the songs you wish to play. Note that a hex editor displays numbers in hexadecimal format. If you don't know what that is, you should look it up so you don't get confused between hexadecimal and decimal number formats and play the wrong songs.

Open your hex editor and go to offset 00000006. Commit the number of songs to memory before editing it to 01. Offset 00000007, the byte for the first song that plays, is usually 01. Edit it to whatever song number you wish and run the S-winamp example to play it. It would help to keep a list of what numbers you use and what songs wind up playing.

Repeat until you know the numbers for all the songs you need.

Step Three: Binary by another name

Now you can play any song from the file by doing the following:

*Unload the winamp input plugin (NSFPlug's in_yansf.dll, in this case), freeing memory associated with it. That is, if it's already loaded.
*Use file_bin functions to open and write to the file as if it was a .bin file. Replace "7" with the position of the song number byte in your file.
Code: [Select]
file=file_bin_open("mysongs.nsf",1);
file_bin_seek(file,7);
file_bin_write_byte(file,songnumber);
file_bin_close(file);
*Load/Reload the input plugin.
*Play the song.

I didn't go into great detail to describe how S-Winamp works, but that extension has its own help so hopefully you should be fine. If I wasn't clear on something or you need help for whatever reason, feel free to speak your thoughts.
"For a just man falleth seven times, and riseth up again: but the wicked shall fall into mischief." --Proverbs 24:16






 

Alternate Earth Visitors


The fangames featured on Fusion Fangaming are non-profit fan-based works.

All commercial games represented, including character likenesses, graphic resources, sound effects, musical compositions, and level designs, are properties of their respective owners, companies, and other entities.

Please support the official games.

Hosted by The Spriters Resource.