Prev: 42523 Up: Map Next: 42616
42544: 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 42544 LD A,(38659) Fetch the room of the player from 38659.
42547 CP (IX+1) Compare with the room of the actor.
42550 RET Z Return if the actor is in the same room as the player.
42551 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.
42552 RRCA Rotate the room of the player right four times.
42553 RRCA
42554 RRCA
42555 RRCA
42556 AND %00001111 Keep only bits 0-3.
42558 LD C,A Stash the row of the player in C.
42559 LD A,(IX+1) Fetch the room of the actor.
42562 RRCA Rotate the room of the actor right four times.
42563 RRCA
42564 RRCA
42565 RRCA
42566 AND %00001111 Keep only bits 0-3.
42568 SUB C Subtract the row of the player to get the number of rows between them.
42569 JP P,BringActorCloser_Distance Jump to BringActorCloser_Distance if the number of rows is positive.
42572 NEG Make the number of rows positive.
BringActorCloser_Distance 42574 CP 2 Compare with 2.
42576 RET C Return if the actor is less than two rows away.
Choose the row above or below the player at random.
42577 LD A,(38549) Fetch the random seed from RandomNumber.
42580 AND %00000001 Keep only bit 0.
42582 JR NZ,ChooseRoomBelow Jump to ChooseRoomBelow to use the row below the player if bit 0 is set.
42584 LD A,B Fetch the room of the player.
42585 SUB 16 Subtract 16 to get the room above.
This entry point is used by the routine at ChooseRoomBelow.
BringActorCloser_CheckRoom 42587 JR C,ChoosePlayerRoom Jump to ChoosePlayerRoom if there is no room above.
This entry point is used by the routine at ChoosePlayerRoom.
BringActorCloser_Room 42589 AND %11111100 Keep only bits 2-7 (the row, and the column in groups of four).
42591 LD C,A Stash the result in C.
42592 LD A,(IX+1) Fetch the room of the actor.
42595 AND %00000011 Keep only bits 0-1.
42597 OR C Merge in the new room.
42598 CP B Compare with the room of the player.
42599 RET Z Return if the new room is the room of the player.
Put the actor in the new room.
42600 LD (IX+1),A Set the new room of the actor.
42603 CALL HandlerOrchidPosition Find the position of the actor in the new room.
42606 LD A,(HL) Fetch the X position from the table.
42607 LD (IX+3),A Set the X position of the actor.
42610 INC HL Move onto the Y position.
42611 LD A,(HL) Fetch the Y position from the table.
42612 LD (IX+4),A Set the Y position of the actor.
42615 RET Return.
Prev: 42523 Up: Map Next: 42616