Prev: ABF4 Up: Map Next: AC1D
AC02: 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 AC02 LD A,($A13C) Fetch the second token from the user input and store it in A.
AC05 CP $FF Jump forward to DirectObject_Process if the token is anything other than the terminator character (FF).
AC07 JR NZ,DirectObject_Process
The token was the terminator character (FF), so the sentence is malformed.
E.g. They tried "TAKE" but didn't write anything after it.
Print "Please be more specific.".
AC09 LD HL,$0017 HL=Messaging_PleaseBeMoreSpecific.
AC0C CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
AC0F SCF Set the carry flag to indicate this call was a failure.
AC10 RET Return.
Process the direct object.
DirectObject_Process AC11 CALL Parser_CountItems Call Parser_CountItems.
AC14 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.".
AC15 LD HL,$0018 HL=Messaging_PleaseRephraseThat.
AC18 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
AC1B SCF Set the carry flag to indicate the command is malformed.
AC1C RET Return.
View the equivalent code in;
Prev: ABF4 Up: Map Next: AC1D