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

Author Topic: A question about SNES SPC Data  (Read 1727 times)

TheLoneSurvivor

  • Jr. Member
  • **
  • Posts: 12
  • back from the dead
    • View Profile
A question about SNES SPC Data
« on: July 22, 2015, 01:24:45 pm »
Hello. I am an SNES ROM Hacker focusing on Doom, for the SNES.
I am trying to figure this out.

How does an SPC ripper find all the data for the music, (aka the pointers, offsets, general music data) and also, is there an SPC ripper that will tell you the location of the music. I know the SPC data is stored in RAM, but the SPC700 has to upload the music data from the ROM to the SPC RAM, where the SPC executes the instructions for patterns, samples, looping, echoing, and etc. So, since the music data is uploaded to the RAM, and is originally in the ROM before being uploaded to the RAM, how to you figure out where it is in the ROM?

Also, if you are curious about my Doom SNES hacking, and my ROM Hacking skills. This is what I have done.

-Replaced sounds in the Doom SNES ROM
-Found sprites and the doom font in the Doom SNES ROM
-Replaced text strings in the Doom SNES ROM (say for example making it say You have been healed instead of you picked up a medikit when you pick up a medikit)
-Discovered ASM code in the Doom SNES SPC files.

I am new here, so if I accidentally broke one of the rules please notify me and I will fix it to comply with the rules.
I try my hardest to stay within the guidelines.
Doom SNES Hacker.

Disch

  • Hero Member
  • *****
  • Posts: 2658
  • NES Junkie
    • View Profile
Re: A question about SNES SPC Data
« Reply #1 on: July 22, 2015, 01:34:13 pm »
How does an SPC ripper find all the data for the music, (aka the pointers, offsets, general music data)

SPCs are typically not ripped, but are usually "dumped".  They are little more than a savestate.

Quote
and also, is there an SPC ripper that will tell you the location of the music.

No.  This varies from game to game so you'll have to find it on your own.

Quote
I know the SPC data is stored in RAM, but the SPC700 has to upload the music data from the ROM to the SPC RAM, where the SPC executes the instructions for patterns, samples, looping, echoing, and etc. So, since the music data is uploaded to the RAM, and is originally in the ROM before being uploaded to the RAM, how to you figure out where it is in the ROM?

There are several ways to do this.  The easiest I can think of would be to mess with an .spc file through corruption or whatever to try to figure out what parts of the file are actually music data.  Then once you've figured out what is music data, you can do a search for that data in the ROM.

MathOnNapkins

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 629
  • Who ya gonna call
    • View Profile
    • Arc-Nova - Rohmackin' and Chiptunin'
Re: A question about SNES SPC Data
« Reply #2 on: July 22, 2015, 01:47:37 pm »
SPC files consist of a minimum 256 byte (but could be larger) header meant for music players, a 64 kilobyte savestate of the S-SMP RAM, and a 256 byte savestate of the S-DSP registers. They are laid out in that order in the file. If you don't know, the S-SMP is what is commonly referred to as the SPC or the SPC-700, and it's the microprocessor along with 64K of ram. The S-DSP is another component that actually generates and mixes all the audio output. It's somewhat tightly coupled with the "SPC-700" as a whole. I don't know the specific techniques that people use to dump SPC files, but I imagine it could involve intentional slow down and possibly manipulation of game variables via cheat codes or use of a debugging emulator.

This approach only works, of course, if all of the song's data is held within the APU's (S-SMP) RAM at the time the savestate is stored. There was a small push in the past to rip SNES audio in a formats more analogous to that of the way PSX and GBA music is stored. In such a format, code on both the S-CPU and the S-SMP side would have to be packaged into the image. But again, one would only need such a format for music that needs updates from the S-CPU side after having been put into motion.

The long and short of it is that people doing SPC rips probably don't need to know all the specific information you're asking about, but I imagine for some games it could be of use if things were to go wrong, or they wanted to start the SPC at a specific time index (rewind, essentially). I imagine a lot of people doing rips just figure out enough to get the songs they want to play and then just savestate at an opportune time. Some games also have sound tests, which would make things much easier.

As for how you find music in a game, that could vary somewhat depending on your skill level and skill set. As someone that can debug pretty well, I might just look for writes to the $002140-3 registers and that would tell me at some point when music was being uploaded to the S-SMP.

TheLoneSurvivor

  • Jr. Member
  • **
  • Posts: 12
  • back from the dead
    • View Profile
Re: A question about SNES SPC Data
« Reply #3 on: September 27, 2015, 12:43:06 am »
Ah, I see, but what about the SNSF format, which directly rips the instructions to play it from the ROM. Only problem is, I can't find the data for the music when I open the SNSF in HxD, And the only music that actually rips and works is the intro and title screen music, the rest of the music is not there though. 
Doom SNES Hacker.