Prev: A5F1 Up: Map Next: A6A6
A678: Handle Falling At Right Edge
Used by the routine at Handle_Sabreman_Falling.
Deals with Sabreman when he falls (or tumbles from a fall) and his x position has gone past the right-hand side of the room. It is entered from A747 with the new x position in A and the room flags in E.
If the x position is less than D8 nothing happens and the routine goes on at Handle_Sabreman_Falling_Apply_Gravity. If the right wall is solid (bit 2 of E), the x position is set to D0 and the x velocity is reversed, which then makes him tumble. If it is not, the contact flags are given the bits 11 and, once the x position reaches F0 he enters the room on the right.
Input
A New x position of Sabreman
E Flags of the room
IX Object record of Sabreman
Handle_Falling_At_Right_Edge A678 CP $D8 Jump to Handle_Sabreman_Falling_Apply_Gravity if he has not reached the right wall (x position less than D8).
A67A JP C,Handle_Sabreman_Falling_Apply_Gravity
A67D BIT 2,E Jump to Handle_Falling_At_Right_Edge_No_Wall if the right wall is not solid (bit 2 of E is clear).
A67F JR Z,Handle_Falling_At_Right_Edge_No_Wall
A681 LD (IX+$01),$D0 Stop him at the right wall by setting the x position to D0.
A685 JP Handle_Sabreman_Falling_Reverse_Velocity Jump to Handle_Sabreman_Falling_Reverse_Velocity.
Handle_Falling_At_Right_Edge_No_Wall A688 EX AF,AF' Mark the ceiling and the floor as solid (bits 0 and 4 of the contact flags of Sabreman), as he is in the gap in the wall, keeping the new x position in AF'.
A689 LD A,$11
A68B OR (IX+$0B)
A68E LD (IX+$0B),A
A691 EX AF,AF'
A692 SET 4,E Mark the room as having a floor (bit 4 of E).
A694 CP $F0 Jump to Handle_Sabreman_Falling_Apply_Gravity if he has not left the room (x position less than F0).
A696 JP C,Handle_Sabreman_Falling_Apply_Gravity
A699 INC (IX+$02) Increase the room x, to go to the room on the right.
A69C LD (IX+$01),$08 Put him at the left edge of the next room (x position 08).
A6A0 CALL Draw_Room Draw the new room.
A6A3 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: A5F1 Up: Map Next: A6A6