What This Is

This was my attempt to get NSF music working in PocketNES, an NES emulator for the GBA, before I discovered HVCA, another NES emulator for the GBA that also played back NSF files natively. In essence, I convert NSF files to *.nes executable files that run in any standard NES emulator. The process is fairly simple: I remove the first 128 bytes of the NSF file, which leaves me with the raw music data. I then use the DASM compiler to compile the code at the end of Chris Covell's "NES Music Ripping Guide".

Other *.nes executable music files that I did not make can be found here.


Creating These Files Example

In my example, everything will be named "dodongo" just for the heck of it. Start with dodongo.nsf and copy the assembler code into a new file called dodongo.asm. Chop off the first 128 bytes of the NSF file, saving this as a new file named dodongo.mus. Next, create a header.ines file which consists of the following when viewed in a hex editor:
4E 45 53 1A 02 00 00 00 00 00 00 00 00 00 00 00

Open the dodongo.asm file in Notepad and modify the INIT, PLAY, START, and MAX values as appropriate (open the NSF file with FCE Ultra and go to Help - Message Log to find out the INIT and PLAY addresses). Leave the ORG code alone for now until you make your first compile. You can then compile everything and create the output dodongo.nes file in one step using a batch file which consists of the following:
dasm dodongo.asm -f3 -ododongo.bin
copy /b /y header.ines + dodongo.mus + dodongo.bin dodongo.nes


The output file will not run yet (unless you got REALLY REALLY lucky) so now we need to mess with the ORG code. Basically, we want the final output dodongo.nes file to be EXACTLY 32,784 bytes in size. To do this, we modify the ORG code to change the dodongo.bin filesize so that when added to the dodongo.mus file it comes to 32,768 bytes (the extra 16 comes from the iNES header). When you increase the ORG code, the output dodongo.bin filesize decreases, and vice versa. Therefore, increase/decrease the ORG code and run the batch file over and over again until the dodongo.nes file comes out at exactly 32,784 bytes. Personally I use the Windows calculator in scientific mode to help out with this. For instance, lets say the output dodongo.nes file after our first compile is 28,385 bytes in size. 32,784 - 28,385 = 4,399, which when converted to hex is $112F. Since we want to increase the filesize by 4,399 bytes (hex $112F bytes), we decrease the ORG code by $112F. In this case, since we started with an ORG code of $C000, our final ORG code is $AED1.

If all goes well, your *.nes file should open and start playing the first tune. If you get a black screen but the graphics are insanely corrupted and nothing works, well then I don't know what to do. This could mean that the NSF file was bankswitched (which this method does not support) or it could just be an incompatible game. Games that I've already tested that don't work with this method include Metroid, Super Mario Bros., Zelda 1, Dr. Mario, Marble Madness, Top Gun, and Slalom.


Ones That Work Correctly

All 10 working files. Includes the following: Press Start to advance to the next track.


Quality is Questionable or Partially Corrupted

This is caused when the *.nsf file is already 32 KB in size (or close to it) and we can't get the *.bin file small enough, so we must delete some of the data at the end of the *.mus file so it will all fit in 32,784 bytes.

Tengen Tetris

Ninja Gaiden 1

Ninja Gaiden 2

Ninja Gaiden 3 1