Sunday, April 21, 2019

Chapter 13. Search for Objects using SEARCH-LIST (part 1)

13.1 Introduction

Another one of the interesting aspects of Infocom games is how it searches and matches objects to those requested by the player. It will use various methods to find these objects and collect them into a table.

13.2 SEARCH-LIST: Finding Objects in Room and on Winner

  • Arguments: Number to Object to search inside, Address to object table, Search level (0-2)
  • Return: Number of objects found
When the user refers to objects in a command, PARSER needs to see which objects are referred and accessible. The given noun, adjective, and/or GWIMBIT will be used as identifiers for a particular object. SEARCH-LIST will check the objects in a given location (a room or person) and see if it matches these identifiers. There are 3 levels of search which affects which objects are checked:
  • Search-TOP/Type 0: ON-GROUND or HELD (reachable objects)
    • Look at objects that are on “top” of all objects
    • Match against all non-container objects and objects on surfaces in the location. Any containers (if they are open or transparent) and surfaces on the surface are checked completely.
  • Search-ALL/Type 1 (all objects)
    • Match against all objects in the location. Only containers that are open or transparent will be searched.
  • Search-BOT/Type 2: IN-ROOM or CARRIED (contained objects)
    • Look inside any containers (look at second-level or any non-top level)
    • Match against all objects on any surface and inside any open or transparent container.
The matched objects are saved in the table addressed passed to SEARCH-LIST.


For example, SEARCH-LIST is examining Room/Person 1. For each search mode, the listed objects will be checked:
TOP: Obj 1,1, Surface 1,2 (Obj 1,2,1, Cont 1,2,2 (Obj 1,2,2,1))
BOT: Surface 1,2, Cont 1,4 (Obj 1,4,1, Surface 1,4,2 (Obj 1,4,2,1), Cont 1,4,3 (Obj 1,4,3,1))
ALL: Obj 1,1, Surface 1,2 (Obj 1,2,1, Cont 1,2,2 (Obj 1,2,2,1)), Surface 1,2, Cont 1,4 (Obj 1,4,1, Surface 1,4,2 (Obj 1,4,2,1), Cont 1,4,3 (Obj 1,4,3,1))
Object Cont 1,3 is invisible.
All Infocom games appeared to be using the same SEARCH-LIST routine.

13.3 DO-SL: Find Objects Based Upon Search Level

  • Arguments: Number of object to search,  LOC value to SRC-TOP, LOC value to SRC-BOT
  • Return: Number of objects found
DO-SL calls SEARCH-LIST with the appropriate search type depending on the LOC flags given in the arguments and the LOC flags in the matched syntax entry. If 1 is used for both DO-SL arguments then, SEARCH-LIST will perform a SRC-ALL match. All matched objects will be saved in P-TABLE.
GET-OBJECT calls DO-SL with the ON-GROUND and IN-ROOM flags to look for any objects in the given location for use with the current syntax entry. Similarly, GET-OBJECT also calls it with the HELD and CARRIED flags to look for objects on the PLAYER. All other calls to DO-SL seem to mainly use the double 1 parameter which will match anything.
All Infocom games appeared to be using the same DO-SL routine.

13.4 GLOBAL-CHECK: Look for Objects Everywhere

  • Arguments: Address to object table
  • Return: True if GLOBALs checked, False if object matched from local-globals or PSEUDO objects
Some objects in a game may be accessible from more than one locations and valid objects to be used with certain actions. GLOBAL-CHECK is the routine that tries to find these potentially valid objects. Infocom had three different types of these special objects: GLOBALS, LOCAL-GLOBALS, and PSEUDO objects.
GLOBALS can be accessed from any location in the game. If a game had an AIR object, that would likely be accessible from any location. Remember, these are not necessarily rooms. LOCAL-GLOBALS are accessible from multiple locations but not all. The best example is a door which would be accessible from the two rooms that are separated by it. PSEUDO (or virtual) objects are the most confusing of the three objects as they are not actual objects. They only have the SYNONYMS (nouns) and ACTION properties. A given location can have PSEUDO objects that are matched if certain nouns are used in that location. The routine then jumps to a different routine for each noun that will figure out what is the object the user was referencing. So a bed object in two different rooms could be handled with a routine instead of creating multiple objects.
GLOBAL-CHECK will first try to match any identifiers (noun/NAM, adj/ADJ, or GWIMBIT) to any object in the GLOBAL property (AKA LOCAL-GLOBALS) of the current location. The number to any matched objects will be added to P-TABLE. The routine does not search inside the local-global objects. Next, the PSEUDO property is checked which contains a list of 2 word pairs. The first word is the Vocabulary address to the noun that references the pseudo object while the second word is an ACTION routine address. If the object matches, the Z-string of the matching noun and ACTION addresses are saved into a pseudo object’s description and ROUTINE properties, respectively, which is then saved to P-TABLE. GLOBAL-CHECK will continue to check the remaining objects in PSEUDO and save any matches.  If no objects have matched by this point, the GLOBAL-OBJECTS are searched using DO-SL on GLOBAL-OBJECTS. SLOC-BITS is temporarily set to $FFFF which makes any match valid and restored afterwards.

13.5 THIS-IT?

  • Arguments: Object number
  • Return: True if object matches
Infocom games can use three different identifiers to see if an object matches the one requested in a command: noun (P-NAM), adjective(P-ADJ), and GWIMBIT. THIS-IT? will see if the given object matches any of these identifiers. First, the routine will see if the object is visible. So invisible (or hidden) objects cannot be matched. THIS-IT? will then see if the given noun (if it exists) matches any of the Vocabulary addresses in the SYNONYMS property of the object. It will do a similar check with the given adjective (if it exists) with the addresses in the ADJECTIVE property. Finally, it will see if the GWIMBIT (if given) is set on the object. If the given information matches, THIS-IT? returns true.

No comments:

Post a Comment