Prev: A61B Up: Map Next: A678
A630: Bring Actor Closer
Used by the routines at HandlerSleepingHippoWarthog and HandlerTribesman.
Moves an actor which is two or more rows of rooms away from the player to a room in the row above or below the player (never the player's own room), placing it at the position in TableOrchidPositions for the layout of the new room. Half of the time it is moved to the row above, and half of the time to the row below.
Input
IX Actor record
BringActorCloser A630 LD A,($9703) Fetch the room of the player from 9703.
A633 CP (IX+$01) Compare with the room of the actor.
A636 RET Z Return if the actor is in the same room as the player.
A637 LD B,A Stash the room of the player in B.
Work out how many rows of rooms are between the player and the actor.
A638 RRCA Rotate the room of the player right four times.
A639 RRCA
A63A RRCA
A63B RRCA
A63C AND %00001111 Keep only bits 0-3.
A63E LD C,A Stash the row of the player in C.
A63F LD A,(IX+$01) Fetch the room of the actor.
A642 RRCA Rotate the room of the actor right four times.
A643 RRCA
A644 RRCA
A645 RRCA
A646 AND %00001111 Keep only bits 0-3.
A648 SUB C Subtract the row of the player to get the number of rows between them.
A649 JP P,BringActorCloser_Distance Jump to BringActorCloser_Distance if the number of rows is positive.
A64C NEG Make the number of rows positive.
BringActorCloser_Distance A64E CP $02 Compare with 02.
A650 RET C Return if the actor is less than two rows away.
Choose the row above or below the player at random.
A651 LD A,($9695) Fetch the random seed from RandomNumber.
A654 AND %00000001 Keep only bit 0.
A656 JR NZ,ChooseRoomBelow Jump to ChooseRoomBelow to use the row below the player if bit 0 is set.
A658 LD A,B Fetch the room of the player.
A659 SUB $10 Subtract 10 to get the room above.
This entry point is used by the routine at ChooseRoomBelow.
BringActorCloser_CheckRoom A65B JR C,ChoosePlayerRoom Jump to ChoosePlayerRoom if there is no room above.
This entry point is used by the routine at ChoosePlayerRoom.
BringActorCloser_Room A65D AND %11111100 Keep only bits 2-7 (the row, and the column in groups of four).
A65F LD C,A Stash the result in C.
A660 LD A,(IX+$01) Fetch the room of the actor.
A663 AND %00000011 Keep only bits 0-1.
A665 OR C Merge in the new room.
A666 CP B Compare with the room of the player.
A667 RET Z Return if the new room is the room of the player.
Put the actor in the new room.
A668 LD (IX+$01),A Set the new room of the actor.
A66B CALL HandlerOrchidPosition Find the position of the actor in the new room.
A66E LD A,(HL) Fetch the X position from the table.
A66F LD (IX+$03),A Set the X position of the actor.
A672 INC HL Move onto the Y position.
A673 LD A,(HL) Fetch the Y position from the table.
A674 LD (IX+$04),A Set the Y position of the actor.
A677 RET Return.
Prev: A61B Up: Map Next: A678