Prev: A433 Up: Map Next: A678
A5F1: Handle Sabreman Jumping
Handler for the object types 11 to 14 which are the jumping sprites of Sabreman (11 and 12 when he jumps to the left and 13 and 14 when he jumps to the right).
The countdown in the object record is decreased on every call. When it reaches 03 the sprite moves on to the next frame, and when it reaches zero the jump is over and the sprite becomes 15 or 16 (falling), so that Handle_Sabreman_Falling takes over. The controls steer him left or right while he is in the air.
At the end of the jump the y position is moved up by 04 and the countdown is set to 0C. If that takes him into the top part of the room and the room has a ceiling, he hits it and tumbles at Continue_Sabreman_Tumbling.
Input
IX Object record of Sabreman
Save the state of the object, then deal with the special states in the same way as Handle_Sabreman_Walking.
Handle_Sabreman_Jumping A5F1 CALL StoreEntity Remember the position and sprite id of Sabreman.
A5F4 BIT 6,(IX+$0F) Jump to Start_Being_Carried if Sabreman is being carried (bit 6 of the redraw flags).
A5F8 JP NZ,Start_Being_Carried
A5FB BIT 7,(IX+$0F) Jump to Start_Tumbling if Sabreman is tumbling (bit 7 of the redraw flags).
A5FF JP NZ,Start_Tumbling
A602 CALL Read_World_Map Read the world map entry of the room.
A605 CALL Check_Bubble_Contact Check for contact with the bubbles.
Decrease the countdown. When it reaches zero the jump ends at Handle_Sabreman_Jumping_Finish.
A608 DEC (IX+$0A) Decrease the jump countdown and jump to Handle_Sabreman_Jumping_Finish if the jump is over.
A60B JR Z,Handle_Sabreman_Jumping_Finish
A60D LD A,(IX+$0A) Fetch the jump countdown and jump to Handle_Sabreman_Jumping_Read_Controls unless it has reached 03.
A610 CP $03
A612 JR NZ,Handle_Sabreman_Jumping_Read_Controls
A614 INC (IX+$00) Move on to the next frame of the jumping sprite, as he is at the top of the jump.
Read the controls. Bit 0 clear sets an x velocity of 02 and moves to the frames for jumping to the right. Bit 1 clear sets an x velocity of FE and moves to the frames for jumping to the left. If neither is clear the velocity is unchanged.
Handle_Sabreman_Jumping_Read_Controls A617 CALL ReadControls Read the controls.
A61A BIT 0,A Jump to Handle_Sabreman_Jumping_Move_Right if the right control is used (bit 0 of the controls is clear).
A61C JR Z,Handle_Sabreman_Jumping_Move_Right
A61E BIT 1,A Jump to Update_Object_Sprite if the left control is not used either (bit 1 of the controls is set).
A620 JP NZ,Update_Object_Sprite
A623 LD (IX+$06),$FE Set the x velocity of Sabreman to FE (moving left).
A627 LD A,(IX+$00) Switch to the frame for jumping to the left.
A62A DEC A
A62B RES 1,A
A62D INC A
A62E LD (IX+$00),A Set the sprite id.
A631 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Handle_Sabreman_Jumping_Move_Right A634 LD (IX+$06),$02 Set the x velocity of Sabreman to 02 (moving right).
A638 LD A,(IX+$00) Switch to the frame for jumping to the right.
A63B DEC A
A63C SET 1,A
A63E INC A
A63F LD (IX+$00),A Set the sprite id.
A642 JP Update_Object_Sprite Jump to Update_Object_Sprite.
The jump is over. The sprite id becomes 15 (when the jump was to the left) or 16 (when it was to the right).
Handle_Sabreman_Jumping_Finish A645 LD A,(IX+$00) Fetch the sprite id of Sabreman.
A648 DEC A Decrease the sprite id.
A649 RRA Rotate it right, which leaves the direction in bit 0.
A64A AND %00000001 Keep only the direction (00 for left, 01 for right).
A64C ADD A,$15 Add 15 to make the sprite id for falling in that direction.
A64E LD (IX+$00),A Set the sprite id.
A651 CALL Read_World_Map Read the world map entry of the room.
A654 LD A,(IX+$0B) Fetch the contact flags of Sabreman.
A657 OR E Combine the contact flags of Sabreman with the contact flags of the room.
A658 LD E,A
A659 LD A,(IX+$03) Fetch the y position of Sabreman.
A65C SUB $04 Take 04 off the y position of Sabreman.
A65E CP $49 Jump to Handle_Sabreman_Jumping_Land if he is not in the top part of the room (y position of at least 49).
A660 JR NC,Handle_Sabreman_Jumping_Land
A662 LD (IX+$0B),$44 Mark the walls on both sides as solid by setting the contact flags to 44 as he is in the upper part of the room.
A666 BIT 0,E Jump to Continue_Sabreman_Tumbling if he hits the ceiling (bit 0 of the contact flags is set).
A668 JP NZ,Continue_Sabreman_Tumbling
Handle_Sabreman_Jumping_Land A66B LD (IX+$03),A Store the new y position of Sabreman.
A66E LD (IX+$0A),$0C Set the countdown of Sabreman to 0C.
A672 CALL SoundsSword Play the sword sound (see SoundsSword).
A675 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: A433 Up: Map Next: A678