Prev: 39614 Up: Map Next: 39779
39641: Update Growing Bubble Entity
Updates an entity of the type 8. Field 32 counts the frames and field 35 holds the state of the entity. The entity moves up or down on its third coordinate depending on field 31.
Input
IX The entity
UpdateGrowingBubbleEntity 39641 INC (IX+32) Increase field 32 of the entity by one.
39644 LD A,(IX+1) Fetch the frame of the entity.
39647 AND %00011111 Keep the number of the frame.
39649 CP 6 Jump to UpdateGrowingBubbleEntity_Speed unless it is 6.
39651 JR NZ,UpdateGrowingBubbleEntity_Speed
39653 BIT 1,(IX+35) Jump to MakeCreature if bit 1 of field 35 of the entity is set.
39657 JP NZ,MakeCreature
UpdateGrowingBubbleEntity_Speed 39660 LD A,(IX+31) Read field 31 of the entity.
39663 INC A Add one.
39664 LD HL,40 Set the speed to 40 to move up.
39667 CP 36 Jump to UpdateGrowingBubbleEntity_SetSpeed if it is below 36.
39669 JR C,UpdateGrowingBubbleEntity_SetSpeed
39671 LD HL,65496 Set the speed to 65496 to move down.
UpdateGrowingBubbleEntity_SetSpeed 39674 LD (IX+20),H Store the first byte of the speed in field 20 of the entity.
39677 LD (IX+21),L Store the second byte of the speed in field 21 of the entity.
39680 LD L,(IX+35) Read field 35 of the entity.
39683 BIT 0,L Jump to UpdateGrowingBubbleEntity_Change if bit 0 is set.
39685 JR NZ,UpdateGrowingBubbleEntity_Change
39687 LD A,(IX+1) Fetch the frame of the entity.
39690 AND %00011111 Keep the number of the frame.
39692 CP 5 Jump to MakeEntitySound if it is below 5.
39694 JP C,MakeEntitySound
39697 JR NZ,UpdateGrowingBubbleEntity_Countdown Jump to UpdateGrowingBubbleEntity_Countdown if it is above 5.
39699 LD A,(24474) Fetch the low byte of the seed from RandomNumber_Seed and keep it in B.
39702 LD B,A
39703 AND %11000000 Use bits 6-7.
39705 JR Z,UpdateGrowingBubbleEntity_Change Jump to UpdateGrowingBubbleEntity_Change if they are zero.
39707 LD A,B Fetch the random number.
39708 AND %00111111 Use bits 0-5.
39710 OR %10000000 Set bit 7.
39712 LD (IX+17),A Set the heading.
39715 LD A,(24475) Fetch the random number from 24475.
39718 AND %10111100 Use bits 2-5 and 7.
39720 ADD A,64 Add 64.
39722 LD (IX+35),A Store it in field 35 of the entity.
39725 INC (IX+1) Move onto the next frame.
39728 CALL SetEntitySize Call SetEntitySize to set the sprite of the entity.
39731 JP UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity.
UpdateGrowingBubbleEntity_Countdown 39734 LD A,(41693) Fetch the low byte of the frame counter from FrameCounter.
39737 RRA Rotate bit 0 into the carry flag.
39738 JR C,UpdateGrowingBubbleEntity_Done Jump to UpdateGrowingBubbleEntity_Done if it is set.
39740 LD A,L Read field 35 of the entity.
39741 SUB 4 Subtract 4.
39743 JR NC,UpdateGrowingBubbleEntity_Store Jump to UpdateGrowingBubbleEntity_Store if there was no carry.
39745 LD A,1 Set the value to 1.
UpdateGrowingBubbleEntity_Store 39747 LD (IX+35),A Store it in field 35 of the entity.
UpdateGrowingBubbleEntity_Done 39750 JP UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity.
UpdateGrowingBubbleEntity_Change 39753 CALL PlaySlowFall Call PlaySlowFall.
39756 LD A,(IX+1) Fetch the frame of the entity.
39759 AND %11100000 Use bits 5-7.
39761 OR %00001000 Set the number of the frame to 8.
39763 LD (IX+1),A Store it.
39766 CALL SetEntitySize Call SetEntitySize to set the sprite of the entity.
39769 LD (IX+28),81 Set field 28 of the entity to 81.
39773 LD (IX+35),130 Set field 35 of the entity to 130.
39777 JR UpdateGrowingBubbleEntity_Done Jump to UpdateGrowingBubbleEntity_Done.
Prev: 39614 Up: Map Next: 39779