Prev: 42481 Up: Map Next: 42662
42616: 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 42823 with the new x position in A and the room flags in E.
If the x position is less than 216 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 208 and the x velocity is reversed, which then makes him tumble. If it is not, the contact flags are given the bits 17 and, once the x position reaches 240 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 42616 CP 216 Jump to Handle_Sabreman_Falling_Apply_Gravity if he has not reached the right wall (x position less than 216).
42618 JP C,Handle_Sabreman_Falling_Apply_Gravity
42621 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).
42623 JR Z,Handle_Falling_At_Right_Edge_No_Wall
42625 LD (IX+1),208 Stop him at the right wall by setting the x position to 208.
42629 JP Handle_Sabreman_Falling_Reverse_Velocity Jump to Handle_Sabreman_Falling_Reverse_Velocity.
Handle_Falling_At_Right_Edge_No_Wall 42632 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'.
42633 LD A,17
42635 OR (IX+11)
42638 LD (IX+11),A
42641 EX AF,AF'
42642 SET 4,E Mark the room as having a floor (bit 4 of E).
42644 CP 240 Jump to Handle_Sabreman_Falling_Apply_Gravity if he has not left the room (x position less than 240).
42646 JP C,Handle_Sabreman_Falling_Apply_Gravity
42649 INC (IX+2) Increase the room x, to go to the room on the right.
42652 LD (IX+1),8 Put him at the left edge of the next room (x position 8).
42656 CALL Draw_Room Draw the new room.
42659 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: 42481 Up: Map Next: 42662