Routines
| Prev: D448 | Up: Map | Next: D495 |
D46C: Find the exit from the actor's room through door A ($D46C) or to room A ($D471)
|
Addresses named in the title: D471.
Walks the exits of the actor's room (D33C; three-byte entries: direction, door, room, stepped by D206) comparing byte 1 (the door, entry D46C) or byte 2 (the room beyond, entry D471) with A. The offset is written into the instruction at D48B (its displacement byte $D48D) - self-modifying code. Returns IX on the exit, or A = $FF if there is none. D471 is why a room can only be named in a command when it is next door: the room search D39B lets through only rooms it finds.
|
||||||||||||||
| D46C | PUSH AF | Save AF on the stack - Entry for a door: patch the offset in the LD A,(IX+n) at D48B to 1 | ||||||||||||
| D46D | LD A,$01 | Load A with $01 | ||||||||||||
| D46F | JR $D474 | Skip ahead to D474 | ||||||||||||
|
This entry point is used by the routines at C628, C6BE, CAAF, D39B and DD61.
|
||||||||||||||
| D471 | PUSH AF | Save AF on the stack - Entry for a room: patch it to 2 | ||||||||||||
| D472 | LD A,$02 | Load A with $02 | ||||||||||||
| D474 | LD ($D48D),A | Store A in $D48D in "Find the exit from the actor's room through..." | ||||||||||||
| D477 | POP AF | Restore AF from the stack | ||||||||||||
| D478 | PUSH BC | Save BC on the stack | ||||||||||||
| D479 | PUSH IY | Save IY on the stack | ||||||||||||
| D47B | LD B,A | Copy A into B - B = the door or room number | ||||||||||||
| D47C | PUSH DE | Save DE on the stack | ||||||||||||
| D47D | CALL $D33C | Call the routine "IX = record of the actor's room" (D33C) - IX = the actor's room record (D33C), past its six header bytes, at its exits | ||||||||||||
| D480 | LD DE,$0006 | Load DE with $0006, the amount that is added next | ||||||||||||
| D483 | ADD IX,DE | Add DE to IX | ||||||||||||
| D485 | POP DE | Restore DE from the stack | ||||||||||||
| D486 | CALL $D206 | Call the routine "Step to the next 3-byte entry" (D206) - Next exit (D206): Z at the end of the list | ||||||||||||
| D489 | JR Z,$D491 | If the zero flag is set, skip ahead to D491 | ||||||||||||
| D48B | LD A,(IX+$02) | Read byte +2 of the record at IX into A - Its byte 1 (the door) or byte 2 (the room beyond) against B | ||||||||||||
| D48E | CP B | Compare A with B | ||||||||||||
| D48F | JR NZ,$D486 | If A differs from B, go back to D486 | ||||||||||||
| D491 | POP IY | Restore IY from the stack - Z: no such exit; NZ: IX = the exit | ||||||||||||
| D493 | POP BC | Restore BC from the stack | ||||||||||||
| D494 | RET | Return to the caller | ||||||||||||
| Prev: D448 | Up: Map | Next: D495 |