Prev: 44020 Up: Map Next: 44061
44034: Parser: Validate Direct Object
Used by the routine at Parser_ValidateTwoDirectObjects.
In most adventure games, the structure for a command is "verb + direct object". This is usually how the player interacts with the game world. The verb describes the action, and the direct object is what the action is performed on. For example; "TAKE SHOE" uses the verb "TAKE" on the direct object "SHOE".
Output
A The number of references to items in the user input tokens
F The carry flag is set when the command is malformed
The first token is the verb, so target the second token for the direct object.
Parser_ValidateDirectObject 44034 LD A,(41276) Fetch the second token from the user input and store it in A.
44037 CP 255 Jump forward to DirectObject_Process if the token is anything other than the terminator character (255).
44039 JR NZ,DirectObject_Process
The token was the terminator character (255), so the sentence is malformed.
E.g. They tried "TAKE" but didn't write anything after it.
Print "Please be more specific.".
44041 LD HL,23 HL=Messaging_PleaseBeMoreSpecific.
44044 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
44047 SCF Set the carry flag to indicate this call was a failure.
44048 RET Return.
Process the direct object.
DirectObject_Process 44049 CALL Parser_CountItems Call Parser_CountItems.
44052 RET NZ Return if there is at least one valid item mentioned in the user input tokens.
Any references are invalid.
Print "Please rephrase that.".
44053 LD HL,24 HL=Messaging_PleaseRephraseThat.
44056 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
44059 SCF Set the carry flag to indicate the command is malformed.
44060 RET Return.
View the equivalent code in;
Prev: 44020 Up: Map Next: 44061