.TAP FILES: ----------- (based on the documentation for Z80 written by G.Lunter) The .TAP files contain blocks of tape-saved data. All blocks start with two bytes specifying how many bytes will follow. Then raw tape data follows, starting with the flag byte and ending with the checksum byte. A .TAP file is a simple sequence of any number of these blocks. Layout of a block in a .TAP file: dc.w length number of bytes that follow (.TAP block header) dc.b flag flag byte (as saved by ZX Spectrum save routine) dc.b data... data (the bytes we are interested in) dc.b checksum checksum (as saved by ZX Spectrum save routine) "length" is the number of bytes that follow: including the "flag", "data...", "checksum"; not counting the "length" itself. Byte order is big endian, this means, the low byte is first. If "length" is less than 3, the number of bytes that follow are actually 0x010000 + "length"; for the ZX Spectrum save routine cannot save 0 bytes, thus the minimum "length" is 3, which means 1 byte flag + 1 byte data + 1 byte checksum. "flag" is the value of the A register when the ZX Spectrum save routine was called. A value of 0x00 normally indicates, that this is a header block, a value of 0xFF indicates, that this is a data block, whose contents is described by the preceeding header block. "data..." contains a header (if "flag"==0x00 and "length"==19) or data. These are the bytes which will be loaded into RAM. "checksum" This is the bitwise XOR of all bytes including the flag byte.