Prev: 46036 Up: Map Next: 46111
46040: Handle Jellyfish
Handler for the object types 68 to 71 (jellyfish). A jellyfish is a flying creature that is handled like the eagles and vultures (see Handle_Flying_Creature), except that its x velocity is always 48 (to the right) or 208 (to the left), and its y velocity only ever increases, up to 32 so that it sinks and bounces off the floor and the decorations.
If the jellyfish is in a different room x from Sabreman, Move_Creature_Horizontally moves it. If it is in a room that is below Sabreman's room, it is removed. If it is in a room that is above Sabreman's room, Move_Creature_Vertically moves it down.
Input
IX Object record
Handle_Jellyfish 46040 CALL Read_World_Map Read the world map entry of the room that the jellyfish is in. The flags of the room are returned in E.
46043 LD A,(IX+11) Fetch the contact flags of the jellyfish.
46046 OR E Combine them with the flags of the room.
46047 LD E,A Store the result in E.
46048 LD A,(36636) Fetch the room x of Sabreman.
46051 CP (IX+2) Jump to Move_Creature_Horizontally if the jellyfish is in a different room x.
46054 JP NZ,Move_Creature_Horizontally
46057 LD A,(36638) Fetch the room y of Sabreman.
46060 CP (IX+4) Jump to Handle_Jellyfish_Animate if the jellyfish is in the same room y.
46063 JR Z,Handle_Jellyfish_Animate
46065 JP NC,Move_Creature_Vertically Jump to Move_Creature_Vertically if Sabreman is in a room below the jellyfish.
46068 LD (IX+0),0 Remove the jellyfish, as Sabreman is in a room above it.
46072 RET Return.
Handle_Jellyfish_Animate 46073 CALL Animate_Jellyfish Animate the jellyfish.
46076 LD A,(IX+9) Fetch the y velocity.
46079 INC A Add one to the y velocity, so that gravity slowly pulls the jellyfish down.
46080 BIT 7,A Jump to Handle_Jellyfish_Store_Y_Velocity if the y velocity is negative.
46082 JR NZ,Handle_Jellyfish_Store_Y_Velocity
46084 CP 33 Jump to Handle_Jellyfish_Set_X_Velocity if the y velocity has reached 33.
46086 JR NC,Handle_Jellyfish_Set_X_Velocity
Handle_Jellyfish_Store_Y_Velocity 46088 LD (IX+9),A Store the y velocity.
This entry point is used by the routine at Handle_Gargoyle.
Handle_Jellyfish_Set_X_Velocity 46091 BIT 7,(IX+8) Jump to Handle_Jellyfish_Move_Left if the x velocity is negative.
46095 JR NZ,Handle_Jellyfish_Move_Left
46097 LD (IX+8),48 Set the x velocity to 48 (right).
46101 JP Handle_Flying_Creature_Check_Contact Jump to Handle_Flying_Creature_Check_Contact to check for contact and to move the jellyfish.
Handle_Jellyfish_Move_Left 46104 LD (IX+8),208 Set the x velocity to 208 (left).
46108 JP Handle_Flying_Creature_Check_Contact Jump to Handle_Flying_Creature_Check_Contact to check for contact and to move the jellyfish.
Prev: 46036 Up: Map Next: 46111