It is currently Sat Nov 18, 2017 10:15 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Sep 11, 2011 8:56 pm 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
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!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 11, 2011 9:17 pm 
Offline
Formerly 65024U

Joined: Sat Mar 27, 2010 12:57 pm
Posts: 2257
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. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 11, 2011 10:21 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
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:
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:
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!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 12:31 am 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
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!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 5:26 am 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 10:52 am 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 11:32 am 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 12:20 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19226
Location: NE Indiana, USA (NTSC)
But does the 6502 emulation take noticeably more time than the APU emulation?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2011 12:40 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
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!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 3:36 pm 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 3:49 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
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

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Last edited by Dwedit on Wed Sep 14, 2011 3:54 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 3:54 pm 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
It uses Game Music Emu. So are you saying the sound effects are there, but Game Music Emu can't play them?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 3:57 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
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!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 4:01 pm 
Offline
User avatar

Joined: Fri Nov 19, 2010 7:06 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2011 4:22 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
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:
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group