![]() |
Routines |
| Prev: 50359 | Up: Map | Next: 50411 |
|
Used by the routine at GameLoop.
Processes the word tokens from the user's command, checking if any token refers to a game item. If a valid item token is found and the item is present (in the current room or player's inventory), the routine returns successfully. Otherwise, it continues checking tokens until one is found or all tokens have been processed.
|
||||
|
Set up to loop through all word tokens in the token buffer.
|
||||
| Parser_ProcessItem | 50375 | LD HL,48486 | Set a pointer to the word token buffer (UserInput_Token_1) in HL. | |
| 50378 | LD B,10 | Set a counter in B for 10 tokens (the maximum number of words). | ||
|
Check if there are any tokens to process. Return immediately if the first token is the terminator (255), meaning the input was empty.
|
||||
| ProcessItem_Loop | 50380 | LD A,(HL) | Return if the current token is 255 (no more tokens to process). | |
| 50381 | CP 255 | |||
| 50383 | RET Z | |||
|
Check if this token refers to a game item by searching the object list table.
|
||||
| 50384 | PUSH HL | Stash the token pointer and counter on the stack for later restoration. | ||
| 50385 | PUSH BC | |||
| 50386 | LD HL,(48414) | Load the object list table pointer into HL. | ||
| 50389 | LD BC,(48426) | Load the number of objects into BC (for the CPIR search). | ||
| 50393 | CPIR | Search the object list table to see if the token matches any object ID. | ||
| 50395 | JR NZ,ProcessItem_NextToken | Jump to ProcessItem_NextToken if the token doesn't match any object ID (not an item token). | ||
|
The token matches an object ID. Now verify that the item is actually present (in the current room or player's inventory).
|
||||
| 50397 | CALL Action_ExamineItem | Call Action_ExamineItem to check if the item is present and accessible. | ||
| 50400 | JR NC,ProcessItem_NextToken | Jump to ProcessItem_NextToken if the item is not present (carry flag set). | ||
|
The token refers to a valid item that is present. Success!
|
||||
| 50402 | POP BC | Restore the token pointer and counter from the stack. | ||
| 50403 | POP HL | |||
| 50404 | RET | Return successfully (the item was found and is accessible). | ||
|
This token wasn't a valid item or the item isn't present. Move to the next token and continue searching.
|
||||
| ProcessItem_NextToken | 50405 | POP BC | Restore the token pointer and counter from the stack. | |
| 50406 | POP HL | |||
| 50407 | INC HL | Move to the next token in the buffer. | ||
| 50408 | DJNZ ProcessItem_Loop | Decrease the counter by one and loop back to ProcessItem_Loop until all 10 tokens have been checked. | ||
| 50410 | RET | Return (no valid item tokens were found in the input). | ||
| Prev: 50359 | Up: Map | Next: 50411 |