News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Locating Music Tracks in NES, SNES, & N64 ROMs?  (Read 1251 times)

Rew

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Locating Music Tracks in NES, SNES, & N64 ROMs?
« on: November 28, 2020, 04:46:33 pm »
Hi!

So I would like to compile a list of music file locations for certain Mario, Zelda, Kirby, Mega Man, etc. games on NES, Super NES, and N64. The problem is, I have very little knowledge of how to obtain such info. To give you an idea of what I'm wanting to do, here is the N64 spreadsheet I'm putting together:
https://docs.google.com/spreadsheets/d/16WLwqcMPOdYi8ZKWT6XXH9Yuf6PIdSaFb2eGQRhP8YE/edit#gid=0

I only have info for Zelda: OoT & MM thanks to lists I found here and here, respectively.

My question is, how can I locate the music in the ROMs of other games, not only for N64 but also NES and Super NES? It's not that I want anyone to find these for me (though if anyone knows of any other lists like what I linked above, that would be awesome), but I'd like to learn how to find this kind of info for myself. But I have minimal hacking/datamining experience. What do I need to get started? How exactly do I begin? I know each game stores its music differently, even on the same system. I guess I'm looking for a starting point to looking for the tracks.

Here's what I already have:
- Hexadecimal editor
- ROMs of most of the games I'm interested in
- NSF, SPC, & USF plug-ins for Winamp, plus rips of most games of those file types (though I don't think the ROM locations of the tracks are embedded in these ripped music files anywhere that I can see?)

Now I don't have any great, overarching purpose to this project. I'm not interested in rips of the music itself (as I already have most of those). It's just the way game ROMs store their data and how it's all ordered--particularly text and music--has long been strangely interesting to me. So I'd like to compile track lists for all the games I like on these three systems.

Thanks in advance! (And I apologize if this thread should be posted on the newcomer's board instead?)

FAST6191

  • Hero Member
  • *****
  • Posts: 3013
    • View Profile
Re: Locating Music Tracks in NES, SNES, & N64 ROMs?
« Reply #1 on: November 28, 2020, 05:27:32 pm »
The trouble will be that music does not necessarily work the way you are imagining.

Your plugins for music players are basically emulators without the graphical aspects. The NSF being a slightly tweaked ROM with the audio aspect described in a certain way and with the graphics and whatnot stripped out. Some later devices can have it a bit easier as they are basically a software format with software defined wave samples but often are still emulators, or still lean into emulator derived playback if there are some nice features custom to the underlying hardware.

This is to say the older devices had several nice custom chips (occasionally governed by their own processor, though most will be thinking megadrive/genesis for that one), possibly another wedged on the game cart itself to give that little bit extra to play with ( https://wiki.nesdev.com/w/index.php/List_of_mappers , see those mentioning audio, though SNES and N64 tended to be more about graphical or clocks or controllers or something extra on the processing than audio, though in doing so it would free up resources to have more fun with audio).
Tracks were not necessarily (some were though) basically a bit of glorified sheet music saying play this sample for this long as much as potentially long string of assembly.
For the N64, though it started to resemble the software defined stuff of today, they still had that bit of custom aspect. I was watching a video stream once with some former Rare devs detailing development and basically dev commentary on Conker's Bad Fur day. One point they mentioned in a game having two tracks play simultaneously so when the player crossed a transition point they would have the track fade into the other right where it would be had the player been there all along. That said end stage boss triggering musical double time or maybe looping a smaller section round and round a few times is something you will probably find examples of.

Back to the older devices then it was also not really like the GBA or DS wherein there is a major software format that the vast vast majority of games use, so much so we note the exceptions, and said exceptions are usually "plain wave", "well known PC format", "well known game format" or minor header on each of those. The audio engineers/game musicians of the day were often highly competent programmers in their own right and usually custom made one for each game, or maybe custom made one games in the same franchise (or possibly same dev/pub) would use, though potentially developed or twisted a bit to suit purposes between different games.

This is not to say you can't do something, and maybe your limited selection could have it more boring and basic (though most of those being flagship titles with several noted examples of devs of them pushing the boat out a bit in terms of what the hardware was normally expected to to rather than cartoon tie in games that is not a bet I would take). However I would not be suggesting a hex editor for this (saving that you compare and contrast your already made rips with the original ROM) and that you have one is assumed and largely immaterial. You will then largely be getting down and dirty with a debugging emulator and hardware documentation of the, maybe if you are lucky a description of the audio setup from that game from a hacker that came before you or an interview with the audio programmer in the years since.

This is also why audio hacks on anything older than the GBA that was not on a CD or maybe Amiga (various tracker formats coming out/rising up in that world) are so rare, generally considered one of the more difficult aspects of it all, and any tools tend to focus on specific games (and are anything but import-export or basically a tracker program you can tweak).

Jorpho

  • Hero Member
  • *****
  • Posts: 4666
  • The cat screams with the voice of a man.
    • View Profile
Re: Locating Music Tracks in NES, SNES, & N64 ROMs?
« Reply #2 on: November 28, 2020, 08:16:53 pm »
- NSF, SPC, & USF plug-ins for Winamp, plus rips of most games of those file types (though I don't think the ROM locations of the tracks are embedded in these ripped music files anywhere that I can see?)
You will note that every SPC file is exactly the same size.  That's because SPC files are just dumps of the memory used by the SPC700.  Making changes to the music for a SNES game involves analyzing the program code to find out how it determines what to write to that memory.  There are very, very few games that write to the SPC directly and for which you will find no SPC dumps – Wario's Woods is the main one.  There is a Winamp plugin, Highly Competitive, and an associated SNSF sound format for those games that is more directly analogous to NSF and USF.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Sanedan56

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Locating Music Tracks in NES, SNES, & N64 ROMs?
« Reply #3 on: November 30, 2020, 04:00:38 pm »
As a start, I'd recommend looking at the Data Crystal wiki for information and offsets. Many games use sound drivers that are company standards e.g Mega Man using Capcom's driver with usually minor variations. A search on the internet for sound driver the games you're looking for should also turn up results.
 
If there are no notes on the offsets of a game you're looking for, you will have to find them yourself. This will require you to use a debugger and learn the system's audio registers. I'd recommend starting with the NES. First, search the RAM
for any values that change with the music. Then, set a breakpoint for it. A faster alternative would be to use the Code/Data logger on FCEUX(This can be used only on the games, not NSF files). Note that some games store the songs in RAM, making it difficult to locate with this method.