Prev: AC2F Up: Map Next: AC60
AC4D: Parser: Validate Any Direct Object
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 valid direct objects in the user input tokens
F The carry flag is set when the command is malformed
F The zero flag is set when there are no valid direct objects present in the input tokens
The first token is the verb, so target the second token for the direct object.
Parser_ValidateAnyDirectObject AC4D LD A,($A13C) Fetch the second token from the user input and store it in A.
AC50 CP $FF Jump forward to ValidateAnyDirectObject if the token is anything other than the terminator character (FF).
AC52 JR NZ,ValidateAnyDirectObject
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.".
AC54 LD HL,$0017 HL=Messaging_PleaseBeMoreSpecific.
AC57 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
AC5A SCF Set the carry flag to indicate this call was a failure.
AC5B RET Return.
The user input tokens have a direct object, return how many are in the command buffer.
ValidateAnyDirectObject AC5C CALL Parser_CountItems Call Parser_CountItems.
AC5F RET Return.
View the equivalent code in;
Prev: AC2F Up: Map Next: AC60