The memory map
The SPC700 sees 64 KB, and the file holds all of it from offset $100, so address a is at file offset $100 + a. The sound program, its song data and the samples (in the BRR form the DSP reads) are all in this one space, as the game loaded them, along with the echo buffer the DSP writes.
| Addresses | Use |
|---|---|
| $0000 to $00EF | The direct page: 240 bytes that short instructions reach with one address byte. When the P flag of PSW is set the direct page is $0100 to $01FF instead. |
| $00F0 to $00FF | The I/O registers. |
| $0100 to $01FF | The stack, growing down from the SP of the header. |
| $0200 to $FFBF | Program, song data, samples, the sample directory and the echo buffer. |
| $FFC0 to $FFFF | The 64-byte boot ROM when it is switched on, otherwise RAM. The file saves the RAM under it twice: here, and again at the end of the file at $101C0. |
The I/O registers
The registers at $F0 to $FF are saved with the RAM. A player must carry them out, not just copy them: the timers, the ports and the DSP address are live.
| Address | Name | Use |
|---|---|---|
| $F0 | TEST | Chip test settings; a song leaves it at its reset value. |
| $F1 | CONTROL | Bits 0, 1 and 2 start timers 0, 1 and 2. Bit 4 clears ports 0 and 1 and bit 5 ports 2 and 3. Bit 7 shows the boot ROM at $FFC0 to $FFFF. |
| $F2 | DSPADDR | The register of the DSP that DSPDATA reads and writes. |
| $F3 | DSPDATA | The data of that DSP register. |
| $F4 to $F7 | Ports 0 to 3 | The four bytes shared with the main console: a write sets what the console reads, a read gets what the console wrote. A song reads them for its commands. |
| $F8, $F9 | Two bytes that act as RAM. | |
| $FA, $FB, $FC | T0TARGET, T1TARGET, T2TARGET | The target of each timer. 0 counts as 256. |
| $FD, $FE, $FF | T0OUT, T1OUT, T2OUT | A 4-bit counter for each timer, cleared when read. |
The processor is clocked at 1,024,000 Hz. Timers 0 and 1 count every 128 clocks (8,000 Hz) and timer 2 every 16 clocks (64,000 Hz); a timer's counter goes up by one each time the count reaches the target, which is how a song keeps its tempo. The DSP produces one stereo pair every 32 clocks, 32,000 a second.
In the explorer
The RAM is five nodes in the tree: the direct page, the I/O registers (each with its name), the stack, the program and data, and the part under the boot ROM. The SPC700 tab shows the processor registers, the control register, the ports and the timer targets as they were saved. The boot ROM is not needed: a song starts at the PC of the header, and the player only provides the reset vector.
Sources
- SPC and RSN file format (SNESdev wiki): the extra RAM under the boot ROM.
- SPC700 reference: the instruction set and the memory map.
- Game_Music_Emu,
Snes_Spc.cpp: the registers, the timers (prescalers of 128, 128 and 16 clocks, a target of 0 meaning 256) and the clocks.