168349Sobrien
268349Sobrien#------------------------------------------------------------------------------
3267843Sdelphij# $File: adventure,v 1.14 2012/06/21 01:32:26 christos Exp $
468349Sobrien# adventure: file(1) magic for Adventure game files
568349Sobrien#
668349Sobrien# from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
768349Sobrien# Edited by Dave Chapeskie <dchapes@ddm.on.ca> Jun 28, 1998
8103373Sobrien# Edited by Chris Chittleborough <cchittleborough@yahoo.com.au>, March 2002
968349Sobrien#
1068349Sobrien# ALAN
1168349Sobrien# I assume there are other, lower versions, but these are the only ones I
1268349Sobrien# saw in the archive.
13103373Sobrien0	beshort	0x0206	ALAN game data
1468349Sobrien>2	byte	<10	version 2.6%d
1568349Sobrien
1668349Sobrien
17159764Sobrien# Infocom (see z-machine)
18159764Sobrien#------------------------------------------------------------------------------
19159764Sobrien# Z-machine:  file(1) magic for Z-machine binaries.
20226048Sobrien# Updated by Adam Buchbinder <adam.buchbinder@gmail.com>
21159764Sobrien#
22226048Sobrien#http://www.gnelson.demon.co.uk/zspec/sect11.html
23226048Sobrien#http://www.jczorkmid.net/~jpenney/ZSpec11-latest.txt
24226048Sobrien#http://en.wikipedia.org/wiki/Z-machine
25226048Sobrien# The first byte is the Z-machine revision; it is always between 1 and 8. We
26226048Sobrien# had false matches (for instance, inbig5.ocp from the Omega TeX extension as
27226048Sobrien# well as an occasional MP3 file), so we sanity-check the version number.
28159764Sobrien#
29226048Sobrien# It might be possible to sanity-check the release number as well, as it seems
30226048Sobrien# (at least in classic Infocom games) to always be a relatively small number,
31226048Sobrien# always under 150 or so, but as this isn't rigorous, we'll wait on that until
32226048Sobrien# it becomes clear that it's needed.
33159764Sobrien#
34226048Sobrien0	ubyte			>0
35226048Sobrien>0	ubyte			<9
36267843Sdelphij>>16	belong&0xfe00f0f0	0x3030
37267843Sdelphij>>>0	ubyte			< 10
38267843Sdelphij>>>>2	ubeshort		< 10
39267843Sdelphij>>>>>18	regex			[0-9][0-9][0-9][0-9][0-9][0-9]
40267843Sdelphij>>>>>>0	ubyte			< 10	Infocom (Z-machine %d,
41267843Sdelphij>>>>>>>2	ubeshort	< 10 	Release %d /
42267843Sdelphij>>>>>>>>18	string		>\0	Serial %.6s)
43267843Sdelphij!:strength + 40
44159764Sobrien
45159764Sobrien#------------------------------------------------------------------------------
46159764Sobrien# Glulx:  file(1) magic for Glulx binaries.
47159764Sobrien#
48159764Sobrien# I haven't checked for false matches yet.
49159764Sobrien#
50159764Sobrien0	string			Glul	Glulx game data
51159764Sobrien>4	beshort			x	(Version %d
52159764Sobrien>>6	byte			x	\b.%d
53159764Sobrien>>8	byte			x	\b.%d)
54159764Sobrien>36	string			Info	Compiled by Inform
55159764Sobrien
56159764Sobrien
57159764Sobrien
58159764Sobrien# For Quetzal and blorb magic see iff
59159764Sobrien
60159764Sobrien
61226048Sobrien# TADS (Text Adventure Development System) version 2
62103373Sobrien#  All files are machine-independent (games compile to byte-code) and are tagged
63226048Sobrien#  with a version string of the form "V2.<digit>.<digit>\0".
64103373Sobrien#  Game files start with "TADS2 bin\n\r\032\0" then the compiler version.
65103373Sobrien0	string	TADS2\ bin	TADS
66103373Sobrien>9	belong  !0x0A0D1A00	game data, CORRUPTED
67103373Sobrien>9	belong	 0x0A0D1A00
68103373Sobrien>>13	string	>\0		%s game data
69103373Sobrien#  Resource files start with "TADS2 rsc\n\r\032\0" then the compiler version.
70103373Sobrien0	string	TADS2\ rsc	TADS
71103373Sobrien>9	belong  !0x0A0D1A00	resource data, CORRUPTED
72103373Sobrien>9	belong	 0x0A0D1A00
73103373Sobrien>>13	string	>\0		%s resource data
74103373Sobrien#  Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian
75103373Sobrien#  2-byte length N, the N-char name of the game file *without* a NUL (darn!),
76103373Sobrien# "TADS2 save\n\r\032\0" and the interpreter version. 
77103373Sobrien0	string	TADS2\ save/g	TADS
78103373Sobrien>12	belong	!0x0A0D1A00	saved game data, CORRUPTED
79103373Sobrien>12	belong	 0x0A0D1A00
80103373Sobrien>>(16.s+32) string >\0		%s saved game data
81103373Sobrien#  Other saved game files start with "TADS2 save\n\r\032\0" and the interpreter
82103373Sobrien#  version.
83103373Sobrien0	string	TADS2\ save	TADS
84103373Sobrien>10	belong	!0x0A0D1A00	saved game data, CORRUPTED
85103373Sobrien>10	belong	 0x0A0D1A00
86103373Sobrien>>14	string	>\0		%s saved game data
87159764Sobrien
88226048Sobrien# TADS (Text Adventure Development System) version 3
89226048Sobrien#  Game files start with "T3-image\015\012\032"
90226048Sobrien0	string	T3-image\015\012\032
91226048Sobrien>11	leshort	x		TADS 3 game data (format version %d)
92226048Sobrien#  Saved game files start with "T3-state-v####\015\012\032"
93226048Sobrien#  where #### is a format version number
94226048Sobrien0	string	T3-state-v
95226048Sobrien>14	string	\015\012\032	TADS 3 saved game data (format version
96226048Sobrien>>10	byte	x		%c
97226048Sobrien>>11	byte	x		\b%c
98226048Sobrien>>12	byte	x		\b%c
99226048Sobrien>>13	byte	x		\b%c)
100226048Sobrien
101186690Sobrien# Danny Milosavljevic <danny.milo@gmx.net>
102186690Sobrien# this are adrift (adventure game standard) game files, extension .taf
103186690Sobrien# depending on version magic continues with 0x93453E6139FA (V 4.0)
104186690Sobrien# 0x9445376139FA (V 3.90)
105186690Sobrien# 0x9445366139FA (V 3.80)
106186690Sobrien# this is from source (http://www.adrift.org.uk/) and I have some taf
107186690Sobrien# files, and checked them.
108186690Sobrien#0	belong	0x3C423FC9
109186690Sobrien#>4	belong	0x6A87C2CF	Adrift game file
110186690Sobrien#!:mime	application/x-adrift
111