![]() |
Routines |
| Prev: 6C0E | Up: Map | Next: 6CC7 |
|
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 | 6C53 | CALL StoreEntity | Remember the position and state using StoreEntity. | |||||||||||
| 6C56 | LD A,($5E8E) | A=the Y position of the flower. | ||||||||||||
| 6C59 | CP (IX+$02) | Compare it with the Y position of the leaf. | ||||||||||||
| 6C5C | JR C,UpdateLeaf_Animate | Jump to UpdateLeaf_Animate if the flower is above the leaf. | ||||||||||||
| 6C5E | LD (IX+$05),$01 | Write 01 to IX+05 (the leaf is being eaten). | ||||||||||||
| 6C62 | LD (IX+$04),$01 | Write 01 to IX+04 (the leaf is animating). | ||||||||||||
| UpdateLeaf_Animate | 6C66 | LD A,(IX+$04) | Jump to UpdateLeaf_Static if the leaf is not animating. | |||||||||||
| 6C69 | AND A | |||||||||||||
| 6C6A | JR Z,UpdateLeaf_Static | |||||||||||||
| 6C6C | LD A,(IX+$05) | Jump to UpdateLeaf_Eaten if the leaf is being eaten. | ||||||||||||
| 6C6F | AND A | |||||||||||||
| 6C70 | JR NZ,UpdateLeaf_Eaten | |||||||||||||
|
The leaf is growing, which is done every eighth update.
|
||||||||||||||
| 6C72 | LD A,($5E17) | A=GameTimer. | ||||||||||||
| 6C75 | CPL | Invert all of the bits in A. | ||||||||||||
| 6C76 | AND %00000111 | Keep only bits 0-2. | ||||||||||||
| 6C78 | JR NZ,UpdateLeaf_Static | Jump to UpdateLeaf_Static if it is not time for the next frame. | ||||||||||||
| 6C7A | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | ||||||||||||
| 6C7D | CALL SetUpPreviousSprite_Address | Set up the previous sprite using SetUpPreviousSprite_Address. | ||||||||||||
| 6C80 | EXX | Switch to the shadow registers. | ||||||||||||
| 6C81 | INC (IX+$06) | Increment the frame in IX+06 by one. | ||||||||||||
| 6C84 | LD A,(IX+$06) | A=the frame. | ||||||||||||
| 6C87 | CP $03 | Jump to UpdateLeaf_Draw if it is not the last frame. | ||||||||||||
| 6C89 | JR NZ,UpdateLeaf_Draw | |||||||||||||
| 6C8B | LD (IX+$04),$00 | Write 00 to IX+04 (the leaf stops animating). | ||||||||||||
| UpdateLeaf_Draw | 6C8F | CALL GetLeafSprite | Get the sprite of the new frame using GetLeafSprite. | |||||||||||
| 6C92 | CALL SetUpSprite_Address | Set up the new sprite using SetUpSprite_Address. | ||||||||||||
| 6C95 | EXX | Switch to the shadow registers. | ||||||||||||
| 6C96 | CALL DisplayEntity_Compare | Erase the previous sprite and draw the new one using DisplayEntity_Compare. | ||||||||||||
| 6C99 | JP ColouriseSprite | Jump to ColouriseSprite to colour the sprite. | ||||||||||||
|
The leaf is being eaten, which is done every fourth update.
|
||||||||||||||
| UpdateLeaf_Eaten | 6C9C | LD A,($5E17) | A=GameTimer. | |||||||||||
| 6C9F | AND %00000011 | Keep only bits 0-1. | ||||||||||||
| 6CA1 | JR NZ,UpdateLeaf_Static | Jump to UpdateLeaf_Static if it is not time for the next frame. | ||||||||||||
| 6CA3 | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | ||||||||||||
| 6CA6 | CALL SetUpPreviousSprite_Address | Set up the previous sprite using SetUpPreviousSprite_Address. | ||||||||||||
| 6CA9 | EXX | Switch to the shadow registers. | ||||||||||||
| 6CAA | DEC (IX+$06) | Decrease the frame in IX+06 by one. | ||||||||||||
| 6CAD | JP P,UpdateLeaf_Draw | Jump to UpdateLeaf_Draw to draw the new frame if there is one. | ||||||||||||
|
The leaf has gone, so remove it.
|
||||||||||||||
| 6CB0 | INC (IX+$06) | Put the frame back to 00. | ||||||||||||
| 6CB3 | CALL GetLeafSprite | Get the sprite of the first frame using GetLeafSprite. | ||||||||||||
| 6CB6 | CALL RemoveObject | Erase the leaf and make it inactive using RemoveObject. | ||||||||||||
| 6CB9 | LD HL,$5E90 | HL=State_Flower_Leaves (the number of leaves on the flower). | ||||||||||||
| 6CBC | DEC (HL) | Decrease the number of leaves by one. | ||||||||||||
| 6CBD | RET | Return. | ||||||||||||
| UpdateLeaf_Static | 6CBE | CALL GetLeafSprite | Get the sprite of the current frame using GetLeafSprite. | |||||||||||
| 6CC1 | CALL DrawSprite | Draw the sprite using DrawSprite. | ||||||||||||
| 6CC4 | JP ColouriseSprite | Jump to ColouriseSprite to colour the sprite. | ||||||||||||
| Prev: 6C0E | Up: Map | Next: 6CC7 |