Prev: ECCA Up: Map Next: ED8A
ED2E: Handle Rock Formation
Handler for the object type 88 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 08 pixels apart, and the rows are 18 pixels apart: the y positions of the rows are 30 48 60 and 78 and the x positions of the first rocks are 78 7A 7E and 82. 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 46 (yellow).
An object touches the formation according to Check_Rock_Formation_Contact.
Input
IX Object record of the rock formation
Handle_Rock_Formation ED2E BIT 0,(IX+$0F) Jump to Handle_Rock_Formation_Colour to colour the formation if it has been drawn already.
ED32 JR Z,Handle_Rock_Formation_Colour
ED34 LD (IX+$01),$78 Set the x position of the first rock to 78.
ED38 LD (IX+$03),$30 Set the y position of the first row to 30.
ED3C LD C,$04 Set the number of rocks in the first row (and of rows) to four.
ED3E LD (IX+$05),$46 Set the attribute of the rocks to 46 (yellow).
Handle_Rock_Formation_Row ED42 LD B,C Set the number of rocks in the row.
Handle_Rock_Formation_Rock ED43 PUSH BC Stash the counters.
ED44 CALL Update_Object_Sprite Draw the rock.
ED47 SET 0,(IX+$0F) Set bit 0 of the redraw flags, so that the next rock does not erase the last one.
ED4B LD A,(IX+$01) Fetch the x position.
ED4E ADD A,$08 Move on to the next rock.
ED50 LD (IX+$01),A Set the x position.
ED53 POP BC Restore the counters.
ED54 DJNZ Handle_Rock_Formation_Rock Loop back until the row has been drawn.
ED56 LD A,C Fetch the number of rows left.
ED57 SLA A Double it.
ED59 DEC A Subtract one.
ED5A SLA A Double it again.
ED5C NEG Negate it.
ED5E ADD A,$88 Add 88 to make the x position of the first rock of the next row.
ED60 LD (IX+$01),A Set the x position.
ED63 LD A,(IX+$03) Fetch the y position.
ED66 ADD A,$18 Move on to the next row.
ED68 LD (IX+$03),A Set the y position.
ED6B DEC C Jump back to Handle_Rock_Formation_Row until all the rows have been drawn.
ED6C JR NZ,Handle_Rock_Formation_Row
ED6E RES 0,(IX+$0F) Reset bit 0 of the redraw flags.
ED72 RET Return.
Handle_Rock_Formation_Colour ED73 LD HL,$3078 Set the x position 78 in L and the y position 30 in H.
ED76 CALL AttributeAddress Get the attribute address of the cell.
ED79 LD DE,$001B Set the offset to the start of the next row (the row is 20 cells long and five have been set).
ED7C LD C,$0A Set the number of rows to colour to ten.
Handle_Rock_Formation_Colour_Row ED7E LD B,$05 Set the number of cells in each row to five.
Handle_Rock_Formation_Colour_Cell ED80 LD (HL),$46 Set the attribute of the cell to 46 (yellow).
ED82 INC L Move on to the next cell.
ED83 DJNZ Handle_Rock_Formation_Colour_Cell Loop back until the row has been coloured.
ED85 ADD HL,DE Move on to the next row.
ED86 DEC C Jump back to Handle_Rock_Formation_Colour_Row until all the rows have been coloured.
ED87 JR NZ,Handle_Rock_Formation_Colour_Row
ED89 RET Return.
Prev: ECCA Up: Map Next: ED8A