Prev: 57576 Up: Map Next: 57740
57623: Handle Bubble
Handler for the object types 88 to 91 (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 11) 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 6 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 114 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 175 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 57623 CALL StoreEntity Save the state of the bubble.
57626 LD A,(36636) Fetch the room x of Sabreman.
57629 CP (IX+2) Jump to Move_Distant_Bubble if the bubble is in a different room x.
57632 JP NZ,Move_Distant_Bubble
57635 LD A,(36638) Fetch the room y of Sabreman.
57638 CP (IX+4) Jump to Move_Distant_Bubble if the bubble is in a different room y.
57641 JP NZ,Move_Distant_Bubble
57644 DEC (IX+3) Move the bubble up two pixels.
57647 DEC (IX+3)
57650 LD (IX+10),80 Reset the countdown in byte 10 to 80.
57654 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.
57657 LD (IX+11),E Store the flags of the room in the contact flags.
57660 BIT 0,E Test bit 0 of the flags (the ceiling).
57662 LD A,(IX+3) Fetch the y position.
57665 JR Z,Handle_Bubble_No_Ceiling Jump to Handle_Bubble_No_Ceiling if the room has no ceiling.
57667 CP 66 Jump to Handle_Bubble_Pop if the bubble has reached the ceiling.
57669 JP C,Handle_Bubble_Pop
57672 CP 175 Jump to Handle_Bubble_Animate if the y position is less than 175.
57674 JR C,Handle_Bubble_Animate
57676 BIT 4,E Jump to Handle_Bubble_Animate if the room has no floor.
57678 JR Z,Handle_Bubble_Animate
57680 BIT 0,(IX+15) Jump to Handle_Bubble_Animate if the bubble has been drawn already.
57684 JR Z,Handle_Bubble_Animate
57686 LD (IX+0),0 Remove the bubble.
57690 RET Return.
Handle_Bubble_Animate 57691 INC (IX+6) Add one to the animation counter of the bubble.
57694 LD A,(IX+6) Fetch the animation counter of the bubble.
57697 AND %00000011 Keep only the two low bits.
57699 ADD A,88 Add 88 to make the type.
57701 LD (IX+0),A Store the type.
57704 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Handle_Bubble_No_Ceiling 57707 CP 34 Jump to Handle_Bubble_Animate if the bubble is still in the room.
57709 JR NC,Handle_Bubble_Animate
57711 DEC (IX+4) Move the bubble to the room above.
57714 BIT 0,(IX+15) Return if the bubble has not been drawn yet.
57718 RET NZ
57719 JP RemoveEntity Erase the sprite of the bubble.
Handle_Bubble_Pop 57722 BIT 0,(IX+15) Jump to Remove_Unseen_Weapon to remove the bubble if it has not been drawn yet.
57726 JP NZ,Remove_Unseen_Weapon
57729 LD (IX+0),114 Change the bubble into a sparkle.
57733 LD (IX+8),3 Set the counter in byte 8 to 3.
57737 JP Update_Object_Sprite Jump to Update_Object_Sprite.
Prev: 57576 Up: Map Next: 57740