vspcplay (v for Visual)

What is vspcplay | Screenshots | Games port usage | Why I wrote vspcplay | Download

What is vspcplay?

A spcplayer based on snes9x snes apu emulation code, featuring a colored visual memory representation, ability to view memory content simply by moving the mouse around, volume/gain bars, pitch dots and simple port manipulation.

Screenshots

screenshot vspcplay uses libSDL for it's display output. Most of the screen space is occupied by the memory surface (512x512). There is a small menubar near the lower edge of the screen. See below for details about each component.

Memory surface:
memory surface image The main component is the memory surface. The upper left corner is address $0000 and the lower right corner is address $ffff. Reads are colored as blue, writes as green (read+write gives cyan). PC (program counter) execution address are colored as red. Pixels slowly fades, but never completely thus leaving a footprint.

Hexdump:
hexdump image By moving the mouse over the memory surface, you can see a 128 bytes hexdump starting at the address under the mouse pointer. You can toggle the hexdump address lock by clicking in the memory surface. Colors used are the same as in the memory surface, but they are brighter for visibility.

Pitch dots:
pitch dots image The pitch dots represent the pitch of the sample for each track. Pitch increase as the dots moves towards the left.

Volume bars:
volbars image Each channel can have it's own left and right volume, which permits panning effects. There is also a gain, which is sometimes used for enveloppe effects. Volume increase as the bars lengths increases.

New in version 1.4: Channels can be muted using the 1-8 keys. 0 toggles mute all / mute none.


Port tool:
port tool image The port tool allows you to change the values as if you were the Snes. With some games, you can use this to play sound effects. In some other games, you can even change the tune.

You can use the mouse to click on the + and - to increase or decrease the port value, or you can roll the mousewheel. The changes you make will be visible at addresses $f4 to $f7 (left to right) in the APU memory space.


Games usage of the APU ports

Below is a table about how to use extra spc features with some games. (Play sound effects, change the tune, etc). This is work in progress. Contributions would be welcomed.
GameFilesUsage
Legend of Zelda 3loz3-*.spc Tune selection: Value in port $f4 selects the tune.
Sound effects: Values in ports $f6 and $f7 plays sound effects.
The value in port $f5 controls how the rain sounds. When set to $ff the rain stops.
Pilotwingsptws-*.spc Tune selection: Value in port $f4 selects the tune. Do it with a menu or information screen tune, otherwise a motor sound kicks in.
Sound effects: Port $f5 and $f7 plays sound effects and beeps.
Port $f6 controls the pitch of the plane motor.
Super Mario Worldsmw-*.spc Tune selection: Values ranging from $0 to $1D in port $f6 selects the tune being played. A value of $ff fades out the current tune.
Sound effects: Values in port $f4 and $f6 plays sound effects.
A Value of 1 in port $f5 plays the jump sound.
Hurry up: If you put a value of $ff in port $f4, the hurry up sound will be played and the music will go faster.
Sim Citysc-*.spc Tune selection: Values from $01 to $13 in port $f4 select the tune.
Sound effects: Values in port $f6 select sound effects due to user actions (place road segment, place zone, etc)
Values in port $f7 is used to control additional sound effects such as airplane noise, disaster noise, etc.
Other:If you change the value in port $f5, the music stops but sound effects will stay active.
Donkey Kong Country 1dkc-*.spc Id of sound effect selected by port $f5. Each time $f4 changes (eg incremented), the sound effect is played.
For sound effects, the most significant bit of $f5 is apparently not used. (eg sound $81 is the same as $01).
Values between $77 and $7F in port $f5 seem to be used for other purposes (changing tune, etc.). When $fd or $fc is in $f5, each time $f4 changes, then playback speed is momentarily increased.

Here is a list of the sound effects IDs. Those which I am not sure are between parentheses.
dkc1.html
Donkey Kong Country 2 (Diddy's Kong Quest)dkq-*.spc Sound effects: Values ranging from $00 to $76 in port $f5 select the sound effect to be played when $f4 changes.
Donkey Kong Country 3 (Dixie Kong's Double Troubledkdt-*.spc Sound effects: Values ranging from $00 to around $60 in port $f5 selects the sound effect to be played when $f4 changes.
Super mario kartsmk-*.spc Sound effects: Some values in port $f5 plays some in-game sound effects.
Value ranging from $0 to $7f in port $f6 controls the player's kart motor pitch (value of 0 == off).
The value in port $f7 controls the motor sound volume and panning of karts passing by.
Other: Changing value in port $f4 from $00 to $ff plays a pause sound and reduce the music volume. When changed back from $ff to $00, the music resumes at it's initial volume.

Why I wrote it?

apu In december 2004, I followed caitsith2's schematics (see his webpage for details) to connect an snes APU (Audio Processing Unit) to a PC using the parallel port. The goal was to play .spc files (Snes music files. (I have a webpage about this project, see Snes APU on a PC). Thoses are save-states of the APU's CPU, the spc700) on the unit without a Snes. The only drawback is that it takes about 5 seconds to load the ~64KB spc file in the APU. Oh well...

Later, I realized that the 64KB of memory is probably not completely used or necessary to play a spc tune. Things such as sound effects used in-game are not needed, and some samples may be present in memory but unused for a given tune. Consider a tune with 50% memory usage. Loading time could be reduced to 50%!

Now the question was: 'How can you know which memory areas are not used?'. The .spc file format is too simple to be helpful for this purpose. Spc's are simply dumps of cpu registers and memory. (see spc_file_format.txt for specification). The only way I thought of is to play the tune in a modified emulator which can log all memory access. I took the source code of an xmms spc plugin based on Snes9X and converted it in a simple tool to log memory accesses. I know that snes9x it is not the best APU emulator, but it was the only one not written in assembler (My main workstations are a Sparc64 and an AMD64) . I decided to represent the memory as 256 blocks of 256 Bytes. Whenever there is a read access in a block, the block is marked as used.

While writing my memory access logging tool, I decided to try to represent the 64KB memory as a 256x256 pixels surface, with a color code for read, write and execution. It's a very neat thing to look at. You see the tracks being read, you see the samples being used, etc. I got so excited about it that I added visual volume bars for each channel, moving dots for each channel pitch, a tool to play with port values (The APU and the Snes communicates together using 4 ports).


Download

For the latest source, see the github repository at https://github.com/raphnet/vspcplay

You will need libsdl to be able to compile this. For win32, I used MinGW and Msys with a self-compiled libsdl. Please note that I need to optimise the code. It is very inefficient right now. I know it works on a Pentium 1 ghz, on an 450mgz sparc64, on a 2 ghz Amd64. It does not work on a Pentium 200 running windows.

Here is a screenshot of the win32 frontend: win32 version frontend
FileTypeComments
vspcplay-1.4.tar.gz Source Version 1.4, released 2022-07-22:
  • Add an option to output a Wave file (--waveout)
  • Add options to mute/unmute specific channels (--mute and --unmute command-line options)
  • Add keyboard controls (1-8 to toggle mute, 0 to toggle mute all/none, N/P to play next/previous song, R to restart song, ESC to quit)
  • Fix a bunch of buffer overflows, fix warnings, some code cleanup...
vspcplay-1.3.tar.gz Source
  • Added the --apply_mask_block command line option which applies the mask to the file (fills unused 256 bytes blocks) with a pattern.
  • Added the --filler command line option which is used to specify the filler byte for the --apply_mask_block option. Default is $00
Also, a tool to apply mask files to spc files has been added to the utils/ subdir.
vspcplay-1.2.tar.gz Source
  • Added --status_line command line option (displays a status line in the terminal).
  • Reads in the sample directory were not reported (Resulting in unusable masks)
vspcplay_win32.rar Win32 Binary Added --extra_time (Play x seconds longer than tag time) and --nice (try to reduce CPU used by graphics) command line options and win32 support (with a GUI frontend!!).
vspcplay-1.1.tar.gz Source
vspcplay-1.0.tar.gzSourceInitial release


Links

Snesmusic.org. A Very big spc archive.
Zophar spc archive.
CaitSith2's APU on a PC Parallel port page
My Snes APU on a PC page
A page on how the APU works


For questions or comments, please contact me at raph@raphnet.net
sensmusic vorc logo mikmod now Valid HTML 4.01!