Prev: A67D Up: Map Next: A6D4
A680: Handler: Orchid
Handles an orchid (sprite IDs 48 to 4F). 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+06 and IX+07 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 A680 CALL StoreEntity Remember the previous position of the orchid.
A683 LD L,(IX+$06) Fetch the timer of the orchid.
A686 LD H,(IX+$07)
A689 LD A,H Jump to ChangeOrchidStage to change the stage of the orchid if the timer is zero.
A68A OR L
A68B JR Z,ChangeOrchidStage
Count down the timer if the player is alive and the game delay is over.
A68D LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
A690 SUB $10 Subtract 10 (the first Sabreman sprite ID).
A692 CP $20 Jump to HandlerOrchid_StoreTimer if the player is not alive.
A694 JR NC,HandlerOrchid_StoreTimer
A696 LD A,($96B5) Fetch the start-of-turn delay from GameDelayTimer.
A699 AND A Set the flags.
A69A JR NZ,HandlerOrchid_StoreTimer Jump to HandlerOrchid_StoreTimer if the start-of-turn delay is still running.
A69C DEC HL Decrease the timer by one.
This entry point is used by the routine at GrowOrchid.
HandlerOrchid_StoreTimer A69D LD (IX+$06),L Store the timer of the orchid.
A6A0 LD (IX+$07),H
A6A3 CALL TestOrchidTouched Test whether the player is touching the orchid.
This entry point is used by the routines at ChangeOrchidStage and GrowOrchid.
HandlerOrchid_Draw A6A6 CALL DisplayEntity Display the orchid.
Colour the stem of the orchid.
A6A9 LD L,(IX+$03) Fetch the X and Y position of the orchid.
A6AC LD H,(IX+$04)
A6AF CALL AttributeAddress Find the attribute address of the orchid.
A6B2 LD C,$01 Set the number of rows in C to 01.
A6B4 LD D,$44 Set the colour in D to 44 (bright green).
A6B6 LD B,$02 Set the number of columns in B to 02.
A6B8 CALL HandlerOrchid_Colour Colour the stem of the orchid.
Colour the flower if the orchid has started to grow.
A6BB LD A,(IX+$00) Fetch the sprite ID of the orchid.
A6BE AND %00000111 Keep only the stage of growth (bits 0-2).
A6C0 RET Z Return if the orchid is hidden.
A6C1 LD C,$01 Set the number of rows in C to 01.
A6C3 LD D,(IX+$05) Fetch the colour of the orchid into D.
A6C6 LD B,$02 Set the number of columns in B to 02.
The orchid is one column wider when it is not fully grown.
HandlerOrchid_Colour A6C8 LD A,(IX+$00) Fetch the sprite ID of the orchid.
A6CB CPL Flip the bits, so that a fully grown orchid gives zero.
A6CC AND %00000111 Keep only bits 0-2.
A6CE JR NZ,HandlerOrchid_ColourRows Jump to HandlerOrchid_ColourRows if the orchid is not fully grown.
A6D0 INC B Add one to the number of columns.
HandlerOrchid_ColourRows A6D1 JP ColourRows Jump to ColourRows to colour the rows.
Prev: A67D Up: Map Next: A6D4