Prev: 9ED6 Up: Map Next: 9F25
9F08: Find the actor's room's exit in a direction
Used by the routines at MOVE and DO_RUN.
Walks the exits for one whose direction matches and whose destination is not zero, and returns with IX on it. Watched as well as read: rewinding from the moment the player's location changed on EAST out of Bag End to where this returned found IX at ROOM1_EAST, the direction 3, and the record 03 05 04 -- east, through the round green door, to location 4.
Input
A The direction, 1-10
Output
IX The exit
F NZ if there is one
FIND_EXIT 9F08 PUSH BC
9F09 PUSH IY
9F0B LD B,A B = the direction wanted
9F0C CALL FIRST_EXIT IX just before the actor's room's first exit
FIND_EXIT_0 9F0F CALL NEXT_EXIT Next exit, or give up at the end of the list
9F12 JR Z,FIND_EXIT_1
9F14 LD A,(IX+$02) An exit leading to location 0 goes nowhere yet: pass over it
9F17 AND A
9F18 JR Z,FIND_EXIT_0
9F1A LD A,(IX+$00) Not the direction wanted: keep looking
9F1D CP B
9F1E JP NZ,FIND_EXIT_0
FIND_EXIT_1 9F21 POP IY
9F23 POP BC
9F24 RET
Prev: 9ED6 Up: Map Next: 9F25