A SID file’s code expects a C64 in a known state. The
header says where to load the code and how to
call it, and this page gives the rules for doing so, from
SID_file_format.txt.
Loading
- If the header’s loadAddress is
$0000, the first two data bytes give the load address, little-endian, and are not loaded. - If loadAddress is not 0, loading starts with the first data byte. Any address prefix in the data must be removed, or everything loads two bytes out.
- For RSID, the effective load address must be at least
$07E8.
initAddress
The accumulator holds the song number minus one when init is called.
| Case | Value |
|---|---|
| PSID with the MUS player flag | Must be $0000: the external player supplies the entry point. |
| RSID with the BASIC flag | Must be $0000: the BASIC program is started. |
| RSID without the BASIC flag | At least $07E8, inside the payload, and not in ROM or I/O ($A000–$BFFF, $D000–$FFFF). |
Otherwise, $0000 | Means the effective load address. |
playAddress
| Case | Value |
|---|---|
| PSID without the MUS player flag | $0000 means the program installs its own interrupt handler. |
| PSID with the MUS player flag | Must be $0000: the external player’s entry point is used. |
| RSID | Must be $0000. |
RSID rules
An RSID file must be rejected unless all of these hold:
- The version is 2, 3, 4 or 5.
- loadAddress, playAddress and speed are 0.
- The effective load address is at least
$07E8. - With the BASIC flag set, initAddress is
$0000; without it, initAddress meets the rule above.
An RSID tune uses the default C64 power-on environment and sets up the hardware
itself. With the BASIC flag, the song number (0 for song 1) is put at
$030C.
Initial environment
| Item | PSID | RSID |
|---|---|---|
$02A6 | 1 for PAL, 0 for NTSC. | |
| VIC | IRQ set to any raster value below $100. Enabled when the song’s speed bit is 0, disabled otherwise. | IRQ set to raster $137, not enabled. |
| CIA 1 timer A | Set to 60 Hz with the counter running. IRQs are on when the speed bit is 1, off otherwise. | Set to 60 Hz with the counter running and IRQs on. |
| Other timers | Disabled and loaded with $FFFF. | |
| Bank register | Written on every init and play call, by address. | $37. |
For a PSID tune with CIA timing, players read $02A6 to set the CIA timer:
$4025 on PAL, $4295 on NTSC. When the tune’s video standard
differs from the machine, a CIA timer may stand in for VBI timing:
$3FFB for an NTSC tune on PAL and $5021 for a PAL tune on
NTSC.
Bank register (PSID)
| Address called | Bank register |
|---|---|
Below $A000 | $37 |
$A000 to below $D000 | $36 |
$D000 to below $E000 | $34 |
$E000 and above | $35 |
MUS tunes and BASIC tunes
With the MUS player flag set, the file holds music data for Compute!’s Sidplayer and no player code; a player must merge in its own. With the BASIC flag set on an RSID file, the file is a C64 BASIC program.