The current URL is datacrystal.tcrf.net.
EarthBound/Audio: Difference between revisions
Line 1: | Line 1: | ||
== SPC RAM == | == SPC RAM == | ||
As with all SNES games, audio data must be loaded into the [[SPC700]]'s RAM before it can be played. This RAM contains all the song data, the instrument data, the sample data, and even the music playback code itself. The lower 32K of the SPC's 64KB memory (0000-7FFF) is used to hold all this data, and the upper 32K (8000-FFFF) is used by the SPC chip itself to hold internal state information | As with all SNES games, audio data must be loaded into the [[SPC700]]'s RAM before it can be played. This RAM contains all the song data, the instrument data, the sample data, and even the music playback code itself. The lower 32K of the SPC's 64KB memory (0000-7FFF) is used to hold all this data, and the upper 32K (8000-FFFF) is used by the SPC chip itself to hold internal state information. SPC files are nothing more than a straightforward dump of SPC RAM with a 256-byte header attached, so you can easily convert a RAM offset to an SPC file offset by adding 0x100 for the header. | ||
=== Patterns === | |||
The first pattern of the song is the first data to be found in the song data. So if, for example, the Song SPC Pointer Table has 0x6000 for your particular song, the first pattern is at 0x6000 in SPC RAM. The value 0x00FF marks a jump, with the following two bytes containing the address to jump to. The game only uses this to loop back to a previous pattern. The value 0x0000 indicates the end of the song (i.e., stop playing), which will never be reached in a song with a loop. | |||
The values pointed to are themselves pointers to the actual pattern data. In C notation, the pattern data for a pattern is at **pattern_tbl[i], not just *pattern_tbl[i]. This extra level indirection seems pointless, but nonetheless, it's there. | |||
The pattern data itself is a table of eight pointers. (Yes, even more pointers!) Each pointer corresponds to a channel. If the value is 0x0000, the channel is silent for that pattern, which is often done on channel 8 to allow sound effects to be played on it. | |||
== Song SPC Pointer Table == | == Song SPC Pointer Table == |
Revision as of 21:24, 16 February 2008
SPC RAM
As with all SNES games, audio data must be loaded into the SPC700's RAM before it can be played. This RAM contains all the song data, the instrument data, the sample data, and even the music playback code itself. The lower 32K of the SPC's 64KB memory (0000-7FFF) is used to hold all this data, and the upper 32K (8000-FFFF) is used by the SPC chip itself to hold internal state information. SPC files are nothing more than a straightforward dump of SPC RAM with a 256-byte header attached, so you can easily convert a RAM offset to an SPC file offset by adding 0x100 for the header.
Patterns
The first pattern of the song is the first data to be found in the song data. So if, for example, the Song SPC Pointer Table has 0x6000 for your particular song, the first pattern is at 0x6000 in SPC RAM. The value 0x00FF marks a jump, with the following two bytes containing the address to jump to. The game only uses this to loop back to a previous pattern. The value 0x0000 indicates the end of the song (i.e., stop playing), which will never be reached in a song with a loop.
The values pointed to are themselves pointers to the actual pattern data. In C notation, the pattern data for a pattern is at **pattern_tbl[i], not just *pattern_tbl[i]. This extra level indirection seems pointless, but nonetheless, it's there.
The pattern data itself is a table of eight pointers. (Yes, even more pointers!) Each pointer corresponds to a channel. If the value is 0x0000, the channel is silent for that pattern, which is often done on channel 8 to allow sound effects to be played on it.
Song SPC Pointer Table
This table is located at 262B8C in the ROM and contains 191 (0xBF) entries. Not all songs are loaded into the same offset in SPC RAM, so this table is used to tell where in SPC RAM the song is located. Each entry is a two-byte pointer in little-endian (LSB first) format.
The first entry in the table is actually song 01, not song 00 (i.e., the table is accessed as if it began at 262B8A instead of 262B8C). Song 00 does not point to an actual song (in fact, it points to an area in the SPC700's upper memory, where the game cannot load its song data), and its space in the table is probably used by the preceding data chunk. Similarly, the last song is actually song C0, although it is entry BF in the table.