Prev: 60618 Up: Map Next: 60810
60718: Handle Rock Formation
Handler for the object type 136 the rock formation that hangs from the ceiling of the cave of a guardian (see Place_Rock_Formation).
The formation is made from ten of the rocks of the sprite at Sprite_Debris_1, in four rows of four, three, two and one rocks. They are drawn once, when bit 0 of the redraw flags is set. The rocks of a row are 8 pixels apart, and the rows are 24 pixels apart: the y positions of the rows are 48 72 96 and 120 and the x positions of the first rocks are 120 122 126 and 130. The bit is set again before each rock is drawn so that nothing is erased.
After that the area that the formation covers is coloured on every call, with five cells in each of ten rows set to the attribute 70 (yellow).
An object touches the formation according to Check_Rock_Formation_Contact.
Input
IX Object record of the rock formation
Handle_Rock_Formation 60718 BIT 0,(IX+15) Jump to Handle_Rock_Formation_Colour to colour the formation if it has been drawn already.
60722 JR Z,Handle_Rock_Formation_Colour
60724 LD (IX+1),120 Set the x position of the first rock to 120.
60728 LD (IX+3),48 Set the y position of the first row to 48.
60732 LD C,4 Set the number of rocks in the first row (and of rows) to four.
60734 LD (IX+5),70 Set the attribute of the rocks to 70 (yellow).
Handle_Rock_Formation_Row 60738 LD B,C Set the number of rocks in the row.
Handle_Rock_Formation_Rock 60739 PUSH BC Stash the counters.
60740 CALL Update_Object_Sprite Draw the rock.
60743 SET 0,(IX+15) Set bit 0 of the redraw flags, so that the next rock does not erase the last one.
60747 LD A,(IX+1) Fetch the x position.
60750 ADD A,8 Move on to the next rock.
60752 LD (IX+1),A Set the x position.
60755 POP BC Restore the counters.
60756 DJNZ Handle_Rock_Formation_Rock Loop back until the row has been drawn.
60758 LD A,C Fetch the number of rows left.
60759 SLA A Double it.
60761 DEC A Subtract one.
60762 SLA A Double it again.
60764 NEG Negate it.
60766 ADD A,136 Add 136 to make the x position of the first rock of the next row.
60768 LD (IX+1),A Set the x position.
60771 LD A,(IX+3) Fetch the y position.
60774 ADD A,24 Move on to the next row.
60776 LD (IX+3),A Set the y position.
60779 DEC C Jump back to Handle_Rock_Formation_Row until all the rows have been drawn.
60780 JR NZ,Handle_Rock_Formation_Row
60782 RES 0,(IX+15) Reset bit 0 of the redraw flags.
60786 RET Return.
Handle_Rock_Formation_Colour 60787 LD HL,12408 Set the x position 120 in L and the y position 48 in H.
60790 CALL AttributeAddress Get the attribute address of the cell.
60793 LD DE,27 Set the offset to the start of the next row (the row is 32 cells long and five have been set).
60796 LD C,10 Set the number of rows to colour to ten.
Handle_Rock_Formation_Colour_Row 60798 LD B,5 Set the number of cells in each row to five.
Handle_Rock_Formation_Colour_Cell 60800 LD (HL),70 Set the attribute of the cell to 70 (yellow).
60802 INC L Move on to the next cell.
60803 DJNZ Handle_Rock_Formation_Colour_Cell Loop back until the row has been coloured.
60805 ADD HL,DE Move on to the next row.
60806 DEC C Jump back to Handle_Rock_Formation_Colour_Row until all the rows have been coloured.
60807 JR NZ,Handle_Rock_Formation_Colour_Row
60809 RET Return.
Prev: 60618 Up: Map Next: 60810