Module spectrusty_formats::mdr
source · Expand description
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:
offset | size | ROM var | description |
---|---|---|---|
0 | 1 | HDFLAG | Bit 0 if set indicates a header and should always be set. |
1 | 1 | HDNUMB | Sector number: starts from 254 down to 1. |
2 | 2 | - | Unknown, probably padding. |
4 | 10 | HDNAME | Name of the cartridge with trailing spaces, repeated every formatted sector. |
14 | 1 | HDCHK | Checksum of the previous 14 bytes. |
15 | 1 | RECFLG | Record flags, see below. Bit 0 should be always reset. |
16 | 1 | RECNUM | File block record number: starts at 0. |
17 | 2 | RECLEN | File block data length (LSB first), less than or equal to 512. |
19 | 10 | RECNAM | Name of the file with trailing spaces, repeated every record. |
29 | 1 | DESCHK | Checksum of the previous 14 bytes. |
30 | 512 | CHDATA | Record block data: 0..RECLEN. |
542 | 1 | DCHK | Checksum 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
MicroCartridge’s file meta data.
The structure returned by MicroCartridgeExt::catalog method.
An iterator of sector indices and unordered block numbers belonging to a single file.
An iterator of sectors belonging to a single file.
Binary (
SAVE *
) file’s header.An error returned when a Sector’s content is invalid.
This struct represents an emulated Microdrive tape cartridge.
This struct represents a single MicroCartridge tape sector.
Instances of this type are returned by FileSectorIdsUnordIter iterator.
Enums
A MicroCartridge’s file type.
Constants
The size of the sector header in bytes, excluding the 12 preamble bytes.
The maximum number of usable ZX Microdrive tape sectors.
Traits
Extends MicroCartridge with methods for reading and manipulating Microdrive’s file system.
Extends MicroCartridge’s Sector with methods for reading and manipulating Microdrive’s file system.
Functions
Checksum calculating routine used by Spectrum for Microdrive data.
Type Definitions
An iterator returned by MicroCartridge::iter_with_indices method.