Prev: B3D4 Up: Map Next: B41F
B3D8: Handle Jellyfish
Handler for the object types 44 to 47 (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 30 (to the right) or D0 (to the left), and its y velocity only ever increases, up to 20 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 B3D8 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.
B3DB LD A,(IX+$0B) Fetch the contact flags of the jellyfish.
B3DE OR E Combine them with the flags of the room.
B3DF LD E,A Store the result in E.
B3E0 LD A,($8F1C) Fetch the room x of Sabreman.
B3E3 CP (IX+$02) Jump to Move_Creature_Horizontally if the jellyfish is in a different room x.
B3E6 JP NZ,Move_Creature_Horizontally
B3E9 LD A,($8F1E) Fetch the room y of Sabreman.
B3EC CP (IX+$04) Jump to Handle_Jellyfish_Animate if the jellyfish is in the same room y.
B3EF JR Z,Handle_Jellyfish_Animate
B3F1 JP NC,Move_Creature_Vertically Jump to Move_Creature_Vertically if Sabreman is in a room below the jellyfish.
B3F4 LD (IX+$00),$00 Remove the jellyfish, as Sabreman is in a room above it.
B3F8 RET Return.
Handle_Jellyfish_Animate B3F9 CALL Animate_Jellyfish Animate the jellyfish.
B3FC LD A,(IX+$09) Fetch the y velocity.
B3FF INC A Add one to the y velocity, so that gravity slowly pulls the jellyfish down.
B400 BIT 7,A Jump to Handle_Jellyfish_Store_Y_Velocity if the y velocity is negative.
B402 JR NZ,Handle_Jellyfish_Store_Y_Velocity
B404 CP $21 Jump to Handle_Jellyfish_Set_X_Velocity if the y velocity has reached 21.
B406 JR NC,Handle_Jellyfish_Set_X_Velocity
Handle_Jellyfish_Store_Y_Velocity B408 LD (IX+$09),A Store the y velocity.
This entry point is used by the routine at Handle_Gargoyle.
Handle_Jellyfish_Set_X_Velocity B40B BIT 7,(IX+$08) Jump to Handle_Jellyfish_Move_Left if the x velocity is negative.
B40F JR NZ,Handle_Jellyfish_Move_Left
B411 LD (IX+$08),$30 Set the x velocity to 30 (right).
B415 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 B418 LD (IX+$08),$D0 Set the x velocity to D0 (left).
B41C JP Handle_Flying_Creature_Check_Contact Jump to Handle_Flying_Creature_Check_Contact to check for contact and to move the jellyfish.
Prev: B3D4 Up: Map Next: B41F