Prev: 54313 Up: Map Next: 54383
54348: Move entity at IX into room to the left, if appropriate
This routine moves an entity (e.g. Berk or Drutt) into the next room to the left, if there is one, in a way that is consistent with the point of view of the currently selected character. For example, if Berk is the selected character and he moves into a new room, he does so as soon as his leading side (left or right) crosses the edge of the screen. He essentially disappears immediately from his old room. However from Drutt's point of view, Berk should move across the boundary smoothly and not just vanish as soon as his leading side crosses the boundary. This routine (along with its counterpart at 54313) ensures that this happens correctly.
Used by the routines at 36116, 36542, 39278, 41961, 42266, 48142, 52053, 52098, 52870, 52914 and 55041.
Input
IX Address of complex state data for an entity
Output
A Zero if no room exists to the left, otherwise, x-coordinate of character's appropriate side
F Carry flag set if entity is not at edge of current room, or has moved into new room and has not collided. Reset otherwise (i.e. can't enter new room).
54348 LD A,(34208) If Drutt-mode flag is reset (Berk mode)...
54351 BIT 0,A ...
54353 JR Z,54363 ...then skip ahead to 54363
54355 LD A,100 If x-coordinate of Drutt's right side is greater than 100 (x-coordinate of left edge of room)...
54357 CP (IX+7) ...
54360 RET C ...then return
54361 JR 54369 Skip ahead to 54369
54363 LD A,100 If x-coordinate of Berk's left side is greater than 100 (x-coordinate of left edge of room)...
54365 CP (IX+5) ...
54368 RET C ...then return
54369 CALL 54539 Load B with index of room to left of entity's current room
54372 JR Z,54381 If there is no room to the left, then jump to 54381
54374 CALL 54419 Move entity at IX into room to left of its current room and update position of carried entity if moving entity is Berk
54377 CALL 54666 Set carry flag if entity at IX has not collided with another impassable / pushable entity immediately to the left, reset otherwise
54380 RET Return
This entry point is used by the routine at 54313.
54381 XOR A Set A to zero
54382 RET Return
Prev: 54313 Up: Map Next: 54383