Introduction
A SID file holds music from the Commodore 64, named after the computer’s SID sound chip (the MOS 6581, later the 8580). It does not store notes or audio: it stores the original 6510 machine code that played the tune, taken from a game or demo, plus a header saying where to load it and how to call it. A player has to run that code, with the C64’s timers and interrupts around it, and emulate the SID chip to make the sound.
The format was made for PlaySID, an Amiga player, by Michael Schwendt, and has grown with The High Voltage SID Collection (HVSC), which holds some 60,000 tunes in it. The format document is kept with the collection.
Structure
The file starts with PSID, or RSID for tunes that need a
real C64 environment (they install their own interrupt handlers and set up the timers
themselves). A big-endian header follows: the format version (1 to 5), the offset of the C64
data, the load address, the init address, the play address, the number of songs, the
start song, a speed field with one bit for each of the first 32 songs, and three
32-byte text fields for the name, author and release. Version 2 adds flags (the
player type, the video clock, the SID model), the pages of free memory and, from
version 3, the address of a second SID chip, in version 4 of a third. Version 5 replaces
those two bytes with a description of up to 15 SID chips, adds stereo panning, lets
the three strings run on, and may append a table of song lengths. The C64 code and data follow; when the header’s load address
is 0, the first two bytes of the data give it, little-endian as on the C64.
0Magic and version PSID or RSID, a version from 1 to 56 bytes6Header data offset, load, init and play addresses, songs, start song, speed16 bytes22Text name, author, released96 bytes118Version 2+ fields flags, free pages, extra SID addresses6 bytes124C64 data machine code and music datavariesendSong lengths version 5 only: one 4-byte entry for each songsongs × 4
The header page gives every field and the versions page what each version added. Several SID chips covers the extra chips and the stereo panning, and C64 environment gives what a player must set up before calling the tune. The SID registers are what the tune’s code writes. Compute!’s Sidplayer music is a file format of its own, carried in a SID file by a flag: Sidplayer (MUS).
What the explorer shows
The explorer reads the whole file: every byte of the header, the data and the length table is in the structure tree, with the flags and the free pages explained. It then runs the tune: a 6510 processor, the C64’s memory banking, the two CIA chips and the VIC-II raster interrupt are emulated as far as a tune uses them, the init routine is called and the play routine is run on every interrupt, with one to fifteen SID chips making the sound. The result is played, drawn as a waveform for the mix and for each voice, and analysed: which waveforms, notes, envelopes and filter settings each voice uses, a picture of pitch and envelope over time, and a table of every write to a SID register with the frame and raster line. The program is disassembled as 6510 code with the C64’s named addresses. The song, the video clock, the SID model, the length and the muted voices are set in the options bar. Playback says how the sound is made and how well it matches a reference player.
Not described
Known, not yet covered
- Viewer: tunes that run C64 BASIC (an RSID file with the BASIC flag) are shown and disassembled but silent, because the BASIC ROM, which cannot be shipped with the site, is needed to run them.
- Viewer: Compute!’s Sidplayer data (the MUS flag, and .mus and .str files) is laid out in the tree down to the credits, but the notes are not decoded and the music is not played: the player routine that plays them is a separate program (Sidplayer (MUS)).
- Viewer: the chip model is simplified: combined waveforms are the AND of the chosen waveforms, the filter is a state-variable filter with a measured cutoff curve rather than a model of the analogue circuit, and the 8580 filter curve is a straight line; the band-pass and high-pass modes leave 3 to 8 dB of error against the reference at some settings (playback).
- Viewer: the processor runs whole instructions and the VIC-II steals no cycles, so tunes that depend on the exact cycle of a raster or timer event (some RSID digi players, and the unstable undocumented opcodes) can differ from a real C64.
- Reference: the .wds companion file of Sidplayer and the HVSC’s Songlengths.md5 are described, but a single dropped file has no folder to look in, so song lengths and STIL notes are not looked up.
Unknown
- Reference and viewer: how the Sidplayer note events are encoded: the only description found is the player’s own machine code, which is not in the open documents the site could use.
Links
Software
Developers
- libsidplayfp – library that emulates the C64 and its SID chip to play SID files (C++)
- libresidfp – the SID chip emulation of libsidplayfp, the reSIDfp engine (C++)
Reference
- High Voltage SID Collection – the main archive of SID tunes
- SID file format description – the format’s own document, versions 1 to 5
- Song length database FAQ – the Songlengths.md5 format
- STIL FAQ – the SID Tune Information List format