Prev: B575 Up: Map Next: B5C6
B5A4: Parser: Count Item References
Parser: Count Item References.
Output
A The number of references to items in the user input tokens
E As A
F The Z flag is set when there are no items present in the input
ParserCountItemReferences B5A4 LD HL,$AF2E Set a pointer to the first word token in HL.
B5A7 LD B,$0A Set a token count in B of 0A which is the total length of the user input tokens.
B5A9 LD E,$00 Initialise the item counter held in E to 00.
Parser_CountItems_Loop B5AB LD A,(HL) Fetch a user input token.
B5AC CP $FF Jump to Parser_CountItems_Process if the terminator character (FF) has been reached.
B5AE JR Z,Parser_CountItems_Process
B5B0 PUSH HL Remember the token and the count while the object list is searched.
B5B1 PUSH BC
B5B2 LD HL,($AEE2) Load the pointer for the character-set pointer into HL.
B5B5 LD BC,($AEF2) Fetch the count of the number of items in the table from the object count.
B5B9 CPIR Search to see if the item room ID is in the table.
B5BB POP BC Restore BC, HL from the stack.
B5BC POP HL
B5BD JR NZ,Parser_CountItems_Skip Jump to Parser_CountItems_Skip if this token doesn't refer to a game item.
This token does point to a game item, so increase the item counter.
B5BF INC E Increment item counter by one.
Parser_CountItems_Skip B5C0 INC HL Move to the next token.
B5C1 DJNZ Parser_CountItems_Loop Decrease the token counter by one and loop back to Parser_CountItems_Loop until all the tokens have been evaluated.
Parser_CountItems_Process B5C3 XOR A Leave the number of items named in the command in A. The zero flag is set when none were named.
B5C4 OR E
B5C5 RET Return.
Prev: B575 Up: Map Next: B5C6