![]() |
Routines |
| Prev: 6D07 | Up: Map | Next: 6D9C |
|
Updates the flower. Nothing happens until Robbie is active and the "get ready" delay has finished. The number of bugs which were eating the flower in the last pass of the main loop is in BugsEating_Flower (which is reset here once it has been read), and the flower then does one of three things each time the timer in IX+05 runs out:
|
||||||||||||
|
The object fields used are:
|
||||||||||||
| UpdateFlower | 6D0C | CALL StoreEntity | Remember the position and state using StoreEntity. | |||||||||
| 6D0F | LD DE,$769A | DE=Sprite_Flower_1 (the flower sprite). | ||||||||||
| 6D12 | LD A,($5E6C) | Jump to DrawFlower to draw the flower if Robbie is inactive. | ||||||||||
| 6D15 | AND A | |||||||||||
| 6D16 | JR Z,DrawFlower | |||||||||||
| 6D18 | LD A,($5E22) | Jump to DrawFlower to draw the flower if the "get ready" delay in PlayDelay_Counter is not finished. | ||||||||||
| 6D1B | AND A | |||||||||||
| 6D1C | JR NZ,DrawFlower | |||||||||||
| 6D1E | LD A,($5E3B) | A=the number of bugs eating the flower from BugsEating_Flower. | ||||||||||
| 6D21 | CP (IX+$06) | Compare it with the number in IX+06. | ||||||||||
| 6D24 | JR Z,UpdateFlower_Timer | Jump to UpdateFlower_Timer if it has not changed. | ||||||||||
| 6D26 | LD (IX+$06),A | Remember the new number in IX+06. | ||||||||||
| 6D29 | LD (IX+$05),$01 | Write 01 to IX+05 so that the timer runs out straight away. | ||||||||||
| UpdateFlower_Timer | 6D2D | DEC (IX+$05) | Decrease the timer in IX+05 by one. | |||||||||
| 6D30 | JR NZ,DrawFlower | Jump to DrawFlower to draw the flower if the timer has not run out. | ||||||||||
| 6D32 | LD A,($5E3B) | A=the number of bugs eating the flower from BugsEating_Flower. | ||||||||||
| 6D35 | AND A | Test the number. | ||||||||||
| 6D36 | JR Z,UpdateFlower_Grow | Jump to UpdateFlower_Grow if no bugs are eating the flower. | ||||||||||
| 6D38 | CP $01 | Jump to DrawFlower to draw the flower if only one bug is eating it. | ||||||||||
| 6D3A | JR Z,DrawFlower | |||||||||||
| 6D3C | JR SinkFlower | Jump to SinkFlower to sink the flower. | ||||||||||
| UpdateFlower_Grow | 6D3E | DEC (IX+$02) | Decrease the Y position of the flower by one. | |||||||||
| 6D41 | LD A,(IX+$04) | A=the number of leaves from IX+04. | ||||||||||
| 6D44 | RLCA | Multiply it by four. | ||||||||||
| 6D45 | RLCA | |||||||||||
| 6D46 | LD B,A | B=four times the number of leaves. | ||||||||||
| 6D47 | LD A,(IX+$02) | A=the Y position of the flower. | ||||||||||
| 6D4A | CP $70 | Jump to StartFlowerBloom if the flower has reached the top. | ||||||||||
| 6D4C | JP C,StartFlowerBloom | |||||||||||
| 6D4F | LD A,$20 | A=20. | ||||||||||
| 6D51 | SUB B | Subtract four times the number of leaves. | ||||||||||
|
This entry point is used by the routine at SinkFlower.
|
||||||||||||
| UpdateFlower_SetTimer | 6D52 | LD (IX+$05),A | Write the time until the next move to IX+05. | |||||||||
| 6D55 | LD A,($5E15) | A=LeafGrowth_Flags. | ||||||||||
| 6D58 | AND %01000000 | Keep only bit 6. | ||||||||||
| 6D5A | LD ($5E15),A | Write it back to LeafGrowth_Flags (so bit 0 is reset and a leaf can be added). | ||||||||||
| 6D5D | CALL ReplaceSprite | Move the flower sprite using ReplaceSprite. | ||||||||||
|
This entry point is used by the routine at DrawFlower.
|
||||||||||||
| UpdateFlower_Colour | 6D60 | CALL ColouriseSprite | Colour the sprite using ColouriseSprite. | |||||||||
|
Draw the stem of the flower from the flower down to the ground.
|
||||||||||||
| 6D63 | LD L,(IX+$01) | L=the X position of the flower. | ||||||||||
| 6D66 | LD H,(IX+$02) | H=the Y position of the flower. | ||||||||||
| UpdateFlower_Stem_Loop | 6D69 | LD A,H | A=the Y position. | |||||||||
| 6D6A | CP $B8 | Jump to UpdateFlower_Finish if the bottom of the stem has been reached. | ||||||||||
| 6D6C | JR NC,UpdateFlower_Finish | |||||||||||
| 6D6E | CPL | Invert all of the bits in A. | ||||||||||
| 6D6F | AND %00000111 | Keep only bits 0-2. | ||||||||||
| 6D71 | JR NZ,UpdateFlower_Stem_Pixels | Jump to UpdateFlower_Stem_Pixels unless this is the last pixel row in a cell. | ||||||||||
| 6D73 | PUSH HL | Stash the position on the stack. | ||||||||||
| 6D74 | CALL AttributeAddress | Convert the position to an attribute buffer address using AttributeAddress. | ||||||||||
| 6D77 | LD (HL),$7C | Write 7C (bright green on white) to the attribute buffer. | ||||||||||
| 6D79 | POP HL | Restore the position from the stack. | ||||||||||
| UpdateFlower_Stem_Pixels | 6D7A | PUSH HL | Stash the position on the stack. | |||||||||
| 6D7B | CALL ScreenAddress | Convert the position to a screen address using ScreenAddress. | ||||||||||
| 6D7E | LD (HL),$B9 | Write B9 to the screen. | ||||||||||
| 6D80 | POP HL | Restore the position from the stack. | ||||||||||
| 6D81 | INC H | Move down one pixel row. | ||||||||||
| 6D82 | JR UpdateFlower_Stem_Loop | Jump to UpdateFlower_Stem_Loop. | ||||||||||
| UpdateFlower_Finish | 6D84 | XOR A | Write 00 to BugsEating_Flower (the number of bugs eating the flower). | |||||||||
| 6D85 | LD ($5E3B),A | |||||||||||
| 6D88 | LD A,(IX+$04) | A=the number of leaves from IX+04. | ||||||||||
| 6D8B | AND A | Test the number. | ||||||||||
| 6D8C | RET M | Return if it is negative. | ||||||||||
| 6D8D | LD A,($5E15) | A=LeafGrowth_Flags. | ||||||||||
| 6D90 | AND %00000001 | Keep only bit 0. | ||||||||||
| 6D92 | RET NZ | Return if a leaf has already been added. | ||||||||||
| 6D93 | LD A,(IX+$02) | A=the Y position of the flower. | ||||||||||
| 6D96 | AND %00001111 | Keep only bits 0-3. | ||||||||||
| 6D98 | RET NZ | Return unless the Y position is a multiple of sixteen. | ||||||||||
| 6D99 | JP GrowLeaf | Jump to GrowLeaf to grow a leaf. | ||||||||||
| Prev: 6D07 | Up: Map | Next: 6D9C |