ReleaseNotes.html 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Inform Release Notes</title>
  6. </head>
  7. <body>
  8. <h1>Inform Release Notes</h1>
  9. <h3>Inform Compiler 6.33, 6.32, 6.31, 6.30<br>Inform Library 6/11</h3>
  10. <h2>Introduction</h2>
  11. This is a maintenance release of the Inform system for creating adventure games, intended to address
  12. issues that have arisen since the 6.21 compiler and 6/10 library files were released in 1999, and
  13. subsequently since the 6.30 compiler was released in 2004. The focus is primarily on fixing problems,
  14. but a small number of enhancements are included.
  15. <p>
  16. Although just about all known bugs are fixed, the approach to enhancing Inform is more conservative.
  17. The selection of suggestions to implement has been governed by three factors:
  18. <ul>
  19. <li><p>avoidance of changes which might cause existing games to misbehave;
  20. <li><p>minimisation of features which would require updates to the <i>Inform Designer&rsquo;s Manual</i>;
  21. <li><p>essential simplicity. With Graham Nelson&rsquo;s permission, this release has been produced by a
  22. volunteer taskforce, whose enthusiasm has been tempered by a certain lack of familiarity with the
  23. internals of Inform. Thus, we have concentrated on &lsquo;safe&rsquo; changes; the implementation of some
  24. good ideas has been postponed until we are more confident that we know what we&rsquo;re doing.
  25. </ul>
  26. Having said that, this release does incorporate one major advance. It is based on Andrew Plotkin&rsquo;s
  27. bi-platform &mdash; Z-machine and Glulx &mdash; compiler and library files, which were in turn derived from the
  28. the 6.21 compiler and 6/10 library. The result is that the two Virtual Machine (VM) strands have
  29. merged into a single compiler and library which, although continuing by default to produce Z-code,
  30. can alternatively generate code for the Glulx VM if you supply the <tt>-G</tt> compiler switch. There&rsquo;s more
  31. on this topic in <a href="#Glulx">Support for Glulx</a>.
  32. Before that, though, we&rsquo;ll summarise the changes to the compiler and to the library files.
  33. <p>
  34. If you&rsquo;ve translated the 6/10 library into another language, you may find
  35. <a href="#Translate">Information for translators</a> helpful.
  36. <h2>Acknowledgements</h2>
  37. Far too many people contributed towards this release &mdash; reporting and resolving bugs, making helpful
  38. suggestions, providing support and facilities, testing, and so on &mdash; for their names to be individually
  39. listed. So instead, this is a general thank-you to everybody who has made this release happen, and
  40. specific ones to Graham for permitting it in the first place, and to Andrew for his pioneering work on
  41. Glulx.
  42. There are, naturally, sure to be imperfections in the release, and these should be reported through the
  43. <a href="http://inform7.com/mantis/">Inform bug tracker</a>.
  44. <h2>Compiler 6.33</h2>
  45. These are the changes delivered in version 6.33 of the Inform compiler.
  46. <h3>Features added</h3>
  47. <ul>
  48. <li><p>Unused routines can now be detected and omitted from the compiled game, through two
  49. new settings. If <tt>$WARN_UNUSED_ROUTINES</tt> is set to 1, unused routines are reported during
  50. compilation. If <tt>$OMIT_UNUSED_ROUTINES</tt> is set to 1, unused routines (other than those in the
  51. Inform library) are omitted; if it is set to 2, unused routines anywhere, even in the library, are
  52. omitted.
  53. <li><p>A new command line switch <tt><b>-Cu</b></tt> can be used to specify that the source file
  54. character set is UTF-8, allowing source files to contain Unicode characters beyond those defined in
  55. ISO 8859-1 to 8859-9.
  56. <li><p>A new <tt>#Undef</tt> directive will cause a previously defined constant to become undefined.
  57. <li><p><tt>#Ifdef</tt> directives are now allowed within an object declaration.
  58. <li><p>Action statements can have an optional extra &lsquo;actor&rsquo; argument, allowing action
  59. statements of the form
  60. <pre>
  61. &lt;Take pie, orc&gt;; ! simple form
  62. &lt;&lt;Look, floyd&gt;&gt;; ! auto-returning form
  63. </pre>
  64. Note that this also requires a library change to be useful.
  65. <li><p>A previously declared routine can be renamed with a new form of the <tt>Replace</tt> directive.
  66. For example, if a source file contained
  67. <pre>
  68. Replace Banner OriginalBanner;
  69. </pre>
  70. It could then (after including the library) contain this definion of a function:
  71. <pre>
  72. [ Banner;
  73. OriginalBanner();
  74. print "Extra version info!^";
  75. ];
  76. </pre>
  77. The library's banner code would then be in <tt>OriginalBanner()</tt>.
  78. <li><p>The previously deprecated <tt>Dictionary</tt> directive can now have the following forms:
  79. <pre>
  80. Dictionary 'word';
  81. Dictionary 'word' val1;
  82. Dictionary 'word' val1 val3;
  83. </pre>
  84. The first of these forms just adds the word to the dictionary, with all flags set to zero, if it is not
  85. already in the dictionary. The second form also sets the <tt>dict_par1</tt> flag to the given value, or
  86. bitwise-or&rsquo;s the value in if the word already exists. The third form also sets the <tt>dict_par3</tt>
  87. in the same way as for <tt>dict_par1</tt>.
  88. <p>
  89. The values can be numeric literals or constants. They can be 0-255 for Z-code, or 0-65535 for Glulx.
  90. <li><p>The &ldquo;<tt>font on</tt>&rdquo; and &ldquo;<tt>font off</tt>&rdquo; statements now call the
  91. <tt>@set_font</tt> opcode for Z-code V5 and higher.
  92. <li><p>The Glulx version of the <tt>Unsigned__Compare()</tt> veneer routine has been changed to a
  93. more efficient implementation, using Glulx&rsquo;s unsigned comparison opcodes.
  94. <li><p>The debugging output file, generated when the <tt><b>-k</b></tt> is used, has been changed to a
  95. new, XML-based format.
  96. <li><p>Two new Z-code settings have been added to support the extra words in the header extension table
  97. specified in section 11.1.7 of the <i>Z-Machine Standards Document</i> version 1.1. <tt>$ZCODE_HEADER_EXT_WORDS</tt>
  98. specifies how many extra words to add (so for all three words defined in the 1.1 standard, this would
  99. be set to 3). <tt>$ZCODE_HEADER_FLAGS_3</tt> specifies the value to put in the first of these three words,
  100. which is the "flags3" field.
  101. <li><p>A new Glulx setting <tt>$GLULX_OBJECT_EXT_BYTES</tt> has been added, which specifies an
  102. amount of additional space to add to each object record. The default is 0.
  103. </ul>
  104. <h3>Bugs fixed</h3>
  105. Items of the form [Mantis 510] quote the bug&rsquo;s reference number in Inform 7&rsquo;s Mantis bug tracker.
  106. <ul>
  107. <li><p>Function calls of the form <tt>f(g)(h)</tt> (that is, where <tt>f()</tt> returns the address of a
  108. function that is called with <tt>h</tt> as its argument) are now compiled correctly: previously, such calls were
  109. compiled as if the code was <tt>f(g(h))</tt>. [Mantis 510]
  110. <li><p>The bounds checking related to internal arrays that are are sized from various compiler settings
  111. has been improved, so that it should not be possible to crash the compiler if these settings are too small.
  112. In addition, a start has been made on allowing the compiler to grow its internal buffers, rather than relying
  113. on these settings to specify sufficient buffer sizes. [Mantis 601,603,610,614,758,842,844]
  114. <li><p>The error message shown when too many global variables are declared now tells the user to
  115. increase the <tt>$MAX_GLOBAL_VARIABLES</tt> setting. [Mantis 611]
  116. <li><p>The setting <tt>$MAX_CLASS_TABLE_SIZE</tt>, which was not used anywhere, has been removed. [Mantis 612]
  117. <li><p>The compiler no longer crashes if run with the <tt><b>-k</b></tt> switch and passed a source file
  118. containing no routines at all. [Mantis 843]
  119. <li><p>Floating-point constants in &ldquo;<tt>#Ifdef TARGET_GLULX;</tt>&rdquo; sections do not now cause an error
  120. when compiling to Z-code. [Mantis 927]
  121. <li><p>The error message produced if an action routine is not found for an action name has been improved to include
  122. the action name, and a sensible line number. [Mantis 1014]
  123. <li><p>The compiler is now better at not producing spurious additional errors after it has encountered a directive
  124. that contains an error. [Mantis 1018,1035]
  125. <li><p>The compiler no longer crashes when reporting errors after line 65,535 in long Inform 6 source files. [Mantis 1023]
  126. <li><p>The compiler now reports a meaningful text compression rate when outputting statistics for Glulx with the
  127. <tt>-Gs</tt> switches. [Mantis 1026]
  128. <li><p>An error is now reported if a source file ends with an unterminated object definition. [Mantis 1036]
  129. <li><p>The three argument form of the <tt>read</tt> statement no longer assumes that the routine passed as the
  130. third argument to the statement will not change the global variable that the statement uses internally. [Mantis 1084]
  131. <li><p>The 'Abbreviate' statement now works with words containing non-English characters. [Mantis 1130]
  132. <li><p>Attempting to use <tt>@pop</tt> opcode for V5 or higher no longer results in a crash. [Mantis 1172]
  133. <li><p>The Glulx setting <tt>$NUM_ATTR_BYTES</tt>, which determines the number of bytes in an object set aside
  134. for attribute flags, now works correctly. Note that this has required a change to the veneer routines that conflicts
  135. with the definition of <tt>FUNC_2_CP__Tab()</tt> in the &lsquo;Accelerated Functions&rsquo; section of the Glulx 3.1.2
  136. specification. If you change this setting, you should take great care if you also use the Glulx accelerated functions
  137. feature (as Inform 7 does by default). [Mantis 1197]
  138. <li><p>The syntax of declaring a function so that it prints its name and arguments:
  139. <pre>
  140. [ Whatever * x y;
  141. ! Whatever function logic ...
  142. ];
  143. </pre>
  144. is now supported for Glulx. [Mantis 1214]
  145. <li><p>The statistics produced by the <tt>-s</tt> compiler switch are now correct for Glulx. [Mantis 1267]
  146. </ul>
  147. <h2>Compiler 6.32</h2>
  148. These are the changes delivered in version 6.32 of the Inform compiler.
  149. <h3>Features added</h3>
  150. Items of the form [C63104] quote the feature&rsquo;s reference number in the &lsquo;Compiler&rsquo; section of the Inform
  151. Patch List.
  152. <ul>
  153. <li><p>The Z-machine opcodes for pushing and pulling values from the stack are <tt>@push</tt> and <tt>@pull</tt>, used like this:
  154. <pre>
  155. @push x;
  156. @pull x;
  157. </pre>
  158. However for Glulx the opcode syntax is different: instead the <tt>@copy</tt> opcode is used:
  159. <pre>
  160. @copy x sp;
  161. @copy sp x;
  162. </pre>
  163. The compiler now supports the <tt>@push</tt> and <tt>@pull</tt> syntax under Glulx as an alias for <tt>@copy</tt>, allowing
  164. the same code to be used for both the Z-machine and Glulx. [C63104]
  165. <li><p>Custom Glulx opcodes (such as opcodes that post-date the compiler) can now be specified with the custom opcode syntax.
  166. The format of this syntax is
  167. <pre> @"FlagsCount:Code"
  168. </pre>
  169. <tt><i>Flags</i></tt> (which are optional) can include &ldquo;S&rdquo; for store, &ldquo;SS&rdquo; for two stores, &ldquo;B&rdquo; for branch format,
  170. or &ldquo;R&rdquo; if execution never continues after the opcode. <tt><i>Count</i></tt> is the number of arguments (currently limited to 0-9),
  171. and <tt><i>Code</i></tt> is a decimal integer representing the opcode number.<p>
  172. For example, <tt>@"S3:123"</tt> is the syntax for a three-argument opcode (load, load, store) whose opcode number in decimal
  173. is 123, and <tt>@"2:234"</tt> is the syntax for a two-argument opcode (load, load) whose number is 234. [C63107]
  174. <li><p>When compiling to Glulx, the Glulx format version number of the resulting story file is usually determined by which Glulx opcodes
  175. are used in the source code. This version number can now be over-ridden by providing a <tt><b>-v</b></tt> command line argument after the
  176. <tt><b>-G</b></tt> switch to select Glulx mode. For example, the arguments
  177. <tt><b>-G -v3.1.0</b></tt> set the Glulx version number to &ldquo;3.1.0&rdquo;. [C63108]
  178. <li><p>The Unicode related opcode added to the Glulx 3.0.0 specification, <tt>@streamunichar</tt>, is now supported.
  179. <li><p>When compiling to Glulx, characters outside of the ISO 8859-1 range can now be used in strings. The maximum number of such
  180. characters allowed is determined by a new memory setting, <tt>$MAX_UNICODE_CHARS</tt>.
  181. <li><p>When compiling to Glulx, the syntax
  182. <pre> print (char) <i>value</i>;</pre>
  183. now works for values greater than 255, printing the appropriate Unicode character. (For such values <tt>@streamunichar</tt> is used;
  184. for those less than or equal to 255, <tt>@streamchar</tt> is used as before.)
  185. <li><p>The memory heap related opcodes added to the Glulx 3.1.0 specification (that is,
  186. <tt>@mzero</tt>, <tt>@mcopy</tt>, <tt>@malloc</tt> and <tt>@mfree</tt>) are now supported.
  187. <li><p>The acceleration related opcodes added to the Glulx 3.1.1 specification (that is,
  188. <tt>@accelfunc</tt> and <tt>@accelparam</tt>) are now supported. There is also a new syntax to get the address of a global variable
  189. <tt><i>var</i></tt>, with the expression &ldquo;<tt>#g$<i>var</i></tt>&rdquo;: this is provided so that such addresses can be provided
  190. to the <tt>@accelparam</tt> opcode.
  191. <li><p>The floating point related opcodes added to the Glulx 3.1.2 specification (that is,
  192. <tt>@numtof</tt>, <tt>@ftonumz</tt>, <tt>@ftonumn</tt>, <tt>@ceil</tt>, <tt>@floor</tt>, <tt>@fadd</tt>, <tt>@fsub</tt>, <tt>@fmul</tt>,
  193. <tt>@fdiv</tt>, <tt>@fmod</tt>, <tt>@sqrt</tt>, <tt>@exp</tt>, <tt>@log</tt>, <tt>@pow</tt>, <tt>@sin</tt>, <tt>@cos</tt>, <tt>@tan</tt>,
  194. <tt>@asin</tt>, <tt>@acos</tt>, <tt>@atan</tt>, <tt>@atan2</tt>, <tt>@jfeq</tt>, <tt>@jfne</tt>, <tt>@jflt</tt>, <tt>@jfle</tt>,
  195. <tt>@jfgt</tt>, <tt>@jfge</tt>, <tt>@jisnan</tt> and <tt>@jisinf</tt>) are now supported.
  196. <li><p>Floating point constants can be used in the Inform source code. Thes constants are expressed in the form &ldquo;$+1.0e+1&rdquo;:
  197. that is, a dollar sign, followed by a plus or minus sign, followed by a floating point number, and then optionally a positive or negative
  198. integer exponent. Inform does not attempt anything other than converting these constants to their 32-bit integer representation: there is
  199. no constant folding as there is with integers, so the expression &ldquo;<tt>$+1.0 + $+1.0</tt>&rdquo; is not meaningful, and does not
  200. produce the floating point value &ldquo;2.0&rdquo;.<p>
  201. As an example of the use of these constants, the following adds together 100 and 123.45:
  202. <pre> @fadd $+100 $+1.2345e+2 result;</pre>
  203. The compiler also defines the constants &ldquo;<tt>FLOAT_INFINITY</tt>&rdquo;, &ldquo;<tt>FLOAT_NINFINITY</tt>&rdquo;
  204. and &ldquo;<tt>FLOAT_NAN</tt>&rdquo; for positive infinity, negative infinity and &ldquo;not a number&rdquo;, respectively.
  205. <li><p>Glulx has a simple memory extension feature, where the game&rsquo;s header declares the memory space to be larger than the game file.
  206. The extra space is filled out with zeroes when the game starts. This is now supported by a new option <tt>$MEMORY_MAP_EXTENSION</tt>.
  207. This defaults to 0: if it is redefined to a larger value then the size of the game&rsquo;s memory space is extended by that amount.
  208. <li><p>The number of verbs allowed by the compiler when compiling to Glulx is no longer limited to fewer than 256. As part of producing
  209. the game file, the compiler creates a dictionary table that contains verb numbers. However, despite in Glulx there being space for a verb
  210. number between 0 and 65535 in this table, only one byte of it (that is, values between 0 and 255) was used. This has been fixed.<p>
  211. However, this also requires library changes to be useful, as the library makes use of this dictionary table. The library used by Inform 7
  212. has been adjusted to take advantage of this, but the Inform 6/11 library has not.
  213. <li><p>The dictionary of Glulx games can now contain characters outside of ISO 8859-1. There is a new
  214. memory setting, <tt>$DICT_CHAR_SIZE</tt>: by default this is 1, but setting it to 4 causes the compiler to create a dictionary containing
  215. 32-bit Unicode characters.<p>
  216. However, this also requires library changes to be useful, as the library makes use of this dictionary table.
  217. </ul>
  218. <h3>Bugs fixed</h3>
  219. Items of the form [C63102] quote the bug&rsquo;s reference number in the &lsquo;Compiler&rsquo; section of the Inform
  220. Patch List.
  221. <ul>
  222. <li><p>Strict mode is no longer enabled by default when generating V3 and V4 Z-code files, as strict mode
  223. makes use of opcodes that are V5+ only. [C63007]
  224. <li><p>The base unit of Inform&rsquo;s internal memory allocation for various structures (for example the buffer used
  225. to hold the generated code) is no longer fixed: it is now controlled by a setting <tt>$ALLOC_CHUNK_SIZE</tt>.
  226. This allows, for example, the maximum Glulx code size to be greater than 640Kb. [C63102]
  227. <li><p>When compiling to Glulx, the stack size of the resulting story file is no longer fixed at 4096: it can be changed
  228. by the setting <tt>$MAX_STACK_SIZE</tt>. [C63108]
  229. <li><p>The compiler could crash if the size of the grammar table exceeded the size of the Z-machine readable memory: this
  230. is now fixed. [C63110]
  231. <li><p>Creating a Z-code game file with precisely 64Kb of readable memory produced an invalid file. This is now prevented,
  232. so that the largest readable memory size is 64Kb minus 2 bytes. [C63112]
  233. <li><p>Previously, under Glulx the <tt>print_to_array()</tt> function could be called with either two arguments, specifying both
  234. the array to print to and its length, or just one argument, the later matching what is allowed when compiling to Z-code. This
  235. one argument form has now been withdrawn under Glulx as a security hole, and a source to problems with writing beyond the end
  236. of the array: now the array length must be specified. (See also <a href="#FeaturesGlulx">Features available only in Glulx</a>.)
  237. <li><p>Veneer routines are no longer excluded from Inform&rsquo;s assembly output (which is accessed with the <tt><b>-a</b></tt>
  238. command line switch).
  239. <li><p>For Linux and other Unix variants the default memory settings have been increased, which should remove the need
  240. to change the compiler settings when building large projects on these platforms.
  241. <li><p>For Mac OS X, the maximum length of a file path is now 8192 characters, which should prevent any further problems with
  242. long paths on this platform.
  243. </ul>
  244. <h2>Compiler 6.31</h2>
  245. These are the changes delivered in version 6.31 of the Inform compiler.
  246. <h3>Bugs fixed</h3>
  247. Items of the form [C63016] quote the bug&rsquo;s reference number in the &lsquo;Compiler&rsquo; section of the Inform
  248. Patch List.
  249. <ul>
  250. <li><p>When individual properties are read (successfully), there is no longer a futile attempt to look up
  251. the property index in the common property table. [C63016]
  252. <li><p>Complex <tt>if</tt> statements, of the form <tt>if (x == 1 or 3 or 5 ... or 99),</tt> now don&rsquo;t crash the
  253. compiler. [C63013]
  254. <li><p>The compiler is better at handling lengthy path names. [C63009]
  255. <li><p>Backpatching and other strange errors no longer occur if the code size of a V8 game exceeds
  256. 256K. [C63005]
  257. <li><p>An Object or Class definition with more than 32 common property values now doesn&rsquo;t cause an
  258. internal compiler error. [C63001]
  259. </ul>
  260. <h2>Compiler 6.30</h2>
  261. These are the changes delivered in version 6.30 of the Inform compiler.
  262. <h3>Features added</h3>
  263. <ul>
  264. <li><p>The compiler automatically defines a <tt>WORDSIZE</tt> constant, whose value is 2 when compiling for the
  265. Z-machine, and 4 when the target is Glulx. The constant specifies the number of bytes in a VM
  266. word, and we recommend that you use it in the small number of circumstances where this value is
  267. significant. The compiler also defines a constant <tt>TARGET_GLULX</tt> if you supply the <tt><b>-G</b></tt> switch, or
  268. <tt>TARGET_ZCODE</tt> otherwise; in both cases the constant value is 0. For more information on the use of
  269. these constants, see <a href="#Glulx">Support for Glulx</a>.
  270. <li><p>The <tt>Switches</tt> directive, which enables certain compiler switches to be set from within the source
  271. file rather than on the compiler command line, has been superseded by a more powerful
  272. mechanism. The special comment characters &ldquo;!%&rdquo;, occurring on the very first line or lines of the
  273. source file, enable you to specify Inform Command Language (ICL) commands to control the
  274. compilation. For example:
  275. <pre>
  276. !% -E1G ! Glulx, 'Microsoft' errors
  277. !% -~S ! disable Strict mode
  278. !% +include_path=./test,./,../lib/contrib ! look in 'test' library
  279. !% $MAX_STATIC_MEMORY=20000
  280. Constant STORY "RUINS";
  281. ...
  282. </pre>
  283. ICL is described in &sect;39 of the <i>Inform Designer&rsquo;s Manual</i>. In brief: each line specifies a single
  284. command, starting with &ldquo;-&rdquo; to define one or more switches, &ldquo;+&rdquo; to define a path variable, or &ldquo;$&rdquo; to
  285. define a memory setting. Comments are introduced by &ldquo;$&rdquo;. The ICL command &ldquo;<tt>compile</tt>&rdquo; is not
  286. permitted at the head of a source file.
  287. <li><p>Two new ICL memory settings are available; both of these could previously be changed only by
  288. rebuilding the compiler. <tt>$MAX_SOURCE_FILES</tt> has a default of 256, and <tt>$MAX_INCLUSION_DEPTH</tt> has a
  289. default value of 5.
  290. <li><p>A new directive, similar to <tt>Array ... string</tt> and <tt>Array ... table</tt>, is provided:
  291. <pre>
  292. Array array buffer N;
  293. Array array buffer expr1 expr2 ... exprN;
  294. Array array buffer "string";
  295. </pre>
  296. This creates a hybrid array of the form used by <tt><i>string</i>.print_to_array()</tt> and the new library
  297. routine <tt>PrintToBuffer()</tt>, in which the first <b>word</b> <tt><i>array</i>-->0</tt>
  298. contains <tt><i>N</i></tt> and the following <tt><i>N</i></tt> <b>bytes</b>
  299. <tt><i>array</i>->WORDSIZE</tt>, <tt><i>array</i>->(WORDSIZE+1)</tt> ... <tt><i>array</i>->(WORDSIZE+<i>N</i>-1)</tt> contain the specified
  300. expression values or string characters.
  301. <li><p>A new <tt>(A)</tt> print rule &mdash; similar to the existing <tt>(The)</tt> &mdash; prints an object&rsquo;s indirect article with its first
  302. letter capitalised. The printed article is &ldquo;A&rdquo; or &ldquo;An&rdquo; by default, or else taken from the object&rsquo;s
  303. article property.
  304. <li><p>The minimum size of the Z-code header extension table can be set using the command line switch
  305. <tt><b>-W</b><i>n</i></tt>. For example, <tt><b>-W6</b></tt> makes the table at least six words long.
  306. <li><p>Source code in character sets other than ISO 8859-1 to 8859-9 is now supported, provided that the
  307. character set can be mapped onto one of the ISO 8859 sets.<p>
  308. A mapping file is used to define how the source code is to be processed. This file consists of a
  309. directive indicating the ISO 8859 set to be mapped to, followed by 256 numbers giving the
  310. mapping. As an example, under Microsoft Windows, Russian text is encoded with the character
  311. set defined as Microsoft code page 1251. The following text defines a mapping to the ISO 8859-5
  312. set:
  313. <pre>
  314. ! Windows Cyrillic (code page 1251) to ISO 8859-5
  315. C5
  316. 0, 63, 63, 63, 63, 63, 63, 63, 63, 32, 10, 63, 10, 10, 63, 63
  317. 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
  318. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
  319. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
  320. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79
  321. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
  322. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
  323. 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126, 63
  324. 162,163, 44,243, 34, 46, 63, 63, 63, 63,169, 60,170,172,171,175
  325. 242, 39, 39, 34, 34, 46, 45, 45,152, 84,249, 62,250,252,251,255
  326. 32,174,254,168, 36, 63,124,253,161, 67,164, 60, 63, 45, 82,167
  327. 63, 63,166,246, 63, 63, 63, 46,241,240,244, 62,248,165,245,247
  328. 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  329. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  330. 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
  331. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  332. </pre>
  333. Lines starting with &ldquo;!&rdquo; are treated as comments. The next line, beginning with &ldquo;C&rdquo;, defines the
  334. ISO set to map to in the same way as the <tt><b>-C</b><i>n</i></tt> command line switch.<p>
  335. To use the mapping, Inform treats each character in the source file as a number between 0 and
  336. 255, and uses that number as an index into the mapping table. For example, suppose that the
  337. character read in from a Russian Windows text file is the Cyrillic small letter &ldquo;ya&rdquo;.This character
  338. is represented in the Russian Windows character set by the number 255. Inform takes the 255th entry in
  339. the mapping, which is 239. Therefore the character is regarded as being 239 in ISO 8859-5.<p>
  340. The name of the mapping file is specified by a new compiler path variable <tt>+charset_map</tt>. If the
  341. above mapping is held in a text file <tt>win1251.map</tt>, a Russian game could be compiled with a
  342. command line of the form:
  343. <pre>
  344. inform +charset_map=win1251.map +language_name=Russian mygame.inf
  345. </pre>
  346. <li><p>The <tt>@check_unicode</tt> and <tt>@print_unicode</tt> opcodes, introduced in the <i>Z-Machine Standards
  347. Document</i> version 1.0, can now be called by name rather than by using the clumsier generic
  348. syntax <tt>@"EXT:11S"</tt> and <tt>@"EXT:12S"</tt>. For example:
  349. <pre>
  350. @print_unicode $0401; ! Cyrillic capital letter IO
  351. </pre>
  352. <li><p>Strict mode (which compiles run-time integrity checks into your game) has been decoupled from
  353. Debug mode (which defines debugging verbs like TRACE and SHOWOBJ). This means that it&rsquo;s
  354. no longer necessary to turn off Strict checking (in order to disable the Debug verbs) before
  355. releasing a game, though of course you can do so if you wish to save space and increase
  356. performance. By default, Strict mode is <b>enabled</b> (turn it off with <tt><b>-~S</b></tt>) and Debug mode is
  357. <b>disabled</b> (turn it on with <tt><b>-D</b></tt>).
  358. <li><p>The compiler now issues a warning if you use <tt><i>array->n</i></tt> on an array of words, or <tt><i>array-->n</i></tt> on an
  359. array of bytes. Use the new <tt>Array ... buffer</tt> directive to create a hybrid array which can be
  360. accessed without these warnings.
  361. <li><p>The compiler also issues a warning if you refer to an unqualified property name within a routine,
  362. for example by typing <tt>(number==0)</tt> when you intended <tt>(self.number==0)</tt>.
  363. <li><p>Another new warning appears if you include something other than a dictionary word in an
  364. object&rsquo;s <tt>name</tt> property. This is most commonly triggered if you try to add a single-letter word by
  365. typing <tt>name 'g' 'string'</tt> when you intended <tt>name 'g//' 'string'</tt>.
  366. </ul>
  367. <h3>Bugs fixed</h3>
  368. Items of the form [C62127] quote the bug&rsquo;s reference number in the &lsquo;Compiler&rsquo; section of the Inform
  369. Patch List.
  370. <ul>
  371. <li><p>A problem with multiple assignment involving pointer arithmetic in Strict mode giving the wrong
  372. answer has been fixed. [C62127]
  373. <li><p>After using <tt>Extend only</tt> to separate off an element of an existing Verb definition, new synonyms
  374. for the separated verb now work correctly; previously they were applied to the residue of the
  375. original definition. [C62126]
  376. <li><p>Strict mode now tests for the use of <tt>@put_prop</tt> or <tt>@get_prop</tt> opcodes when a common property is
  377. longer than two bytes &mdash; the <i>Z-Machine Standards Document</i> says that this is illegal, and that the
  378. result is unspecified. The error message is of the form &ldquo;[** Programming error: <i>obj</i> (object
  379. number <i>N</i>) has a property <i>prop</i>, but it is longer than 2 bytes so you cannot use "." to read **]&rdquo;. This
  380. means that you have used the <tt><i>obj.prop</i></tt> construct in the situation where <tt><i>prop</i></tt> is a <b>common</b>
  381. property containing two or more values; typically <tt><i>prop</i></tt> is being explicitly used as an array, or it&rsquo;s
  382. an additive property and both <tt><i>obj</i></tt> and its parent class have defined values for it. The problem does
  383. not occur if <tt><i>prop</i></tt> is an individual property. [C62125]
  384. <li><p>Handling of European quotes is (finally) correct: the &ldquo;&laquo;&rdquo; symbol is produced by any of <tt>@&lt;&lt;</tt>, <tt>@@163</tt>
  385. and <tt>@{00AB}</tt>, while any of <tt>@>></tt>, <tt>@@162</tt> and <tt>@{00BB}</tt> produce the matching &ldquo;&raquo;&rdquo;. Note, however, that
  386. this problem originated in an error in the previous version of the <i>Z-Machine Standards Document</i>,
  387. and therefore older interpreters written to that specification, or more recent ones adjusted to work
  388. with the incorrect fix introduced at Inform 6.12, may still not give the correct results. [C62124]
  389. <li><p>The &ldquo;no such constant&rdquo; compilation error message now quotes the number of the appropriate
  390. source line. [C62123]
  391. <li><p>The <tt>metaclass()</tt> and <tt>ZRoutine()</tt> routines no longer report large unsigned values &mdash; above the
  392. game&rsquo;s Static memory area &mdash; as of type String. More usefully, the constant <tt>NULL</tt> (-1) is not
  393. reported as a String. [C62122]
  394. <li><p>Complex expressions combining a routine call and the <tt>ofclass</tt> and <tt>or</tt> operators no longer
  395. generate incorrect code. [C62121]
  396. <li><p>Negative constants in assembly operations &mdash; for example, <tt>@set_colour 4 (-1);</tt> &mdash; no longer cause
  397. the compiler to report an unexpected expression. [C62119]
  398. <li><p>Various problems with handling ISO 8859 characters in the range 128-255, and also in the use of
  399. @@ escape sequences, have been resolved. [C62117, C62115, C6211, C62003]
  400. <li><p>An <tt>Abbreviate</tt> directive containing a substring of &ldquo;&lt;unknown attribute&gt;&rdquo; may crash the
  401. compiler; hopefully, no more. [C62116]
  402. <li><p>The 320Kb size limit placed by Inform on v6 and v7 games has been raised to 512Kb. [C62114]
  403. <li><p>Following a <tt>Zcharacter</tt> directive replacing the entire alphabet table, dictionary entries are no
  404. longer corrupted. [C62113]
  405. <li><p>The compiler now generates conditional branches spanning up to 63 bytes, lifting the previous
  406. unnecessary limit of a 31-byte span and leading to slightly shorter code. [C62112]
  407. <li><p>Putting an object in itself doesn&rsquo;t now loop indefinitely. [C62110]
  408. <li><p>Various problems with the <tt>@store</tt>, <tt>@inc_chk</tt>, <tt>@dec_chk</tt>, <tt>@not</tt> and <tt>@je</tt> opcodes have been resolved.
  409. [C62109, C62108, C62105]
  410. <li><p>Problems with nested conditional compilation directives <tt>#Ifndef...#Ifnot...#Endif</tt> have been
  411. resolved. [C62107]
  412. <li><p>A long dictionary word &mdash; such as <tt>'elephants//p'</tt> &mdash; now correctly sets the plural bit. [C62103]
  413. <li><p>Problems with constant folding &mdash; that is, having the expression evaluated at compile-time &mdash; partly
  414. addressed in the previous bi-platform compiler, have been fixed. [C62102]
  415. <li><p>When compiling for Glulx, the compiler uses the <tt>@callf</tt>, <tt>@callfi</tt>, <tt>@callfii</tt> or <tt>@callfiii</tt> opcodes
  416. where applicable for generated calls instead of always pushing arguments onto the stack and
  417. using <tt>@call</tt>.
  418. <li><p>The presence of a <tt>Switches G;</tt> directive no longer causes the compiler to crash.
  419. <li><p>An unexpected limit of 1024 labels per routine in the Z-machine assembly language generated by
  420. the compiler has been raised to 32768. The most likely way to encounter this limit is by creating a
  421. <tt>switch</tt> statement with an extremely large number of cases.
  422. <li><p>A problem with the <tt>read</tt> statement generating the wrong opcode in a version 4 game has been
  423. corrected.
  424. <li><p>A dynamic class declaration such as <tt>Class Pebble(NUM_PEBBLES) ... ;</tt> no longer creates a
  425. mysteriously large number of instances if <tt>NUM_PEBBLES</tt> isn&rsquo;t defined.
  426. </ul>
  427. <h2>Library 6/11</h2>
  428. These are the changes delivered in version 6/11 of the Inform library.
  429. <h3>Features added</h3>
  430. <ul>
  431. <li><p>The library automatically defines four constants: <tt>LIBRARY_PARSER</tt> at the end of Parser.h,
  432. <tt>LIBRARY_VERBLIB</tt> at the end of VerbLib.h, <tt>LIBRARY_GRAMMAR</tt> at the end of Grammar.h, and
  433. <tt>LIBRARY_ENGLISH</tt> at the end of English.h. Contributed library extensions can use these constants to
  434. check that they have been Included in the correct location. A fifth constant <tt>LIBRARY_VERSION</tt>,
  435. currently defined as the number 611, can be checked by extensions which require this particular
  436. version of the library.
  437. <li><p>The word &ldquo;wall&rdquo; has been removed from the <tt>CompassDirection</tt> objects defined in English.h,
  438. whose names are now simply &ldquo;north&rdquo;, &ldquo;south&rdquo;, etc.
  439. <li><p>The verbs LOOK [TO THE] NORTH, LOOK DOWN, LOOK OUT[SIDE] etc &mdash; but not
  440. LOOK IN[SIDE], which is already available &mdash; have been added. By default, the response is of the
  441. form &ldquo;You see nothing unexpected ...&rdquo;, but you can change this for individual directions in
  442. individual rooms by providing a compass_look property:
  443. <pre>
  444. Room study "Your study"
  445. with description "There is a doorway to the east of this austere room.",
  446. compass_look [ obj;
  447. if (obj == e_obj) "You see a doorway.";
  448. if (obj == n_obj or s_obj or w_obj) "You see the wall.";
  449. ],
  450. e_to hallway;
  451. </pre>
  452. This enhancement uses the mechanism described in
  453. <a href="http://www.firthworks.com/roger/informfaq/ww.html#1">this topic in the Inform 6 FAQ</a>
  454. (except that the <tt>compass_look</tt> property was previously named <tt>compasslook</tt>), and means that you
  455. no longer need to make the library changes described there.
  456. <li><p>The verbs <tt>ASK <i>npc</i> TO <i>command</i></tt> and <tt>TELL <i>npc</i> TO <i>command</i></tt>
  457. &mdash; both synomymous with <tt><i>npc,command</i></tt> &mdash;
  458. are provided. The new grammar is:
  459. <pre>
  460. Verb 'ask'
  461. ...
  462. * creature 'to' topic -> AskTo
  463. ...
  464. </pre>
  465. in which the <tt>creature</tt> token matches the <tt><i>npc</i></tt> and the <tt>topic</tt> token represents
  466. the <tt><i>command</i></tt>. <tt>AskTo</tt> isn&rsquo;t an action in the usual sense: it&rsquo;s trapped by the parser and
  467. converted to the original <tt><i>npc,command</i></tt> format. The <tt><i>npc</i></tt> can intercept the
  468. <tt><i>command</i></tt> by providing an <tt>orders</tt> property in the usual way &mdash;
  469. see &sect;18 of the <i>Inform Designer&rsquo;s Manual</i>.<p>
  470. This enhancement means that you may no longer require Irene Callaci&rsquo;s <tt>AskTellOrder.h</tt> library
  471. extension.
  472. <li><p>The verbs RECORDING [ON|OFF] and REPLAY are now always available, irrespective of the
  473. DEBUG state. This may cause compilation errors if you have already defined these verbs
  474. yourself.
  475. <li><p>The verbs PRY, PRISE, PRIZE and LEVER have been added. This may cause compilation errors
  476. if you have already defined these verbs yourself.
  477. <li><p>The parser treats input lines beginning with &ldquo;*&rdquo; as a comment, without attempting any further
  478. parsing. The character used to introduce comments can be changed by defining
  479. <tt>COMMENT_CHARACTER</tt> before you <tt>Include Parser</tt>. For example:
  480. <pre> Constant COMMENT_CHARACTER '!';</pre>
  481. Since comments are used primarily when capturing a transcript &mdash; either of a complete game
  482. (SCRIPT ON) or of input commands only (RECORDING ON) &mdash; the parser responds &ldquo;[Comment
  483. recorded]&rdquo; or &ldquo;[Comment NOT recorded]&rdquo; as appropriate.
  484. <li><p>The <tt>selfobj</tt> object now includes an empty <tt>add_to_scope</tt> property, which you can over-ride with
  485. your own routine, typically to equip the player with body parts. For a single object:
  486. <pre> selfobj.add_to_scope = nose;</pre>
  487. or for multiple objects:
  488. <pre>
  489. [ IncludeBodyParts; PlaceInScope(nose); PlaceInScope(hands); ];
  490. selfobj.add_to_scope = IncludeBodyParts;
  491. </pre>
  492. <li><p>The task-based scoring system (&sect;22 of the <i>Inform Designer&rsquo;s Manual</i>) uses a byte array, which
  493. precludes the awarding of large or negative scores. To get round this, you can <tt>Replace</tt> the
  494. <tt>TaskScore()</tt> library routine as follows, and then define <tt>task_scores</tt> as a <b>word</b> array:
  495. <pre>
  496. Replace TaskScore;
  497. Array task_scores --> 100 200 300 400 (-50) 600;
  498. [ TaskScore i; return task_scores-->i; ];
  499. </pre>
  500. <li><p>The scoring system is completely disabled if you define a constant <tt>NO_SCORE</tt> near the start of your
  501. game.
  502. <pre> Constant NO_SCORE;</pre>
  503. <li><p>A new <tt>before_implicit</tt> property is available; at the moment this is used only by the parser, when
  504. it is about to perform an implicit TAKE (for example, EAT APPLE when you&rsquo;re not holding the
  505. apple). You can give this property to an object if you wish to control the parser&rsquo;s behaviour. The
  506. property&rsquo;s value should be a constant or a routine which returns: 0 to report &ldquo;(first taking the...)&rdquo;
  507. and then attempt to do so (this is what currently happens); 1 to attempt the TAKE without first
  508. issuing the message, 2 to proceed with the requested action without attempting the TAKE, or 3 to
  509. object that &ldquo;You aren&rsquo;t holding that!&rdquo;. The object can test <tt>action_to_be</tt> to determine which action
  510. has triggered the TAKE:
  511. <pre>
  512. before_implicit [;
  513. Take: if (action_to_be == ##Eat) return 2;
  514. ],
  515. </pre>
  516. <li><p>A new system variable <tt>sys_statusline_flag</tt> is set to 1 initially if you have used the
  517. <tt>statusline time;</tt> directive in your program to show a clock, and to 0 otherwise. It can be
  518. changed by the program.
  519. <li><p>An object&rsquo;s <tt>invent</tt> property &mdash; if it has one &mdash; is now invoked both when displaying the player&rsquo;s
  520. inventory <b>and</b> when including the object in a room description. <tt>invent</tt> is invoked in the usual
  521. way (with <tt>inventory_stage</tt> first set to 1, and then set to 2) both when mentioning the object in a
  522. room description, and when listing it in the player&rsquo;s inventory. By default you&rsquo;ll get the same
  523. output each time. If you need to distinguish between the two occasions, you can test
  524. <tt>(c_style&amp;PARTINV_BIT)</tt> &mdash; true during a room description &mdash; or <tt>(c_style&amp;FULLINV_BIT)</tt> &mdash; true
  525. during an inventory. Here&rsquo;s an example:
  526. <pre>
  527. Object -> "sack"
  528. with name 'sack',
  529. invent [;
  530. ! When listing objects in the player's inventory
  531. if (c_style&amp;FULLINV_BIT) rfalse;
  532. ! When listing objects at the end of a room description
  533. if (inventory_stage == 1) switch (children(self)) {
  534. 0: print "an empty sack";
  535. 1: print "a sack containing ", (a) child(self);
  536. default: print "an assortment of objects in a sack";
  537. }
  538. rtrue;
  539. ],
  540. has container open;
  541. </pre>
  542. This enhancement uses the mechanism described in
  543. <a href="http://www.firthworks.com/roger/informfaq/ww.html#4">this topic in the Inform 6 FAQ</a>
  544. and means that you no longer need to <tt>Include WriteList</tt>.
  545. <li><p>The <tt>turns</tt> counter is now initialised to 0, not 1. You can change this if you define a constant
  546. <tt>START_MOVE</tt> near the start of your game.
  547. <pre> Constant START_MOVE 1;</pre>
  548. <li><p>A new <tt>LibraryExtensions</tt> object is defined, whose function is to act as a parent to initialisation
  549. objects created by library extensions. These objects may provide <tt>ext_initialise</tt> and/or
  550. <tt>ext_messages</tt> property routines, whose role is to help integrate the extension into a game. This is
  551. best explained by example.<p>
  552. Consider the <tt>SmartCantGo.h</tt> extension, which replaces &ldquo;You can&rsquo;t go that way&rdquo; messages by the
  553. more informative &ldquo;You can go only north, south and east&rdquo;, and can be integrated into a game by
  554. adding a <tt>ChangeDefault(cant_go, SmartCantGo)</tt> statement to your <tt>Initialise()</tt> routine. Instead
  555. of requiring the author to make this addition, the extension could now cause it to happen
  556. automatically by defining an initialisation object as a child of <tt>LibraryExtensions</tt>, like this:
  557. <pre>
  558. Object "(SmartCantGo)" LibraryExtensions
  559. with ext_initialise [; ChangeDefault(cant_go, SmartCantGo); ];
  560. </pre>
  561. Just before calling the game&rsquo;s <tt>Initialise()</tt> routine, the library loops through the children &mdash; if any
  562. &mdash; of <tt>LibraryExtensions</tt>, and executes those <tt>ext_initialise</tt> properties that it finds there. The
  563. property routines can perform any appropriate setup processing that would otherwise have to be
  564. inserted into the <tt>Initialise()</tt> routine itself; for example, starting a daemon running.<p>
  565. A similar process takes place when displaying library messages. The library first checks whether
  566. the author has provided a <tt>LibraryMessages</tt> object to intercept the message which it is about to
  567. display. If not, it now loops through the children of <tt>LibraryExtensions</tt>, and executes
  568. <tt>ext_messages</tt> properties that it finds there. If none of those routines returns true to signal that the
  569. message has been dealt with, the standard library text is then printed in the usual way. For
  570. example, here&rsquo;s how an extension might automatically intercept Inventory messages (unless the
  571. game has already handled them via <tt>LibraryMessages</tt>):
  572. <pre>
  573. Object "(someInventoryExtension)" LibraryExtensions
  574. with ext_messages [;
  575. Inv: switch(lm_n) {
  576. 1: "You are empty-handed.";
  577. 2: "Your possessions include";
  578. }
  579. ];
  580. </pre>
  581. Note that this is an experimental feature, and may be modified or extended in the light of
  582. experience.
  583. </ul>
  584. <h3>Library routines</h3>
  585. Several new library routines are provided to harmonise commonly-encountered differences between
  586. the Z-machine and Glulx VMs (see also <a href="#LibraryGlulx">Library routines available only in Glulx</a>).
  587. <p><tt>KeyCharPrimitive()</tt>
  588. <p><blockquote>waits for a single key, and returns the character from 1-255 (or, for Glulx, one of the Glk special
  589. key codes.). For Glulx only, an extended form is available &mdash;
  590. see <a href="#LibraryGlulx">Library routines available only in Glulx</a>.</blockquote>
  591. <p><tt>KeyDelay(<i>time</i>)</tt>
  592. <p><blockquote>waits <tt><i>time</i></tt> tenths of a second for a single key. If no key is pressed within that period it returns
  593. zero; otherwise it returns the character from 1-255.</blockquote>
  594. <p><tt>ClearScreen()<br>
  595. ClearScreen(<i>selector</i>)</tt>
  596. <p><blockquote><tt>ClearScreen()</tt> clears both the status line and the main window. The cursor moves to the top of the
  597. screen. The routine should be followed by a call to <tt>MoveCursor()</tt> or <tt>MainWindow()</tt>. Alternatively,
  598. using <tt>ClearScreen(<i>selector</i>)</tt>: if <tt><i>selector</i></tt> is 0, both are cleared; if <tt><i>selector</i></tt> is 1 only the
  599. status line is cleared; if <tt><i>selector</i></tt> is 2 only the main window is cleared.</blockquote>
  600. <p><tt>MoveCursor()<br>
  601. MoveCursor(<i>line</i>, <i>column</i>)</tt>
  602. <p><blockquote><tt>MoveCursor()</tt> selects the status line for output. <tt>MoveCursor(<i>line</i>, <i>column</i>)</tt> selects the status line
  603. for output and moves the cursor to the given <tt><i>line</i></tt> and <tt><i>column</i></tt> within the status area, where line 1
  604. is the top line and column 1 is the far left. (This is necessary because the Glk convention is to
  605. number both lines and columns from 0 rather than 1.)</blockquote>
  606. <p><tt>MainWindow()</tt>
  607. <p><blockquote>selects the main (buffered) text window for output.</blockquote>
  608. <p><tt>StatusLineHeight(<i>lines</i>)</tt>
  609. <p><blockquote>sets the height of the status line in lines. The standard <tt>DrawStatusLine()</tt> calls this every turn,
  610. which isn&rsquo;t a bad thing, since <tt>StatusLineHeight()</tt> is smart. If you replace <tt>DrawStatusLine()</tt>,
  611. maintain this convention. (The library menu routines fiddle with the status line, and it&rsquo;s up to
  612. <tt>DrawStatusLine()</tt> to reset it after the menus are over.)<p>
  613. A new library variable <tt>gg_statuswin_cursize</tt> holds the current setting (in both VMs).</blockquote>
  614. <p><tt>ScreenWidth()</tt>
  615. <p><blockquote>returns the number of characters that can be printed in a monospaced font between the left and
  616. right borders of the currently selected window. For Glulx only, the extended form
  617. <tt>ScreenWidth(<i>win</i>)</tt> works on a specified window id; note that the results are unreliable if the
  618. normal style for that window uses a proportional font.</blockquote>
  619. <p><tt>ScreenHeight()</tt>
  620. <p><blockquote>returns the height in lines of the main window.</blockquote>
  621. <p><tt>SetColour(<i>fg</i>, <i>bg</i>)<br>
  622. SetColour(<i>fg</i>, <i>bg</i>, <i>selector</i>)</tt>
  623. <p><blockquote><tt>SetColour(<i>fg</i>, <i>bg</i>)</tt> sets the current foreground and background text colours, using the same codes
  624. as the <tt>@set_colour</tt> opcode in the Z-machine (1=default, 2=black, 3=red, 4=green etc.). Using
  625. <tt>SetColour(<i>fg</i>, <i>bg</i>, <i>selector</i>)</tt>, colours can be set separately in each window: if <tt><i>selector</i></tt> is 0,
  626. both are set (the top window will have inverted colours for the Z-machine); if <tt><i>selector</i></tt> is 1 only
  627. the status line is affected; if <tt><i>selector</i></tt> is 2 only the main window is affected.<p>
  628. All colour functions are effective only if the library variable <tt>clr_on</tt> is set to non-zero.<p>
  629. The advantage over <tt>@set_colour</tt> is that when the player restores a saved game or types UNDO,
  630. the colours will be correct for that state of the game.<p>
  631. For Glulx, the routine produces an appropriate effect if style hints are enabled by the interpreter; it
  632. also clears the screen. For the Z-machine, a separate call to <tt>ClearScreen()</tt> is required.<p>
  633. These associated constants are now provided for use with <tt>SetColour()</tt>; the final three are useful
  634. also with <tt>ClearScreen()</tt>:
  635. <pre>
  636. Constant CLR_DEFAULT 1;
  637. Constant CLR_BLACK 2;
  638. Constant CLR_RED 3;
  639. Constant CLR_GREEN 4;
  640. Constant CLR_YELLOW 5;
  641. Constant CLR_BLUE 6;
  642. Constant CLR_MAGENTA 7;
  643. Constant CLR_CYAN 8;
  644. Constant CLR_WHITE 9;
  645. Constant CLR_PURPLE 7;
  646. Constant CLR_AZURE 8;
  647. Constant WIN_ALL 0;
  648. Constant WIN_STATUS 1;
  649. Constant WIN_MAIN 2;
  650. </pre></blockquote>
  651. <p><tt>DecimalNumber(<i>num</i>)</tt>
  652. <p><blockquote>prints <tt><i>num</i></tt> as a decimal number (it is in fact identical to <tt>print <i>num</i>;</tt>). It may be useful in
  653. conjunction with...</blockquote>
  654. <p><tt>PrintToBuffer(<i>array</i>, <i>arraylen</i>, <i>string</i>)<br>
  655. PrintToBuffer(<i>array</i>, <i>arraylen</i>, <i>obj</i>)<br>
  656. PrintToBuffer(<i>array</i>, <i>arraylen</i>, <i>obj</i>, <i>prop</i>)<br>
  657. PrintToBuffer(<i>array</i>, <i>arraylen</i>, <i>routine</i>, <i>arg1</i>, <i>arg2</i>)</tt>
  658. <p><blockquote>prints its arguments &mdash; a string, an object&rsquo;s name, the value of an object&rsquo;s property, or a routine
  659. with up to two arguments &mdash; to the buffer <tt><i>array</i></tt>. The number of characters written to the buffer is a
  660. word at <tt><i>array</i>-->0</tt> (and is the value returned by the routine); the actual characters start at
  661. <tt><i>array</i>->WORDSIZE</tt>. The maximum number of characters is specified in <tt><i>arraylen</i></tt>; for the
  662. Z-machine, an overrun caused by printing more than this value will produce an error message that
  663. you have corrupted the contents of memory beyond the array (for Glulx, the output is
  664. automatically truncated at the specified <tt><i>arraylen</i></tt>).<p>
  665. For Glulx, see also <tt>PrintAnyToArray()</tt> in <a href="#LibraryGlulx">Library routines available only in Glulx</a>,
  666. which has slightly extended capabilities, and which returns the number of characters written
  667. rather than writing them at <tt><i>array</i>-->0</tt>.</blockquote>
  668. <p><tt>Length(<i>string</i>)<br>
  669. Length(<i>obj</i>, <i>prop</i>)</tt>
  670. <p><blockquote>returns the number of characters in the string. Note that this prints to one of the parser arrays, and
  671. therefore it is your responsibility to ensure that the length <b>cannot be greater that 160
  672. characters</b>.</blockquote>
  673. <p><tt>UpperCase(<i>char</i>)<br>
  674. LowerCase(<i>char</i>)</tt>
  675. <p><blockquote>return <tt><i>char</i></tt> in upper or lower case (if it was alphabetic), or unchanged (otherwise). Changes
  676. affecting A-Z and a-z are always reliable; changes to accented characters will not work if you
  677. have supplied a compiler switch <tt>-C2</tt> through <tt>-C9</tt>, or used a <tt>Zcharacter</tt> directive to adjust the
  678. standard ZSCII character set.</blockquote>
  679. <p><tt>PrintCapitalised(<i>obj</i>, <i>prop</i>, <i>flag</i>, <i>nocaps</i>)</tt>
  680. <p><blockquote>is based upon <tt>PrintOrRun(<i>obj</i>, <i>prop</i>, <i>flag</i>)</tt>. <tt>PrintOrRun()</tt> tests
  681. <tt><i>obj.prop</i></tt>, and either runs it (if a
  682. Routine), or prints it (if a String). In the latter case, a newline is then output unless <tt><i>flag</i></tt> is <tt>true</tt>.
  683. <tt>PrintCapitalised()</tt> does all that; the difference is that the first letter of any output is in upper
  684. case unless <tt><i>nocaps</i></tt> is <tt>true</tt>.</blockquote>
  685. <p><tt>Cap(string, nocaps)</tt>
  686. <p><blockquote>prints the <tt><i>string</i></tt> with the first letter in upper case, unless <tt><i>nocaps</i></tt> is true. Can also be used as a
  687. print rule:
  688. <pre> print ..., (Cap) myString, ...;</pre></blockquote>
  689. <p><tt>Centre(<i>string</i>)<br>
  690. Centre(<i>obj</i>, <i>prop</i>)</tt>
  691. <p><blockquote>prints a single-line <tt><i>string</i></tt> approximately centrally between the left and right borders of the screen
  692. by preceding it with an appropriate number of spaces. The routine works only for monospaced
  693. fonts (that is, after <tt>font off;</tt>), and is only likely to work well in the main Glulx window if the
  694. normal style for TextBuffer uses a non-proportional font. It is however useful for centring
  695. information in the status line. Can also be used as a print rule:
  696. <pre> print ..., (Centre) myString, ...;</pre></blockquote>
  697. <p><tt>PrintOrRunVal(<i>value</i>, <i>flag</i>)</tt>
  698. <p><blockquote>if <tt><i>value</i></tt> refers to to an object, prints that object&rsquo;s name;
  699. if <tt><i>value</i></tt> refers to a routine, runs that routine; if <tt><i>value</i></tt> refers to a string,
  700. prints that string (with a terminating newline unless <tt><i>flag</i></tt> is
  701. true).</blockquote>
  702. <h3>Bugs fixed</h3>
  703. Items of the form [L61036] quote the bug&rsquo;s reference number in the &lsquo;Library&rsquo; section of the Inform
  704. Patch List.
  705. <ul>
  706. <li><p>A command like EMPTY ME no longer replies &ldquo;yourself can't contain things&rdquo;. [L61036]
  707. <li><p>The commands TAKE ALL FROM X and REMOVE ALL FROM X, where X is a closed or
  708. empty container, now produce sensible messages rather than &ldquo;You can&rsquo;t see any such thing&rdquo; and
  709. &ldquo;You can&rsquo;t use multiple objects with that verb&rdquo; respectively. [L61035]
  710. <li><p>A problem with the misbehaviour of <tt>name</tt> properties on rooms, in conjunction with THE, has been
  711. corrected. [L61034]
  712. <li><p>The command PUT X INTO X now correctly produces &ldquo;You can&rsquo;t put something inside itself&rdquo;,
  713. rather than &ldquo;You can&rsquo;t see any such thing&rdquo;. [L61033]
  714. <li><p>Run-time errors resulting from <tt>IndirectlyContains()</tt> attempting to find the parent of a Class
  715. which supports dynamic creation of objects have been resolved. [L61032]
  716. <li><p>Code in <tt>Parser__parse()</tt> which deals with looking ahead to the indirect object in cases like PUT
  717. ALL INTO BAG (a MULTIEXCEPT token) and TAKE ALL FROM BAG (a MULTIINSIDE
  718. token) now correctly sets the <tt>advance_warning</tt> global (to BAG). [L61031, L61023]
  719. <li><p>The <i>Inform Designer&rsquo;s Manual</i> (p. 98) states that SHOWOBJ should accept an object number;
  720. now it does. [L61030]
  721. <li><p>The <tt>YesOrNo()</tt> routine now re-prompts correctly after garbage input. [L61029]
  722. <li><p>The parse buffer is no longer declared and initialised incorrectly (albeit harmlessly). [L61028,
  723. L60708]
  724. <li><p>The <i>Inform Designer&rsquo;s Manual</i> (p. 93) defines the calling order of routines and properties for the
  725. &lsquo;Before&rsquo; stage as follows:<p>
  726. <ol><li> <tt>GamePreRoutine()</tt>
  727. <li> <tt>orders</tt> of the player
  728. <li> <tt>react_before</tt> of every object in scope
  729. <li> <tt>before</tt> of the current room
  730. <li> <tt>before</tt> of the first noun, if specified</ol><p>
  731. In the library, however, steps 3 and 4 are executed in reverse order. They are now as documented.
  732. [L61027]
  733. <li><p> A <tt>found_in</tt> floating object which the player is able to take (probably due to a coding error) is no
  734. longer silently dropped when the player returns to one of the listed rooms. [L61026]
  735. <li><p>A small problem with inherited <tt>describe</tt> properties has been corrected. [L61025]
  736. <li><p>Standard screen-handling is now implemented in v6 games. [L61022]
  737. <li><p>The handling of &ldquo;You can&rsquo;t go that way&rdquo; messages is made consistent. Also, the statement
  738. <tt>ChangeDefault(cant_go,myRoutine);</tt> now works. [L61020]
  739. <li><p>Attempting to place an object in/on an object where it is already now results in &ldquo;It&rsquo;s already
  740. there&rdquo;, rather than &ldquo;You need to be holding it before you can put it into something else&rdquo;. [L61019]
  741. <li><p>A problem with misleading inventory listing has been clarified. [L61018]
  742. <li><p>The command LEAVE X now correctly produces &ldquo;But you aren&rsquo;t in/on the X&rdquo;, if appropriate.
  743. [L61017]
  744. <li><p>The response to READ was inappropriate when an object is misspelled or out of scope. [L61016]
  745. <li><p>A small bug in the choice of library messages for PUSH and TURN, which wasn&rsquo;t noticeable
  746. unless you overrode the messages to be different from PULL, has been corrected. [L61015]
  747. <li><p>If you are in a dark room, you cannot examine what you are holding. Yet if you open a container
  748. you brought in from a lit room, the standard message &ldquo;You open the box, revealing a...&rdquo; was not
  749. being suppressed. [L61014]
  750. <li><p>The <tt>ScoreMatchL()</tt> routine in Parserm.h incorrectly decided which objects meet descriptors. As a
  751. result, some objects that didn&rsquo;t meet descriptors were not properly removed from the match list
  752. when the library is deciding which objects best match a player&rsquo;s input. [L61013]
  753. <li><p>The Infix problem parsing commands containing commas and periods has been fixed.
  754. [L61010]
  755. <li><p>A problem when describing what&rsquo;s visible after opening a container has been corrected. [L61009]
  756. <li><p>An inappropriate message after GO NORTH CIRCULAR has been corrected. [L61008]
  757. <li><p>Modified foreground and background colours are now correct after RESTORE and UNDO.
  758. [L61007]
  759. <li><p>The <tt>grammar</tt> property now works with a large game whose dictionary lies above $8000. [L61006]
  760. <li><p>A buffer conflict with disambiguation and UNDO has been resolved. [L61004]
  761. <li><p>If a player is inside a closed, non-transparent container, the library prints an extra blank line
  762. between the header &ldquo;The container&rdquo; and the first <tt>inside_description</tt> line it prints. No more.
  763. [L61002]
  764. <li><p>The list writing routines do not handle plural containers correctly. If you have two empty boxes, it
  765. might list &ldquo;two boxes (which is closed)&rdquo;. Not only should it say &ldquo;are closed&rdquo;, but it will lump
  766. empty containers together even if some are open and others aren&rsquo;t. Now resolved. [L61001]
  767. <li><p>A conflict between <tt>DrawStatusLine()</tt> and <tt>DisplayStatus()</tt> on how to determine whether to
  768. display turns or time is settled in favour of checking a header flag. [L60709]
  769. </ul>
  770. <h2><a name="Glulx">Support for Glulx</a></h2>
  771. One of the limitations of the Z-machine is the size of the largest game that it supports: 256Kb if you
  772. compile a version 5 game, or 512Kb if you compile for version 8. If you find yourself up against this
  773. limit and you&rsquo;ve tried all the standard tricks to save a few bytes here and there, then it&rsquo;s time to switch
  774. to Glulx. That&rsquo;s easy to do: you just supply the <tt><b>-G</b></tt> compiler switch, the compiler generates Glulx code,
  775. and any Glulx interpreter will be able to run it.<p>
  776. Actually, it isn&rsquo;t always quite that simple...
  777. <h3><a name="KnowingWhich">Knowing which is which</a></h3>
  778. As mentioned earlier, the compiler automatically defines a couple of useful constants. If you&rsquo;re
  779. compiling for the Z-machine then <tt>TARGET_ZCODE</tt> is defined; if you&rsquo;re compiling for Glulx then you&rsquo;re
  780. given <tt>TARGET_GLULX</tt> instead. You can use these with the <tt>Ifdef</tt> directive, like this:
  781. <pre>
  782. #Ifdef TARGET_ZCODE;
  783. ! Z-machine code here
  784. #Endif;
  785. #Ifdef TARGET_GLULX;
  786. ! Equivalent Glulx code here
  787. #Endif;
  788. </pre>or more commonly like this:<pre>
  789. #Ifdef TARGET_ZCODE;
  790. ! Z-machine code here
  791. #Ifnot;
  792. ! Equivalent Glulx code here
  793. #Endif;
  794. </pre>You&rsquo;ll find a lot of this if you look in the library files, but it&rsquo;s less frequently needed in a source file.
  795. <h3>Glulx differences</h3>
  796. The two VMs are not identical, and you need to be aware of their differences.
  797. <h4>Word size</h4>
  798. The most basic difference between Glulx and the Z-machine is that words are four bytes long instead
  799. of two. All Glulx variables are 32-bit values, the stack contains 32-bit values, property entries are
  800. 32-bit values, and so on.<p>
  801. In most Inform programming, you don&rsquo;t need to worry about this change at all. For example, if you
  802. have an array
  803. <pre> Array mylist --> 10;</pre>
  804. ...then Z-code Inform allocates ten words &mdash; that is, twenty bytes &mdash; and you can access these values as
  805. <tt>mylist-->0</tt> through <tt>mylist-->9</tt>. If you compile the same code under Glulx Inform, the compiler again
  806. allocates ten words &mdash; now forty bytes &mdash; and you can still access them as <tt>mylist-->0</tt> through
  807. <tt>mylist-->9</tt>. Everything works the same, except that the array can contain values greater than the
  808. Z-machine&rsquo;s limit of 65535.<p>
  809. <tt>Table</tt> arrays also refer to two- or four-byte word values, and the first word is the length of the array.
  810. <tt>String</tt> and <tt>-></tt> arrays, and the <tt>-></tt> notation, still refer to single bytes. You should not have to modify
  811. your code here, either.<p>
  812. There are two important cases where you <b>will</b> have to modify your code. First is the <tt>.#</tt> operator. The
  813. expression <tt><i>obj</i>.#<i>prop</i></tt> returns the length of the property <b>in bytes</b>. Since properties almost always
  814. contain words rather than bytes, it is very common to have Z-machine code like:
  815. <pre>
  816. len = (obj.#prop) / 2;
  817. for (i=0 : i&lt;len : i++)
  818. print (string) (obj.&amp;prop)-->i;
  819. </pre>
  820. In Glulx Inform programs, it is necessary to divide by 4 instead of by 2, so you should replace the
  821. above code with:
  822. <pre>
  823. len = (obj.#prop) / WORDSIZE;
  824. for (i=0 : i&lt;len : i++)
  825. print (string) (obj.&amp;prop)-->i;
  826. </pre>
  827. This will compile and run correctly in both VMs. <p>
  828. The other circumstance where your code may need modifying in this manner is when using the &lsquo;print
  829. to array&rsquo; feature. Code like this:
  830. <pre>
  831. Array mybuf buffer 100; ! must be big enough for largest string you'll print
  832. mystr = "hello";
  833. mystr.print_to_array(mybuf);
  834. </pre>
  835. results in the first <b>word</b> of <tt>mybuf</tt> containing 5 (the number of characters in <tt>mystr</tt>), and the following
  836. five <b>bytes</b> containing &lsquo;h&rsquo;, &lsquo;e&rsquo;, &lsquo;l&rsquo;, &lsquo;l&rsquo; and &lsquo;o&rsquo;.
  837. In the Z-machine, you could then output the characters from the array with either of these code fragments:
  838. <pre>
  839. len = 2 + mybuf-->0
  840. for (i=2 : i&lt;len : i++)
  841. print (char) mybuf->i;
  842. len = mybuf-->0
  843. for (i=0 : i&lt;len : i++)
  844. print (char) mybuf->(i+2);
  845. </pre>
  846. Again, you can make the code safe for both VMs if you change &ldquo;<tt>2</tt>&rdquo; to &ldquo;<tt>WORDSIZE</tt>&rdquo;:
  847. <pre>
  848. len = WORDSIZE + mybuf-->0
  849. for (i=WORDSIZE : i&lt;len : i++)
  850. print (char) mybuf->i;
  851. len = mybuf-->0
  852. for (i=0 : i&lt;len : i++)
  853. print (char) mybuf->(i+WORDSIZE);
  854. </pre>
  855. See also <a href="#FeaturesGlulx">Features available only in Glulx</a> for details of <tt>print_to_array</tt> under Glulx.
  856. <h4>Directives</h4>
  857. Glulx handles the majority of Inform directives, with two exceptions:
  858. <ul>
  859. <li><p>The <tt>Zcharacter</tt> directive causes a compilation error, since Glulx does not use the ZSCII character set.
  860. Your best approach is to bypass the directive when compiling for Glulx:
  861. <pre>
  862. #Ifdef TARGET_ZCODE;
  863. Zcharacter ... ;
  864. #Endif;
  865. </pre>
  866. <li><p>The (obsolete) <tt>Lowstring</tt> directive causes a run-time error when used like this:
  867. <pre>
  868. Lowstring mystr "hello";
  869. string 0 mystr;
  870. print "@00 and goodbye.";
  871. </pre>
  872. This simpler form, avoiding the use of <tt>Lowstring</tt>, works successfully:
  873. <pre>
  874. string 0 "hello";
  875. print "@00 and goodbye.";
  876. </pre>
  877. See also <a href="#FeaturesGlulx">Features available only in Glulx</a> for additional printing variable support.
  878. </ul>
  879. <h4>Statements</h4>
  880. Glulx handles the majority of Inform statements, with a few exceptions. If you try to use any of these
  881. statements in Glulx, you will cause a compilation error:
  882. <ul>
  883. <li><p><tt>save, restore</tt>: These are more complicated procedures in Glulx than in Z-code, and cannot be
  884. implemented without involving library variables and routines. If you want to do this sort of thing,
  885. modify or copy the library <tt>SaveSub()</tt> and <tt>RestoreSub()</tt> routines.
  886. <li><p><tt>read</tt>: Similarly, reading a line of text in Glulx involves the library; the compiler cannot generate
  887. stand-alone code to do it. See instead the library <tt>KeyboardPrimitive()</tt> routine.
  888. <li><p><tt>@<i>opcode</i></tt>: The Z-machine assembly language is completely different from that of Glulx. If you
  889. have used any assembly instructions, you will need to conceal them when compiling for Glulx, as
  890. described in <a href="#KnowingWhich">Knowing which is which</a>. See also
  891. <a href="#FeaturesGlulx">Features available only in Glulx</a> for details of the <tt>glk()</tt> function call.
  892. </ul>
  893. Glulx now supports the Inform <tt>style</tt> statement, mapping the Z-machine forms onto Glk styles:
  894. <blockquote><table width="80%" cellpadding="6pt" border="1" bordercolor="black" frame="hsides" rules="groups">
  895. <thead>
  896. <tr><td width="30%"><b>Inform statement</b></td><td><b>Equivalent Glk style</b></td></tr>
  897. </thead>
  898. <tr><td><tt>style roman;</tt></td><td><tt>style_Normal</tt></td></tr>
  899. <tr><td><tt>style reverse;</tt></td><td><tt>style_Alert</tt></td></tr>
  900. <tr><td><tt>style bold;</tt></td><td><tt>style_Subheader</tt></td></tr>
  901. <tr><td><tt>style underline;</tt></td><td><tt>style_Emphasized</tt></td></tr>
  902. <tr><td><tt>style fixed;</tt></td><td><tt>style_Preformatted</tt></td></tr>
  903. </table></blockquote>
  904. However, it is important to remember that, with Glulx, the appearance of a game is under the player&rsquo;s
  905. control &mdash; Glulx interpreters enable the font parameters associated with each style to be specified
  906. at run-time. Therefore, you should use styles with caution, and if necessary alert the player to the
  907. settings which your game expects.
  908. <h4>Character handling</h4>
  909. Unlike the Z-machine, which internally uses the ZSCII character set (see the <i>Inform Designer&rsquo;s
  910. Manual</i> Table 2 on p. 519), Glulx uses strings consisting of either 8-bit characters in the ISO
  911. 8859-1 (Latin-1) encoding (which is the same as ZSCII for character values 0-127, but different for
  912. character values 128-255), or 32-bit Unicode characters. In general you don't need to worry about
  913. which string representation is used: the compiler will figure it out for you. The impact is as follows:
  914. <ul>
  915. <li><p><tt>@<i>escape_sequence</i></tt>: Escape sequences such as <tt>@:a</tt> and <tt>@LL</tt>
  916. (for &ldquo;&auml;&rdquo; and &ldquo;&pound;&rdquo; respectively) are accepted identically by both VMs.
  917. <li><p><tt>@@<i>decnum</i></tt>: The number is the character&rsquo;s internal decimal value, so <tt>@@65</tt>
  918. is &ldquo;A&rdquo; in both VMs, but <tt>@@165</tt> is &ldquo;&iuml;&rdquo; in the Z-machine and &ldquo;&yen;&rdquo; in Glulx.
  919. <li><p><tt>@{<i>hexnum</i>}</tt>: The number is the character&rsquo;s Unicode value, so <tt>@{41}</tt> is &ldquo;A&rdquo;
  920. and <tt>@{EF}</tt> is &ldquo;&iuml;&rdquo; in both VMs. However, <tt>@{A5}</tt> is &ldquo;&yen;&rdquo; in Glulx,
  921. but causes a Z-machine compilation error because &ldquo;&yen;&rdquo; isn&rsquo;t a ZSCII character.
  922. <li><p><tt>-C<i>n</i></tt>: The compiler switches <tt><b>-C1</b></tt> through <tt><b>-C9</b></tt>
  923. specify that the source file uses the character set
  924. defined by ISO 8859-1 through 8859-9 respectively. In the Z-machine, the switch also initialises
  925. the higher ZSCII character set to appropriate values; this later feature is irrelevant when compiling for
  926. Glulx.
  927. <li><p>Dictionaries in Glulx Inform 6 games have to consist of only ISO 8859-1 characters at present. This is
  928. being worked on, and the necessary compiler changes have been made, but further library work is still needed.
  929. </ul>
  930. <h4>Compiler switches</h4>
  931. We&rsquo;ve already mentioned the <tt><b>-G</b></tt> command line switch, which causes the compiler to output code
  932. for Glulx rather than for the Z-machine. There are a few other changes in this area (see the <i>Inform
  933. Designer&rsquo;s Manual</i> Table 3 on p. 521).
  934. <blockquote><table width="80%" cellpadding="6pt" border="1" bordercolor="black" frame="hsides" rules="groups">
  935. <thead>
  936. <tr><td width="10%"><b>Switch</b></td><td width="10%"><b>To</b></td><td><b>Meaning</b></td></tr>
  937. </thead>
  938. <tr><td><tt>-k</tt></td><td>off/on</td><td>incompatible with <tt>-G</tt> (output debugging information)</td></tr>
  939. <tr><td><tt>-v*</tt></td><td>3 to 8</td><td>incompatible with <tt>-G</tt> (set Z-machine Version)</td></tr>
  940. <tr><td><tt>-G</tt></td><td>off/on</td><td>compile for Glulx VM</td></tr>
  941. <tr><td><tt>-H</tt></td><td>off/on</td><td>use Huffman compression on Glulx strings (on by default)</td></tr>
  942. <tr><td><tt>-X</tt></td><td>off/on</td><td>incompatible with <tt>-G</tt> (include Infix debugger)</td></tr>
  943. </table></blockquote>
  944. <h3>Glulx additions</h3>
  945. Glulx offers some additional capabilities above those of the Z-machine:
  946. <h4><a name="FeaturesGlulx">Features available only in Glulx</a></h4>
  947. <ul>
  948. <li><p>For Glulx, <tt>print_to_array</tt> function requires two arguments, the first being the array to print to,
  949. and the second the length of that array:
  950. <pre> <i>len</i> = <i>mystr</i>.print_to_array(<i>mybuf</i>, 80);</pre>
  951. This example writes no more than 76 characters into the array. If <tt><i>mybuf</i></tt> is an 80-byte array, you
  952. can be sure it will not be overrun. (Do not try this with the second argument less than 4.)<p>
  953. The value written into <tt>mybuf-->0</tt>, and the value returned, are <b>not</b> limited to the number of
  954. characters written; they represent the number of characters in the complete string. This means
  955. that:
  956. <pre> <i>len</i> = <i>mystr</i>.print_to_array(<i>mybuf</i>, 4);</pre>
  957. is an ugly but perfectly legal way to find the length of a string. (And in this case, <tt>mybuf</tt> need only
  958. be four bytes long.)
  959. <li><p>Z-code Inform supports 32 printing variables, <tt>@00</tt> to <tt>@31</tt>, which you can include in strings and
  960. then set with the statement:
  961. <pre> string <i>num</i> "<i>value</i>";</pre>
  962. In Glulx, this limit is raised to 64. Furthermore, in Glulx you can set these variables to a
  963. stand-alone routine as well as a string:
  964. <pre>
  965. [ <i>routine</i>; print "<i>value</i>"; ];
  966. string <i>num routine</i>;
  967. </pre>
  968. In this case, the routine is called with no arguments and the result discarded; you should print your
  969. desired output inside the routine. <p>
  970. In Glulx, unlike Z-code, a printing variable string can itself contain <tt>@..</tt> codes, allowing recursion.
  971. You can nest this as deeply as you want. However, it is obviously a bad idea to cause an infinite
  972. recursion. For example, this will certainly crash the interpreter:
  973. <pre>
  974. string 3 "This is a @03!";
  975. print "What is @03?";
  976. </pre>
  977. <li><p>Many of the things that used to be Z-code assembly are now handled by Glk function calls.
  978. Making a Glk function call from Inform is slightly awkward, but not difficult.<p>
  979. All of Glk is handled by the built-in Inform function <tt>glk()</tt>, which takes one or more arguments.
  980. The first argument is an integer; this tells <b>which</b> Glk call in being invoked. The remaining
  981. arguments are just the arguments to the Glk call, in order.<p>
  982. Say, for example, that you want to set the text style to &ldquo;preformatted&rdquo;. The Inform code to
  983. accomplish this is:
  984. <pre> glk($0086, 2);</pre>
  985. The hex value $0086 means <tt>glk_set_style</tt>; the value &ldquo;2&rdquo; means <tt>Preformatted</tt>.<p>
  986. The table of Glk calls, and the integers that refer to them, is given in Section 12.1.6 of the Glk specification
  987. (remember that the values given there are hexadecimal).
  988. <p>
  989. Since calls based on numeric codes are not very easy to read, we recommend that you download
  990. John Cater&rsquo;s <tt>infglk.h</tt> library header, which defines wrapper functions and constants. For
  991. example, you could achieve the same effect with this call:
  992. <pre> glk_set_style(style_Preformatted);</pre>
  993. When you read the Glk specification, bear in mind that the <tt>NULL</tt> value it talks about is the C
  994. language <tt>NULL</tt> (0), not the Inform Library <tt>NULL</tt> (-1). <tt>infglk.h</tt> defines a constant <tt>GLK_NULL</tt> (equal
  995. to 0) which you can use where appropriate.
  996. <li><p>By default, arguments to routines work the same in Glulx as they do in Z-code. When you call a
  997. routine, the arguments that you pass are written into the routine&rsquo;s local variables, in order. If you
  998. pass too many arguments, the extras are discarded; too few, and the unused local variables are
  999. filled with zeroes.<p>
  1000. However, the Glulx VM supports a second style of routine. You can define a routine of this type
  1001. by naming the first argument <tt>_vararg_count</tt>. For example:
  1002. <pre>
  1003. [ StackFunc _vararg_count ix pos len;
  1004. ! <i>Glulx code here</i>
  1005. ];
  1006. </pre>
  1007. If you do this, the routine arguments are <b>not</b> written into the local variables. Instead, they are
  1008. pushed onto the stack, and you must use Glulx assembly to pull them off. All the local variables
  1009. are initialized to zero, except for <tt>_vararg_count</tt>, which (as you might expect) contains the number
  1010. of arguments that were passed in.<p>
  1011. Note that <tt>_vararg_count</tt> is a normal local variable, aside from its useful initial value. You can
  1012. assign to it, increment or decrement it, use it in expressions, and so on.<p>
  1013. Stack-argument routines are most useful if you want a routine with variable arguments, or if you
  1014. want to write a wrapper that passes its arguments on to another routine.
  1015. </ul>
  1016. <h4><a name="LibraryGlulx">Library routines available only in Glulx</a></h4>
  1017. <p><tt>KeyCharPrimitive(<i>win</i>, <i>nostat</i>);</tt>
  1018. <p><blockquote>If <tt><i>win</i></tt> is nonzero, the character input request goes to that Glk window
  1019. (instead of <tt>gg_mainwin</tt>, the
  1020. default.) If <tt><i>nostat</i></tt> is nonzero, any window rearrangement event is returned immediately as value
  1021. 80000000 (instead of the default behavior, which is to call <tt>DrawStatusLine()</tt> and keep waiting.)</blockquote>
  1022. <p><tt>PrintAnything(<i>thingie</i>, ...);</tt>
  1023. <p><blockquote>In the Z-machine, strings and routines are &ldquo;packed&rdquo; addresses, dictionary words are normal
  1024. addresses, and game objects are represented as sequential numbers from 1 to <tt>#top_object</tt>. These
  1025. ranges overlap; a string, a dictionary word, and an object could conceivably all be represented by
  1026. the same numeric value.<p>
  1027. In Glulx, all those things are represented by normal addresses, so different items will always have
  1028. different values. Furthermore, the first byte found at the address is an identifier value, which
  1029. specifies what kind of item the address contains.<p>
  1030. <tt>PrintAnything()</tt> prints any thingie &mdash; string, routine (with optional arguments), object, object
  1031. property (with optional arguments), or dictionary word &mdash; known to the library.
  1032. <blockquote><table width="80%" cellpadding="6pt" border="1" bordercolor="black" frame="hsides" rules="groups">
  1033. <thead>
  1034. <tr><td width="50%"><b>Calling</b></td><td><b>Is equivalent to</b></td></tr>
  1035. </thead>
  1036. <tr><td><tt>PrintAnything()</tt></td><td>(nothing printed)</td></tr>
  1037. <tr><td><tt>PrintAnything(0)</tt></td><td>(nothing printed)</td></tr>
  1038. <tr><td><tt>PrintAnything(<i>string</i>)</tt></td><td><tt>print (string) "<i>string</i>";</tt></td></tr>
  1039. <tr><td><tt>PrintAnything(<i>dictionaryword</i>)</tt></td><td><tt>print (address) '<i>dictionaryword</i>';</tt></td></tr>
  1040. <tr><td><tt>PrintAnything(<i>obj</i>)</tt></td><td><tt>print (name) <i>obj</i>;</tt></td></tr>
  1041. <tr><td><tt>PrintAnything(<i>obj</i>, <i>prop</i>)</tt></td><td><tt><i>obj</i>.<i>prop</i>();</tt></td></tr>
  1042. <tr><td><tt>PrintAnything(<i>obj</i>, <i>prop</i>, <i>args</i>...)</tt></td><td><tt><i>obj</i>.<i>prop</i>(<i>args</i>...);</tt></td></tr>
  1043. <tr><td><tt>PrintAnything(<i>routine</i>)</tt></td><td><tt><i>routine</i>();</tt></td></tr>
  1044. <tr><td><tt>PrintAnything(<i>routine</i>, <i>args</i>...)</tt></td><td><tt><i>routine</i>(<i>args</i>...);</tt></td></tr>
  1045. </table></blockquote>
  1046. Extra arguments after a <tt><i>string</i></tt> or dictionary <tt><i>word</i></tt> are safely ignored.
  1047. The (first) argument you pass in is always interpreted as a thingie reference, not as an integer.
  1048. This is why none of the forms shown above print out an integer. However, you can get the same
  1049. effect by calling
  1050. <pre> PrintAnything(DecimalNumber, <i>num</i>);</pre>
  1051. ...which is where the <tt>DecimalNumber()</tt> routine comes in handy. You can also, of course, use other
  1052. library routines, and do tricks like
  1053. <pre>
  1054. PrintAnything(EnglishNumber, <i>num</i>);
  1055. PrintAnything(DefArt, <i>obj</i>);
  1056. </pre>
  1057. None of this may seem very useful; after all, there are already ways to print all those things. But
  1058. <tt>PrintAnything()</tt> is vital in implementing the following routine:</blockquote>
  1059. <p><tt>PrintAnyToArray(<i>array</i>, <i>arraylen</i>, <i>thingie</i>, ...);</tt>
  1060. <p><blockquote>This works the same way, except that instead of printing to the screen, the output is diverted to the
  1061. given array.<p>
  1062. The first two arguments must be the array address and its maximum length. Up to that many
  1063. characters will be written into the array; any extras will be silently discarded. This means that you
  1064. do not have to worry about array overruns.<p>
  1065. The <tt>PrintAnyToArray()</tt> routine returns the number of characters generated. (This may be greater
  1066. than the length of the array. It represents the entire text that was output, not the limited number
  1067. written into the array.)<p>
  1068. It is safe to nest <tt>PrintAnyToArray()</tt> calls. That is, you can call <tt>PrintAnyToArray(<i>routine</i>)</tt>, where
  1069. <tt><i>routine</i>()</tt> itself calls <tt>PrintAnyToArray()</tt>. (However, if they try to write to the <b>same array</b>, chaos
  1070. will ensue.)<p>
  1071. It is legal for <tt><i>arraylen</i></tt> to be zero (in which case <tt><i>array</i></tt> is ignored, and may be zero as well.) This
  1072. discards <b>all</b> of the output, and simply returns the number of characters generated. You can use this
  1073. to find the length of anything &mdash; even a function call.</blockquote>
  1074. <h4>Entry points available only in Glulx</h4>
  1075. An entry point is a routine which you can provide in your code, or leave out; the library will call it if
  1076. it&rsquo;s present, ignore it if not &mdash; see &sect;21 of the <i>Inform Designer&rsquo;s Manual</i>.<p>
  1077. The library has some entry points which aid in writing more complicated interfaces &mdash; games with
  1078. sound, graphics, extra windows, and other fancy Glk tricks. If you&rsquo;re just writing a standard
  1079. Infocom-style game, <b>you can ignore this section</b>.
  1080. <p><tt>HandleGlkEvent(<i>ev</i>, <i>context</i>, <i>abortres</i>)</tt>
  1081. <p><blockquote>This entry point is called every time a Glk event occurs. The event could indicate nearly anything:
  1082. a line of input from the player, a window resize or redraw event, a clock tick, a mouse click, or so
  1083. on.<p>
  1084. The library handles all the events necessary for a normal Infocom-style game. You need to supply
  1085. a <tt>HandleGlkEvent()</tt> routine only if you want to add extra functionality. The <tt><i>ev</i></tt> argument is a
  1086. four-word array which describes the event. <tt><i>ev</i>-->0</tt> is the type of the event; <tt><i>ev</i>-->1</tt> is the window
  1087. involved (if relevant); and <tt><i>ev</i>-->2</tt> and <tt><i>ev</i>-->3</tt> are extra information.
  1088. The <tt><i>context</i></tt> argument is 0 if
  1089. the event occurred during line input (normal commands, <tt>YesOrNo()</tt>, or some other use of the
  1090. <tt>KeyboardPrimitive()</tt> library routine); 1 indicates that the event occurred during character input
  1091. (any use of the <tt>KeyCharPrimitive()</tt> library routine). The <tt><i>abortres</i></tt> argument is used only if you
  1092. want to cancel player input and force a particular result; see below.<p>
  1093. If you return 2 from <tt>HandleGlkEvent()</tt>, player input will immediately be aborted. Some additional
  1094. code is also required:
  1095. <ul>
  1096. <li><p>If this was character input <tt>(<i>context</i>==1)</tt>, you must call the Glk <tt>cancel_char_event</tt> function,
  1097. and then set <tt><i>abortres</i>-->0</tt> to the character you want returned. Then return 2;
  1098. <tt>KeyCharPrimitive()</tt> will end and return the character, as if the player had hit it.
  1099. <li><p>If this was line input <tt>(<i>context</i>==0)</tt>, you must call the Glk <tt>cancel_line_event function</tt>. (You
  1100. can pass an array argument to see what the player had typed so far.) Then, fill in the length of
  1101. the input to be returned in <tt><i>abortres</i>-->0</tt>. If this is nonzero, write the input characters
  1102. sequentially into the array starting at <tt><i>abortres</i>-->WORDSIZE</tt>, up to (but not including)
  1103. <tt><i>abortres</i>-->(WORDSIZE+len)</tt>. Do not exceed 256 characters. Then return 2;
  1104. <tt>KeyboardPrimitive()</tt> will end and return the line.
  1105. </ul>
  1106. If you return -1 from <tt>HandleGlkEvent()</tt>, player input will continue even after a keystroke (for
  1107. character input) or after the enter key (for line input).
  1108. You must re-request input by calling <tt>request_char_input</tt> or <tt>request_line_input</tt>.
  1109. Any other return value from <tt>HandleGlkEvent()</tt> (a normal return, <tt>rfalse</tt>, or <tt>rtrue</tt>) will not affect
  1110. the course of player input.</blockquote>
  1111. <p><tt>InitGlkWindow(<i>winrock</i>)</tt>
  1112. <p><blockquote>This entry point is called by the library when it sets up the standard windows: the story window,
  1113. the status window, and (if you use quote boxes) the quote box window. The story and status
  1114. windows are created when the game starts (before <tt>Initialise()</tt>). The quote window is created
  1115. and destroyed as necessary.<p>
  1116. <tt>InitGlkWindow()</tt> is called in five phases:
  1117. <ol>
  1118. <li><p>The library calls <tt>InitGlkWindow(0)</tt>. This occurs at the very beginning of execution,
  1119. even before <tt>Initialise()</tt>. You can set up any situation you want. (However, remember
  1120. that the story and status windows might already exist &mdash; for example, if the player has
  1121. just typed RESTART.) This is a good time to set <tt>gg_statuswin_size</tt> to a value other
  1122. than 1. Return 0 to proceed with the standard library window setup, or 1 if you&rsquo;ve
  1123. created all the windows yourself.
  1124. <li><p>The library calls <tt>InitGlkWindow(GG_MAINWIN_ROCK)</tt>, before creating the story window.
  1125. This is a good time to set up style hints for the story window. Return 0 to let the library
  1126. create the window; return 1 if you have yourself created a window and stored it in
  1127. <tt>gg_mainwin</tt>.
  1128. <li><p>The library calls <tt>InitGlkWindow(GG_STATUSWIN_ROCK)</tt>, before creating the status
  1129. window. Again, return 0 to let the library do it; return 1 if you have created a window
  1130. and stored it in <tt>gg_statuswin</tt>.
  1131. <li><p>The library calls <tt>InitGlkWindow(1)</tt>. This is the end of window setup; you can take this
  1132. opportunity to open other windows. (Or you can do that in your <tt>Initialise()</tt> routine.
  1133. It doesn&rsquo;t matter much.)
  1134. <li><p>The library calls <tt>InitGlkWindow(GG_QUOTEWIN_ROCK)</tt>, before creating the quote box
  1135. window. This does not occur during game initialization; the quote box window is
  1136. created during the game, whenever you print a quote, and destroyed one turn later. As
  1137. usual, return 1 to indicate that you&rsquo;ve created a window in <tt>gg_quotewin</tt>. (The desired
  1138. number of lines for the window can be found in <tt>gg_arguments-->0</tt>.)
  1139. </ol>
  1140. However you handle window initialization, remember that the library requires a <tt>gg_mainwin</tt>. If
  1141. you don&rsquo;t create one, and don&rsquo;t allow the library to do so, the game will shut down. Contrariwise,
  1142. the status window and quote windows are optional; the library can get along without them.</blockquote>
  1143. <p><tt>IdentifyGlkObject(<i>phase</i>, <i>type</i>, <i>ref</i>, <i>rock</i>)</tt>
  1144. <p><blockquote>This entry point is called by the library to let you know what Glk objects exist. You must supply
  1145. this routine if you create any windows, filerefs, file streams, or sound channels beyond the
  1146. standard library ones. (This is necessary because after a RESTORE, RESTART, or UNDO
  1147. command, your global variables containing Glk objects will be wrong.)<p>
  1148. <tt>IdentifyGlkObject()</tt> is called in three phases:
  1149. <ol>
  1150. <li><p>The library calls <tt>IdentifyGlkObject()</tt> with <tt><i>phase</i>==0</tt>. You should set all your Glk
  1151. object references to zero.
  1152. <li><p>The library calls <tt>IdentifyGlkObject()</tt> with <tt><i>phase</i>==1</tt>. This occurs once for each
  1153. window, stream, and fileref that the library doesn&rsquo;t recognize. (The library handles the
  1154. two standard windows, and the files and streams that have to do with saving,
  1155. transcripts, and command records. You only have to deal with objects that you create.)
  1156. You should set whatever reference is appropriate to the object. For each object: <tt><i>type</i></tt>
  1157. will be 0, 1, 2 for windows, streams, filerefs respectively; <tt><i>ref</i></tt> will be the object
  1158. reference; and <tt><i>rock</i></tt> will be the object&rsquo;s rock, by which you can recognize it.
  1159. <li><p>The library calls <tt>IdentifyGlkObject()</tt> with <tt><i>phase</i>==2</tt>. This occurs once, after all the
  1160. other calls, and gives you a chance to recognize objects that aren&rsquo;t windows, streams,
  1161. or filerefs. If you don&rsquo;t create any such objects, you can ignore that bit. But you should
  1162. also take the opportunity to update all your Glk objects to the game state that was just
  1163. started or restored. (For example, redraw graphics, or set the right background sounds
  1164. playing.)
  1165. </ol></blockquote>
  1166. <h3><a name="Translate">Information for translators</a></h3>
  1167. The library is designed to be easily translatable, and there are currently versions available in French,
  1168. German and several other languages. If you maintain one of these translations, the following
  1169. information may be useful to you.
  1170. <h4>English.h</h4>
  1171. This is the &ldquo;language definition file&rdquo;, and in translation is replaced by <tt>French.h</tt>, <tt>German.h</tt>, etc. The
  1172. following changes have been made:
  1173. <ul>
  1174. <li><p>Class <tt>CompassDirection</tt> and its objects have been extensively revised.
  1175. <li><p>Routine <tt>LanguageVerb()</tt> has been reworked.
  1176. <li><p>Routines <tt>LanguageVerbIsDebugging()</tt>, <tt>LanguageVerbLikesAdverb()</tt> and <tt>LanguageVerbMayBeName()</tt>
  1177. have been added to isolate language-specific tests previously embedded in <tt>parserm.h</tt>.
  1178. <li><p>Constants <tt>YOU__TX</tt> and <tt>COMMA__TX</tt> have been added.
  1179. <li><p>Routine <tt>LanguageLM()</tt> has been sorted alphabetically.
  1180. <li><p>In that routine, <tt>CommandsOff</tt>, <tt>CommandsOn</tt> and <tt>CommandsRead</tt> have been added.
  1181. <li><p>Also in that routine, <tt>Exit</tt>, <tt>Inv</tt>, <tt>Look</tt>, <tt>Miscellany</tt>, <tt>Places</tt>,
  1182. <tt>Pronouns</tt> and <tt>Score</tt> have been extended,
  1183. and <tt>Go</tt> has been modified.
  1184. <li><p>Constant <tt>LIBRARY_ENGLISH</tt> has been added. We suggest that translated versions instead define <tt>
  1185. LIBRARY_DUTCH</tt>, <tt>LIBRARY_FRENCH</tt>, <tt>LIBRARY_GERMAN</tt>, <tt>LIBRARY_ITALIAN</tt>, <tt>LIBRARY_SPANISH</tt>, <tt>
  1186. LIBRARY_SWEDISH</tt> etc, in case it becomes useful at some time to determine which language is in
  1187. force.
  1188. </ul>
  1189. <h4>Grammar.h</h4>
  1190. This file contains grammars for English verbs like TAKE and DROP, and in translation is replaced
  1191. by <tt>FrenchG.h</tt>, <tt>GermanG.h</tt>, etc. The following changes have been made:
  1192. <ul>
  1193. <li><p>The grammars have been sorted alphabetically.
  1194. <li><p>Verb definitions <tt>'recording'</tt> and <tt>'replay'</tt> are no longer conditional on DEBUG.
  1195. <li><p>Verb definitions <tt>'showobj'</tt>, <tt>'ask'</tt>, <tt>'exit'</tt>, <tt>'look'</tt> and <tt>'tell'</tt> have been extended.
  1196. <li><p>Verb definition <tt>'pry'</tt> <tt>'prise'</tt> etc has been added.
  1197. <li><p>Constant <tt>LIBRARY_GRAMMAR</tt> has been added.
  1198. </ul>
  1199. </body>
  1200. </html>