1 2 #------------------------------------------------------------------------------ 3 # $File: spectrum,v 1.10 2023/05/08 01:33:36 christos Exp $ 4 # spectrum: file(1) magic for Spectrum emulator files. 5 # 6 # John Elliott <jce (a] seasip.demon.co.uk> 7 8 # 9 # Spectrum +3DOS header 10 # 11 0 string PLUS3DOS\032 Spectrum +3 data 12 >15 byte 0 - BASIC program 13 >15 byte 1 - number array 14 >15 byte 2 - character array 15 >15 byte 3 - memory block 16 >>16 belong 0x001B0040 (screen) 17 >15 byte 4 - Tasword document 18 >15 string TAPEFILE - ZXT tapefile 19 # 20 # Tape file. This assumes the .TAP starts with a Spectrum-format header, 21 # which nearly all will. 22 # 23 # Update: Sanity-check string contents to be printable. 24 # -Adam Buchbinder <adam.buchbinder (a] gmail.com> 25 # Update: Joerg Jenderek 2023 May 26 # URL: http://fileformats.archiveteam.org/wiki/TAP_(ZX_Spectrum) 27 # Reference: http://web.archive.org/web/20110711141601/http://www.zxmodules.de/fileformats/tapformat.html 28 # http://mark0.net/download/triddefs_xml.7z/defs/t/tap-zx.trid.xml 29 # Note: called "ZX Spectrum Tape image" by TrID and "TAP (ZX Spectrum)" by DROID via PUID fmt/801 30 # verified by fuse-emulator-utils `tzxlist EXAMPLES.TAP` 31 # 32 # headers length 19=023 and flag byte 0 indicating a standard ROM loading header 33 0 string \023\000\000 34 >4 string >\0 35 # skip {85CEE8D6-0F90-4492-B484-98E38862B28D}.2.ver0x0000000000000004.db {DDF571F2-BE98-426D-8288-1A9A39C3FDA2}.2.ver0x0000000000000001.db 36 # inside c:\ProgramData\Microsoft\Windows\Caches according to TrID and DROID 37 >>23 ubyte =0xFF 38 # skip DROID fmt-801-signature-id-1166.tap with invalid name \253\253\253\253\253\253\253\253\253\253 39 # which looks like: "TF COPY II" "screen " "\023\001TF" " 1943 " 40 >>>4 string <\177 Spectrum .TAP data "%-10.10s" 41 #!:mime application/octet-stream 42 !:mime application/x-spectrum-tap 43 !:ext tap 44 >>>>3 byte 0 - BASIC program 45 # autostart line; 0..9999 are valid; 32768 means "no auto-loading" 46 >>>>>16 uleshort x \b, autostart line %u 47 # program length; length of BASIC program 48 >>>>>18 uleshort x \b, program length %u 49 >>>>3 byte 1 - number array 50 >>>>3 byte 2 - character array 51 >>>>3 byte 3 - memory block 52 # length of the following data 1B00h=6912 and start address 4000h=16384 in case of a SCREEN$ header 53 >>>>>14 belong 0x001B0040 (screen) 54 # unused 32768=8000h 55 >>>>>18 uleshort !32768 \b, unused %u 56 # zxlength; length of the following data after the header 57 >>>>14 uleshort x \b, data length %u 58 #>>14 uleshort x \b, data length %#x 59 # checksum byte; simply all bytes (including flag byte) XORed 60 #>>>>20 ubyte x \b, checksum %#x 61 62 # The following three blocks are from pak21-spectrum (a] srcf.ucam.org 63 # TZX tape images 64 # Update: Joerg Jenderek 2023 May 65 # URL: http://fileformats.archiveteam.org/wiki/TZX 66 # Reference: https://worldofspectrum.net/TZXformat.html 67 # http://mark0.net/download/triddefs_xml.7z/defs/t/tzx.trid.xml 68 # Note: called "ZX Spectrum Tape image" by TrID and "TZX Format" by DROID via PUID fmt/1000 69 0 string ZXTape!\x1a Spectrum .TZX data 70 #!:mime application/octet-stream 71 !:mime application/x-spectrum-tzx 72 # CDT is used for Amstrad tapes 73 !:ext tzx/cdt 74 >8 byte x version %d 75 >9 byte x \b.%d 76 # ID of first block 77 >10 ubyte x \b; ID %#x 78 # turbo speed data block 79 >10 ubyte =0x11 (turbo) 80 # length of PILOT tone (number of pulses) 81 >>21 uleshort x \b, %u pilot pulses 82 # length of PILOT pulse 83 >>11 uleshort x with %u tstates 84 # length of SYNC first pulse 85 >>13 uleshort x \b, %u and 86 # length of SYNC second pulse 87 >>15 uleshort x %u sync tstates 88 # length of ZERO bit pulse 89 >>17 uleshort x \b, %u zero tstates 90 # length of ONE bit pulse 91 >>19 uleshort x \b, %u one tstates 92 # used bits in the last byte 93 >>23 ubyte x \b, use %u bit 94 # plural s 95 >>23 ubyte >1 \bs 96 # pause after this block in milliseconds 97 >>24 uleshort x \b, %u ms pause 98 # BYTE[3]; length of data that follow 99 >>26 ulelong&0x00FFffFF x \b, %u data bytes 100 >10 ubyte =0x20 (pause) 101 # pause duration in milliseconds 102 >>11 uleshort x %u ms 103 # text description 104 >10 ubyte =0x30 (text) 105 # length of the text description 106 #>>11 ubyte x L=%u 107 >>11 pstring x "%s" 108 # archive text description in ASCII format 109 >10 ubyte =0x32 (archive info) 110 # length of archive text 111 >>11 uleshort x \b, %#x bytes 112 # number of text strings 113 >>13 ubyte x with %u (type) text parts 114 # text type identification byte: 0~title 1~publisher 2~author 3~year 4~language 5~type 6~price 7~protection 8~origin ff~comment 115 >>14 byte <9 (%d) 116 >>>14 byte >-2 117 # length of text string 118 #>>>>15 ubyte x L=%u 119 >>>>15 pstring x %s 120 # 2nd possible text description 121 >>>>>&0 byte <9 (%d) 122 >>>>>>&-1 byte >-2 123 >>>>>>>&0 pstring x %s 124 # 3rd possible text description 125 >>>>>>>>&0 byte <9 (%d) 126 >>>>>>>>>&-1 byte >-2 127 >>>>>>>>>>&0 pstring x %s 128 # 4th possible text description 129 >>>>>>>>>>>&0 byte <9 (%d) 130 >>>>>>>>>>>>&-1 byte >-2 131 >>>>>>>>>>>>>&0 pstring x %s 132 # 5th possible text description 133 >>>>>>>>>>>>>>&0 byte <9 (%d) 134 >>>>>>>>>>>>>>>&-1 byte >-2 135 >>>>>>>>>>>>>>>>&0 pstring x %s 136 # 6th possible text description 137 >>>>>>>>>>>>>>>>>&0 byte <9 (%d) 138 >>>>>>>>>>>>>>>>>>&-1 byte >-2 139 >>>>>>>>>>>>>>>>>>>&0 pstring x %s 140 # 7th possible text description 141 >>>>>>>>>>>>>>>>>>>>&0 byte <9 (%d) 142 >>>>>>>>>>>>>>>>>>>>>&-1 byte >-2 143 >>>>>>>>>>>>>>>>>>>>>>&0 pstring x %s 144 145 # RZX input recording files 146 0 string RZX! Spectrum .RZX data 147 >4 byte x version %d 148 >5 byte x \b.%d 149 150 # Floppy disk images 151 0 string MV\ -\ CPCEMU\ Disk-Fil Amstrad/Spectrum .DSK data 152 0 string MV\ -\ CPC\ format\ Dis Amstrad/Spectrum DU54 .DSK data 153 0 string EXTENDED\ CPC\ DSK\ Fil Amstrad/Spectrum Extended .DSK data 154 0 string SINCLAIR Spectrum .SCL Betadisk image 155 156 # Hard disk images 157 0 string RS-IDE\x1a Spectrum .HDF hard disk image 158 >7 byte x \b, version %#02x 159 160 # SZX snapshots (fuse and spectaculator) 161 # Martin M. S. Pedersen <martin (a] linux.com> 162 # http://www.spectaculator.com/docs/zx-state/header.shtml 163 # 164 0 string ZXST zx-state snapshot 165 >4 byte x version %d 166 >5 byte x \b.%d 167 >>6 byte 0 16k ZX Spectrum 168 >>6 byte 1 48k ZX Spectrum/ZX Spectrum+ 169 >>6 byte 2 ZX Spectrum 128 170 >>6 byte 3 ZX Spectrum +2 171 >>6 byte 4 ZX Spectrum +2A/+2B 172 >>6 byte 5 ZX Spectrum +3 173 >>6 byte 6 ZX Spectrum +3e 174 >>6 byte 7 Pentagon 128 175 >>6 byte 8 Timex Sinclair TC2048 176 >>6 byte 9 Timex Sinclair TC2068 177 >>6 byte 10 Scorpion ZS-256 178 >>6 byte 11 ZX Spectrum SE 179 >>6 byte 12 Timex Sinclair TS2068 180 >>6 byte 13 Pentagon 512 181 >>6 byte 14 Pentagon 1024 182 >>6 byte 15 48k ZX Spectrum (NTSC) 183 >>6 byte 16 ZX Spectrum 12Ke 184 >>>7 byte 1 (alternate timings) 185