Need NSFs with Sound Effects

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

Moderator: Moderators

User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Need NSFs with Sound Effects

Post by Exploding Rabbit »

Hi. I need NSFs with sound effects for my game, Super Mario Bros. Crossover. Previously I was using prerecorded sound effects, but it'd save a lot of memory if I can read sfx directly from nsf files in-game.

A few games that I need nsfs with sound effects are Contra, The Legend of Zelda, Metroid, and Blaster Master. Is there an easy way to do it, or would I have to figure out how to rip them myself? Thanks!
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

Hmm, not sure about the NSF files, although I know they're standards, I'd try looking for a document on how they're set up and work, and then emulate the audio portion of the NES. I've never messed with anything like this to tell you what to expect more in detail, sorry. Somebody will surely provide more insight on this subject I am sure. :)
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Many NSF files have been ASM hacked to include a track order.

To find out what the first thing the NSF does, open it in FCEUX, Pause the emulator, Reset. Open the debugger, press the Step Into button twice.

For example, here's the Contra NSF:

Code: Select all

04:C3BE:AA        TAX
04:C3BF:BD C5 C3  LDA $C3C5,X @ $C3C5 = #$26
04:C3C2:4C 9B 87  JMP $879B
This code reads a replacement track number from a lookup table, located in memory at C3C5. To get rid of that stuff, replace all those instructions with NOP instructions. In this case, we can see all the hex values from FCEUX's debugger.
Grab a hex editor. Change byte 0006 in the file to FF to unlock all 255 tracks. Then look for the replacement track number code (AA BD C5 C3), and replace with NOP instructions (EA EA EA EA).

I happen to have a copy of a Legend of Zelda NSF with sound effects. It came from the defunct NSF repository at desnet.fobby.net.

The Metroid NSF doesn't have sound effects, but the rip of the FDS version does.

For Blaster Master, here's the track replacement code:

Code: Select all

03:BFA0:AA        TAX
03:BFA1:BD B0 BF  LDA $BFB0,X @ $BFB0 = #$54
So look for AA BD B0 BF, and replace with EA EA EA EA. (Also change byte 6 to FF)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Post by Exploding Rabbit »

Awesome! I was able to get everything I needed with all the info you provided. I was also able to use the same technique to get the sound effects from the Mega Man 2 nsf. Thanks for helping me. I need to ask on here more often when I need help!
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

I think, for a Flash game it would be better to not use NSFs as is (with all the ripped code and music data), but to convert them into a simple register writes log. This way you'll only need to emulate sound hardware without CPU and memory.
User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Post by Exploding Rabbit »

Shiru wrote:I think, for a Flash game it would be better to not use NSFs as is (with all the ripped code and music data), but to convert them into a simple register writes log. This way you'll only need to emulate sound hardware without CPU and memory.
I'm not sure I understand what you mean. It seems to work fine with NSFs.
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

NSF file contains piece of 6502 code and data extracted from a NES game. In order to play NSF you need to emulate NES CPU and sound hardware. Flash is slow, so this takes noticeable amount of processing power.

You can play NSF in an external tool that will emulate 6502 and record sound hardware register writes into a file. To play such a file in a Flash game you'll only need to emulate sound hardware but not 6502 CPU. This would reduce amount of processing power needed to play the sounds, and also exclude the ripped code/data from actual Flash game. This form of recording is comparable with NSF by packed size, much smaller than MP3.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

But does the 6502 emulation take noticeably more time than the APU emulation?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Isn't everything done using floating point math in Flash? So emulation of a 6502 would be a tad slower. But not all that much 6502 is actually executed, it's just the music playback code. Usually under 32 scanlines worth of code or so. Greatly dwarfed by the glue you need to stream sound to Flash.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Post by Exploding Rabbit »

I'm not sure how flash does math, but I know it needs floating points for sound.

Anyway, I got all the sound effects I needed for the previous NSFs and I have them working in the game. There is one problem. The Metroid FDS NSF only has about half the sound effects from the game. Does anyone know how to get the rest of the sound effects for Metroid in NSF format?

Also, I was trying to get sound effects for Mega Man 1 and Super C, but I didn't have any luck. Does anyone know how to get them? These are far less important than Metroid, but if anyone knows how to get them, it'd be helpful.

Thanks for the help.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Megaman 2 with sound effects. Not quite Megaman 1, but maybe it will do.

The Flash NSF player probably doesn't emulate the FDS sound channels, so about half of the sound effects will be missing.

Edit: Also Megaman 1 with sound effects.
Just increased number of songs to 255, and removed the song remapping table lookup code.
02:BE70:AA TAX
02:BE71:BD 80 BE LDA $BE80,X @ $BE80 = #$01
Last edited by Dwedit on Wed Sep 14, 2011 3:54 pm, edited 1 time in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Post by Exploding Rabbit »

It uses Game Music Emu. So are you saying the sound effects are there, but Game Music Emu can't play them?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Looks like it does NOT do FDS. It does do Konami VRC6 (some extra square waves and a sawtooth channel), Namco 106 (GB-like wavetable channels), and FME-7 (a few extra square waves). But I don't see anything in there about it doing FDS. This is just a quick glance.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Exploding Rabbit
Posts: 16
Joined: Fri Nov 19, 2010 7:06 pm

Post by Exploding Rabbit »

I tried playing the Metroid FDS Nsf in FCEUX and it plays the same sounds that Game Music Emu did. I don't think the other sounds are there. So am I out of luck? Would I have to learn to rip the Metroid NSF myself?

Edit: Thanks for the Mega Man 1 NSF. I tried finding the remapping thing but I don't really know how to do it I guess. Any luck on Super C?

Edit 2: I guess the Super C sound effects are there, I just didn't notice because they're all over the place.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Super C with sound effects. The old rip had 60 something tracks, but did not properly include sound effects at all.

This one had this boot code:

Code: Select all

07:F800:A8        TAY
07:F801:A2 0D     LDX #$0D
07:F803:A9 00     LDA #$00
07:F805:9D 00 40  STA $4000,X @ $400C = #$FF
07:F808:CA        DEX
07:F809:10 FA     BPL $F805
07:F80B:B9 20 F8  LDA $F820,Y @ $F820 = #$28
Took out the LDA $F820,Y, replaced with TYA NOP NOP.

Edit:
My copy of Metroid FDS nsf in case yours is any different.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply