Prev: C470 Up: Map Next: C490
C47B: Parser: Validate 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
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 C47B LD A,($BD67) Fetch the second token from the user input and store it in A.
C47E CP $FF Jump forward to DirectObject_Process if the token is anything other than the terminator character (FF).
C480 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.
C482 CALL Response_PleaseBeMoreSpecific Call Response_PleaseBeMoreSpecific.
C485 SCF Set the carry flag to indicate this call was a failure.
C486 RET Return.
Process the direct object.
DirectObject_Process C487 CALL Parser_CountItems Call Parser_CountItems.
C48A RET NZ Return if A is not equal to FF.
C48B CALL Response_PleaseRephraseThat Call Response_PleaseRephraseThat.
C48E SCF Set the carry flag to indicate the command is malformed.
C48F RET Return.
Prev: C470 Up: Map Next: C490