Prev: DF42 Up: Map Next: DF98
DF58: Spawn Falling Stalactite
Used by the routine at Run_Game.
Lets a stalactite fall from the ceiling of a cave room every now and then. Nothing happens in a special room, in a room that has no ceiling, or while the stalactite record at Falling_Stalactite_Record is in use. The stalactite is only made when the low four bits of the tick counter and the frame counter, combined, are zero.
The record is a copy of the record of Sabreman, so the stalactite falls from the same x position, with the type 50 the y position 40 the attribute 46 (yellow) and a y velocity of 10 (see Handle_Falling_Stalactite).
Spawn_Falling_Stalactite DF58 LD A,(IX+$04) Fetch the room y of the object.
DF5B CP $10 Return if it is a special room.
DF5D RET C
DF5E LD A,($AAAC) Fetch the flags of the room that Sabreman is in.
DF61 AND %00000001 Keep only bit 0 (the ceiling).
DF63 RET Z Return if the room has no ceiling.
DF64 LD A,($8F3A) Fetch the type of the stalactite record.
DF67 AND A Return if the record is already in use.
DF68 RET NZ
DF69 LD A,($8ED6) Fetch the tick counter and keep it in B.
DF6C LD B,A
DF6D LD A,($5C78) Fetch the low byte of the frame counter.
DF70 OR B Combine it with the tick counter.
DF71 AND %00001111 Keep only the low four bits.
DF73 RET NZ Return unless they are zero.
DF74 LD HL,$8F1A Point HL at Sabreman_Record.
DF77 LD DE,$8F3A Point DE at Falling_Stalactite_Record.
DF7A LD BC,$0010 Set a counter of 10 bytes.
DF7D PUSH DE Stash the address of the stalactite record.
DF7E LDIR Copy the record of Sabreman to the stalactite record.
DF80 POP HL Restore the address of the stalactite record to HL.
DF81 LD (HL),$50 Set the type to 50.
DF83 INC HL Move to the y position.
DF84 INC HL
DF85 INC HL
DF86 LD (HL),$40 Set the y position to 40.
DF88 INC HL Move to the attribute.
DF89 INC HL
DF8A LD (HL),$46 Set the attribute to 46 (yellow).
DF8C INC HL Move to the y velocity.
DF8D INC HL
DF8E INC HL
DF8F INC HL
DF90 LD (HL),$10 Set the y velocity to 10.
DF92 LD A,$01 Set the redraw flags of the stalactite to 01 so that it is drawn without being erased first.
DF94 LD ($8F49),A
DF97 RET Return.
Prev: DF42 Up: Map Next: DF98