Prev: C4B7 Up: Map Next: C4EB
C4C7: Parser: Process Item
Used by the routine at GameLoop.
Checks that every object the command names is here. For each word in UserInput_Token_1 that is an object, Parser_CheckObjectIsHere looks for one of its items in the current room or the inventory. If none is there, Parser_CheckObjectIsHere has already said so, and this returns with the carry flag set so that the game loop at GameLoop skips the command.
Set up to loop through all word tokens in the token buffer.
Parser_ProcessItem C4C7 LD HL,$BD66 Set a pointer to the word token buffer (UserInput_Token_1) in HL.
C4CA LD B,$0A Set a counter in B for 0A tokens (the maximum number of words).
Check if there are any tokens to process. Return immediately if the first token is the terminator (FF), meaning the input was empty.
ProcessItem_Loop C4CC LD A,(HL) Return if the current token is FF (no more tokens to process).
C4CD CP $FF
C4CF RET Z
Check if this token refers to a game item by searching the object list table.
C4D0 PUSH HL Stash the token pointer and counter on the stack for later restoration.
C4D1 PUSH BC
C4D2 LD HL,($BD1E) Load the object list table pointer into HL.
C4D5 LD BC,($BD2A) Load the number of objects into BC (for the CPIR search).
C4D9 CPIR Search the object list table to see if the token matches any object ID.
C4DB JR NZ,ProcessItem_NextToken Jump to ProcessItem_NextToken if the token doesn't match any object ID (not an item token).
The token matches an object ID. Now verify that the item is actually present (in the current room or player's inventory).
C4DD CALL Parser_CheckObjectIsHere Call Parser_CheckObjectIsHere to check if the item is present and accessible.
C4E0 JR NC,ProcessItem_NextToken Jump to ProcessItem_NextToken if the object is here (carry flag clear).
The object isn't here and Parser_CheckObjectIsHere has printed why.
C4E2 POP BC Restore the token pointer and counter from the stack.
C4E3 POP HL
C4E4 RET Return with the carry flag set.
This word isn't an object, or the object is here. Move on to the next word.
ProcessItem_NextToken C4E5 POP BC Restore the token pointer and counter from the stack.
C4E6 POP HL
C4E7 INC HL Move to the next token in the buffer.
C4E8 DJNZ ProcessItem_Loop Decrease the counter by one and loop back to ProcessItem_Loop until all 0A tokens have been checked.
C4EA RET Return (every object named is here).
Prev: C4B7 Up: Map Next: C4EB