Prev: C5D3 Up: Map Next: C613
C5E9: Shorten dU at the walls
Used by the routine at ADJ_FOR_OUT_OF_BOUNDS.
Keeps the object's whole footprint within the room: its U after the move no further from 128 than the room's U half-size (ROOM_HALF_U, 64 or 32) less its own half-size. dU is shortened a unit at a time, and bit 0 of +$0C set if it had to be.
Two things switch the walls off, as in Knight Lore: the count in bits 4-7 of +$0C, the walk into a room, which the legs' update runs down a turn at a time (PLAYER_LEGS); and bit 0 of the flags, which a doorway sets on the robot while he is in it (CHK_PLYR_NEAR_ARCH). That is how he walks through one at all.
Input
IX the object
C dU
Output
C dU, shortened
ADJ_DU_FOR_OUT_OF_BOUNDS C5E9 LD A,(IX+$0C) Not while the count in +$0C runs
C5EC AND $F0
C5EE RET NZ
C5EF BIT 0,(IX+$07) Not in a doorway
C5F3 RET NZ
C5F4 LD A,(ROOM_HALF_U) B = the room's U half-size
C5F7 LD B,A
CLIP_DU_TO_WALLS C5F8 LD A,(IX+$01) A = |U + dU - 128|
C5FB ADD A,C
C5FC SUB $80
C5FE JR NC,ADJ_DU_FOR_OUT_OF_BOUNDS_0
C600 NEG
ADJ_DU_FOR_OUT_OF_BOUNDS_0 C602 ADD A,(IX+$04) Inside if that plus the half-size is less than the room's: done
C605 CP B
C606 RET C
C607 SET 0,(IX+$0C) Stopped in U
C60B LD A,C A unit shorter, and again unless nothing is left
C60C CALL SHORTEN_DELTA
C60F LD C,A
C610 JR NZ,CLIP_DU_TO_WALLS
C612 RET
Prev: C5D3 Up: Map Next: C613