Inside the Sharp MZF tape file

A byte-by-byte tour of the format used to preserve Sharp MZ-80K and MZ-700 cassette software, and how MZF Viewer decides what to show you.

By Andrew · Last updated

Sharp's MZ-80K, launched in Japan in 1978 and in Europe soon after, came with a built-in cassette deck. All of its software, even its BASIC interpreter, loaded from tape. Today that software survives as .mzf files: the bytes read from each recording, saved to disk. Knowing the layout of an MZF file is the key to reading one. It's also the first thing MZF Viewer does when you open a file.

New to $1200-style hex numbers or "little-endian"? The glossary explains them from scratch.

Two parts: header and body

Every recording on a Sharp MZ tape has two blocks. The first is a fixed-size header that describes the file. The second is the body, which holds the program or data itself. An MZF file keeps both, one after the other:

+------------------------+----------------------------------+
| header (128 bytes)     | body (size given in the header)  |
+------------------------+----------------------------------+

The 128-byte header

Offset (hex)LengthMeaning
001Attribute: what kind of file this is (see below)
01–1117Filename in the Sharp character set, ended by 0D (carriage return)
12–132Size of the body in bytes
14–152Load address, where the body goes in memory
16–172Execution address, where to start running machine code
18–7F104Comment area, often empty or used by loaders

The 16-bit values are little-endian, as usual for the Z80: the low byte comes first. So the bytes 00 12 mean $1200.

A worked example

Here's the start of a header for a machine-code game called GAME. It's an illustrative example, not a real file:

00: 01 47 41 4D 45 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D 0D
10: 0D 0D 00 10 00 12 00 12 ...

$1200 is no accident. On the MZ-80K the monitor ROM uses the memory just below it, so $1200 is where user programs normally load.

The attribute byte

The first byte tells the loader what to do with the body. The two you'll meet most often are:

Other values exist for data files and for software from later Sharp models. When MZF Viewer meets an attribute it doesn't recognise, the hex dump view (mode=DUMP) is the safest way to look inside.

Why BASIC needs the right "mode"

The MZ-80K had no BASIC in ROM. You loaded an interpreter from tape, and there were several to choose from: Sharp's own SP-5025 family, SA-5510 and others. The MZ-700 had its own 1Z-013B BASIC. To save memory, each one stores keywords such as PRINT and GOTO as single-byte tokens. But they don't all use the same numbers for the same keywords.

The header can't tell you which interpreter saved a BASIC file, so the viewer can't always tell either. That's why MZF Viewer lets you choose the token table:

If a listing looks like nonsense, with keywords in odd places, try another mode. Seeing a listing suddenly make sense when you switch is a satisfying moment.

Once the right table is chosen, a short program reads just as it did on a Sharp screen:

10 PRINT "HELLO FROM 1979"
20 GOTO 10

Shown in the MZ80B font, built from the character ROM of the MZ-80B, the MZ-80K's 1981 sibling, so a close relative of the MZ-80K's own characters (see credits).

The Sharp character set

The MZ-80K's version of ASCII, often called Sharp ASCII, matches standard ASCII for the space, digits, capital letters and most punctuation, from $20 to $5D. After that it goes its own way:

There's a second twist. The codes in a file aren't the codes the screen uses. Screen memory holds display codes, a separate numbering in which space is 0 and A–Z are 1–26. The computer converts from Sharp ASCII to display codes whenever it prints a character. MZF files contain Sharp ASCII, so that's the table that matters when you read them. MZF Viewer converts each character to the closest readable equivalent, so filenames and PRINT strings display sensibly in a modern browser.

To see every character, look at the MZ-80K character set chart (PDF) at mz-80a.com, from Sharp's MZ-80K manual. It has both the ASCII code table and the display code table.

Try it yourself

  1. Open Cursed Chambers in MZF Viewer, an MZ-80K BASIC adventure.
  2. Switch to DUMP and find the attribute byte and filename at the start of the header.
  3. Open Connect Four for the MZ-700 in Z80 mode, and check that the disassembly starts at the load address from the header.

For thousands more files, the MZ-Archive is the place to go. For the history of the machine itself, see sharpmz.no.

Comments

  1. Loading comments…

Leave a comment

Every comment is read by me before it appears. Please keep it friendly and on topic. Links and personal details are removed. See the comment policy.