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