Prev: D317 Up: Map Next: D33F
D320: Put the player in the doorway he came through
Used by the routine at build_room.
When the player walks out of a room, the exit code (screen_west and its three neighbours, ending at exit_screen) moves him to the next room number and sets the coordinate he left by to an extreme -- X to 0 on leaving towards -X, $FF towards +X, and the same for Y. That extreme says which side of the new room he enters from, and this routine moves him to that side, with his inner side two units inside the room's edge and the rest of him in the doorway. His Z is then set to the floor of the arch there (adjust_plyr_Z_for_arch).
The names follow the compass used for the arches: +X is east, +Y north. If no coordinate is at an extreme -- the start of a life -- nothing is changed.
$5BAB and $5BAC are the room's X and Y half-sizes, measured from the centre, $80.
Input
IX object 0, the player's legs
adjust_plyr_xyz_for_room_size D320 LD A,($5BAB)
D323 SUB $02
D325 LD L,A
D326 LD A,($5BAC)
D329 SUB $02
D32B LD H,A
D32C LD A,(IX+$01) X = 0: came in on the east side
D32F AND A
D330 JR Z,enter_arch_e X = $FF: the west side
D332 INC A
D333 JR Z,enter_arch_w
D335 LD A,(IX+$02) Y = 0: the north side
D338 AND A
D339 JR Z,enter_arch_n Y = $FF: the south side; otherwise stay put
D33B INC A
D33C JR Z,enter_arch_s
D33E RET
Prev: D317 Up: Map Next: D33F