Sunday, April 21, 2019

Chapter 17. Basic Screen Output and TELL

17.1 Introduction

Infocom strived for readability, natural feel, and varied responses of its games with its text routines. The games tried to be grammatically correct with display articles before nouns and using plural forms if necessary. Later games would fine tune these routines even more. Infocom did use programming macros for creating the proper text display routines. These macros would then be expanded into the proper ZIL code during compiling. It is difficult to figure out which was the first game to use this without the source code. The macros are seen in the Mini-Zork source code.

17.2 Abbreviations / Frequent words table

Starting with ZIP version 2, Infocom games used abbreviations to help reduce the space taken up by text. In version 2, the ZSCII character $01 signaled an abbreviation is to be display.The next ZSCII character indicates the requested abbreviation. This allows for 32 abbreviations. The abbreviation ZSCII character is consistent throughout the 3 character sets. The previous new-line control character (ZSCII 1) was moved to ZSCII 7 in character set 2.
To allow for more abbreviations, ZIP versions 3 and higher also use characters $02 and $03 to signal an abbreviation. Since each of these special control characters can access 32 abbreviations, these games could have 96 abbreviation, calculated using the formation: (abbreviation character value - 1) * 32 + next character’s ZSCII value. This also left only 2 control characters (ZSCII 4 and 5) remain to change the character set. Those control characters were repurposed to change the character set for next character only. There would be no “shift lock”.
An abbreviation table contains 32 (or 96 for versions 3 or higher) word addresses for the Z-strings. The abbreviation and next characters will then point to an entry in this abbreviation table with an address to a Z-string which will then be displayed. Because each abbreviation uses 2 characters, abbreviations for string longer than 2 characters could help reduce the size of the story file.

17.3 Special PRINT Routines - WORD-PRINT, CLAUSE-PRINT, PREP-PRINT

Zork 1 also included three print routines that work with the given command and prepositions:
  • WORD-PRINT
  • PREP-PRINT
  • CLAUSE-PRINT
WORD-PRINT displays a sequence of characters from INBUF given the starting character and number of characters to print.
PREP-PRINT displays the preposition given the preposition byte number,. The routine uses PREP-FIND to convert the preposition byte number to a Vocabulary address for the preposition. The only except is “through” which is larger than the 6 character limit for ZIP 3 or earlier. PREP-PRINT looks for the corresponding preposition number and just display the entire token.
CLAUSE-PRINT display the entire noun clause using the boundary addresses stored in ITBL.  A preceding preposition can also be displayed if the preposition number is also passed as an argument. The boundary addresses to use are based upon the element numbers in ITBL. Displaying the token from Vocabulary or from INBUF depends on state of O-FLAG. The routine will use strings from the Vocabulary (maximum of 6 characters) if the O-FLAG is set. Otherwise, it will use WORD-PRINT to print the entire token from INBUF.  
display the tokens in LEXV given by the start and end address of the requested noun clause. This limited any token to 6 characters. If the O-FLAG was clear, the routine extracted the length and location of each token in INBUF and displayed the complete token.

17.4 New versions PRINT routines

Deadline introduced several 4 new routines and updated CLAUSE-PRINT to improve the quality of the displayed text.
BUFFER-PRINT is a new routine that displays a sequence of tokens while modifying any truncated or referred tokens. For example, the “mrs” token will then be displayed as “mrs.” while the “it” token is replaced with its referring object. The address of the starting token and token after the last one to display are passed to the routine. The fourth argument is a boolean value to indicate print a preceding space before the first and subsequent tokens.
PRSO-PRINT and PRSI-PRINT are new routines that will display the direct or indirect object clause, respectively. They extract the starting and ending addresses of the clause from ITBL and see if the first token in the clause is “it”. If so, the current PRSO is displayed. Otherwise, these addresses are passed to BUFFER-PRINT.
The last new routine display a token with the first letter capitalized. No official name is known but could be called CAPITALIZE-PRINT. The routine pulls the first character and converts it to uppercase without checking the case first. Then it will use WORD-PRINT to display the remaining part of the token.
The new CLAUSE-PRINT utilizes BUFFER-PRINT to display those representative tokens with their proper names. The routine will take the start and end element numbers from ITBL and extracts the start and end addresses for the tokens to print. These are then sent to BUFFER-PRINT.
Enchanter would later introduce THING-PRINT which takes a boolean argument to choose which object clause to use (true for direct, false for indirect). The routine pulls the start and end addresses for the requested object clause and passes it to BUFFER-PRINT.

17.5 Error message routines

All Infocom games have several default error messages when handling errors with given commands.
  • CANT-USE
  • CANT-ORPHAN
  • UNKNOWN-WORD
CANT-USE was first used in Deadline and would insert an invalid token into the phrase: The word ‘<word>’ can’t be used in that sense.
CANT-OPRHAN was added in Starcross and had the static message: That command was incomplete. Why don't you try again?
UNKNOWN-WORD would display the word that is not found in Vocabulary:
[I don't know the word "<word>” in a way that I don't understand.]
and also updates the OOPS-TABLE with the location of the token that is unrecognized.

17.6 Using the TELL Macro

Source code for Infocom games used macros where a specific keyword and associated data would be replaced with code incorporating that extra data. TELL was the universal way of displaying text. However, this could result in repetitive code to display the same kind of text. So, later design guides for Infocom games describes the use of the TELL macro with multiple modifiers. But, the macros would not be replaced with strings of ZIL code but a call to separate routines for displaying text with any additional modifiers such as proper definite and indefinite articles (depending on the type and number of the object) or ending periods and linefeeds. “Learning ZIL” describes these modifiers.  

No comments:

Post a Comment