The bytes of the data chunks (&0100, and &0104 with 8 data bits and no parity), joined end to end, are what the BBC Micro's cassette filing system wrote. They are a series of blocks, each up to 256 bytes of a file, with tone and silence (the other chunks) between them. A tape file is one or more blocks.
A block
| Field | Size | Meaning |
|---|---|---|
| Sync | 1 | $2A: marks the start of a block. The bytes before it (the $AA dummy bytes the system sends while the carrier tone plays) belong to no block |
| Name | 1 to 10, then $00 | The file's name |
| Load address | 4 | Low byte first |
| Execution address | 4 | Low byte first |
| Block number | 2 | 0 for the first block of a file, then 1, 2 and so on |
| Block length | 2 | The bytes of data in this block (256 at most) |
| Block flag | 1 | Bit 7 set on the last block of the file. Bit 0 set when the file is locked. Bit 6 is read as "the block holds no data" (see below). The other bits are shown as they are |
| Spare | 4 | Four bytes after the flag; the viewer shows nothing in them |
| Header CRC | 2 | High byte first. The CRC of the name (with its $00) through the spare bytes |
| Data | block length | The block's part of the file |
| Data CRC | 2 | High byte first. The CRC of the data. Not present when the block length is 0 |
The CRC is CRC-16 CCITT: polynomial $1021, start value 0, bytes taken most significant bit first, no
final change. It is checked on every block of the real tape Test.uef (six blocks, twelve CRCs, all agree) and on
built tapes, and flipping one bit of a data byte breaks the data CRC.
Blocks make files
The viewer starts a file at a block of a new name or whose number is not the next one, and adds blocks to it until one
carries the last flag. The file's data is the blocks' data joined, and its load and execution address are those of its
first block. A file with no last block is shown as not complete. The real tape has one file, PUGWASH, of six
blocks (five of 256 bytes, one of 38), flag $00 on the first five and $80 on the sixth, load address
&FFFF1900, execution address &FFFF8023: a BASIC program of 1,318 bytes.
There is nothing on the tape to say what kind of file it is: the viewer guesses from the bytes exactly as it does for a disc file, and opens each file in the BBC file viewer.
Empty blocks
A block of length 0 has no data and no data CRC. The viewer reads that as a valid block. It is also the reason bit 6 of the flag is read as "no data"; no block on the real tape has either, so this reading is not checked on a real tape.
A discrepancy worth knowing
The EmWare emulator's tape writer, which turns bytes the machine sent back into a UEF, finds the end of a block by reading the block length at 12 bytes after the end of the name, not at 10. In the layout above, those two bytes are the flag and the first spare byte. The layout here was checked by the CRCs of the real tape, which come out right only with the length at 10; the writer's offset would give wrong lengths for a block whose flag is not 0. That code is not used by this site.