Routines
| Prev: D349 | Up: Map | Next: D36A |
D34E: Find a 3-byte record by id, in a sentinel-terminated table
|
Same shape as CC0E's actor-table search, but for 3-byte records (1 id byte + a 16-bit value) instead of 8-byte ones: given a base in IX and an id in A (via B), walks the table until a record's id matches (found) or reads $FF (end of table). Uses the shadow register set (EXX) internally so it doesn't disturb the caller's own BC/DE/HL while searching.
|
||||||||||||||||||
| D34E | EXX | Switch to the shadow registers to work in | ||||||||||||||||
| D34F | LD E,$03 | Record size is 3 bytes | ||||||||||||||||
|
This entry point is used by the routine at D349.
|
||||||||||||||||||
| D351 | PUSH IX | HL -> the table base the caller passed in IX | ||||||||||||||||
| D353 | POP HL | Restore HL from the stack | ||||||||||||||||
| D354 | LD B,A | B = the id we are looking for | ||||||||||||||||
| D355 | LD D,$00 | Load D with $00 | ||||||||||||||||
| D357 | LD A,(HL) | This record's id byte... | ||||||||||||||||
| D358 | CP B | ...does it match? | ||||||||||||||||
| D359 | JR Z,$D363 | If A equals B, skip ahead to D363 | ||||||||||||||||
| D35B | CP $FF | ...or is it the end-of-table sentinel? | ||||||||||||||||
| D35D | JR Z,$D363 | If A equals $FF, skip ahead to D363 | ||||||||||||||||
| D35F | ADD HL,DE | Neither: move to the next 3-byte record | ||||||||||||||||
| D360 | JP $D357 | Go back to D357 | ||||||||||||||||
| D363 | PUSH HL | |||||||||||||||||
| D364 | POP IX | Restore IX from the stack | ||||||||||||||||
| D366 | CP $FF | |||||||||||||||||
| D368 | EXX | Back to the normal registers | ||||||||||||||||
| D369 | RET | Return to the caller | ||||||||||||||||
| Prev: D349 | Up: Map | Next: D36A |