![]() |
Routines |
Prev: 50047 | Up: Map | Next: 50128 |
Count how many tokens in the user input refer to game items.
|
||||||||||
Parser_CountItems | 50094 | LD HL,48486 | Set a pointer to UserInput_Token_1 in HL. | |||||||
50097 | LD B,10 | Set a token count in B of 10 which is the total length of the user input tokens. | ||||||||
50099 | LD E,0 | Initialise the item counter held in E to 0. | ||||||||
Parser_CountItems_Loop | 50101 | LD A,(HL) | Fetch a user input token. | |||||||
50102 | CP 255 | Jump to Parser_CountItems_Process if the terminator character (255) has been reached. | ||||||||
50104 | JR Z,Parser_CountItems_Process | |||||||||
50106 | PUSH HL | Stash the token pointer and token counter on the stack. | ||||||||
50107 | PUSH BC | |||||||||
50108 | LD HL,(48414) | HL=*Pointer_ObjectList. | ||||||||
50111 | LD BC,(48426) | BC=*Count_Objects. | ||||||||
50115 | CPIR | CPIR. | ||||||||
50117 | POP BC | Restore the token counter and token pointer from the stack. | ||||||||
50118 | POP HL | |||||||||
50119 | 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.
|
||||||||||
50121 | INC E | Increment item counter by one. | ||||||||
Parser_CountItems_Skip | 50122 | INC HL | Move to the next token. | |||||||
50123 | 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 | 50125 | XOR A | Transfer the item count into A and set flags accordingly. | |||||||
50126 | OR E | |||||||||
50127 | RET | Return. |
Prev: 50047 | Up: Map | Next: 50128 |