Prev: E556 Up: Map Next: E622
E570: Handle Carried Sabreman
Handler for the object types 60 to 63 which are the sprites of Sabreman while an eagle carries him (see Handle_Carrying_Eagle). Bit 1 of the type is set when he moves to the left and bit 0 follows bit 1 of the tick counter.
His position is taken from bytes 08 (x) and 09 (y) of his record, which the eagle sets. If bit 7 of the redraw flags is set (he has been hit) bit 5 is set to ask the eagle to let go, and the countdown in byte 0A is set to 0F.
If no eagle was carrying him in the last pass of the main loop (see Previous_Type_5C_Active_Flag) he drops, and so does he when bit 6 of the redraw flags is set (see Release_Sabreman). He starts to tumble, with the sprite id 18 and a y velocity of 10.
Touching a decoration puts him on top of it when he is on top of it or near its middle. If he touches the side of one he sets bit 5 to ask the eagle to let go. He is kept within the walls of the room. If the fire key is pressed he throws a weapon (see Throw_Weapon).
Input
IX Object record of Sabreman
Handle_Carried_Sabreman E570 CALL StoreEntity Save the state of Sabreman.
E573 BIT 7,(IX+$0F) Jump to Handle_Carried_Sabreman_Update if bit 7 of the redraw flags is reset.
E577 JP Z,Handle_Carried_Sabreman_Update
E57A SET 5,(IX+$0F) Set bit 5 of the redraw flags, to ask the eagle to let go.
E57E LD (IX+$0A),$0F Set the countdown to 0F.
This entry point is used by the routine at Start_Being_Carried.
Handle_Carried_Sabreman_Update E582 LD A,(IX+$08) Fetch the x position that the eagle has set.
E585 SUB (IX+$01) Subtract the current x position.
E588 RLCA Rotate bit 6 of the result into bit 1.
E589 RLCA
E58A AND %00000010 Keep only bit 1, which is set when he is moving to the left.
E58C LD C,A Store the result in C.
E58D LD A,($8ED6) Fetch the tick counter.
E590 RRA Move bit 1 into bit 0.
E591 AND %00000001 Keep only that bit.
E593 ADD A,C Add the direction bit.
E594 LD C,A Store the result in C.
E595 LD A,(IX+$00) Fetch the type.
E598 AND %11111100 Reset bits 0 and 1.
E59A ADD A,C Add the frame and direction bits.
E59B LD (IX+$00),A Store the type.
E59E LD A,(IX+$09) Fetch the y position that the eagle has set.
E5A1 LD (IX+$03),A Set the y position of Sabreman.
E5A4 LD A,(IX+$08) Fetch the x position that the eagle has set.
E5A7 LD (IX+$01),A Set the x position of Sabreman.
E5AA LD A,($8EF2) Fetch the flag at Previous_Type_5C_Active_Flag.
E5AD AND A Jump to Handle_Carried_Sabreman_Drop if no eagle was carrying him.
E5AE JR Z,Handle_Carried_Sabreman_Drop
E5B0 CALL Check_Decoration_Contact Check for contact with the decorations.
E5B3 BIT 2,C Jump to Handle_Carried_Sabreman_Check_Walls if he is not touching a decoration.
E5B5 JR Z,Handle_Carried_Sabreman_Check_Walls
E5B7 BIT 1,C Jump to Handle_Carried_Sabreman_Stand if he is on top of it.
E5B9 JR NZ,Handle_Carried_Sabreman_Stand
E5BB BIT 0,C Jump to Handle_Carried_Sabreman_Stand if he is near the middle of it.
E5BD JR Z,Handle_Carried_Sabreman_Stand
E5BF SET 5,(IX+$0F) Set bit 5 of the redraw flags, to ask the eagle to let go.
Handle_Carried_Sabreman_Check_Walls E5C3 CALL Read_World_Map Read the world map entry of the room that he is in. The flags of the room are returned in E.
E5C6 LD A,(IX+$01) Fetch the x position.
E5C9 CP $CF Jump to Handle_Carried_Sabreman_Check_Right_Wall if it is CF or more.
E5CB JR NC,Handle_Carried_Sabreman_Check_Right_Wall
E5CD CP $18 Jump to Handle_Carried_Sabreman_Check_Release if it is 18 or more.
E5CF JR NC,Handle_Carried_Sabreman_Check_Release
E5D1 BIT 6,E Jump to Handle_Carried_Sabreman_Check_Floor if the room has no wall on the left.
E5D3 JR Z,Handle_Carried_Sabreman_Check_Floor
E5D5 LD (IX+$01),$18 Set the x position to 18.
E5D9 JR Handle_Carried_Sabreman_Check_Floor Jump to Handle_Carried_Sabreman_Check_Floor.
Handle_Carried_Sabreman_Check_Right_Wall E5DB BIT 2,E Jump to Handle_Carried_Sabreman_Check_Floor if the room has no wall on the right.
E5DD JR Z,Handle_Carried_Sabreman_Check_Floor
E5DF LD (IX+$01),$CF Set the x position to CF.
Handle_Carried_Sabreman_Check_Floor E5E3 BIT 4,E Jump to Handle_Carried_Sabreman_Check_Release if the room has a floor.
E5E5 JR NZ,Handle_Carried_Sabreman_Check_Release
E5E7 LD A,(IX+$03) Fetch the y position.
E5EA CP $9F Jump to Handle_Carried_Sabreman_Check_Release if it is less than 9F.
E5EC JR C,Handle_Carried_Sabreman_Check_Release
E5EE LD (IX+$03),$9F Set the y position to 9F.
Handle_Carried_Sabreman_Check_Release E5F2 BIT 6,(IX+$0F) Jump to Handle_Carried_Sabreman_Drop if bit 6 of the redraw flags is set, as the eagle has let go.
E5F6 JR NZ,Handle_Carried_Sabreman_Drop
E5F8 CALL ReadControls Read the controls.
E5FB BIT 4,A Jump to Update_Object_Sprite if the fire key is not pressed.
E5FD JP NZ,Update_Object_Sprite
E600 CALL Throw_Weapon Throw a weapon.
E603 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Handle_Carried_Sabreman_Drop E606 DI Disable interrupts.
E607 RES 6,(IX+$0F) Reset bit 6 of the redraw flags.
E60B LD (IX+$00),$18 Set the sprite id to 18 (tumbling).
E60F LD (IX+$09),$10 Set the y velocity to 10.
E613 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Handle_Carried_Sabreman_Stand E616 LD A,B Copy A0 less the y position of the top of the decoration to A.
E617 DEC A Subtract one.
E618 NEG Negate it.
E61A ADD A,$A0 Add A0 to get the y position just below the top of the decoration.
E61C LD (IX+$03),A Set the y position of Sabreman.
E61F JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: E556 Up: Map Next: E622