![]()  | 
Routines | 
| Prev: 44672 | Up: Map | Next: 44753 | 
| 
 
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 | 44719 | LD HL,43044 | Set a pointer to UserInput_Token_1 in HL. | |||||||
| 44722 | LD B,10 | Set a token count in B of 10 which is the total length of the user input tokens. | ||||||||
| 44724 | LD E,0 | Initialise the item counter held in E to 0. | ||||||||
| Parser_CountItems_Loop | 44726 | LD A,(HL) | Fetch a user input token. | |||||||
| 44727 | CP 255 | Jump to Parser_CountItems_Process if the terminator character (255) has been reached. | ||||||||
| 44729 | JR Z,Parser_CountItems_Process | |||||||||
| 44731 | PUSH HL | Stash the token pointer and token counter on the stack. | ||||||||
| 44732 | PUSH BC | |||||||||
| 44733 | LD HL,(42968) | HL=*Pointer_TokenItemList. | ||||||||
| 44736 | LD BC,(42984) | Fetch the count of the number of items in the table from *Count_Items. | ||||||||
| 44740 | CPIR | Search to see if the item ID is in the table. | ||||||||
| 44742 | POP BC | Restore the token counter and token pointer from the stack. | ||||||||
| 44743 | POP HL | |||||||||
| 44744 | 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.
 
 | 
||||||||||
| 44746 | INC E | Increment item counter by one. | ||||||||
| Parser_CountItems_Skip | 44747 | INC HL | Move to the next token. | |||||||
| 44748 | 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 | 44750 | XOR A | Transfer the item count into A and set flags accordingly. | |||||||
| 44751 | OR E | |||||||||
| 44752 | RET | Return. | ||||||||
| 
 
View the equivalent code in The Jewels Of Babylon.
 
 | 
||||||||||
| Prev: 44672 | Up: Map | Next: 44753 |