Sunday, April 21, 2019

Chapter 15. It's Time to Perform with PERFORM

15.1 Introduction

At this point, all necessary information should be checked and processed. All the direct and indirect objects and the action number to use those objects have been found. Many combinations of objects and actions can be handled by the specific action routine. The designer of Infocom games understood that many actions on objects could be handled with a generic verb action routine. Any special circumstances usually depend on the objects used. Therefore, these circumstances could be checked when accessing those objects and not clutter up a generic verb action routine.

15.2 Checks and Order

Since action routines can call PERFORM separately from PARSER to perform functions that mimic a command, PERFORM does not use the global PRSA, PRSO, and PRSI but will be passed a separate action, direct object, and indirect object arguments. It then temporarily saves the current PRSA, PRSO, and PRSI.
  1. PERFORM will check for the IT object in the direct or indirect object. If so, it will be replaced with the previously referenced object for IT.
  2. It will copy all the given arguments (action, direct object, and indirect object values) into the appropriate global variables (PRSA, PRSO, PRSI).
  3. If the given action is not GO, PERFORM will then update the IT object to the just given direct object argument and update the location of the winner to the current location.
  4. If the given action is not AGAIN, PERFORM will update the global variables for the last action number, direct object, and indirect object. These are used by the AGAIN command.
After updating the necessary variables, PERFORM will call various routines to handle the action on the objects. A non-handled action (by returning M-NOT-HANDLE) will be passed to the next possible routine to handle it. The order of handler preference is below:
  1. WINNER’s action routine
  2. WINNER’s location’s action routine with M-BEG argument
  3. Verb (PRSA) pre-action routine
  4. Indirect object (PRSI) action routine
  5. Direct object (PRSO) action routine (skipping if the action is GO)
  6. Verb (PRSA) action routine
ACTION routines for objects and rooms can be passed standard RARG values for a specific type of function to perform. Any needed objects can be found in PRSO and PRSI. The routine will then return an action return value. If the routine can successfully complete a function, then M-HANDLED is return. PERFORM will skip over all other subsequent handlers. If the routine cannot handle a function, M-NOT-HANDLED is returned. PERFORM will then try other handlers to handle the function. The verb action routine is considered the default handle routine and can always handle an action. It usually displays a generic message. Once a function has been handled, the current room’s ACTION routine is sent M-END to handle any remaining functions before the turn is completed. If M-FATAL is ever returned by an action, then PERFORM will exit immediately and return M-FATAL. Also, the current room’s ACTION routine is not called with M-END. Before PERFORM returns, the previous values of PRSA, PRSO, and PRSI are restored.
Room Arguments (RARG)
Action Return Values
  • M-END, 0
  • M-BEG, 1
  • M-LOOK, 3
  • M-FLASH, 4
  • M-OBJDESC, 5
  • M-NOT-HANDLED, 0
  • M-HANDLED, 1
  • M-FATAL, 2
Objects trying to handle actions may need to double check which object is the direct and indirect object. In an example from Infocom:

        TAKE SWORD FROM THE STONE

would have the STONE object process the TAKE action first. In that case, the STONE could interpret the user trying to take the STONE. To prevent this, STONE object could see if it is the PRSI before handling the action.
Later ZIP 3 games also included checking an object’s CONTFCN (container function) before having the direct object try to handle the action. This was only called in those rare situations (such as in Starcross) where the direct object’s container would try to handle an action.

15.3 THIS-IS-IT


Starting with Sorcerer, PERFORM calls THIS-IS-IT after acting upon the PRSO and PRSI to update the IT-OBJECT. The PRSO value is stored as the IT-OBJECT value. Planetfall would introduce saving the location of the IT-OBJECT as well in a separate global variable. Wishbringer added other pronouns objects (HIM-OBJECT, HER-OBJECT, and THEM-OBJECT) along with their associated global variables which would be updated if needed based upon the attributes of the PRSO (such as gender or being plural). The routine is also called from other parts of the game like ITAKE-CHECK and specific action routines. It was only used in LGOP,  MoonmistHollywood HijinxStationfall, and Plundered Hearts.

No comments:

Post a Comment