Prev: E0E8 Up: Map Next: E18C
E117: Handle Bubble
Handler for the object types 58 to 5B (a bubble that rises). A bubble is made by Spawn_Bubble, or by Release_Bubble.
The bubble rises by two pixels on each call. The contact flags (byte 0B) are set to the flags of the room, which lets other objects stand on top of it (see Check_Bubble_Contact). The counter in byte 06 goes up on each call and makes the two low bits of the type, so the bubble goes through three frames.
A bubble in a room with a ceiling bursts when it reaches the ceiling and becomes a sparkle (the type 72 see Handle_Sparkle). A bubble in a room with no ceiling moves into the room above when it reaches the top. A bubble that has just been made in a room with a floor and a ceiling, and is AF or more down the screen, is removed.
If the bubble is in a different room from Sabreman, Move_Distant_Bubble moves it.
Input
IX Object record
Handle_Bubble E117 CALL StoreEntity Save the state of the bubble.
E11A LD A,($8F1C) Fetch the room x of Sabreman.
E11D CP (IX+$02) Jump to Move_Distant_Bubble if the bubble is in a different room x.
E120 JP NZ,Move_Distant_Bubble
E123 LD A,($8F1E) Fetch the room y of Sabreman.
E126 CP (IX+$04) Jump to Move_Distant_Bubble if the bubble is in a different room y.
E129 JP NZ,Move_Distant_Bubble
E12C DEC (IX+$03) Move the bubble up two pixels.
E12F DEC (IX+$03)
E132 LD (IX+$0A),$50 Reset the countdown in byte 0A to 50.
E136 CALL Read_World_Map Read the world map entry of the room that the bubble is in. The flags of the room are returned in E.
E139 LD (IX+$0B),E Store the flags of the room in the contact flags.
E13C BIT 0,E Test bit 0 of the flags (the ceiling).
E13E LD A,(IX+$03) Fetch the y position.
E141 JR Z,Handle_Bubble_No_Ceiling Jump to Handle_Bubble_No_Ceiling if the room has no ceiling.
E143 CP $42 Jump to Handle_Bubble_Pop if the bubble has reached the ceiling.
E145 JP C,Handle_Bubble_Pop
E148 CP $AF Jump to Handle_Bubble_Animate if the y position is less than AF.
E14A JR C,Handle_Bubble_Animate
E14C BIT 4,E Jump to Handle_Bubble_Animate if the room has no floor.
E14E JR Z,Handle_Bubble_Animate
E150 BIT 0,(IX+$0F) Jump to Handle_Bubble_Animate if the bubble has been drawn already.
E154 JR Z,Handle_Bubble_Animate
E156 LD (IX+$00),$00 Remove the bubble.
E15A RET Return.
Handle_Bubble_Animate E15B INC (IX+$06) Add one to the animation counter of the bubble.
E15E LD A,(IX+$06) Fetch the animation counter of the bubble.
E161 AND %00000011 Keep only the two low bits.
E163 ADD A,$58 Add 58 to make the type.
E165 LD (IX+$00),A Store the type.
E168 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Handle_Bubble_No_Ceiling E16B CP $22 Jump to Handle_Bubble_Animate if the bubble is still in the room.
E16D JR NC,Handle_Bubble_Animate
E16F DEC (IX+$04) Move the bubble to the room above.
E172 BIT 0,(IX+$0F) Return if the bubble has not been drawn yet.
E176 RET NZ
E177 JP RemoveEntity Erase the sprite of the bubble.
Handle_Bubble_Pop E17A BIT 0,(IX+$0F) Jump to Remove_Unseen_Weapon to remove the bubble if it has not been drawn yet.
E17E JP NZ,Remove_Unseen_Weapon
E181 LD (IX+$00),$72 Change the bubble into a sparkle.
E185 LD (IX+$08),$03 Set the counter in byte 08 to 03.
E189 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: E0E8 Up: Map Next: E18C