Prev: 42621 Up: Map Next: 42708
42624: Handler: Orchid
Handles an orchid (sprite IDs 72 to 79). An orchid goes through a cycle of growing, staying in bloom for a short time, shrinking and then staying hidden for a while. The lowest three bits of the sprite ID are the stage of growth and a timer in IX+6 and IX+7 counts down how long it is before the next change (see ChangeOrchidStage). The timer only counts down while the player is alive and the game delay timer in GameDelayTimer is zero.
Once the orchid has finished growing it can be touched by the player (see TestOrchidTouched). The stem of the orchid is coloured bright green and the flower is coloured with the colour of the orchid.
Input
IX Actor record of the orchid
HandlerOrchid 42624 CALL StoreEntity Remember the previous position of the orchid.
42627 LD L,(IX+6) Fetch the timer of the orchid.
42630 LD H,(IX+7)
42633 LD A,H Jump to ChangeOrchidStage to change the stage of the orchid if the timer is zero.
42634 OR L
42635 JR Z,ChangeOrchidStage
Count down the timer if the player is alive and the game delay is over.
42637 LD A,(38658) Fetch the sprite ID of the player from ImmortalData.
42640 SUB 16 Subtract 16 (the first Sabreman sprite ID).
42642 CP 32 Jump to HandlerOrchid_StoreTimer if the player is not alive.
42644 JR NC,HandlerOrchid_StoreTimer
42646 LD A,(38581) Fetch the start-of-turn delay from GameDelayTimer.
42649 AND A Set the flags.
42650 JR NZ,HandlerOrchid_StoreTimer Jump to HandlerOrchid_StoreTimer if the start-of-turn delay is still running.
42652 DEC HL Decrease the timer by one.
This entry point is used by the routine at GrowOrchid.
HandlerOrchid_StoreTimer 42653 LD (IX+6),L Store the timer of the orchid.
42656 LD (IX+7),H
42659 CALL TestOrchidTouched Test whether the player is touching the orchid.
This entry point is used by the routines at ChangeOrchidStage and GrowOrchid.
HandlerOrchid_Draw 42662 CALL DisplayEntity Display the orchid.
Colour the stem of the orchid.
42665 LD L,(IX+3) Fetch the X and Y position of the orchid.
42668 LD H,(IX+4)
42671 CALL AttributeAddress Find the attribute address of the orchid.
42674 LD C,1 Set the number of rows in C to 1.
42676 LD D,68 Set the colour in D to 68 (bright green).
42678 LD B,2 Set the number of columns in B to 2.
42680 CALL HandlerOrchid_Colour Colour the stem of the orchid.
Colour the flower if the orchid has started to grow.
42683 LD A,(IX+0) Fetch the sprite ID of the orchid.
42686 AND %00000111 Keep only the stage of growth (bits 0-2).
42688 RET Z Return if the orchid is hidden.
42689 LD C,1 Set the number of rows in C to 1.
42691 LD D,(IX+5) Fetch the colour of the orchid into D.
42694 LD B,2 Set the number of columns in B to 2.
The orchid is one column wider when it is not fully grown.
HandlerOrchid_Colour 42696 LD A,(IX+0) Fetch the sprite ID of the orchid.
42699 CPL Flip the bits, so that a fully grown orchid gives zero.
42700 AND %00000111 Keep only bits 0-2.
42702 JR NZ,HandlerOrchid_ColourRows Jump to HandlerOrchid_ColourRows if the orchid is not fully grown.
42704 INC B Add one to the number of columns.
HandlerOrchid_ColourRows 42705 JP ColourRows Jump to ColourRows to colour the rows.
Prev: 42621 Up: Map Next: 42708