![]() |
Routines |
| Prev: 6C02 | Up: Map | Next: 6C53 |
|
Used by the routine at UpdateFlower.
Looks for an inactive leaf object and, if there is one, starts a new leaf growing on the flower. The leaves alternate between the right and the left of the flower using bit 6 of LeafGrowth_Flags, and bit 0 of LeafGrowth_Flags is set to stop another leaf being added until the flower has moved again.
|
||||
| GrowLeaf | 6C0E | LD HL,$5E94 | HL=Leaf_1_State (the first leaf object). | |
| 6C11 | LD B,$04 | Set the leaf counter to 04. | ||
| 6C13 | LD DE,$0008 | DE=08 (the size of an object). | ||
| GrowLeaf_Loop | 6C16 | LD A,(HL) | Jump to GrowLeaf_Found if the leaf is inactive. | |
| 6C17 | AND A | |||
| 6C18 | JR Z,GrowLeaf_Found | |||
| 6C1A | ADD HL,DE | Move onto the next leaf object. | ||
| 6C1B | DJNZ GrowLeaf_Loop | Decrease the leaf counter by one and loop back to GrowLeaf_Loop until all four leaves have been checked. | ||
| 6C1D | RET | Return. | ||
| GrowLeaf_Found | 6C1E | LD A,($5E15) | A=LeafGrowth_Flags. | |
| 6C21 | XOR %01000000 | Flip bit 6. | ||
| 6C23 | OR %00000001 | Set bit 0. | ||
| 6C25 | LD ($5E15),A | Write it back to LeafGrowth_Flags. | ||
| 6C28 | PUSH HL | Stash the leaf object on the stack. | ||
| 6C29 | EX DE,HL | DE=the leaf object. | ||
| 6C2A | LD HL,$5F38 | HL=DefaultState_Leaf (the default leaf). | ||
| 6C2D | LD BC,$0008 | BC=08 (the size of an object). | ||
| 6C30 | LDIR | Copy the default leaf into the leaf object. | ||
| 6C32 | POP HL | Restore the leaf object from the stack. | ||
| 6C33 | LD A,($5E15) | A=LeafGrowth_Flags. | ||
| 6C36 | AND %01000000 | Keep only bit 6. | ||
| 6C38 | LD DE,$5E8D | DE=State_Flower_Pos_X (the X position of the flower). | ||
| 6C3B | LD A,(DE) | A=the X position of the flower. | ||
| 6C3C | JR Z,GrowLeaf_Left | Jump to GrowLeaf_Left if bit 6 was not set, to put the leaf on the left. | ||
| 6C3E | ADD A,$08 | Add 08. | ||
| GrowLeaf_Position | 6C40 | INC HL | Move onto the X position of the leaf. | |
| 6C41 | LD (HL),A | Write the X position. | ||
| 6C42 | INC DE | Move onto the Y position of the flower. | ||
| 6C43 | INC HL | Move onto the Y position of the leaf. | ||
| 6C44 | LD A,(DE) | A=the Y position of the flower. | ||
| 6C45 | ADD A,$07 | Add 07. | ||
| 6C47 | LD (HL),A | Write the Y position. | ||
| 6C48 | LD HL,$5E90 | HL=State_Flower_Leaves (the number of leaves on the flower). | ||
| 6C4B | INC (HL) | Increment the number of leaves by one. | ||
| 6C4C | RET | Return. | ||
| GrowLeaf_Left | 6C4D | SET 6,(HL) | Set bit 6 of the state of the leaf (so it faces left). | |
| 6C4F | SUB $10 | Subtract 10. | ||
| 6C51 | JR GrowLeaf_Position | Jump to GrowLeaf_Position. | ||
| Prev: 6C02 | Up: Map | Next: 6C53 |