[][src]Module spectrusty_formats::mdr

MDR file format utilities.

Utilities in this module provide additional methods to the MicroCartridge type with abilities:

  • to inspect and manipulate sector data on the Microdrive file system level (read, create, erase and list files from cartridges);
  • to extract files into and from the TAP format;
  • to write and read MicroCartridge data to and from MDR file format.

MDR files are data images of formatted sectors of ZX Microdrive tape cartridges.

The number of sectors may vary but it will never be a larger than 254.

The last byte determines the write protection flag: if it's not 0 the cartridge should be protected.

The structure of a single cartridge sector saved in the MDR file:

offsetsizeROM vardescription
01HDFLAGBit 0 if set indicates a header and should always be set.
11HDNUMBSector number: starts from 254 down to 1.
22-Unknown, probably padding.
410HDNAMEName of the cartridge with trailing spaces, repeated every formatted sector.
141HDCHKChecksum of the previous 14 bytes.
151RECFLGRecord flags, see below. Bit 0 should be always reset.
161RECNUMFile block record number: starts at 0.
172RECLENFile block data length (LSB first), less than or equal to 512.
1910RECNAMName of the file with trailing spaces, repeated every record.
291DESCHKChecksum of the previous 14 bytes.
30512CHDATARecord block data: 0..RECLEN.
5421DCHKChecksum of the previous 512 bytes, regardless of RECLEN value.

Record flags (RECFLG):

  • Bit 0 is always reset to indicate a record block descriptor.
  • Bit 1 is set for the last record block (End Of File).
  • Bit 2 is set for regular files and reset if the record is part of a PRINT type file (a stream).

The above structure and ROM variable names are from the book by Gianluca Carri "Spectrum Shadow ROM Disassembly".

Structs

CatFile

MicroCartridge's file meta data.

Catalog

The structure returned by MicroCartridgeExt::catalog method.

FileSectorIdsUnordIter

An iterator of sector indices and unordered block numbers belonging to a single file.

FileSectorIter

An iterator of sectors belonging to a single file.

MdrFileHeader

Binary (SAVE *) file's header.

MdrValidationError

An error returned when a Sector's content is invalid.

MicroCartridge

This struct represents an emulated Microdrive tape cartridge.

Sector

This struct represents a single MicroCartridge tape sector.

SectorBlock

Instances of this type are returned by FileSectorIdsUnordIter iterator.

Enums

CatFileType

A MicroCartridge's file type.

Constants

HEAD_SIZE

The size of the sector header in bytes, excluding the 12 preamble bytes.

MAX_USABLE_SECTORS

The maximum number of usable ZX Microdrive tape sectors.

Traits

MicroCartridgeExt

Extends MicroCartridge with methods for reading and manipulating Microdrive's file system.

SectorExt

Extends MicroCartridge's Sector with methods for reading and manipulating Microdrive's file system.

Functions

checksum

Checksum calculating routine used by Spectrum for Microdrive data.

Type Definitions

MicroCartridgeIdSecIter

An iterator returned by MicroCartridge::iter_with_indices method.