-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsect11.html
302 lines (254 loc) · 16.4 KB
/
sect11.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<html>
<head>
<title>The Z-Machine Standards Document</title>
<link rel="stylesheet" type="text/css" href="zspec.css">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<img class="icon" src="images/icon11.gif" alt="">
<h1>11. The format of the header</h1>
<h2 id="11.1">11.1</h2>
<p>The header table summarises those locations in the Z-machine's
header which an interpreter must deal with. (For further notes on
traditional usage, see <a href="appb.html">Appendix B</a>.)
"Hex" means the address, in hexadecimal;
"Len" means the length in bytes;
"V" the earliest Version to which the rule is applicable;
"Dyn" means that the byte or bit may legally be changed by the game
during play; "Int" means that the interpreter may change it; "Rst"
means that the interpreter must set it correctly after loading the game,
after a restore or after a restart.
</p>
<p>Where Flags occupy two bytes, "Bit 0" refers to bit 0 of the second byte, "Bit 8" refers to bit 0 of the first byte.
</p>
<table>
<caption><strong>Header format</strong></caption>
<tr><th> Hex </th><th>Len<th>V </th><th>Dyn </th>
<th>Int </th><th>Rst </th><th>Contents</th>
</tr>
<tr><td> 0 </td><td>1 </td><td>1 </td><td> </td><td> </td><td> </td><td>Version number (1 to 8)</td>
<tr><td> 1 </td><td>1 </td><td>3 </td><td> </td><td> </td><td> </td><td><em>Flags 1 (in Versions 1 to 3):</em></td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> Bit 1: Status line type: 0=score/turns, 1=hours:mins</td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> 2: Story file split across two discs?</td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> * </td><td> * </td><td> 4: Status line not available?</td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> * </td><td> * </td><td> 5: Screen-splitting available?</td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> * </td><td> * </td><td> 6: Is a variable-pitch font the default?</td></tr>
<tr><td> </td><td> </td><td>4 </td><td> </td><td> </td><td> </td><td><em>Flags 1 (from Version 4):</em></td></tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> * </td><td> * </td><td> Bit 0: Colours available?</td></tr>
<tr><td> </td><td> </td><td><em>6</em> </td><td> </td><td> * </td><td> * </td><td> 1: Picture displaying available?</td></tr>
<tr><td> </td><td> </td><td><em>4</em> </td><td> </td><td> * </td><td> * </td><td> 2: Boldface available?</td></tr>
<tr><td> </td><td> </td><td><em>4</em> </td><td> </td><td> * </td><td> * </td><td> 3: Italic available?</td></tr>
<tr><td> </td><td> </td><td><em>4</em> </td><td> </td><td> * </td><td> * </td>
<td> 4: Fixed-space style available?</td>
</tr>
<tr><td> </td><td> </td><td><em>6</em> </td><td> </td><td> * </td><td> * </td><td> 5: Sound effects available?</td></tr>
<tr><td> </td><td> </td><td><em>4</em> </td><td> </td><td> * </td><td> * </td><td> 7: Timed keyboard input available?</td></tr>
<tr><td> 4 </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Base of high memory (byte address)</td></tr>
<tr><td> 6 </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Initial value of program counter (byte address)</td></tr>
<tr><td> </td><td>2 </td><td>6 </td><td> </td><td> </td><td> </td><td>Packed address of initial "main" routine</td></tr>
<tr><td> 8 </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Location of dictionary (byte address)</td></tr>
<tr><td> A </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Location of object table (byte address)</td></tr>
<tr><td> C </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Location of global variables table (byte address)</td></tr>
<tr><td> E </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td>Base of static memory (byte address)</td></tr>
<tr><td> 10 </td><td>2 </td><td>1 </td><td> </td><td> </td><td> </td><td><em>Flags 2:</em></td></tr>
<tr><td> </td><td> </td><td><em>1</em> </td><td> * </td><td> * </td><td> * </td><td> Bit 0: Set when transcripting is on</td></tr>
<tr><td> </td><td> </td><td><em>3</em> </td><td> * </td><td> </td><td> * </td>
<td> 1: Game sets to force printing in fixed-pitch font</td>
</tr>
<tr><td> </td><td> </td><td><em>6</em> </td><td> * </td><td> * </td><td> </td>
<td> 2: Int sets to request screen redraw: game clears when it complies with this.</td>
</tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> * </td><td> * </td><td> 3: If set, game wants to use pictures</td></tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> * </td><td> * </td><td> 4: If set, game wants to use the UNDO opcodes</td></tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> * </td><td> * </td><td> 5: If set, game wants to use a mouse</td></tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> </td><td> </td><td> 6: If set, game wants to use colours</td></tr>
<tr><td> </td><td> </td><td><em>5</em> </td><td> </td><td> * </td><td> * </td><td> 7: If set, game wants to use sound effects</td></tr>
<tr><td> </td><td> </td><td><em>6</em> </td><td> </td><td> * </td><td> * </td><td> 8: If set, game wants to use menus</td></tr>
<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td>
<td> (For bits 3,4,5,7 and 8, Int clears again if it cannot provide the requested effect.)</td>
</tr>
<tr><td> 18 </td><td>2 </td><td>2 </td><td> </td><td> </td><td> </td><td>Location of abbreviations table (byte address)</td></tr>
<tr><td> 1A </td><td>2 </td><td>3+</td><td> </td><td> </td><td> </td><td>Length of file (see note)</td></tr>
<tr><td> 1C </td><td>2 </td><td>3+</td><td> </td><td> </td><td> </td><td>Checksum of file</td></tr>
<tr><td> 1E </td><td>1 </td><td>4 </td><td> </td><td> * </td><td> * </td><td>Interpreter number</td></tr>
<tr><td> 1F </td><td>1 </td><td>4 </td><td> </td><td> * </td><td> * </td><td>Interpreter version</td></tr>
<tr><td> 20 </td><td>1</td><td>4 </td><td> </td><td> * </td><td> * </td><td>Screen height (lines)</td></tr>
<tr><td> 21 </td><td>1</td><td>4 </td><td> </td><td> * </td><td> * </td><td>Screen width (characters)</td></tr>
<tr><td> 22 </td><td>2</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Screen width in units</td></tr>
<tr><td> 24 </td><td>2</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Screen height in units</td></tr>
<tr><td> 26 </td><td>1</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Font width in units (defined as width of a '0')</td></tr>
<tr><td> </td><td> </td><td>6 </td><td> </td><td> * </td><td> * </td><td>Font height in units</td></tr>
<tr><td> 27 </td><td>1</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Font height in units</td></tr>
<tr><td> </td><td> </td><td>6 </td><td> </td><td> * </td><td> * </td><td>Font width in units (defined as width of a '0')</td></tr>
<tr><td> 28 </td><td>2</td><td>6 </td><td> </td><td> </td><td> </td><td>Routines offset (divided by 8)</td></tr>
<tr><td> 2A </td><td>2</td><td>6 </td><td> </td><td> </td><td> </td><td>Static strings offset (divided by 8)</td></tr>
<tr><td> 2C </td><td>2</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Default background colour</td></tr>
<tr><td> 2D </td><td>2</td><td>5 </td><td> </td><td> * </td><td> * </td><td>Default foreground colour</td></tr>
<tr><td> 2E </td><td>2</td><td>5 </td><td> </td><td> </td><td> </td><td>Address of terminating characters table (bytes)</td></tr>
<tr><td> 30 </td><td>2</td><td>6 </td><td> </td><td> * </td><td> </td><td>Total width in pixels of text sent to output stream 3</td></tr>
<tr><td> 32 </td><td>2</td><td>1 </td><td> </td><td> * </td><td> * </td><td>Standard revision number</td></tr>
<tr><td> 34 </td><td>2</td><td>5 </td><td> </td><td> </td><td> </td><td>Alphabet table address (bytes), or 0 for default</td></tr>
<tr><td> 36 </td><td>2</td><td>5 </td><td> </td><td> </td><td> </td><td>Header extension table address (bytes)</td></tr>
</table>
<p>Some early Version 3 files do not contain length and checksum
data, hence the notation <strong>3+</strong>.
</p>
<h2 id="11.1.1">11.1.1</h2>
<p>It is illegal for a game to alter those
fields not marked as "Dyn". An interpreter is therefore free to
store values of such fields in its own variables.
</p>
<h2 id="11.1.2"> 11.1.2</h2>
<p>The state of the transcription bit
(bit 0 of Flags 2) can
be changed directly by the game to turn transcribing on or off
(see <strong>§</strong> 7.3, <strong>§</strong> 7.4). The interpreter must also alter it if
stream 2 is turned on or off, to ensure that the bit always
reflects the true state of transcribing. Note that the
interpreter ensures that its value survives a restart or restore.
</p>
<h2 id="11.1.3"> 11.1.3</h2>
<p>Infocom used the interpreter numbers:</p>
<pre>
1 DECSystem-20 5 Atari ST 9 Apple IIc
2 Apple IIe 6 IBM PC 10 Apple IIgs
3 Macintosh 7 Commodore 128 11 Tandy Color
4 Amiga 8 Commodore 64
</pre>
<p>(The DECSystem-20 was Infocom's own in-house mainframe.) An interpreter
should choose the interpreter number most suitable for the machine it
will run on. In Versions up to 5, the main consideration is that the
behaviour of 'Beyond Zork' depends on the interpreter number (in terms
of its usage of the character graphics font). In Version 6, the
decision is more serious, as existing Infocom story files depend
on interpreter number in many ways: moreover, some story files
expect to be run only on the interpreters for a particular machine.
(There are, for instance, specifically Amiga versions.)
</p>
<h2 id="11.1.3.1"> 11.1.3.1</h2>
<p>Interpreter versions are conventionally ASCII codes for
upper-case letters in Versions 4 and 5 (note that Infocom's Version 6
interpreters just store numbers here).
</p>
<p>Modern games are strongly discouraged from testing the interpreter number or interpreter version
header information for any game-changing behaviour. It is rarely meaningful, and a Standard interpreter
provides many better ways to query the interpreter for information.
</p>
<h2 id="11.1.4"> 11.1.4</h2>
<p><strong>***</strong>
The use of bit 7 in 'Flags 1' to signal whether timed
input is available is new in this document: see the preface.
</p>
<h2 id="11.1.5"> 11.1.5</h2>
<p><strong>***</strong>
If an interpreter obeys Revision <strong>n.m</strong> of this document
<em>perfectly</em>, as far as anyone knows,
then byte <strong>$32</strong> should be written with
<strong>n</strong> and byte <strong>$33</strong> with <strong>m</strong>.
If it is an earlier (non-standard)
interpreter, it should leave these bytes as 0.
</p>
<h2 id="11.1.6"> 11.1.6</h2>
<p>The file length stored at <strong>$1a</strong> is actually divided by a constant,
depending on the Version, to make it fit into a header word. This constant
is 2 for Versions 1 to 3, 4 for Versions 4 to 5 or 8 for Versions 6 and
later.
</p>
<h2 id="11.1.7"> 11.1.7</h2>
<p>The header extension table provides potentially unlimited
room for further header information. It is a table of word entries,
in which the initial word contains the number of words of data to follow.
</p>
<h2 id="11.1.7.1"> 11.1.7.1</h2>
<p>If the interpreter needs to read a word which is beyond the
length of the extension table, or the extension table doesn't exist at
all, then the result is 0.
</p>
<h2 id="11.1.7.2"> 11.1.7.2</h2>
<p>If the interpreter needs to write a word which is beyond the
length of the extension table, or the extension table doesn't exist at
all, then the result is that nothing happens.
</p>
<h2 id="11.1.7.3"> 11.1.7.3</h2>
<p><strong>***</strong>
Words in the header extension table have been allocated
as follows:
</p>
<table>
<caption><strong>Header extension format</strong></caption>
<tr><th>Word </th><th>V </th><th>Dyn </th><th>Int </th>
<th>Rst </th><th>Contents</th>
</tr>
<tr><td> 0 </td><td>5 </td><td> </td><td> </td><td> </td><td>Number of further words in table</td></tr>
<tr><td> 1 </td><td>5 </td><td> </td><td> * </td><td> </td><td>X-coordinate of mouse after a click</td></tr>
<tr><td> 2 </td><td>5 </td><td> </td><td> * </td><td> </td><td>Y-coordinate of mouse after a click</td></tr>
<tr><td> 3 </td><td>5 </td><td> </td><td> </td><td> </td><td>Unicode translation table address (optional)</td></tr>
</table>
<hr>
<h2 id="remarks">Remarks</h2>
<p>In the Infocom period, the larger Version 3 story files would
not entirely fit on a single Atari 800 disc (though they would fit
on a single Apple II, or a single PC disc). Atari versions were
therefore made which were identical to the normal ones except for
having Flags 1 bit 2 set, and were divided into the resident part
on one disc and the rest on another. (This discovery was announced
by Stefan Jokisch on 26 August 1997 and sees the end of one of the
very few Z-machine mysteries left when Standard 1.0 was first published.)
</p>
<p>See the "Infocom fact sheet" for numbers and letters of the known
interpreters shipped by Infocom. Interpreter versions are conventionally
the upper case letters in sequence (A, B, C, ...). At present most ports
of <strong>Zip</strong> use interpreter number 6, and most of <strong>ITF</strong> use number 2.
</p>
<p>The unusual behaviour of 'Beyond Zork' concerns its character graphics:
see the remarks to <strong>§</strong> 16.
</p>
<p>The Macintosh story file for 'Zork Zero' erroneously does not set
the pictures bit (Flags 2, bit 3).
</p>
<p>The bit in the header described as "requesting screen redraw" may be set by
modern interpreters after, for example, resizing the "screen"; games should
ideally redraw the screen if they see this bit set. This will usually mean
the game clears the screen contents and rearranges borders, etc, so the bit
should not be set except when necessary.
</p>
<p>The (Version 6) sound and picture bits in Flags 1 indicate general
availability of sound and graphics - ie whether the associated opcodes are
available and functional.
</p>
<p>The bits in Flags 2 should ideally be set reflecting current
availability, rather than general support. In other words, if no Blorb (or
other) resources for this story file have been found, or if the Blorb file
contains no graphics or no sound, the corresponding bits should be cleared.
</p>
<p>Also, it is recommended that interpreters that would prompt for an auxiliary
Blorb file should do so immediately on start up if any of the "game wants to
use sound/music/graphics" bits are set; this allows the bits to be cleared if
no file is forthcoming, before the game starts execution. The game can then
take appropriate action.
</p>
<hr>
<p>
<a href="index.html">Contents</a> /
<a href="preface.html">Preface</a> /
<a href="overview.html">Overview</a>
</p>
<p>Section
<a href="sect01.html">1</a> / <a href="sect02.html">2</a> /
<a href="sect03.html">3</a> / <a href="sect04.html">4</a> /
<a href="sect05.html">5</a> / <a href="sect06.html">6</a> /
<a href="sect07.html">7</a> / <a href="sect08.html">8</a> /
<a href="sect09.html">9</a> / <a href="sect10.html">10</a> /
<a href="sect11.html">11</a> / <a href="sect12.html">12</a> /
<a href="sect13.html">13</a> / <a href="sect14.html">14</a> /
<a href="sect15.html">15</a> / <a href="sect16.html">16</a>
</p>
<p>Appendix
<a href="appa.html">A</a> / <a href="appb.html">B</a> /
<a href="appc.html">C</a> / <a href="appd.html">D</a> /
<a href="appe.html">E</a> / <a href="appf.html">F</a>
</p>
<hr>
</body>
</html>