![]() |
Routines |
Prev: C37F | Up: Map | Next: C3D0 |
Count how many tokens in the user input refer to game items.
|
||||||||||||
Parser_CountItems | C3AE | LD HL,$BD66 | Set a pointer to UserInput_Token_1 in HL. | |||||||||
C3B1 | LD B,$0A | Set a token count in B of 0A which is the total length of the user input tokens. | ||||||||||
C3B3 | LD E,$00 | Initialise the item counter held in E to 00. | ||||||||||
Parser_CountItems_Loop | C3B5 | LD A,(HL) | Fetch a user input token. | |||||||||
C3B6 | CP $FF | Jump to Parser_CountItems_Process if the terminator character (FF) has been reached. | ||||||||||
C3B8 | JR Z,Parser_CountItems_Process | |||||||||||
C3BA | PUSH HL | Stash the token pointer and token counter on the stack. | ||||||||||
C3BB | PUSH BC | |||||||||||
C3BC | LD HL,($BD1E) | HL=*Pointer_ObjectList. | ||||||||||
C3BF | LD BC,($BD2A) | Fetch the count of the number of items in the table from *Count_Objects. | ||||||||||
C3C3 | CPIR | Search to see if the item room ID is in the table. | ||||||||||
C3C5 | POP BC | Restore the token counter and token pointer from the stack. | ||||||||||
C3C6 | POP HL | |||||||||||
C3C7 | 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.
|
||||||||||||
C3C9 | INC E | Increment item counter by one. | ||||||||||
Parser_CountItems_Skip | C3CA | INC HL | Move to the next token. | |||||||||
C3CB | 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 | C3CD | XOR A | Transfer the item count into A and set flags accordingly. | |||||||||
C3CE | OR E | |||||||||||
C3CF | RET | Return. |
Prev: C37F | Up: Map | Next: C3D0 |