Audio-SID
view release on metacpan or search on metacpan
SID_file_format.txt view on Meta::CPAN
tune written for the NTSC C64 will be slightly detuned if played back on a PAL
C64. Furthermore, NTSC C64 tunes driven by a vertical blank interrupt have to
be converted to use the CIA 1 timer to fit into this scheme. This can cause
severe problems, as the NTSC refresh rate is once every 17045 cycles, while
the CIA 1 timer A is latched with 17095 cycles. Apart from the difference in
timing itself, the SID ADSR bugs can actually break the tune.
The 'clock' (video standard) field was introduced to circumvent this problem.
- Bits 4-5 specify the SID version (sidModel):
00 = Unknown,
01 = MOS6581,
10 = MOS8580,
11 = MOS6581 and MOS8580.
This is a v2NG specific field.
- Bits 6-7 specify the SID version (sidModel) of the second SID:
00 = Unknown,
01 = MOS6581,
10 = MOS8580,
11 = MOS6581 and MOS8580.
This is a v3 specific field.
If bits 6-7 are set to Unknown then the second SID will be set to the same SID
model as the first SID.
- Bits 8-9 specify the SID version (sidModel) of the third SID:
00 = Unknown,
01 = MOS6581,
10 = MOS8580,
11 = MOS6581 and MOS8580.
This is a v4 specific field.
If bits 8-9 are set to Unknown then the third SID will be set to the same SID
model as the first SID.
The MOS6581 and the MOS8580 have three notable differences. First, combined
waveforms are generally louder on a MOS8580, to the extent that some
combinations that are clearly audible on a MOS8580 are completely silent on a
MOS6581. Second, the internal DC levels in the MOS8580 are so small that
software or hardware tricks must be used to play volume samples. Third, the
MOS8580 analog filter has totally different characteristics from the MOS6581
analog filter.
To ensure that music specifically written for one of the two SID versions can
be played back correctly, bits 4-9 in 'flags' are used as stated above.
- Bits 10-15 are reserved and should be set to 0.
+78 BYTE startPage (relocStartPage)
This is a v2NG specific field.
This is an 8 bit number. If 'startPage' is 0, the SID file is clean, i.e. it
does not write outside its data range within the driver ranges. In this case
the largest free memory range can be determined from the start address and the
data length of the SID binary data. If 'startPage' is 0xFF, there is not even
a single free page, and driver relocation is impossible. Otherwise,
'startPage' specifies the start page of the single largest free memory range
within the driver ranges. For example, if 'startPage' is 0x1E, this free
memory range starts at $1E00.
+79 BYTE pageLength (relocPages)
This is a v2NG specific field.
This is an 8 bit number indicating the number of free pages after 'startPage'.
If 'startPage' is not 0 or 0xFF, 'pageLength' is set to the number of free
pages starting at 'startPage'. If 'startPage' is 0 or 0xFF, 'pageLength' must
be set to 0.
The relocation range indicated by 'startPage' and 'pageLength' should never
overlap or encompass the load range of the C64 data. For RSID files, the
relocation range should also not overlap or encompass any of the ROM areas
($A000-$BFFF and $D000-$FFFF) or the reserved memory area ($0000-$03FF).
+7A BYTE secondSIDAddress
This is a v3 specific field. For v2NG, it should be set to 0.
This is an 8 bit number indicating the address of the second SID. It specifies
the middle part of the address, $Dxx0, starting from value 0x42 for $D420 to
0xFE for $DFE0). Only even values are valid. Ranges 0x00-0x41 ($D000-$D410) and
0x80-0xDF ($D800-$DDF0) are invalid. Any invalid value means that no second SID
is used, like 0x00.
+7B BYTE thirdSIDAddress
This is a v4 specific field. For v2NG and v3, it should be set to 0.
This is an 8 bit number indicating the address of the third SID. It specifies
the middle part of the address, $Dxx0, starting from value 0x42 for $D420 to
0xFE for $DFE0). Only even values are valid. Ranges 0x00-0x41 ($D000-$D410) and
0x80-0xDF ($D800-$DDF0) are invalid. Any invalid value means that no third SID
is used, like 0x00.
The address of the third SID cannot be the same as the second SID.
+7C <data>
Version 2, 3 and 4 of the SID header ends here. This offset is the start of the
binary C64 data. See also 'loadAddress' for what the first 2 bytes of 'data'
might indicate.
The SID file environment
========================
Before the data of a SID file is loaded in memory of a C64, certain addresses
and chips must be initialized in order to play the SID tune correctly.
For RSID and PSID files the following address must be set for an emulated
environment:
$02A6 : depending on the PAL/NTSC flag in the SID file header, it is set to
0x01 for PAL and set to 0x00 for NTSC.
On a real C64, when the speed flag is set to CIA, the value of $02A6 should be
read to setup the CIA timers accordingly (0x4025 for PAL and 0x4295 for NTSC).
When the speed flag is set to CIA, and a NTSC SID tune is played on a PAL
machine or a PAL SID tune is played on a NTSC machine, the player may set up a
CIA timer instead of VBI to run the tune at the correct speed.
The following CIA timer values can be used for:
NTSC tune on PAL machine: 0x3FFB (312 * 63 * 50 / 60 - 1)
PAL tune on NTSC machine: 0x5021 (263 * 65 * 60 / 50 - 1)
The default C64 environment for PSID files is as follows:
VIC : IRQ set to any raster value less than 0x100. Enabled when
speed flag is 0, otherwise disabled.
CIA 1 timer A : set to 60Hz (0x4025 for PAL and 0x4295 for NTSC) with the
counter running. IRQs active when speed flag is 1, otherwise
IRQs are disabled.
( run in 0.459 second using v1.01-cache-2.11-cpan-71847e10f99 )