![]() |
Routines |
| Prev: 40343 | Up: Map | Next: 40409 |
|
Used by the routines at Start, Drawing, DisplayLocateHelpMessage, Action_Direction, Turn_RunTheActionHandler, Turn_RunTheHandlerIfPresent, Turn_UseASpecialObject, TableFindAnActionRecord, LocateObject and Event_DayDawnsOnTheTrolls.
Looks an id up in a table of id-and-address pairs.
|
||||||||||||||
|
Searches through what is essentially key value data to find a key match.
|
||||||||||||||
| IndexIdTable | 40381 | EXX | Exchange registers. | |||||||||||
| 40382 | PUSH IX | Point HL at the table in IX and keep the sought id in B. | ||||||||||||
| 40384 | POP HL | |||||||||||||
| 40385 | LD B,A | |||||||||||||
| 40386 | LD E,3 | Each index entry is 3 bytes. | ||||||||||||
| 40388 | LD D,0 | The index stride's high byte is zero. | ||||||||||||
|
Begin searching the table.
|
||||||||||||||
| IndexIdTable_Loop | 40390 | LD A,(HL) | Grab the next ID. | |||||||||||
| 40391 | CP B | Jump to IndexIdTable_Found if this entry's id is the one sought. | ||||||||||||
| 40392 | JR Z,IndexIdTable_Found | |||||||||||||
| 40394 | CP 255 | Jump to IndexIdTable_Found at the end of the index. | ||||||||||||
| 40396 | JR Z,IndexIdTable_Found | |||||||||||||
| 40398 | ADD HL,DE | Step 3 bytes to the next id. | ||||||||||||
| 40399 | JP IndexIdTable_Loop | Jump back to IndexIdTable_Loop to begin searching the table. | ||||||||||||
|
Handle the output.
|
||||||||||||||
| IndexIdTable_Found | 40402 | PUSH HL | Set flags (checking if the key ID was not found). | |||||||||||
| 40403 | POP IX | |||||||||||||
| 40405 | CP 255 | |||||||||||||
| 40407 | EXX | Exchange registers. | ||||||||||||
| 40408 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: 40343 | Up: Map | Next: 40409 |