spectrum 7.0 KB

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