![]()  | 
Routines | 
| Prev: 40343 | Up: Map | Next: 40409 | 
| 
 
Used by the routines at Start, Drawing, DisplayLocHlpMsg, Action_Dir, Action_Examine, 39557, 39809, LocateObject and 42335.
 
 
  | 
||||||||||||||
| 
 
Searches through what is essentially key value data to find a key match.
 
 | 
||||||||||||||
| IndexIdTable | 40381 | EXX | Exchange registers. | |||||||||||
| 40382 | PUSH IX | HL=IX (using the stack to do so). | ||||||||||||
| 40384 | POP HL | |||||||||||||
| 40385 | LD B,A | B=key ID | ||||||||||||
| 40386 | LD E,3 | DE=$0003 as each record is 3 bytes of data. | ||||||||||||
| 40388 | LD D,0 | |||||||||||||
| 
 
Begin searching the table.
 
 | 
||||||||||||||
| IndexIdTable_Loop | 40390 | LD A,(HL) | Grab the next ID. | |||||||||||
| 40391 | CP B | If the key ID is the one we want, jump to IndexIdTable_Found. | ||||||||||||
| 40392 | JR Z,IndexIdTable_Found | |||||||||||||
| 40394 | CP 255 | If we've reached the termination character (key ID not found), jump to IndexIdTable_Found. | ||||||||||||
| 40396 | JR Z,IndexIdTable_Found | |||||||||||||
| 40398 | ADD HL,DE | Add DE to HL to check the next row, and jump back to IndexIdTable_Loop to continue checking. | ||||||||||||
| 40399 | JP IndexIdTable_Loop | |||||||||||||
| 
 
Handle the output.
 
 | 
||||||||||||||
| IndexIdTable_Found | 40402 | PUSH HL | IX=HL (using the stack to do so). | |||||||||||
| 40403 | POP IX | |||||||||||||
| 40405 | CP 255 | Set flags (checking if the key ID was not found). | ||||||||||||
| 40407 | EXX | Exchange registers. | ||||||||||||
| 40408 | RET | Return. | ||||||||||||
| Prev: 40343 | Up: Map | Next: 40409 |