Prev: 54283 Up: Map Next: 54348
54313: Move entity at IX into room to the right, if appropriate
This routine moves an entity (e.g. Berk or Drutt) into the next room to the right, 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 54348) ensures that this happens correctly.
Used by the routines at 36116, 36542, 39278, 41961, 42266, 52148, 52193, 52889, 52914 and 55041.
Input
IX Address of complex state data for an entity
Output
A Zero if no room exists to the right, 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).
54313 LD A,(34235) Load C with width of entity's current room (chars) + 99...
54316 LD C,A ...
54317 LD A,(34208) If Drutt-mode flag is reset (Berk mode)...
54320 BIT 0,A ...
54322 JR Z,54329 ...then skip ahead to 54329
54324 LD A,(IX+5) Load A with x-coordinate of Drutt's left side
54327 JR 54332 Skip ahead to 54332
54329 LD A,(IX+7) Load A with x-coordinate of Berk's right side
54332 CP C If x-coordinate of room's right edge is greater than x-coordinate in A...
54333 RET C ...then return
54334 CALL 54505 Load B with index of room to right of current character's current room
54337 JR Z,54381 If there is no room to the right, then jump to 54381
54339 CALL 54383 Move entity at IX into room to right of its current room and update position of carried entity if moving entity is Berk
54342 CALL 54569 Check entity at IX for collision with another impassable / pushable entity immediately to the right...
54345 JR NC,54381 ...and if a collision occurred, then jump to 54381
54347 RET Return
Prev: 54283 Up: Map Next: 54348