![]() |
Routines |
Prev: AE80 | Up: Map | Next: AED1 |
Used by the routines at Parser_ValidateDirectObject, Parser_ValidateInputTokens and Parser_ValidateAnyDirectObject.
Count how many tokens in the user input refer to game items.
|
||||||||||
Parser_CountItems | AEAF | LD HL,$A824 | Set a pointer to UserInput_Token_1 in HL. | |||||||
AEB2 | LD B,$0A | Set a token count in B of 0A which is the total length of the user input tokens. | ||||||||
AEB4 | LD E,$00 | Initialise the item counter held in E to 00. | ||||||||
Parser_CountItems_Loop | AEB6 | LD A,(HL) | Fetch a user input token. | |||||||
AEB7 | CP $FF | Jump to Parser_CountItems_Process if the terminator character (FF) has been reached. | ||||||||
AEB9 | JR Z,Parser_CountItems_Process | |||||||||
AEBB | PUSH HL | Stash the token pointer and token counter on the stack. | ||||||||
AEBC | PUSH BC | |||||||||
AEBD | LD HL,($A7D8) | HL=*Pointer_ObjectList. | ||||||||
AEC0 | LD BC,($A7E8) | Fetch the count of the number of items in the table from *Count_Objects. | ||||||||
AEC4 | CPIR | Search to see if the item room ID is in the table. | ||||||||
AEC6 | POP BC | Restore the token counter and token pointer from the stack. | ||||||||
AEC7 | POP HL | |||||||||
AEC8 | 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.
|
||||||||||
AECA | INC E | Increment item counter by one. | ||||||||
Parser_CountItems_Skip | AECB | INC HL | Move to the next token. | |||||||
AECC | 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 | AECE | XOR A | Transfer the item count into A and set flags accordingly. | |||||||
AECF | OR E | |||||||||
AED0 | RET | Return. | ||||||||
View the equivalent code in The Jewels Of Babylon.
|
Prev: AE80 | Up: Map | Next: AED1 |