Prev: 66D7 Up: Map Next: 6748
670E: Colour Open Flower
Used by the routine at UpdateBloomingFlower.
Writes the attributes of the open flower into the attribute buffer, using the table at FlowerAttributes, which is nine cells wide and seven cells high. The colour of the centre of the flower changes from yellow to magenta, unless the level is a multiple of four (and not the first level), which are the levels that award an extra life.
Input
IX Flower object
ColouriseFlower 670E LD A,(IX+$01) L=the X position of the flower - 20.
6711 SUB $20
6713 LD L,A
6714 LD A,(IX+$02) H=the Y position of the flower - 30.
6717 SUB $30
6719 LD H,A
671A CALL AttributeAddress Convert the position to an attribute buffer address using AttributeAddress.
671D LD DE,$6748 DE=FlowerAttributes.
6720 LD BC,$0907 B=09 (the number of columns) and C=07 (the number of rows).
ColouriseFlower_Row 6723 PUSH BC Stash the column and row counters on the stack.
6724 PUSH HL Stash the attribute address on the stack.
ColouriseFlower_Column 6725 LD A,($5E37) Jump to ColouriseFlower_Replace if this is the first level (ActivePlayer_Level is zero).
6728 AND A
6729 JR Z,ColouriseFlower_Replace
672B AND $03 Jump to ColouriseFlower_Replace if the level is not a multiple of four.
672D JR NZ,ColouriseFlower_Replace
ColouriseFlower_Write 672F LD A,(DE) A=the attribute from the table.
ColouriseFlower_Store 6730 LD (HL),A Write it to the attribute buffer.
6731 INC HL Move onto the next attribute buffer cell.
6732 INC DE Move onto the next attribute in the table.
6733 DJNZ ColouriseFlower_Column Decrease the column counter by one and loop back to ColouriseFlower_Column until the row has been coloured.
6735 POP HL Restore the attribute address from the stack.
6736 LD BC,$0020 BC=20 (the size of a row).
6739 ADD HL,BC Move down one row.
673A POP BC Restore the column and row counters from the stack.
673B DEC C Decrease the row counter by one.
673C JR NZ,ColouriseFlower_Row Loop back to ColouriseFlower_Row until all of the rows have been coloured.
673E RET Return.
For any other level, the yellow in the centre of the flower is replaced.
ColouriseFlower_Replace 673F LD A,(DE) A=the attribute from the table.
6740 CP $5E Jump to ColouriseFlower_Store if it is not 5E (yellow on magenta).
6742 JR NZ,ColouriseFlower_Store
6744 LD A,$5B A=5B (magenta on magenta).
6746 JR ColouriseFlower_Store Jump to ColouriseFlower_Store.
Prev: 66D7 Up: Map Next: 6748