SPC Tool v0.61
Copyright © 2000 Alpha-II Productions

DO NOT RUN THIS PROGRAM IN A DOS BOX!!
SPC Tool uses a custom video mode, and cannot be windowed.  You can still run it under Windows, but you must be at a full screen [Alt-Enter].

If you want to run SPC Tool without the GUI, see section 2.1 about Play Only mode.
 

Disclaimer

This program was written in my spare time for my purposes.  I make no guarantee that it will run in part or in whole, as intended or implied on your system.

I've released it because I felt that some people may find it useful.  If you find it useful, good.  If not, don't complain.


 

Contents

1. Intro
1.1 What is it?
1.2 Features
1.3 System Requirements
1.4 Ripping .SPC's

2. Commands

2.1 Command Line Options
2.2 Key Commands

3. Main Program and Emulator

3.1 Main
3.2 Emulation

4. Wave Forms

4.1 The Wave Table
4.2 Wave Options
4.3 Wave Forms

5. Logging the DSP

5.1 Logging to .WAV
5.2 Logging to .MID

6. Debug Mode

6.1 Walking Around
6.2 Inside the SPC700

Appendix

A. Missing Features and Known Bugs
B. Program History
C. Credits
D. Contacting the Author
E. GM Program List

 

1. Intro

1.1 What is it?

SPC Tool is a program that takes the functions of several programs already available and places them into one.  What's the purpose of that?  Well initially this started out as an idea I had to create a fast, low-level emulation core.  The SPC700 was simple enough, and I set out about my task.  When I finished I realized I hadn't accomplished much.  (What good is a stand alone SPC700 emulator?)  So I decided to add a DSP emulator, and as I was doing that I started adding other options and features.  By now it's progressed to a point that I figure others could make use of it.  So here it is.

Like any emulator author, my goal is to create a perfect emulator.  And although SPC Tool is probably the fastest and most accurate, that goal still has not been reached. This is version 0.61, meaning it's a public beta.  There are bugs in this program.  There are still features that are not yet fully implemented, or implemented at all.  Use it for what it's worth.

- Anti Resonance

1.2 Features

CPU emulation -
Emulation of all opcodes, except BRK
Integrated run-time debugger

DSP emulation -

Non-standard output sample rates
ADSR/Gain envelope modification
Pitch modulation
Noise generation
Almost correct sample decompression
Correct FIR filtering on output rates other than 32kHz
Linear and cubic spline interpolation
Log output to WAV file
Log registers to MIDI file

SPC files -

Support for song and fade length
Edit text in ID666 tag
Pull from ZST's

Waveforms -

Rip BRR data as a WAV
Convert WAV to BRR using ADPCM compression

Coded entirely in assembly and compiled with TASM v5.2

1.3 System requirements

Minimum -
80486 w/ 480K free conventional memory
VGA video card
SoundBlaster or compatible with DSP v2.00 or higher

Recommended -

Pentium with MMX support
100 percent IBM VGA compatible video card
SoundBlaster Live!
MS-Mouse v6.0 or higher

These are my system specs, and I've had no problems -

PII 400
STB Voodoo 3 3000
SoundBlaster Live! Value
MS Optical IntelliMouse
I haven't actually tried this program on a 486, but I have run it on a P100.  So it probably could run on a 486 100 at 8kHz.

I don't have an 8-bit sound card, so working out bugs is difficult.  On one of the machines I tested, SPC Tool would lock up after pausing emulation.  This appears to be a problem with certain 8-bit sound cards when running in high-speed DMA mode.  The only work around to this is to run at 16kHz mono or less.

1.4 Ripping SPC's

There is a device in the SNES.  This device consists of an 8-bit CPU (Sony SPC700) and 64KB of RAM mounted on a circuit board.  It's connected to the main board by a series of pins, and communication with it is carried out through one of four ports.  Other than that, though, this device is completely separate physically and logically from the console.

The SPC700 runs at a whole 2.048MHz, has six internal registers, and can execute 256 opcodes.  Obviously it's not as powerful as the computers of today, but in and of itself it's quite capable of performing many tasks.  However, there are no input or display devices attached to it, so what good does it do us?

Well, the SPC700 does have a 16-bit DSP attached.  This DSP functions much like the wave table sound cards today, capable of mixing 8 voices simultaneously at various pitch and volume.  Programs can be written for the SPC700 that play music with the DSP just like people write programs for your PC that play music with your sound card.

Knowing that background, it's easier to understand how the music on the SNES works.  A composer at [some gaming company] puts together a happy little tune using a sequencer on a PC.  He then gives this song to the game programmers. They in turn place this song, along with some graphics, data, and code into a game.  Part of that code consists of a program written for the SPC700 that can play this song.  Most likely when the game boots it uploads this program to the SPC's RAM.  Then at intervals in the game different songs are uploaded and played by this program.

Here's where the problem arises.  The format of this song could be anything from a standard MIDI file to a proprietary format devised by the gaming company.  But that doesn't matter, because the game programmers wrote a program that can play this song.  Well, it doesn't matter to the common gamer anyway.  For those of us who actually listen to video game music (admit it, some game music is actually pretty good) this is a problem because we don't know to play these songs!

Keep that thought for a second while I switch topics.  Imagine if you could freeze the current state of your PC, and save all of your RAM to disk.  Later on your computer crashes, but rather than rebooting, you just load all that data back into memory.  Now your computer is back where it was as if nothing had changed.  (This option to save the state of the machine is actually utilized by some laptops as a way to conserve power when sleeping, but you're probably more familiar with emulators using it as a cheap way to save the game.)

Now, coming back, you're playing your favorite SNES game on your PC.  You look down at the dusty SNES console on the floor and wonder if your friend still has the Chrono Trigger cart you let him borrow last year, but then your attention is suddenly turned back to the monitor as that kick ass theme starts playing.  You want to save the music, so you dump it to the hard drive, and later play it in a loop a few hundred times (or maybe not that long) with SPCAmp.

How is this possible?  The emulated SPC has in its RAM both the song and the program needed to play it.  When you save the song, you're mearly freezing the state of the SPC, and saving all the memory to disk.  It's still unknown what the song is and how to play it, but you now have the program that can interpret it.  By means of an emulator you can load this small memory dump and continue playing the song.  The program inside has no idea that it's not really inside an SNES, or that it was even stopped at any time.

Instruments have to be stored using BRR blocks in order to be utilized by the DSP.  By looking for characteristics in the data that matches BRR compression methods we can find stored waveforms.  But since there's no standard format for the music, we don't have anything to search for.  This is why .SPC's can't be ripped from ROMs directly.


 

2. Commands

2.1 Command-line Options

FILE Input file
Any standard 8.3 file name that belongs to an SPC dump, ZSNES saved state, or SNES ROM image.
 
/V Non-standard VGA
SPC Tool runs in 90x60 text mode, and creates a graphical cursor by updating the character map.  If your video card is not compatible with the standard VGA, attempts at updating the screen will produce garbage.  This option turns the cursor into a friendly block, and uses slower BIOS routines to update the screen.
 
/J Japanese character set
If a ROM is detected as being from Japan, the character set will be automatically switched to JIS-X0201.  However, if you want to use Katakana characters in the ID666 tag of an .SPC, use this to overload the default US ASCII character set.
Because of the nature of the graphical mouse, characters Mi through Yu will not be viewable unless you use /V.
 
/X Disable MMX instructions
If you have an MMX processor, 64-bit instructions will be used for faster processing.   (On Pentium IIs conditional move instructions will also be used.)  If, for some strange reason, you don't want faster processing, this option will disable MMX support.  This option has no effect on non-MMX CPU's.
 
/P[#] Play Only mode
This removes any functionality of SPC Tool by disabling the GUI and all keys except Esc.   Use this mode for playing songs in the background of Windows.
The value passed with /P is the pre-amplification level.  If no value is passed, the default level (30) is used.  Valid values are 0-99.
 
/O Disable sound card output
This disables the sound card, though I'm not sure why you'd want to.  If the sound card is disabled, all output will be written to disk as a .WAV file.
 
/8 Force 8-bit samples
/M Force monaural samples
The highest quality supported by your sound card will be detected automatically.
Mixing is performed in 32-bit stereo regardless of output type, so forcing mono won't speed things up.
 
/R# Output sample rate:
1-8000Hz2-11025Hz3-16000Hz4-22050Hz
5-32000Hz6-44100Hz7-48000Hz8-64000Hz
The default is 32kHz, same as the SNES.
The 64kHz is there because it can be.  Maybe someday a sound card will support it.
 
/I# Default interpolation:
1-None2-Linear3-Cubic Spline
The default is cubic, but slower systems may need to change to linear.
 

2.2 Key Commands

Main commands -
F1  Help
F11  Exit program
F12  About

Emulation -
F3  Save .SPC file
Alt-F3  Log DSP
F5  Emulate SPC700
Shift-F5  Reload RAM
F7  Debug mode
F8  Pause emulation
Shift-F8  Reset SPC700
Emulate at full speed
+/-  Adjust amplification
1-8  Mute channel

Wave Table -
Shift-F2  Import waveform
Shift-F3  Save waveform
Shift-F9  Reload source directory
Up/Down  Select previous/next waveform
PgUp/PgDn  Move forward/back one page in wave table
Space  Play waveform

Debug Mode -
F7  Emulate next instruction / Stop Emulation
Shift-F7  Emulate to next line
Alt-F3  Log Disassembly
0,1,2,3  Watch out-port 0-3
Alt-0,1,2  Watch timer 0-2
Ctrl-0,1,2  Watch counter 0-2
Watch control register port
Watch DSP address port
Watch DSP data port
Esc  Exit debug mode


 

3. Main Program and Emulator

3.1 Main

Help
F1

Provides basic help for current screen.

Exit Program
F11 or Quit button

Stops any emulation and logging processes, and exits the program.

About
F12

Your standard about box.  Also has some info about the current environment.

Enter Debug Mode
F7

Turns off the sound output and switches to the debug screen.

Changing ID666 text
Click on text in the header window

Text can be composed of any of the 256 ASCII characters.

Changing song and fade length
Click on total time in the output window

Song Length: The length of the song, in seconds, not including the fade time.  Values can range from 1 to 9999.
Fade Time: The duration of the fade, in milliseconds, after song length.  Values can range from 1 to 120000.

3.2 Emulation

Emulate SPC
F5 or Play button
Cranks out the tunage man!
Pause Emulation
F8 or Pause button
Stops the music or logging in progress
Reload RAM
Shift-F5 or Rewind button
Resets the music by reloading the RAM and CPU state.  Reloading the RAM doesn't reload the wave table or unmute any channels.
Emulate at full-speed
~ or Fast-forward button
Speeds up the song by not waiting for an interrupt to occur before creating the next block of sound.  The speed of playback is solely dependent on your processor.

Pressing the ~ key turns FF on and off.
Pressing the FF button turns FF on until it's released.

Save .SPC File
F3 or... that upside down eject button

Write ID666 Tag Only: Just saves the text and song length.
Write DSP Registers Only: Just saves the 128 bytes of DSP RAM.
Save All .SPC Data: Saves ID666 tag, CPU state, SPC RAM, and DSP RAM.
Use SPCAmp format: Checking this box causes the numerical values in the ID666 tag to be stored in binary form instead of text.

If the SPC data was loaded from a .ZST, the first save will save everything regardless of which option you select.

Once changes are saved they cannot be undone.

Log DSP
Alt-F3 or Record button

MicroSoft Waveform: This logs the sound as you hear it to a .WAV file.
MIDI: This logs the pitch, waveform, key registers, and changes in volume to a .MID file each time counter 0 is increased.

Logging will begin as soon as you press OK.  The filename will be the same as the .SPC, but with the appropriate extension.

By default, the .WAV file sample settings will be the same as the current settings.

During logging, the output sound is turned off.

Pre-amplification Level
+ and -

.SPC's vary greatly in how they're mixed.  SquareSoft music is often too quiet, while Capcom music can be too loud.  This lets you adjust the level of amplification before output.  If amplification is too high, clipping will occur.

Mute Channel
1-8 or Clicking on channel number

Disables mixing a channel into the output or logging its updates.

Reset SPC700
Shift-F8 or up arrow button

Erases all RAM and places the CPU in a loop.  Not really useful for anything.

 

4. Waveforms

4.1 The Wave Table

If the file loaded is an .SPC or .ZST, the Wave Table window contains a list of the waveforms loaded into RAM.  This list is derrived from the source directory.  A filter similar to the one used in the search algorithm is used to eliminate invalid instruments, but it's not completely accurate.

If a ROM was scanned for BRR data, then the window contains the search results.

There are five columns in the table:

Column    .SPC or .ZST BRR Search
Number The index in the source directory No meaning
Offset Offset in RAM Offset in file
Length Size of waveform in samples Size of waveform in samples
Loop Starting sample of loop Waveform has a loop point
BRR BRR compression methods used with waveform    BRR compression methods used with waveform
Select Waveform
Up or Down or Clicking
Selects the waveform to modify.
Scroll through table
PgUp or PgDn or the (partial) scroll bar

4.2 Wave Options

The Wave Options window is used to set how the waveform is mixed and logged.

Left/Right clicking on a label will decrease/increase the value associated with it.  In the case of Mid-C, the value will be lowered/raised a half-step.

Interpolation
Inter

Selects the type of interpolation to use for playback:
None The waveform is scaled for playback without any form of anti-aliasing.  Use this if anti-aliasing softens the samples too much.
Linear Delta samples in a scaled waveform are changed at an even rate.  This method greatly improves sound quality by eliminating hard edges.
Cubic Spline    Delta samples in a scaled waveform are based on surrounding samples.  This method recreates natural sounds better than linear, but may skew samples from synthesized sources.
Playback Rate for Middle-C
Mid-C
Specifies the default sample rate for playback.  Also used for logging.  Values can range from 1 to 128000.
The rest of the options are used for only MIDI logging, and are further explained in 3.4.2.

Instrument Type
Type

Can be either Tone or Drum Set
Program Number
Prog #
Values can range from 1 to 128
Bank Number
Bank #
Values can range from 0 to 127
Amplification
Amp
Values can range from 1 to 127
Envelope Logging
Env
Value can be Ignore, EnvX, or ADSR

4.3 Wave Form

The Wave Form window is a graphical representation of the waveform.  The domain is scaled so the waveform fits the window.

All waveform functions, except save, are disabled during emulation.

Play Waveform
Space or Play button

Plays the waveform at the rate specified by Mid-C
Stop Playback
F8 or Stop button
Stops the waveform from playing
Import Waveform
Shift-F2 or Eject button
Replaces the BRR data with a user supplied 8 or 16-bit mono .WAV file.  The best method of compression will be chosen by the import routine.

.WAV files longer than the BRR data will be truncated.

A baseline block will automatically be inserted at the beginning of the BRR data to reset the reference samples.  Keep this is mind because it decreases your maximum wave length by 16 samples.

Imports into ROM files are permanent and cannot be undone.
Imports into .SPC's must be saved, and can be undone by reloading the RAM (F5 or Rewind).

Waveforms that have been successfully imported will be displayed in green.

Export .WAV File
Shift-F3 or inverse eject button
Decompresses the waveform and saves it as a .WAV file.

Waveforms that have been successfully exported will be displayed in red.

Reload Wave Table
Shift-F9 or up arrow button

Reloads the wave table by scanning the source directory.  This function also resets and options that have been set to their default values.

Has no effect on ROMs.


 

5. Logging the DSP

SPC Tool has the ability to log the output of the DSP to disk in Micro$oft wave format, and the state of the DSP registers in a Musical Instrument Digital Interface format.

Currently you cannot specify what filename to use to log to.  The filename used is the same as the .SPC file, but with an appropriate extension.

After selecting which kind of logging to perform, logging will start as soon as you press OK.  During the logging process the output to the sound card will be disabled.  This is done for two reasons:  First, it makes logging faster.  Second, slow disk writes can cause the playback to become broken up.

5.1 Logging to .WAV

Logging to Microsoft Wave format takes the same output you hear, and saves it to a .WAV file.  .WAV files can be created at different sample rates and resolutions by changing the options in the lower half of the window, but aspects like song length, pre-amplification, and channel muting will remain the same.

5.2 Logging to .MID

Logging to MIDI is more difficult that to .WAV because each instrument has to have specific options set.  In fact all the option fields, except interpolation, are used.

Because of all the variables involved, SPC Tool wasn't intended to create perfect .MID files.  Instead, it's pupose is to remove much of the guesswork and aid those who sequence video game music manually.

Middle C

The most important value, this is the playback sample rate for middle C, and is needed to determine which note to log.  The default is 32kHz, though that's rarely the actual value used.

Tone or Drum?

By default, an instrument is logged as a tone, but instruments can be logged as percussion notes that are played on MIDI channel 10.  Since percussion instruments have an indeterminate pitch, the Mid-C value is not used.  (One less thing you have to do.)

Program Number

Specifies which program number to log in place of the waveform.  (A list of program numbers can be found in Appendix E.)

Bank Change

If your MIDI device is capable of different banks, this value is logged as the MSB of the bank select word.

When the type of instrument is specified as Drum Set, this value acts as the note corresponding to the percussion instrument.  (A list of percussion notes can be found in Appendix E.)

Amplification

Often the volume of the waveform and the instrument in your MIDI device are quite different.  After the log volume is calculated, this value is used to adjust it.  The method of adjustment is volume*(amp/8).  So the default amplification of 32 will log the volume at 4x the level calculated.

The log volume will be clipped at 127.

Envelope Logging

The DSP uses ADSR envelope modification just like a MIDI device does.  In rare instances, envelope modification isn't applied by the MIDI device.  In these cases you can log the envelope value used by the DSP to recreate the same sound.

The default is Ignore which bases the log volume off the left and right channel volume only.  Currently, EnvX and ADSR have the same effect which is to average the envelope value you see on the screen and the channel volume.  

example

I'm now going to give an example to better explain how this works.  In this case, I'm going to use the prelude music from Final Fantasy II.  I chose that song for several reasons:  Most people are familiar with it, it doesn't have many instruments, and it was originally sequenced on a Sound Canvas, so it converts to MIDI quite well.

Getting middle-C

The first thing you need to do is determine which waveforms get used as instruments.   Do this by playing the song and seeing which ones get played.  In this case, the first six waveforms don't get used.  The three that do are 64, 65, and 66.

Now the tough part. Most musical formats store the pitch to play an instrument at as a note value (A#2, D-7, etc.)  However, the pitch in an .SPC is stored as a playback rate (similar to how .MOD's store the pitch as a timer constant).  So in order to figure out which notes instruments are being played at we need to know the value of a base note.  By calculating the difference between the playback rate and the base rate we can figure out which note is being recreated.  For SPC Tool I chose middle C (C-4) as the base note, because, well, it's middle C.

So how do we figure out what rate is middle C for a particular instrument?  There's several ways, and I'll start with the easiest.  First, though, I want to mention that the middle C rate doesn't have to be exact.  The logging routine will pick the note that's closest.  So as long as you're within 20-30Hz, you'll be okay.

1. Using the loop length

Look at the graph of the waveform.  If there's a loop point it will be signified by a dotted line.  Count how many cycles are in the loop portion.  Next, figure out the length of the loop by subtracting the loop point from the length of the instrument.  Now multiply the loop length by the middle C frequency, and divide the result by the number of cycles in a loop.  Make sense?  Probably not.  Let's go the the FF2 .SPC.

The first instrument, 64, has no loop point.  So that one's out.  The next instrument has a loop length that covers almost the whole thing.  So it's out also.  Now the third instrument has a short loop length, and one oscillation can be clearly seen inside.  Easy.  So get the loop length, 688 - 656 = 32.  Multiply by the frequency of middle C, 261.6255653.  The answer is 32 * 262 = 8372.  Since the loop covers one oscillation, we don't need to divide the answer by anything.  So 8372 is the playback rate for this particular instrument.

2. Letting the computer decide

Analog X has made a program called Sample AutoTune that determines the frequency of a waveform.  If you have AutoTune, save the instruments to disk that you want to calculate.  Open AutoTune.  For the note enter C4, for the sample rate select Enabled and deselect Specify, then choose Mono 16-bit.  Open up explorer.  Find the instruments you saved to disk, and drag them into AutoTune.

AutoTune will analyze each .WAV file and change the sample rate to match C-4.  You'll need to use a .WAV editor to find out what the new sample rates are for each file.

3. Using an external program

Save the instruments to disk.  Now use your favorite .WAV editor to look at them.   Pick somewhere in the instrument where the amplitude and frequency appear to be rather constant, usually in the middle.  Zoom up on that point until you have a 1:1 view.   If the program you're using is any good, you'll be able to hi-light a section of the waveform, and it will tell you how many samples you have selected.%nbsp; Use the above formula to calculate the frequency.

Again, let's go with the easy one, which happens to be the first instrument.  Zoom up in the middle of the waveform.  Select ten oscillations.  You should show 362 (plus or minus one) samples selected.  Now apply the last method discussed:  362 * 261.63 / 10 = 9471Hz.

4. Just short of a random guess

What if the only .WAV editor you have is the POS that came with Winblows?  Or the waveform is too complicated?  I have one more method you can use.  Play the .SPC.   When the instrument is playing, take note of the playback rate.  Plug this rate into the Mid-C value, and play the instrument.  Does it sound like middle C?   Try comparing it with other instruments, and adjust the rate in half-steps until you get it right.

For the second instrument we'll use this method.  One of the playback rates is 12023.   Plug that value in, and play the instrument.  Nope, that's too high.  So start decreasing the rate in half-steps.  This can be done by clicking on the label Mid-C, or if you want to be more accurate you can do it by hand.  The magic number in this case is the 12th root of 2, or 1.059463094.  If you multiply the rate by this number you'll go up a half-step.  If you divide the rate by this number you'll go down a half-step.  Keep going down, comparing with the other instruments, until you get the right rate.  In this case it'll be around 9550.

Choosing tone or drum

None of the instruments in the FF2 song are percussive, so leave them all as tone.

Which programs

This part can be difficult when authors create their own instruments, but this time it's easy.  For instruments 64-66 use:  47 (Harp), 49 (Strings), and 74 (Flute).

Volume amplification

Like many of the SquareSoft songs, the volume is too low.  These values work well on my Roland SCC-1, but may not for other devices:  45, 55, and 60

Envelope logging

Your MIDI device should have built-in ADSR for these instruments.  Leave them all as Ignore.

Some examples of values used to log MIDI data:

Final Fantasy II - Prelude

64  9578  Tone  47  0  45  Ignore
659550Tone49055Ignore
668372Tone74060Ignore
 
Secret of Mana - Flight Bound for the Unknown
32  n/aDrum  136  18  Ignore
33n/a Drum1 3816Ignore
34n/a Drum1 4211Ignore
35n/a Drum1 4611Ignore
3614070Tone490 45Ignore
376297 Tone2 0 36Ignore
389425 Tone760 38Ignore
39100464  Tone37  029Ignore
4018750Tone690 37Ignore
4114210Tone648 44Ignore
4237674Tone130 42Ignore

 

6. Debug Mode

I think I may have taken the debugger a step further than I needed to, but if you really want to know what that SPC is doing or change it in any way, here's your chance.

In debug mode the sound output is disabled.

6.1 Walking Around

Emulate next instruction / Stop emulation
F7
Emulates the current instruction pointed to by PC.  If the debugger is watching a value, or waiting for a break point, this will stop it.

Emulate to next line
Shift-F7

Sets a breakpoint on the instruction after the current one.

Exit debug mode
Esc

Log Disassembly
Alt-F3

After turning on logging, every instruction disassembled will be written to the file SPCList.Txt.  Logging can be stopped only by exiting debug mode.

Modify value
Left click

All values on screen can be modified except the Up Counters and Out Ports.  Values are entered in hex.

Watch memory location
Right click

Watching a location in memory causes the emulator to run until the value at that location changes.  A watch can be placed on any value in SPC or DSP RAM, but only one watch can be placed at a time.

Set break point

Setting a break point will cause the emulator to run until PC equals the value of the break point.

Watch out-port
0 - 3

Places a watch on the out-port value corresponding to the keypress.

Watch timer
Alt-0 - Alt-2

Places a watch on the corresponding timer [$FA-FC].

Watch counter
Ctrl-0 - Ctrl-2

Places a watch on the corresponding counter [$FD-FF].

Watch control register
4

Places a watch on the control register [$F1].

Watch DSP address
5

Places a watch on the DSP address port [$F2].

Watch DSP data
6

Places a watch on the DSP data port [$F3].

6.2 Inside the SPC700

The screen is composed of seven windows:

Disassembly

This window shows the disassembly of the next instruction to be executed, as well as previous instructions.  This is your typical disassembler with the program counter in the first column, the opcodes in the second, followed by the mnemonic and operands.  Instructions that reference memory will be followed by a comment containing the pointer and the value pointed to.

Nothing in this window can be modified.

Registers

The six CPU registers and the timer up counter registers.

The CPU registers can be modified.

Direct Page 0 & 1

The direct pages are the first 512 bytes of RAM.  The first 240 bytes (0-$EF) of page 0 are generally used for variables.  The last 16 bytes ($F0-$FF) are set aside as function registers:

F0 Not used
F1 Control register
Used to turn the timers on and off, reset the in ports, and control access to ROM.
F2 DSP Address
The pointer into DSP RAM.
F3 DSP Data
The value in DSP RAM pointed to by $F2.  Modifying this value will have an immediate effect in the DSP emulator.
F4-F7 In ports 0 through 3
This is where data is received from the console.  Of course, SPC Tool isn't attached to a console emulator, so these values will never change.  However, you can change these values to simulate communication.  For example, Castlevania IV uses port 0 to tell which sound effect to play.  (Amazingly, the numbers sent to port 0 coincide with those on the options screen of the game.)
F8-F9   Not used
FA-FC Timer registers 0 through 2
The SPC700 has three timers.  The first two run at 8kHz and the third at 64kHz.  These timers can be used for anything, but are generally used to set the tempo of the song.  By changing these values, you can speed up and slow down the music.
FD-FF Counters 0 through 2
When the value of the up counter is the same as the value in the timer register, the value in the counter is increased.  These registers are constantly being reset by the program in RAM, so modifying them is pointless.

The next page of memory is used for the stack, but can also contain data.  The current byte pointed to by SP will be hi-lighted.

All values can be modified.

Vector Table / IPL ROM

This window displays the last 64 bytes of memory.  The memory here will contain either a small program used to transfer blocks of data from the console, or a table of vectors to sub-routines.

All values can be modified.

DSP Registers

128 bytes of memory used by the DSP to store the status of each channel:

RegChannel statusValues
x0R/W Left volume -128 to 127
x1R/W Right volume -128 to 127
x2-x3    R/W    Playback rate 1 to 16383 (4096 is 32kHz)
x4R/W Waveform 0 to 255
x5-x7R/W Envelope varies
x8R Envelope heigth 0 to 127 (0 if not in ADSR mode)
x9R Wave out -128 to 127
 
Global status
0CR/W Left volume -128 to 127
1CR/W Right volume -128 to 127
5DR/W Page containing wave table info    0 to 255
6CR/W Noise freqency 0 to 31
2CR/W Echo left volume -128 to 127
3CR/W Echo right volume -128 to 127
0DR/W Echo feedback -128 to 127
6DR/W Starting page for echo 0 to 255
7DR/W Echo delay 0 to 15 (0 to 240ms)
0F-7FR/W Echo FIR filter taps -128 to 127
 
Switch status
4CR/W Key on bits 0-7 for channels 1-8
5CR/W Key off
7CR End block (Any write resets)
2DR/W Pitch modulation on/off
3DR/W Noise on/off
4DR/W Echo on/off

Any modifications will have an immediate effect in the DSP emulator.

Analyzing

These values are used for debugging, and are not part of the SPC700.

Out ports    Data sent to the console.
Watch Stop emulation when this location in memory changes.
Break Stop emulation when PC equals this value.

The out ports cannot be modified.


 

Appendix

A. Missing Features and Known Bugs

DSP -
+Echo volume isn't logged to MIDI (could be used for the reverb depth).
-Logger only uses counter 0.
-Logger doesn't catch pitch changes after a key-on signal (Arpeggio, portamento, and legato effects disappear)
-Inaccurate envelope modification when the attack/decay time is very short and the output sample rate is less that 32kHz.
-BRR decompression still isn't completely correct.

CPU -

-Source directory in Star Ocean .SPC's is getting corrupted.
-No read checking performed on 16-bit operations.
-BRK instruction not implemented.
-Disassembler may misinterpret some opcodes, though they will be emulated correctly.

Main -

+Programmed in real mode, which makes for a lot of far calls and segment overrides.
+Some 8-bit sound cards lock up in high-speed DMA mode.
+Full speed emulation sometimes crashes.
+Configuration can't be saved.
+Files can't be loaded from within the GUI.
+Date dumped and program dumped with can't be modified.
+Japanese character set is incomplete.
+VU metering is done on the positive side of the base line.  If a song has a negative DC offset, the bars will report incorrectly.
+Scroll bar isn't finished.
+BRR search can't be refined.
+BRR search mode still has problems.
+No error messages are displayed.  If something didn't work, it just... didn't work.
+Mouse cursor disappears under some parts of the screen (live with it).
-Some video cards have display problems.
-PgUp and PgDn don't work on some keyboards.
-New screen routines could have some redraw problems.

And other things I didn't feel like adding.

B. Program History

0.61 - 25.03.00
+Added SNESAmp, a Winamp plug-in
-MAIN  Fixed high-speed DMA mode crashes, hopefully
-MAINForgot to the set loop bit in instruments when importing
+DSPAdded MMX support for non-Intel CPU's
-DSPFixed a bug in the .WAV header
-DSPEcho was too loud
-DSPEcho was decaying too fast
0.6 - 29.02.00
+MAIN  Improved command-line parsing
+MAINGUI can be disabled for a 'play only' mode
+MAINAdded a poorly drawn, incomplete JIS-X0201 character set (If anyone has information/character maps, e-mail me.)
+MAINScreens are now dynamic (Should fix some problems, as well as create some new ones)
+MAINButtons that get disabled now look disabled
+MAINSound card can be disabled
+MAINChannels can be muted with the keyboard instead of the mouse
+MAINCan use the tilde key to fast forward
+MAINWave options lists a GM instrument instead of a number
+MAINWave form options can be changed with the mouse
+MAINWave form options can be saved on exit
+MAINOutput to .WAV can be customized
-MAINLoader correctly reads text ID666 tags
-MAINFixed a major bug when files were loaded from a different directory
-MAIN16-bit DMA transfers can now reside above [1000:FFFF]
-MAINRewrote DMA routines for 8-bit sound cards
-MAIN8kHz mixing works
-MAINFixed a minor bug in the OK buttons of the dialog boxes
+DSPOptimized interpolation routine
+DSPOptimized FIR filter
+DSPMixing routine is now dynamically created to eliminate repetitive branching
+DSPImproved interpolation routine to taper off the samples of instruments that don't end on the base-line (No more clicking in Starfox)
+DSPMade pitch modulation 256 times finer
-DSPA negative channel volume no longer corrupts the instrument
-DSPEcho volume was corrupt in monaural mode (SB owners can hear now)
-DSPADSR is more accurate
-DSPBent line doesn't stall
-DSPLinear interpolation doesn't overflow
-DSPThe noise generator is a little more random
-DSPBRR decompression method 3 works better (No noise in Toy Story)
-DSPFixed a small bug in the pitch converting code
-DSPFixed a bug in pitch modulation when using cubic interpolation (wind doesn't crackle anymore)
-DSPEcho works in the MMX code (MMX instructions are now enabled)
-DSPOutput is logged correctly when other than 16-bit stereo
-DSPTemporary file created during MIDI logging gets deleted
+CPUAdded a hack to eliminate polling the counters (speeds up overall processing by as much as 25%)
+CPUOptimized opcode handler and paragraph aligned short jump destinations
+CPUAdded a trace log option to debugger
-CPUFixed a stupid bug in the 16-bit memory checker that was causing random crashes and Vortex to get stuck
-CPUPCALL jumps to the right location (Terranigma doesn't stall)
-CPUSTOP and SLEEP actually stop the CPU
0.5 - 26.01.00 First public beta

0.1 - 13.12.99 Initial release

C. Credits

Thanks goes out to the following for...
SNES9x team invaluable help on handling some opcodes and most of the DSP, and help finding bugs
Butcha info on the BRR ADPCM methods and .ZST's
OpenCP team their cubic spline interpolation routine
VLA for teaching me assembly, and the workings of ModeX and the DMA controller (this is thanks long overdue)
ZSNES team giving us SPC's in the first place
Zophar's Domain    supplying me with .SPC's to test, and telling people about this program
Datschge suggestions, bugs, and being a pain :)

And everyone who's e-mailed me with support.

D. Contacting the Author

If you have questions or comments about SPC Tool ("How come my sound card doesn't work," is not a question about SPC Tool) you can e-mail me.  I try to reply to all e-mail, however, working and going to school full-time does take its toll on my free time.
e-mail: antires@aol.com
web: Alpha-II Productions

E. GM Program List

This is a list of the general MIDI programs.  Your MIDI device may have additional instruments in other banks.  Consult your documentation for more information.

Tone Table
 
PianoChromatic Percussion
1Piano 19Celesta
2Piano 210Glockenspiel
3Piano 311Music Box
4Honky-tonk12Vibraphone
5Electric Piano 113Marimba
6Electric Piano 214Xylophone
7Harpsichord15Tubular Bell
8Clav.16Santur
 
OrganGuitar
17Organ 125Nylon
18Organ 226Steel
19Organ 327Jazz
20Church Organ28Clean
21Reed Organ29Muted
22Accordion30Overdrive
23Harmonica31Distortion
24Bandneon32Harmonics
 
BassStrings/Orchestra
17Acoustic81Violin
18Fingered82Viola
19Picked83Cello
20Fretless84Contrabass
21Slap 185Tremolo String
22Slap 286Pizzicato String
23Synth 187Harp
24Synth 288Timpani
 
EnsembleBrass
25Strings89Trumpet
26Slow Strings90Trombone
27Synth Strings 191Tuba
28Synth Strings 292Muted Trumpet
29Choir Aahs93French Horn
30Voice Oohs94Brass
31SynVox95Synth Brass 1
32Orchestra Hit96Synth Brass 2
 
ReedPipe
33Soprano Sax97Piccolo
34Alto Sax98Flute
35Tenor Sax99Recorder
36Baritone Sax100Pan Flute
37Oboe101Bottle Blow
38English Horn102Shakuhachi
39Bassoon103Whistle
40Clarinet104Ocarina
 
Synth LeadSynth Pad
41Square Wave105Fantasia
42Saw Wave106Warm Pad
43Syn. Calliope107Polysynth
44Chiffer Lead108Space Voice
45Charang109Bowed Glass
46Solo Vox110Metal Pad
475th Saw Wave111Halo Pad
48Bass & Lead112Sweep Pad
 
Synth SFXEthnic
49Ice Rain113Sitar
50Soundtrack114Banjo
51Crystal115Shamisen
52Atmosphere116Koto
53Brightness117Kalimba
54Goblin118Bag Pipe
55Echo Drops119Fiddle
56Star Theme120Shannai
 
PercussiveSound Effects
57Tinkle Bell121Guitar Fret Noise
58Agogo122Breath Noise
59Steel Drum123Seashore
60Wood Block124Bird
61Taiko125Telephone
62Melo Tom126Helicopter
63Synth Drum127Applause
64  Reverse Cymbal  128  Gun Shot

Drum Table
 
Octave 1Octave 2
36Bass Drum 1
37Side Stick
38Snare Drum 1
39Hand Clap
40Snare Drum 2
41Low Tom 2
42Closed Hi-Hat
43Low Tom 1
44Pedal Hi-Hat
45Mid Tom 2
46Open Hi-Hat
35  Bass Drum 247  Mid Tom 1
 
Octave 3Octave 4
48High Tom 260High Bongo
49Crash Cymbal 161Low Bongo
50High Tom 162Mute High Conga
51Ride Cymbal 163Open High Conga
52Chinese Cymbal64Low Conga
53Ride Cymbal Bell65High Timbale
54Tambourine66Low Timbale
55Splash Cymbal67High Agogo
56Cowbell68Low Agogo
57Crash Cymbal 269Cabasa
58Vibra-slap70Maracas
59Ride Cymbal 271Short High Whistle
 
Octave 5
72Long Low Whistle  
73Short Guiro
74Long Guiro
75Claves
76High Wood Block
77Low Wood Block
78Mute Culca
79Open Culca
80Mute Triangle
81Open Triangle