Home » Archimedes archive » Archimedes World » AW-1996-02-Disc2.adf » !Z80Dem_Z80Demo » Docs/FileFormat/Z80format

Docs/FileFormat/Z80format

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » AW-1996-02-Disc2.adf » !Z80Dem_Z80Demo
Filename: Docs/FileFormat/Z80format
Read OK:
File size: 1595 bytes
Load address: 0000
Exec address: 0000
File contents
(from the docs for Gerton Lunter's Z80 emulator for the PC)

.Z80 FILES
----------

    The old .Z80 snapshot format (for version 1.45 and below) looks like
    this:

        Byte    Length  Description
        0       1       A register
        1       1       F register
        2       2       BC register pair (LSB, i.e.  C, first)
        4       2       HL register pair
        6       2       Program counter
        8       2       Stack pointer
        10      1       Interrupt register
        11      1       Refresh register (Bit 7 is not significant!)
        12      1       Bit 0  : Bit 7 of the R-register
                        Bit 1-3: Border colour
                        Bit 4  : 1=Basic SamRom switched in
                        Bit 5  : 1=Block of data is compressed
                        Bit 6-7: No meaning
        13      2       DE register pair
        15      2       BC' register pair
        17      2       DE' register pair
        19      2       HL' register pair
        21      1       A' register
        22      1       F' register
        23      2       IY register (Again LSB first)
        25      2       IX register
        27      1       Interrupt flipflop, 0=DI, otherwise EI
        28      1       IFF2 (not particularly important...)
        29      1       Bit 0-1: Interrupt mode (0, 1 or 2)
                        Bit 2  : 1=Issue 2 emulation
                        Bit 3  : 1=Double interrupt frequency
                        Bit 4-5: 1=High video synchronisation
                                 3=Low video synchronisation
                                 0,2=Normal
                        Bit 6-7: 0=Cursor/Protek/AGF joystick
                                 1=Kempston joystick
                                 2=Sinclair 1 joystick
                                 3=Sinclair 2 joystick

    Because of compatibility, if byte 12 is 255, it has to be regarded as
    being 1.  After this header block of 30 bytes the 48K bytes of Spectrum
    memory follows in a compressed format (if bit 5 of byte 12 is one). The
    compression method is very simple: it replaces repetitions of at least
    five equal bytes by a four-byte code ED ED xx yy, which stands for "byte
    yy repeated xx times".  Only sequences of length at least 5 are coded.
    The exception is sequences consisting of ED's; if they are encountered,
    even two ED's are encoded into ED ED 02 ED.  Finally, every byte
    directly following a single ED is not taken into a block, for example
    ED 6*00 is not encoded into ED ED ED 06 00 but into ED 00 ED ED 05 00.
    The block is terminated by an end marker, 00 ED ED 00.

    That's the format of .Z80 files as used by versions up to 1.45.  Since
    version 2.01 emulates the Spectrum 128 too, there was a need for a new
    format.

    The first 30 bytes are almost the same as the old versions' header.  Of
    the flag byte, bit 4 and 5 have got no meaning anymore, and the program
    counter (bytes 6 and 7) are zero to signal a version 2.01 .Z80 file.  So
    loading a new style .Z80 file into an old emulator will cause an error
    or a reset at the most.

    After the first 30 bytes, an additional header follows:

        Byte    Length  Description
        30      2       Length of additional header block (contains 23)
        32      2       Program counter
        34      1       Hardware mode: 0=Spectrum 48K, 1=0+interface I,
                        2=SamRam, 3=Spectrum 128K, 4=3+interface I.
        35      1       If in SamRam mode, bitwise state of 74ls259.
                        For example, bit 6=1 after an OUT 31,13 (=2*6+1)
                        If in 128 mode, contains last OUT to 7ffd
        36      1       Contains 0FF if Interface I rom paged
        37      1       Bit 0: 1 if R register emulation on
                        Bit 1: 1 if LDIR emulation on
        38      1       Last OUT to fffd (soundchip register number)
        39      16      Contents of the sound chip registers

    Hereafter a number of memory blocks follow, each containing the
    compressed data of a 16K block.  The compression is according to the old
    scheme, except for the end-marker, which is now absent.  The structure
    of a memory block is:

        Byte    Length  Description
        0       2       Length of data (without this 3-byte header)
        2       1       Page number of block
        3       [0]     Compressed data

    The pages are numbered, depending on the hardware mode, in the following
    way:

        Page    In '48 mode     In '128 mode    In SamRam mode

         0      48K rom         rom (basic)     48K rom
         1      Interf. I rom   Interf. I rom   Interf. I rom
         2      -               rom (reset)     samram rom (basic)
         3      -               page 0          samram rom (monitor,..)
         4      8000-bfff       page 1          Normal 8000-bfff
         5      c000-ffff       page 2          Normal c000-ffff
         6      -               page 3          Shadow 8000-bfff
         7      -               page 4          Shadow c000-ffff
         8      4000-7fff       page 5          4000-7fff
         9      -               page 6          -
        10      -               page 7          -

    In 48K mode, pages 4,5 and 8 are saved.  In SamRam mode, pages 4 to 8
    are saved.  In 128 mode, all pages from 3 to 10 are saved.  This
    version saves the pages in numerical order.  There is no end marker.
    end marker.


00000000  28 66 72 6f 6d 20 74 68  65 20 64 6f 63 73 20 66  |(from the docs f|
00000010  6f 72 20 47 65 72 74 6f  6e 20 4c 75 6e 74 65 72  |or Gerton Lunter|
00000020  27 73 20 5a 38 30 20 65  6d 75 6c 61 74 6f 72 20  |'s Z80 emulator |
00000030  66 6f 72 20 74 68 65 20  50 43 29 0a 0a 2e 5a 38  |for the PC)...Z8|
00000040  30 20 46 49 4c 45 53 0a  2d 2d 2d 2d 2d 2d 2d 2d  |0 FILES.--------|
00000050  2d 2d 0a 0a 20 20 20 20  54 68 65 20 6f 6c 64 20  |--..    The old |
00000060  2e 5a 38 30 20 73 6e 61  70 73 68 6f 74 20 66 6f  |.Z80 snapshot fo|
00000070  72 6d 61 74 20 28 66 6f  72 20 76 65 72 73 69 6f  |rmat (for versio|
00000080  6e 20 31 2e 34 35 20 61  6e 64 20 62 65 6c 6f 77  |n 1.45 and below|
00000090  29 20 6c 6f 6f 6b 73 20  6c 69 6b 65 0a 20 20 20  |) looks like.   |
000000a0  20 74 68 69 73 3a 0a 0a  20 20 20 20 20 20 20 20  | this:..        |
000000b0  42 79 74 65 20 20 20 20  4c 65 6e 67 74 68 20 20  |Byte    Length  |
000000c0  44 65 73 63 72 69 70 74  69 6f 6e 0a 20 20 20 20  |Description.    |
000000d0  20 20 20 20 30 20 20 20  20 20 20 20 31 20 20 20  |    0       1   |
000000e0  20 20 20 20 41 20 72 65  67 69 73 74 65 72 0a 20  |    A register. |
000000f0  20 20 20 20 20 20 20 31  20 20 20 20 20 20 20 31  |       1       1|
00000100  20 20 20 20 20 20 20 46  20 72 65 67 69 73 74 65  |       F registe|
00000110  72 0a 20 20 20 20 20 20  20 20 32 20 20 20 20 20  |r.        2     |
00000120  20 20 32 20 20 20 20 20  20 20 42 43 20 72 65 67  |  2       BC reg|
00000130  69 73 74 65 72 20 70 61  69 72 20 28 4c 53 42 2c  |ister pair (LSB,|
00000140  20 69 2e 65 2e 20 20 43  2c 20 66 69 72 73 74 29  | i.e.  C, first)|
00000150  0a 20 20 20 20 20 20 20  20 34 20 20 20 20 20 20  |.        4      |
00000160  20 32 20 20 20 20 20 20  20 48 4c 20 72 65 67 69  | 2       HL regi|
00000170  73 74 65 72 20 70 61 69  72 0a 20 20 20 20 20 20  |ster pair.      |
00000180  20 20 36 20 20 20 20 20  20 20 32 20 20 20 20 20  |  6       2     |
00000190  20 20 50 72 6f 67 72 61  6d 20 63 6f 75 6e 74 65  |  Program counte|
000001a0  72 0a 20 20 20 20 20 20  20 20 38 20 20 20 20 20  |r.        8     |
000001b0  20 20 32 20 20 20 20 20  20 20 53 74 61 63 6b 20  |  2       Stack |
000001c0  70 6f 69 6e 74 65 72 0a  20 20 20 20 20 20 20 20  |pointer.        |
000001d0  31 30 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |10      1       |
000001e0  49 6e 74 65 72 72 75 70  74 20 72 65 67 69 73 74  |Interrupt regist|
000001f0  65 72 0a 20 20 20 20 20  20 20 20 31 31 20 20 20  |er.        11   |
00000200  20 20 20 31 20 20 20 20  20 20 20 52 65 66 72 65  |   1       Refre|
00000210  73 68 20 72 65 67 69 73  74 65 72 20 28 42 69 74  |sh register (Bit|
00000220  20 37 20 69 73 20 6e 6f  74 20 73 69 67 6e 69 66  | 7 is not signif|
00000230  69 63 61 6e 74 21 29 0a  20 20 20 20 20 20 20 20  |icant!).        |
00000240  31 32 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |12      1       |
00000250  42 69 74 20 30 20 20 3a  20 42 69 74 20 37 20 6f  |Bit 0  : Bit 7 o|
00000260  66 20 74 68 65 20 52 2d  72 65 67 69 73 74 65 72  |f the R-register|
00000270  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000280  20 20 20 20 20 20 20 20  20 42 69 74 20 31 2d 33  |         Bit 1-3|
00000290  3a 20 42 6f 72 64 65 72  20 63 6f 6c 6f 75 72 0a  |: Border colour.|
000002a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000002b0  20 20 20 20 20 20 20 20  42 69 74 20 34 20 20 3a  |        Bit 4  :|
000002c0  20 31 3d 42 61 73 69 63  20 53 61 6d 52 6f 6d 20  | 1=Basic SamRom |
000002d0  73 77 69 74 63 68 65 64  20 69 6e 0a 20 20 20 20  |switched in.    |
000002e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000002f0  20 20 20 20 42 69 74 20  35 20 20 3a 20 31 3d 42  |    Bit 5  : 1=B|
00000300  6c 6f 63 6b 20 6f 66 20  64 61 74 61 20 69 73 20  |lock of data is |
00000310  63 6f 6d 70 72 65 73 73  65 64 0a 20 20 20 20 20  |compressed.     |
00000320  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000330  20 20 20 42 69 74 20 36  2d 37 3a 20 4e 6f 20 6d  |   Bit 6-7: No m|
00000340  65 61 6e 69 6e 67 0a 20  20 20 20 20 20 20 20 31  |eaning.        1|
00000350  33 20 20 20 20 20 20 32  20 20 20 20 20 20 20 44  |3      2       D|
00000360  45 20 72 65 67 69 73 74  65 72 20 70 61 69 72 0a  |E register pair.|
00000370  20 20 20 20 20 20 20 20  31 35 20 20 20 20 20 20  |        15      |
00000380  32 20 20 20 20 20 20 20  42 43 27 20 72 65 67 69  |2       BC' regi|
00000390  73 74 65 72 20 70 61 69  72 0a 20 20 20 20 20 20  |ster pair.      |
000003a0  20 20 31 37 20 20 20 20  20 20 32 20 20 20 20 20  |  17      2     |
000003b0  20 20 44 45 27 20 72 65  67 69 73 74 65 72 20 70  |  DE' register p|
000003c0  61 69 72 0a 20 20 20 20  20 20 20 20 31 39 20 20  |air.        19  |
000003d0  20 20 20 20 32 20 20 20  20 20 20 20 48 4c 27 20  |    2       HL' |
000003e0  72 65 67 69 73 74 65 72  20 70 61 69 72 0a 20 20  |register pair.  |
000003f0  20 20 20 20 20 20 32 31  20 20 20 20 20 20 31 20  |      21      1 |
00000400  20 20 20 20 20 20 41 27  20 72 65 67 69 73 74 65  |      A' registe|
00000410  72 0a 20 20 20 20 20 20  20 20 32 32 20 20 20 20  |r.        22    |
00000420  20 20 31 20 20 20 20 20  20 20 46 27 20 72 65 67  |  1       F' reg|
00000430  69 73 74 65 72 0a 20 20  20 20 20 20 20 20 32 33  |ister.        23|
00000440  20 20 20 20 20 20 32 20  20 20 20 20 20 20 49 59  |      2       IY|
00000450  20 72 65 67 69 73 74 65  72 20 28 41 67 61 69 6e  | register (Again|
00000460  20 4c 53 42 20 66 69 72  73 74 29 0a 20 20 20 20  | LSB first).    |
00000470  20 20 20 20 32 35 20 20  20 20 20 20 32 20 20 20  |    25      2   |
00000480  20 20 20 20 49 58 20 72  65 67 69 73 74 65 72 0a  |    IX register.|
00000490  20 20 20 20 20 20 20 20  32 37 20 20 20 20 20 20  |        27      |
000004a0  31 20 20 20 20 20 20 20  49 6e 74 65 72 72 75 70  |1       Interrup|
000004b0  74 20 66 6c 69 70 66 6c  6f 70 2c 20 30 3d 44 49  |t flipflop, 0=DI|
000004c0  2c 20 6f 74 68 65 72 77  69 73 65 20 45 49 0a 20  |, otherwise EI. |
000004d0  20 20 20 20 20 20 20 32  38 20 20 20 20 20 20 31  |       28      1|
000004e0  20 20 20 20 20 20 20 49  46 46 32 20 28 6e 6f 74  |       IFF2 (not|
000004f0  20 70 61 72 74 69 63 75  6c 61 72 6c 79 20 69 6d  | particularly im|
00000500  70 6f 72 74 61 6e 74 2e  2e 2e 29 0a 20 20 20 20  |portant...).    |
00000510  20 20 20 20 32 39 20 20  20 20 20 20 31 20 20 20  |    29      1   |
00000520  20 20 20 20 42 69 74 20  30 2d 31 3a 20 49 6e 74  |    Bit 0-1: Int|
00000530  65 72 72 75 70 74 20 6d  6f 64 65 20 28 30 2c 20  |errupt mode (0, |
00000540  31 20 6f 72 20 32 29 0a  20 20 20 20 20 20 20 20  |1 or 2).        |
00000550  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000560  42 69 74 20 32 20 20 3a  20 31 3d 49 73 73 75 65  |Bit 2  : 1=Issue|
00000570  20 32 20 65 6d 75 6c 61  74 69 6f 6e 0a 20 20 20  | 2 emulation.   |
00000580  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000590  20 20 20 20 20 42 69 74  20 33 20 20 3a 20 31 3d  |     Bit 3  : 1=|
000005a0  44 6f 75 62 6c 65 20 69  6e 74 65 72 72 75 70 74  |Double interrupt|
000005b0  20 66 72 65 71 75 65 6e  63 79 0a 20 20 20 20 20  | frequency.     |
000005c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000005d0  20 20 20 42 69 74 20 34  2d 35 3a 20 31 3d 48 69  |   Bit 4-5: 1=Hi|
000005e0  67 68 20 76 69 64 65 6f  20 73 79 6e 63 68 72 6f  |gh video synchro|
000005f0  6e 69 73 61 74 69 6f 6e  0a 20 20 20 20 20 20 20  |nisation.       |
00000600  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000610  20 20 20 20 20 20 20 20  20 20 33 3d 4c 6f 77 20  |          3=Low |
00000620  76 69 64 65 6f 20 73 79  6e 63 68 72 6f 6e 69 73  |video synchronis|
00000630  61 74 69 6f 6e 0a 20 20  20 20 20 20 20 20 20 20  |ation.          |
00000640  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000650  20 20 20 20 20 20 20 30  2c 32 3d 4e 6f 72 6d 61  |       0,2=Norma|
00000660  6c 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |l.              |
00000670  20 20 20 20 20 20 20 20  20 20 42 69 74 20 36 2d  |          Bit 6-|
00000680  37 3a 20 30 3d 43 75 72  73 6f 72 2f 50 72 6f 74  |7: 0=Cursor/Prot|
00000690  65 6b 2f 41 47 46 20 6a  6f 79 73 74 69 63 6b 0a  |ek/AGF joystick.|
000006a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000006c0  20 31 3d 4b 65 6d 70 73  74 6f 6e 20 6a 6f 79 73  | 1=Kempston joys|
000006d0  74 69 63 6b 0a 20 20 20  20 20 20 20 20 20 20 20  |tick.           |
000006e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000006f0  20 20 20 20 20 20 32 3d  53 69 6e 63 6c 61 69 72  |      2=Sinclair|
00000700  20 31 20 6a 6f 79 73 74  69 63 6b 0a 20 20 20 20  | 1 joystick.    |
00000710  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000720  20 20 20 20 20 20 20 20  20 20 20 20 20 33 3d 53  |             3=S|
00000730  69 6e 63 6c 61 69 72 20  32 20 6a 6f 79 73 74 69  |inclair 2 joysti|
00000740  63 6b 0a 0a 20 20 20 20  42 65 63 61 75 73 65 20  |ck..    Because |
00000750  6f 66 20 63 6f 6d 70 61  74 69 62 69 6c 69 74 79  |of compatibility|
00000760  2c 20 69 66 20 62 79 74  65 20 31 32 20 69 73 20  |, if byte 12 is |
00000770  32 35 35 2c 20 69 74 20  68 61 73 20 74 6f 20 62  |255, it has to b|
00000780  65 20 72 65 67 61 72 64  65 64 20 61 73 0a 20 20  |e regarded as.  |
00000790  20 20 62 65 69 6e 67 20  31 2e 20 20 41 66 74 65  |  being 1.  Afte|
000007a0  72 20 74 68 69 73 20 68  65 61 64 65 72 20 62 6c  |r this header bl|
000007b0  6f 63 6b 20 6f 66 20 33  30 20 62 79 74 65 73 20  |ock of 30 bytes |
000007c0  74 68 65 20 34 38 4b 20  62 79 74 65 73 20 6f 66  |the 48K bytes of|
000007d0  20 53 70 65 63 74 72 75  6d 0a 20 20 20 20 6d 65  | Spectrum.    me|
000007e0  6d 6f 72 79 20 66 6f 6c  6c 6f 77 73 20 69 6e 20  |mory follows in |
000007f0  61 20 63 6f 6d 70 72 65  73 73 65 64 20 66 6f 72  |a compressed for|
00000800  6d 61 74 20 28 69 66 20  62 69 74 20 35 20 6f 66  |mat (if bit 5 of|
00000810  20 62 79 74 65 20 31 32  20 69 73 20 6f 6e 65 29  | byte 12 is one)|
00000820  2e 20 54 68 65 0a 20 20  20 20 63 6f 6d 70 72 65  |. The.    compre|
00000830  73 73 69 6f 6e 20 6d 65  74 68 6f 64 20 69 73 20  |ssion method is |
00000840  76 65 72 79 20 73 69 6d  70 6c 65 3a 20 69 74 20  |very simple: it |
00000850  72 65 70 6c 61 63 65 73  20 72 65 70 65 74 69 74  |replaces repetit|
00000860  69 6f 6e 73 20 6f 66 20  61 74 20 6c 65 61 73 74  |ions of at least|
00000870  0a 20 20 20 20 66 69 76  65 20 65 71 75 61 6c 20  |.    five equal |
00000880  62 79 74 65 73 20 62 79  20 61 20 66 6f 75 72 2d  |bytes by a four-|
00000890  62 79 74 65 20 63 6f 64  65 20 45 44 20 45 44 20  |byte code ED ED |
000008a0  78 78 20 79 79 2c 20 77  68 69 63 68 20 73 74 61  |xx yy, which sta|
000008b0  6e 64 73 20 66 6f 72 20  22 62 79 74 65 0a 20 20  |nds for "byte.  |
000008c0  20 20 79 79 20 72 65 70  65 61 74 65 64 20 78 78  |  yy repeated xx|
000008d0  20 74 69 6d 65 73 22 2e  20 20 4f 6e 6c 79 20 73  | times".  Only s|
000008e0  65 71 75 65 6e 63 65 73  20 6f 66 20 6c 65 6e 67  |equences of leng|
000008f0  74 68 20 61 74 20 6c 65  61 73 74 20 35 20 61 72  |th at least 5 ar|
00000900  65 20 63 6f 64 65 64 2e  0a 20 20 20 20 54 68 65  |e coded..    The|
00000910  20 65 78 63 65 70 74 69  6f 6e 20 69 73 20 73 65  | exception is se|
00000920  71 75 65 6e 63 65 73 20  63 6f 6e 73 69 73 74 69  |quences consisti|
00000930  6e 67 20 6f 66 20 45 44  27 73 3b 20 69 66 20 74  |ng of ED's; if t|
00000940  68 65 79 20 61 72 65 20  65 6e 63 6f 75 6e 74 65  |hey are encounte|
00000950  72 65 64 2c 0a 20 20 20  20 65 76 65 6e 20 74 77  |red,.    even tw|
00000960  6f 20 45 44 27 73 20 61  72 65 20 65 6e 63 6f 64  |o ED's are encod|
00000970  65 64 20 69 6e 74 6f 20  45 44 20 45 44 20 30 32  |ed into ED ED 02|
00000980  20 45 44 2e 20 20 46 69  6e 61 6c 6c 79 2c 20 65  | ED.  Finally, e|
00000990  76 65 72 79 20 62 79 74  65 0a 20 20 20 20 64 69  |very byte.    di|
000009a0  72 65 63 74 6c 79 20 66  6f 6c 6c 6f 77 69 6e 67  |rectly following|
000009b0  20 61 20 73 69 6e 67 6c  65 20 45 44 20 69 73 20  | a single ED is |
000009c0  6e 6f 74 20 74 61 6b 65  6e 20 69 6e 74 6f 20 61  |not taken into a|
000009d0  20 62 6c 6f 63 6b 2c 20  66 6f 72 20 65 78 61 6d  | block, for exam|
000009e0  70 6c 65 0a 20 20 20 20  45 44 20 36 2a 30 30 20  |ple.    ED 6*00 |
000009f0  69 73 20 6e 6f 74 20 65  6e 63 6f 64 65 64 20 69  |is not encoded i|
00000a00  6e 74 6f 20 45 44 20 45  44 20 45 44 20 30 36 20  |nto ED ED ED 06 |
00000a10  30 30 20 62 75 74 20 69  6e 74 6f 20 45 44 20 30  |00 but into ED 0|
00000a20  30 20 45 44 20 45 44 20  30 35 20 30 30 2e 0a 20  |0 ED ED 05 00.. |
00000a30  20 20 20 54 68 65 20 62  6c 6f 63 6b 20 69 73 20  |   The block is |
00000a40  74 65 72 6d 69 6e 61 74  65 64 20 62 79 20 61 6e  |terminated by an|
00000a50  20 65 6e 64 20 6d 61 72  6b 65 72 2c 20 30 30 20  | end marker, 00 |
00000a60  45 44 20 45 44 20 30 30  2e 0a 0a 20 20 20 20 54  |ED ED 00...    T|
00000a70  68 61 74 27 73 20 74 68  65 20 66 6f 72 6d 61 74  |hat's the format|
00000a80  20 6f 66 20 2e 5a 38 30  20 66 69 6c 65 73 20 61  | of .Z80 files a|
00000a90  73 20 75 73 65 64 20 62  79 20 76 65 72 73 69 6f  |s used by versio|
00000aa0  6e 73 20 75 70 20 74 6f  20 31 2e 34 35 2e 20 20  |ns up to 1.45.  |
00000ab0  53 69 6e 63 65 0a 20 20  20 20 76 65 72 73 69 6f  |Since.    versio|
00000ac0  6e 20 32 2e 30 31 20 65  6d 75 6c 61 74 65 73 20  |n 2.01 emulates |
00000ad0  74 68 65 20 53 70 65 63  74 72 75 6d 20 31 32 38  |the Spectrum 128|
00000ae0  20 74 6f 6f 2c 20 74 68  65 72 65 20 77 61 73 20  | too, there was |
00000af0  61 20 6e 65 65 64 20 66  6f 72 20 61 20 6e 65 77  |a need for a new|
00000b00  0a 20 20 20 20 66 6f 72  6d 61 74 2e 0a 0a 20 20  |.    format...  |
00000b10  20 20 54 68 65 20 66 69  72 73 74 20 33 30 20 62  |  The first 30 b|
00000b20  79 74 65 73 20 61 72 65  20 61 6c 6d 6f 73 74 20  |ytes are almost |
00000b30  74 68 65 20 73 61 6d 65  20 61 73 20 74 68 65 20  |the same as the |
00000b40  6f 6c 64 20 76 65 72 73  69 6f 6e 73 27 20 68 65  |old versions' he|
00000b50  61 64 65 72 2e 20 20 4f  66 0a 20 20 20 20 74 68  |ader.  Of.    th|
00000b60  65 20 66 6c 61 67 20 62  79 74 65 2c 20 62 69 74  |e flag byte, bit|
00000b70  20 34 20 61 6e 64 20 35  20 68 61 76 65 20 67 6f  | 4 and 5 have go|
00000b80  74 20 6e 6f 20 6d 65 61  6e 69 6e 67 20 61 6e 79  |t no meaning any|
00000b90  6d 6f 72 65 2c 20 61 6e  64 20 74 68 65 20 70 72  |more, and the pr|
00000ba0  6f 67 72 61 6d 0a 20 20  20 20 63 6f 75 6e 74 65  |ogram.    counte|
00000bb0  72 20 28 62 79 74 65 73  20 36 20 61 6e 64 20 37  |r (bytes 6 and 7|
00000bc0  29 20 61 72 65 20 7a 65  72 6f 20 74 6f 20 73 69  |) are zero to si|
00000bd0  67 6e 61 6c 20 61 20 76  65 72 73 69 6f 6e 20 32  |gnal a version 2|
00000be0  2e 30 31 20 2e 5a 38 30  20 66 69 6c 65 2e 20 20  |.01 .Z80 file.  |
00000bf0  53 6f 0a 20 20 20 20 6c  6f 61 64 69 6e 67 20 61  |So.    loading a|
00000c00  20 6e 65 77 20 73 74 79  6c 65 20 2e 5a 38 30 20  | new style .Z80 |
00000c10  66 69 6c 65 20 69 6e 74  6f 20 61 6e 20 6f 6c 64  |file into an old|
00000c20  20 65 6d 75 6c 61 74 6f  72 20 77 69 6c 6c 20 63  | emulator will c|
00000c30  61 75 73 65 20 61 6e 20  65 72 72 6f 72 0a 20 20  |ause an error.  |
00000c40  20 20 6f 72 20 61 20 72  65 73 65 74 20 61 74 20  |  or a reset at |
00000c50  74 68 65 20 6d 6f 73 74  2e 0a 0a 20 20 20 20 41  |the most...    A|
00000c60  66 74 65 72 20 74 68 65  20 66 69 72 73 74 20 33  |fter the first 3|
00000c70  30 20 62 79 74 65 73 2c  20 61 6e 20 61 64 64 69  |0 bytes, an addi|
00000c80  74 69 6f 6e 61 6c 20 68  65 61 64 65 72 20 66 6f  |tional header fo|
00000c90  6c 6c 6f 77 73 3a 0a 0a  20 20 20 20 20 20 20 20  |llows:..        |
00000ca0  42 79 74 65 20 20 20 20  4c 65 6e 67 74 68 20 20  |Byte    Length  |
00000cb0  44 65 73 63 72 69 70 74  69 6f 6e 0a 20 20 20 20  |Description.    |
00000cc0  20 20 20 20 33 30 20 20  20 20 20 20 32 20 20 20  |    30      2   |
00000cd0  20 20 20 20 4c 65 6e 67  74 68 20 6f 66 20 61 64  |    Length of ad|
00000ce0  64 69 74 69 6f 6e 61 6c  20 68 65 61 64 65 72 20  |ditional header |
00000cf0  62 6c 6f 63 6b 20 28 63  6f 6e 74 61 69 6e 73 20  |block (contains |
00000d00  32 33 29 0a 20 20 20 20  20 20 20 20 33 32 20 20  |23).        32  |
00000d10  20 20 20 20 32 20 20 20  20 20 20 20 50 72 6f 67  |    2       Prog|
00000d20  72 61 6d 20 63 6f 75 6e  74 65 72 0a 20 20 20 20  |ram counter.    |
00000d30  20 20 20 20 33 34 20 20  20 20 20 20 31 20 20 20  |    34      1   |
00000d40  20 20 20 20 48 61 72 64  77 61 72 65 20 6d 6f 64  |    Hardware mod|
00000d50  65 3a 20 30 3d 53 70 65  63 74 72 75 6d 20 34 38  |e: 0=Spectrum 48|
00000d60  4b 2c 20 31 3d 30 2b 69  6e 74 65 72 66 61 63 65  |K, 1=0+interface|
00000d70  20 49 2c 0a 20 20 20 20  20 20 20 20 20 20 20 20  | I,.            |
00000d80  20 20 20 20 20 20 20 20  20 20 20 20 32 3d 53 61  |            2=Sa|
00000d90  6d 52 61 6d 2c 20 33 3d  53 70 65 63 74 72 75 6d  |mRam, 3=Spectrum|
00000da0  20 31 32 38 4b 2c 20 34  3d 33 2b 69 6e 74 65 72  | 128K, 4=3+inter|
00000db0  66 61 63 65 20 49 2e 0a  20 20 20 20 20 20 20 20  |face I..        |
00000dc0  33 35 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |35      1       |
00000dd0  49 66 20 69 6e 20 53 61  6d 52 61 6d 20 6d 6f 64  |If in SamRam mod|
00000de0  65 2c 20 62 69 74 77 69  73 65 20 73 74 61 74 65  |e, bitwise state|
00000df0  20 6f 66 20 37 34 6c 73  32 35 39 2e 0a 20 20 20  | of 74ls259..   |
00000e00  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000e10  20 20 20 20 20 46 6f 72  20 65 78 61 6d 70 6c 65  |     For example|
00000e20  2c 20 62 69 74 20 36 3d  31 20 61 66 74 65 72 20  |, bit 6=1 after |
00000e30  61 6e 20 4f 55 54 20 33  31 2c 31 33 20 28 3d 32  |an OUT 31,13 (=2|
00000e40  2a 36 2b 31 29 0a 20 20  20 20 20 20 20 20 20 20  |*6+1).          |
00000e50  20 20 20 20 20 20 20 20  20 20 20 20 20 20 49 66  |              If|
00000e60  20 69 6e 20 31 32 38 20  6d 6f 64 65 2c 20 63 6f  | in 128 mode, co|
00000e70  6e 74 61 69 6e 73 20 6c  61 73 74 20 4f 55 54 20  |ntains last OUT |
00000e80  74 6f 20 37 66 66 64 0a  20 20 20 20 20 20 20 20  |to 7ffd.        |
00000e90  33 36 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |36      1       |
00000ea0  43 6f 6e 74 61 69 6e 73  20 30 46 46 20 69 66 20  |Contains 0FF if |
00000eb0  49 6e 74 65 72 66 61 63  65 20 49 20 72 6f 6d 20  |Interface I rom |
00000ec0  70 61 67 65 64 0a 20 20  20 20 20 20 20 20 33 37  |paged.        37|
00000ed0  20 20 20 20 20 20 31 20  20 20 20 20 20 20 42 69  |      1       Bi|
00000ee0  74 20 30 3a 20 31 20 69  66 20 52 20 72 65 67 69  |t 0: 1 if R regi|
00000ef0  73 74 65 72 20 65 6d 75  6c 61 74 69 6f 6e 20 6f  |ster emulation o|
00000f00  6e 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |n.              |
00000f10  20 20 20 20 20 20 20 20  20 20 42 69 74 20 31 3a  |          Bit 1:|
00000f20  20 31 20 69 66 20 4c 44  49 52 20 65 6d 75 6c 61  | 1 if LDIR emula|
00000f30  74 69 6f 6e 20 6f 6e 0a  20 20 20 20 20 20 20 20  |tion on.        |
00000f40  33 38 20 20 20 20 20 20  31 20 20 20 20 20 20 20  |38      1       |
00000f50  4c 61 73 74 20 4f 55 54  20 74 6f 20 66 66 66 64  |Last OUT to fffd|
00000f60  20 28 73 6f 75 6e 64 63  68 69 70 20 72 65 67 69  | (soundchip regi|
00000f70  73 74 65 72 20 6e 75 6d  62 65 72 29 0a 20 20 20  |ster number).   |
00000f80  20 20 20 20 20 33 39 20  20 20 20 20 20 31 36 20  |     39      16 |
00000f90  20 20 20 20 20 43 6f 6e  74 65 6e 74 73 20 6f 66  |     Contents of|
00000fa0  20 74 68 65 20 73 6f 75  6e 64 20 63 68 69 70 20  | the sound chip |
00000fb0  72 65 67 69 73 74 65 72  73 0a 0a 20 20 20 20 48  |registers..    H|
00000fc0  65 72 65 61 66 74 65 72  20 61 20 6e 75 6d 62 65  |ereafter a numbe|
00000fd0  72 20 6f 66 20 6d 65 6d  6f 72 79 20 62 6c 6f 63  |r of memory bloc|
00000fe0  6b 73 20 66 6f 6c 6c 6f  77 2c 20 65 61 63 68 20  |ks follow, each |
00000ff0  63 6f 6e 74 61 69 6e 69  6e 67 20 74 68 65 0a 20  |containing the. |
00001000  20 20 20 63 6f 6d 70 72  65 73 73 65 64 20 64 61  |   compressed da|
00001010  74 61 20 6f 66 20 61 20  31 36 4b 20 62 6c 6f 63  |ta of a 16K bloc|
00001020  6b 2e 20 20 54 68 65 20  63 6f 6d 70 72 65 73 73  |k.  The compress|
00001030  69 6f 6e 20 69 73 20 61  63 63 6f 72 64 69 6e 67  |ion is according|
00001040  20 74 6f 20 74 68 65 20  6f 6c 64 0a 20 20 20 20  | to the old.    |
00001050  73 63 68 65 6d 65 2c 20  65 78 63 65 70 74 20 66  |scheme, except f|
00001060  6f 72 20 74 68 65 20 65  6e 64 2d 6d 61 72 6b 65  |or the end-marke|
00001070  72 2c 20 77 68 69 63 68  20 69 73 20 6e 6f 77 20  |r, which is now |
00001080  61 62 73 65 6e 74 2e 20  20 54 68 65 20 73 74 72  |absent.  The str|
00001090  75 63 74 75 72 65 0a 20  20 20 20 6f 66 20 61 20  |ucture.    of a |
000010a0  6d 65 6d 6f 72 79 20 62  6c 6f 63 6b 20 69 73 3a  |memory block is:|
000010b0  0a 0a 20 20 20 20 20 20  20 20 42 79 74 65 20 20  |..        Byte  |
000010c0  20 20 4c 65 6e 67 74 68  20 20 44 65 73 63 72 69  |  Length  Descri|
000010d0  70 74 69 6f 6e 0a 20 20  20 20 20 20 20 20 30 20  |ption.        0 |
000010e0  20 20 20 20 20 20 32 20  20 20 20 20 20 20 4c 65  |      2       Le|
000010f0  6e 67 74 68 20 6f 66 20  64 61 74 61 20 28 77 69  |ngth of data (wi|
00001100  74 68 6f 75 74 20 74 68  69 73 20 33 2d 62 79 74  |thout this 3-byt|
00001110  65 20 68 65 61 64 65 72  29 0a 20 20 20 20 20 20  |e header).      |
00001120  20 20 32 20 20 20 20 20  20 20 31 20 20 20 20 20  |  2       1     |
00001130  20 20 50 61 67 65 20 6e  75 6d 62 65 72 20 6f 66  |  Page number of|
00001140  20 62 6c 6f 63 6b 0a 20  20 20 20 20 20 20 20 33  | block.        3|
00001150  20 20 20 20 20 20 20 5b  30 5d 20 20 20 20 20 43  |       [0]     C|
00001160  6f 6d 70 72 65 73 73 65  64 20 64 61 74 61 0a 0a  |ompressed data..|
00001170  20 20 20 20 54 68 65 20  70 61 67 65 73 20 61 72  |    The pages ar|
00001180  65 20 6e 75 6d 62 65 72  65 64 2c 20 64 65 70 65  |e numbered, depe|
00001190  6e 64 69 6e 67 20 6f 6e  20 74 68 65 20 68 61 72  |nding on the har|
000011a0  64 77 61 72 65 20 6d 6f  64 65 2c 20 69 6e 20 74  |dware mode, in t|
000011b0  68 65 20 66 6f 6c 6c 6f  77 69 6e 67 0a 20 20 20  |he following.   |
000011c0  20 77 61 79 3a 0a 0a 20  20 20 20 20 20 20 20 50  | way:..        P|
000011d0  61 67 65 20 20 20 20 49  6e 20 27 34 38 20 6d 6f  |age    In '48 mo|
000011e0  64 65 20 20 20 20 20 49  6e 20 27 31 32 38 20 6d  |de     In '128 m|
000011f0  6f 64 65 20 20 20 20 49  6e 20 53 61 6d 52 61 6d  |ode    In SamRam|
00001200  20 6d 6f 64 65 0a 0a 20  20 20 20 20 20 20 20 20  | mode..         |
00001210  30 20 20 20 20 20 20 34  38 4b 20 72 6f 6d 20 20  |0      48K rom  |
00001220  20 20 20 20 20 20 20 72  6f 6d 20 28 62 61 73 69  |       rom (basi|
00001230  63 29 20 20 20 20 20 34  38 4b 20 72 6f 6d 0a 20  |c)     48K rom. |
00001240  20 20 20 20 20 20 20 20  31 20 20 20 20 20 20 49  |        1      I|
00001250  6e 74 65 72 66 2e 20 49  20 72 6f 6d 20 20 20 49  |nterf. I rom   I|
*
00001270  6e 74 65 72 66 2e 20 49  20 72 6f 6d 0a 20 20 20  |nterf. I rom.   |
00001280  20 20 20 20 20 20 32 20  20 20 20 20 20 2d 20 20  |      2      -  |
00001290  20 20 20 20 20 20 20 20  20 20 20 20 20 72 6f 6d  |             rom|
000012a0  20 28 72 65 73 65 74 29  20 20 20 20 20 73 61 6d  | (reset)     sam|
000012b0  72 61 6d 20 72 6f 6d 20  28 62 61 73 69 63 29 0a  |ram rom (basic).|
000012c0  20 20 20 20 20 20 20 20  20 33 20 20 20 20 20 20  |         3      |
000012d0  2d 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |-               |
000012e0  70 61 67 65 20 30 20 20  20 20 20 20 20 20 20 20  |page 0          |
000012f0  73 61 6d 72 61 6d 20 72  6f 6d 20 28 6d 6f 6e 69  |samram rom (moni|
00001300  74 6f 72 2c 2e 2e 29 0a  20 20 20 20 20 20 20 20  |tor,..).        |
00001310  20 34 20 20 20 20 20 20  38 30 30 30 2d 62 66 66  | 4      8000-bff|
00001320  66 20 20 20 20 20 20 20  70 61 67 65 20 31 20 20  |f       page 1  |
00001330  20 20 20 20 20 20 20 20  4e 6f 72 6d 61 6c 20 38  |        Normal 8|
00001340  30 30 30 2d 62 66 66 66  0a 20 20 20 20 20 20 20  |000-bfff.       |
00001350  20 20 35 20 20 20 20 20  20 63 30 30 30 2d 66 66  |  5      c000-ff|
00001360  66 66 20 20 20 20 20 20  20 70 61 67 65 20 32 20  |ff       page 2 |
00001370  20 20 20 20 20 20 20 20  20 4e 6f 72 6d 61 6c 20  |         Normal |
00001380  63 30 30 30 2d 66 66 66  66 0a 20 20 20 20 20 20  |c000-ffff.      |
00001390  20 20 20 36 20 20 20 20  20 20 2d 20 20 20 20 20  |   6      -     |
000013a0  20 20 20 20 20 20 20 20  20 20 70 61 67 65 20 33  |          page 3|
000013b0  20 20 20 20 20 20 20 20  20 20 53 68 61 64 6f 77  |          Shadow|
000013c0  20 38 30 30 30 2d 62 66  66 66 0a 20 20 20 20 20  | 8000-bfff.     |
000013d0  20 20 20 20 37 20 20 20  20 20 20 2d 20 20 20 20  |    7      -    |
000013e0  20 20 20 20 20 20 20 20  20 20 20 70 61 67 65 20  |           page |
000013f0  34 20 20 20 20 20 20 20  20 20 20 53 68 61 64 6f  |4          Shado|
00001400  77 20 63 30 30 30 2d 66  66 66 66 0a 20 20 20 20  |w c000-ffff.    |
00001410  20 20 20 20 20 38 20 20  20 20 20 20 34 30 30 30  |     8      4000|
00001420  2d 37 66 66 66 20 20 20  20 20 20 20 70 61 67 65  |-7fff       page|
00001430  20 35 20 20 20 20 20 20  20 20 20 20 34 30 30 30  | 5          4000|
00001440  2d 37 66 66 66 0a 20 20  20 20 20 20 20 20 20 39  |-7fff.         9|
00001450  20 20 20 20 20 20 2d 20  20 20 20 20 20 20 20 20  |      -         |
00001460  20 20 20 20 20 20 70 61  67 65 20 36 20 20 20 20  |      page 6    |
00001470  20 20 20 20 20 20 2d 0a  20 20 20 20 20 20 20 20  |      -.        |
00001480  31 30 20 20 20 20 20 20  2d 20 20 20 20 20 20 20  |10      -       |
00001490  20 20 20 20 20 20 20 20  70 61 67 65 20 37 20 20  |        page 7  |
000014a0  20 20 20 20 20 20 20 20  2d 0a 0a 20 20 20 20 49  |        -..    I|
000014b0  6e 20 34 38 4b 20 6d 6f  64 65 2c 20 70 61 67 65  |n 48K mode, page|
000014c0  73 20 34 2c 35 20 61 6e  64 20 38 20 61 72 65 20  |s 4,5 and 8 are |
000014d0  73 61 76 65 64 2e 20 20  49 6e 20 53 61 6d 52 61  |saved.  In SamRa|
000014e0  6d 20 6d 6f 64 65 2c 20  70 61 67 65 73 20 34 20  |m mode, pages 4 |
000014f0  74 6f 20 38 0a 20 20 20  20 61 72 65 20 73 61 76  |to 8.    are sav|
00001500  65 64 2e 20 20 49 6e 20  31 32 38 20 6d 6f 64 65  |ed.  In 128 mode|
00001510  2c 20 61 6c 6c 20 70 61  67 65 73 20 66 72 6f 6d  |, all pages from|
00001520  20 33 20 74 6f 20 31 30  20 61 72 65 20 73 61 76  | 3 to 10 are sav|
00001530  65 64 2e 20 20 54 68 69  73 0a 20 20 20 20 76 65  |ed.  This.    ve|
00001540  72 73 69 6f 6e 20 73 61  76 65 73 20 74 68 65 20  |rsion saves the |
00001550  70 61 67 65 73 20 69 6e  20 6e 75 6d 65 72 69 63  |pages in numeric|
00001560  61 6c 20 6f 72 64 65 72  2e 20 20 54 68 65 72 65  |al order.  There|
00001570  20 69 73 20 6e 6f 20 65  6e 64 20 6d 61 72 6b 65  | is no end marke|
00001580  72 2e 0a 20 20 20 20 65  6e 64 20 6d 61 72 6b 65  |r..    end marke|
00001590  72 2e 0a 0a 0a                                    |r....|
00001595