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 set when the block is empty (the BeebWiki page on the Acorn cassette format says so; see below). The other bits are not defined for tape and are shown as they are |
| Address of next file | 4 | The device address field of the Acorn cassette format: on cassette there is no random access, so it is reserved and conventionally four zero bytes; in a paged ROM it is the little-endian address of the next file in the ROM space (&8000 to &BFFF). The viewer reads it as spare bytes and 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 arises (the BeebWiki page says) when an empty file is saved, or when a file is closed just after a full block was written, and bit 6 of the flag marks it. No block on the real tape has either, so this is checked on built tapes only.
The same page says: the blocks of a file are numbered in ascending order from 0; for compatibility every block but the last
should be 256 bytes and the last 256 or fewer; the file name may hold any character but NUL (a name with non-printable
characters can only be loaded with CHAIN ""). The CRC is the Rocksoft model "XMODEM": width 16, polynomial
$1021, initial value 0, no reflection, no final XOR, check value $31C3 for the text 123456789 (the check value was
re-computed here and agrees).
Two more block types exist for ROMs and PHROMs only, not for tape: a continuation block (first byte $23, then data of the length in the last header, then its CRC, none when the length is 0) and an end-of-ROM block (the single byte $2B). The viewer does not read them. The same page describes the other Acorn layouts (System series: two address words and the data in one block with no checksum; Atom: four $2A bytes, a name ending $0D, a flag, big-endian numbers and a checksum byte), which the viewer does not read either.
The signal, from the same page: a 0 is a 1200 Hz wave (nominally 16,000,000 / 13,312 = 1201.9 Hz), a 1 a 2400 Hz wave (about 2403.8 Hz); 1200 baud uses one or two cycles per bit, 300 baud four or eight. Each stream is preceded by a leader of 2400 Hz tone of 5.1 seconds (1.1 seconds when the computer paused in the middle of a file, 0.9 seconds between blocks recorded in one go) and ends with a trailer of 5.3 seconds (0.2 seconds when pausing); the timings come from vertical sync interrupts and vary. MOS 1.20 and above put a dummy byte $AA at the start of each leader (the Electron does not).
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.