![]() |
Routines |
| Prev: 27662 | Up: Map | Next: 27847 |
|
Updates a leaf of the flower. A new leaf grows through four frames (one every eight updates), an eaten leaf shrinks back through them (one every four updates) and is then removed. A leaf is eaten if the flower sinks down to the level of the leaf, or when a bug touches it (see LeafCollision).
|
||||||||||||||
|
The object fields used are:
|
||||||||||||||
| UpdateLeaf | 27731 | CALL StoreEntity | Remember the position and state using StoreEntity. | |||||||||||
| 27734 | LD A,(24206) | A=the Y position of the flower. | ||||||||||||
| 27737 | CP (IX+2) | Compare it with the Y position of the leaf. | ||||||||||||
| 27740 | JR C,UpdateLeaf_Animate | Jump to UpdateLeaf_Animate if the flower is above the leaf. | ||||||||||||
| 27742 | LD (IX+5),1 | Write 1 to IX+5 (the leaf is being eaten). | ||||||||||||
| 27746 | LD (IX+4),1 | Write 1 to IX+4 (the leaf is animating). | ||||||||||||
| UpdateLeaf_Animate | 27750 | LD A,(IX+4) | Jump to UpdateLeaf_Static if the leaf is not animating. | |||||||||||
| 27753 | AND A | |||||||||||||
| 27754 | JR Z,UpdateLeaf_Static | |||||||||||||
| 27756 | LD A,(IX+5) | Jump to UpdateLeaf_Eaten if the leaf is being eaten. | ||||||||||||
| 27759 | AND A | |||||||||||||
| 27760 | JR NZ,UpdateLeaf_Eaten | |||||||||||||
|
The leaf is growing, which is done every eighth update.
|
||||||||||||||
| 27762 | LD A,(24087) | A=GameTimer. | ||||||||||||
| 27765 | CPL | Invert all of the bits in A. | ||||||||||||
| 27766 | AND %00000111 | Keep only bits 0-2. | ||||||||||||
| 27768 | JR NZ,UpdateLeaf_Static | Jump to UpdateLeaf_Static if it is not time for the next frame. | ||||||||||||
| 27770 | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | ||||||||||||
| 27773 | CALL SetUpPreviousSprite_Address | Set up the previous sprite using SetUpPreviousSprite_Address. | ||||||||||||
| 27776 | EXX | Switch to the shadow registers. | ||||||||||||
| 27777 | INC (IX+6) | Increment the frame in IX+6 by one. | ||||||||||||
| 27780 | LD A,(IX+6) | A=the frame. | ||||||||||||
| 27783 | CP 3 | Jump to UpdateLeaf_Draw if it is not the last frame. | ||||||||||||
| 27785 | JR NZ,UpdateLeaf_Draw | |||||||||||||
| 27787 | LD (IX+4),0 | Write 0 to IX+4 (the leaf stops animating). | ||||||||||||
| UpdateLeaf_Draw | 27791 | CALL GetLeafSprite | Get the sprite of the new frame using GetLeafSprite. | |||||||||||
| 27794 | CALL SetUpSprite_Address | Set up the new sprite using SetUpSprite_Address. | ||||||||||||
| 27797 | EXX | Switch to the shadow registers. | ||||||||||||
| 27798 | CALL DisplayEntity_Compare | Erase the previous sprite and draw the new one using DisplayEntity_Compare. | ||||||||||||
| 27801 | JP ColouriseSprite | Jump to ColouriseSprite to colour the sprite. | ||||||||||||
|
The leaf is being eaten, which is done every fourth update.
|
||||||||||||||
| UpdateLeaf_Eaten | 27804 | LD A,(24087) | A=GameTimer. | |||||||||||
| 27807 | AND %00000011 | Keep only bits 0-1. | ||||||||||||
| 27809 | JR NZ,UpdateLeaf_Static | Jump to UpdateLeaf_Static if it is not time for the next frame. | ||||||||||||
| 27811 | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | ||||||||||||
| 27814 | CALL SetUpPreviousSprite_Address | Set up the previous sprite using SetUpPreviousSprite_Address. | ||||||||||||
| 27817 | EXX | Switch to the shadow registers. | ||||||||||||
| 27818 | DEC (IX+6) | Decrease the frame in IX+6 by one. | ||||||||||||
| 27821 | JP P,UpdateLeaf_Draw | Jump to UpdateLeaf_Draw to draw the new frame if there is one. | ||||||||||||
|
The leaf has gone, so remove it.
|
||||||||||||||
| 27824 | INC (IX+6) | Put the frame back to 0. | ||||||||||||
| 27827 | CALL GetLeafSprite | Get the sprite of the first frame using GetLeafSprite. | ||||||||||||
| 27830 | CALL RemoveObject | Erase the leaf and make it inactive using RemoveObject. | ||||||||||||
| 27833 | LD HL,24208 | HL=State_Flower_Leaves (the number of leaves on the flower). | ||||||||||||
| 27836 | DEC (HL) | Decrease the number of leaves by one. | ||||||||||||
| 27837 | RET | Return. | ||||||||||||
| UpdateLeaf_Static | 27838 | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | |||||||||||
| 27841 | CALL DrawSprite | Draw the sprite using DrawSprite. | ||||||||||||
| 27844 | JP ColouriseSprite | Jump to ColouriseSprite to colour the sprite. | ||||||||||||
| Prev: 27662 | Up: Map | Next: 27847 |