Prev: 38554 Up: Map Next: 38756
38592: Update states of stalactites (level 2)
Used by the routine at 38009.
38592 LD IX,44305 Load IX with address of complex state data for first of seven falling stalactites (level 2)
38596 LD A,(IX+8) If current entity class is not 34 (stalactite, level 2)...
38599 CP 34 ...
38601 RET NZ ...then return
38602 LD A,(IX+12) If velocity factor of stalactite is not zero (i.e. it is falling)...
38605 OR A ...
38606 JR NZ,38635 ...then skip ahead to 38635
38608 LD A,40 Load A with a random number, 0-39...
38610 CALL 54222 ...
38613 OR A ...and if this is not zero (39 in 40 chance)...
38614 JP NZ,38748 ...then advance IX to next entry in complex state data and loop back to 38596
38617 CALL 38756 Move stalactite down one character and load A with new top y-coordinate
38620 LD A,(IX+4) Load A with top y-coordinate of stalactite (see trivia)
38623 CP 101 If new top y-coordinate is not 101
38625 JP NZ,38748 ...then advance IX to next entry in complex state data and loop back to 38596
38628 LD (IX+12),1 Set stalactite's velocity factor to 1
38632 JP 38748 Advance IX to next entry in complex state data and loop back to 38596
38635 CP 1 If velocity factor is not 1...
38637 JR NZ,38707 ...then check for collision with Berk killing him if so, ensure stalactite is falling and update its vertical position (38707)
38639 LD E,(IX+5) Load E with x-coordinate of left of stalactite
38642 LD IY,(34240) Load IY with address of current level's complex state data for Berk
38646 LD A,(IY+0) If Berk's current room is not the same as the stalactite's...
38649 CP (IX+0) ...
38652 JR NZ,38679 ...then skip ahead to 38679 to check Drutt's position
38654 LD A,(IY+11) If Berk's walking-left flag is set...
38657 BIT 1,A ...
38659 JR NZ,38673 ...then skip ahead to 38673
38661 BIT 0,A If Berk's walking-right flag is not set...
38663 JR Z,38679 ...then skip ahead to 38679 to check Drutt's position
38665 LD A,(IY+7) If Berk's right-side x-coordinate is the same as the stalactite's left-side x-coordinate...
38668 CP E ...
38669 JR Z,38707 ...then check for collision with Berk killing him if so, ensure stalactite is falling and update its vertical position (38707)
38671 JR 38679 Skip ahead to 38679 to check Drutt's position
38673 LD A,(IY+5) If Berk's left-side x-coordinate is the same as the stalactite's left-side x-coordinate...
38676 CP E ...
38677 JR Z,38707 ...then check for collision with Berk killing him if so, ensure stalactite is falling and update its vertical position (38707)
38679 LD IY,44396 Load IY with address of complex state data for Drutt (level 2)
38683 LD A,(IY+0) If Drutt's current room is not the same as the stalactite's...
38686 CP (IX+0) ...
38689 JR NZ,38699 ...then skip ahead to 38699
38691 LD A,(IY+5) If Drutt's left-side x-coordinate is the same as the stalactite's left-side x-coordinate...
38694 CP (IX+5) ...
38697 JR Z,38707 ...then check for collision with Berk killing him if so, ensure stalactite is falling and update its vertical position (38707)
38699 LD A,200 Load A with a random number, 0-199...
38701 CALL 54222 ...
38704 OR A ...and if this is not zero (199 in 200 chance)...
38705 JR NZ,38748 ...then advance IX to next entry in complex state data and loop back to 38596
38707 CALL 54768 Check entity at IX for collision with another entity at same depth whose interaction-(11,6) flag is set...
38710 CP 31 ...and if collision was not with entity of class 31 (Berk)...
38712 JR NZ,38718 ...then skip ahead to 38718 (start stalactite falling)
38714 CALL 53667 Set Berk-has-been-killed flag
38717 RET Return
38718 LD B,(IX+12) Load B with stalactite's velocity factor...
38721 CALL 38756 ...and move stalactite down by this many characters...
38724 DJNZ 38721 ...
38726 INC (IX+12) Increase stalactite's velocity factor by one
38729 LD A,(IX+4) If y-coordinate of top of stalactite is less than 150...
38732 CP 150 ...
38734 JR C,38748 ...then advance IX to next entry in complex state data and loop back to 38596
38736 LD (IX+4),98 Move stalactite back to top of room...
38740 LD (IX+6),100 ...
38744 LD (IX+12),0 ...and set its velocity factor to zero
38748 LD BC,13 Advance IX by 13 bytes to move to next complex state data entry...
38751 ADD IX,BC ...
38753 JP 38596 ...and loop back to 38596 for next entity
Prev: 38554 Up: Map Next: 38756