83
edits
m (Use {{See Also}} template for hatnote) |
(Blocks and Pulses. Header structure, data block structure. Some gaps) |
||
Line 1: | Line 1: | ||
{{See Also|the ZX Spectrum ROM load/save format|the .TAP emulator format|TAP format}} | {{See Also|the ZX Spectrum ROM load/save format|the .TAP emulator format|TAP format}} | ||
The Spectrum ROM routines save files to tape in two blocks, a header and a data block. Each of these blocks is encoded as a sequence of pulses. | |||
There are also a wide variety of "[[:Category:Custom tape formats|custom loaders]]" which have been used for Spectrum software, for purposes such as copy protection or faster loading times. This article deals only with the format written by the Spectrum ROM. | |||
== Pulses == | |||
Pilot tone: before each block is a sequence of pulses "over 1 second long" [http://www.worldofspectrum.org/tapsamp.html]. ''(Need to find out the pulse length and minimum number of pulses)'' | |||
Sync pulses: the pilot tone is followed by two sync pulses "which are significantly smaller than a pilot pulse. This marks the end of the pilot". ''(Again, need the exact values)'' | |||
A '0' bit is encoded as 2 pulses of 855 T-states each (a 'pulse' here is either a mark or a space, so 2 pulses makes a complete square wave cycle) | |||
A '1' bit is encoded as 2 pulses of 1710 T-states each (ie. twice the length of a '0') | |||
''(Does initial polarity matter?)'' | |||
== Blocks == | |||
=== Header block === | |||
The header, which is 17 bytes long, is as follows: | |||
{|border="1" | |||
!Byte (decimal) | |||
!Length | |||
!Description | |||
|- | |||
|0 | |||
|1 | |||
|Type (0,1,2 or 3) | |||
|- | |||
|1 | |||
|10 | |||
|Filename (padded with blanks) | |||
|- | |||
|11 | |||
|2 | |||
|Length of data block | |||
|- | |||
|13 | |||
|2 | |||
|Parameter 1 | |||
|- | |||
|15 | |||
|2 | |||
|Parameter 2 | |||
|} | |||
The type is 0,1,2 or 3 for a Program, Number array, Character array or Code file. A SCREEN$ file is regarded as a Code file with start address 16384 and length 6912 decimal. If the file is a Program file, parameter 1 holds the autostart line number (or a number >=32768 if no LINE parameter was given) and parameter 2 holds the start of the variable area relative to the start of the program. If it's a Code file, parameter 1 holds the start of the code block when saved, and parameter 2 holds 32768. For data files finally, the byte at position 14 decimal holds the variable name. | |||
=== Data block === | |||
''(Someone who knows the formats for data arrays should complete this section. Is it the same as the format in RAM? The latter can be found at [http://www.worldofspectrum.org/ZXBasicManual/zxmanchap24.html])'' | |||
Program files are stored as a sequence of lines each stored the same way it is in RAM: | |||
Line number[2BE] Length[2] Text[] 0x0D[1] | |||
Note that numeric literals will be stored in both text and binary (text[] 0x0E[1] zxfloat[5]). | |||
Code files are stored as a flat sequence of bytes, in the order they appear in RAM. |
edits