The Multiface 3 Save File Format
Conventions:
All items marked * should be present in the Multiface save file and identical to those in the files saved by the Multiface itself. Even though they do not contribute data to the actual snapshot, they may well be needed by the Multiface during loading. Items marked with a + must be present, but need not be identical to those in the M3's "own" datafiles. Two-byte values are in Zilog/Intel form (LSB first). Words and phrases enclosed in [square brackets] are Spectrum keywords or colour codes.
The Multiface 3 save file consists of either:
1. Two disc files, the Loader and the Datafile.
The Datafile is treated as a
series of concatenated data blocks, exactly corresponding to the separate
headerless files of the tape save file. The Loader has a filename of seven
characters with no file type extension (ie nothing after the dot); the Datafile has the same
filename, with the letter C appended to it. Thus a typical pair would be
HORACE
and
HORACEC
.
or:
2. A collection of tape files; the Loader and three or more headerless files. The Loader may have any name, although the Multiface can save with names only up to seven characters in length.
The M3 loader file has the following format (all figures in Hex):
Offset Length Purpose ================================================================================ 000h* 80h Standard +3DOS header for a BASIC program (disc only). For tape files, subtract 80h from all offsets in this loader. 080h* 69h The start of the BASIC line: "1 REMThe loader should be exactly the same length as a "real" M3 loader (169h bytes) since this value is hardwired into the Multiface ROM." 0E9h 09h Filename of datafile (disc only), ASCII, terminated by 0FFh. There will be spaces after the 0FFh byte if the filename is shorter than 8 characters. Unused for tape files. 0F2h 02h Length of first data block (disc files) or headerless file (tape files). 0F4h+ 0Eh The message "[AT 20,12][FLASH 1][PAPER 6]NOT ON!". This message is printed by the loader when it cannot detect the presence of the Multiface. 102h 02h A word which is 006Eh for tape or 0071h for disc. 104h 10h The 16 AY-3-8912 sound chip register values, in ascending order. 114h* 01h Carriage Return - the end of the REM line. 115h* 54h BASIC line 2. This resets RAMTOP and runs the machine code loader program in the REM in line 1. Parts of this line may be altered. It starts: [BORDER][SGN][PI]:[INK][SGN][PI]:[PAPER][SGN][PI]:[CLEAR] [VAL]"24543":[PRINT]"[AT 20,9][FLASH 1][PAPER 6]M3 LOADING": The address of the string "LOADING" should not be altered, since it is used by the machine code loader. However, the colour codes in the string can be changed. Replace [SGN] by [NOT], [SQR], [INT] for colours 0, 2, 3 respectively. Or, the entire first part of the line can be replaced by [CLEAR][VAL]"24543":[LOAD]"loadscr"[SCREEN$] (up to 7 characters in the name of the loading screen). ===============================================================================
You can get a sample Multiface 3 loader by clicking here (You may have to set your viewer to download to disk first). Note that the Spectrum +3 uses CP/M format discs, so the file is made up to a multiple of 128 bytes with random bytes.
The M3 data file has the following format:
The file is treated as a sequence of 3-8 data blocks, which are either separate headerless tape files or consecutive parts of a large headerless disc file. The first data block begins with a data area 0D3h bytes long. Many bytes in this area are scratchpads used by the Multiface and have no meaning in the saved file.
Offset Length Purpose ================================================================================ 000h 01h A flags byte. Bit 7 is set if the first data block may need decompression. Bit 6 is set if the second data block may need decompression. 016h 02h Load address of the data following this header. This should always be 60B3h. 01Ah 02h Length of this data block, including the header. 01Ch 02h Length of the second data block. If 1B00h, the block is not compressed. 01Eh 02h One greater than the last address used by the first block. If it is zero, the first block is not compressed. 020h 01h Another flags byte. Bit 2 is set if the snapshot is in 128k format. Bit 5 is set if the file is a tape file. 038h 01h Used only in 128k files. The low 4 bits of this byte form a nibble which controls how memory banks 1,3,4 and 6 were saved. It can take the following values: 00h: None of Banks 1,3,4 or 6 was saved. 01h: There is one data block, containing Bank 1. 03h: There are two data blocks - Banks 1 and 3. 07h: There are three data blocks - Banks 1, 3 and 4. 0Fh: There are four data blocks - Banks 1, 3, 4 and 6. The high bits relate to compression: Bit 4 is set if the image of Bank 1 is compressed. Bit 5 is set if the image of Bank 3 is compressed. Bit 6 is set if the image of Bank 4 is compressed. Bit 7 is set if the image of Bank 6 is compressed. 039h 01h Used only in 128k files. Bit 3 is set if Bank 7 was saved to a data block. Bit 7 is set if the image of Bank 7 is compressed. 03Ah 02h Used only in 128k files. Length of Bank 1 data block. 03Ch 02h Used only in 128k files. Length of Bank 3 data block. 03Eh 02h Used only in 128k files. Length of Bank 4 data block. 040h 02h Used only in 128k files. Length of Bank 6 data block. 042h 02h Used only in 128k files. Length of Bank 7 data block. 04Ah 1Ch Z80 registers and ports information, in the order: DW PC ;All double DW IY DW IX ;registers are DW B'C' DW D'E' ;stored low byte first. DW H'L' DB F' DB A' DW BC DW DE DB Mb ;last value output to port 7FFDh DB R DB Mi ;High nibble is the low nibble of the ;last value output to 1FFDh. ;Low nibble: Bit 0 is set for IM 2 ; reset for IM 1 ; Bit 2 is set for EI ; reset for DI DB I DW HL DB F DB A DW SP PC is also stored at the top of the stack. The names Mb and Mi come from the Multiface's register display when it is running the Multi Toolkit. 067h* 6Bh Multiface 3 memory banking and disc access routines. These are used while loading. 0D3h ??? Data for 60B3h-FFFFh, possibly compressed. ================================================================================
The first data block contains an image (possibly compressed) of the RAM from 60B3h-FFFFh.
The second data block contains the screen, possibly compressed.
The third data block is never compressed, and is always of length 05B3h. It contains the image of memory from 5B00h-60B2h.
48k datafiles end at this point. 128k datafiles continue with up to five additional data blocks containing the RAM pages 1,3,4,6 and 7. All of these may be compressed; see below for their format if they are.
Note: When saving, either of the first two blocks may be flagged as "compressed" but be uncompressed. This can be detected from the block lengths.
The border colour is not saved.
Compression
If a block is compressed, then it will contain 6-byte codes instead of
repeated sequences of one byte. The code is:
c, b, a, 37h, EDh, CBh
- b*256+c
- is the number of repetitions of the byte;
- a
- is the byte to be repeated.
If a block contains the sequence 37h, EDh, CBh
then it will
not be compressed.
The extra blocks for a 128k datafile have the following format if compressed:
Offset Purpose ================================================================================ 0 DW length ;Length of this block. 2 Compressed data..... ;The compressed image length-2 DB byte0,byte1 ;First two bytes of the compressed image, which ;should be transferred to offset 0 before ;decompression starts. ================================================================================
Click here for the first 256 bytes of a Multiface 3 datafile. Again, you may need to select downloading to disc.
Disclaimer:
This format has been determined by disassembling the M3 ROM, and by examining the snapshot files it produces. I have no guarantee that it will work in all cases - but it hasn't let me down yet.John Elliott - jce@seasip.demon.co.uk