Prev: 49490 Up: Map Next: 49564
49508: Update Ball
The routine for objects of type 128 to 131, the balls. A ball changes through four frames and then turns into a creature (type 112 to 127) or, at random, into a type 64 to 79 object. The kind is that of the monster that is nearest to the ball.
Animate the ball, and play its sound if it is in the view.
UpdateBall 49508 BIT 1,(IX+7) Test whether the ball has been drawn in the view.
49512 RES 1,(IX+7) Clear the flag.
49516 CALL NZ,PlayObjectSound Play the sound of the ball if it was drawn.
49519 INC (IX+0) Move on to the next frame of animation.
49522 LD A,(IX+0) Fetch the type of the ball, and return unless the frame number has wrapped round to zero.
49525 AND 3
49527 RET NZ
Become a type 64 to 79 object, or a creature.
49528 LD A,(48042) Jump to UpdateBall_Creature if a random number is less than 128.
49531 CP 128
49533 JR C,UpdateBall_Creature
49535 CALL FindNearestMonster Find the nearest living monster.
49538 ADD A,A Multiply its number by four to get its kind.
49539 ADD A,A
49540 OR %01000000 Make it a type 64 to 79 object.
49542 LD (IX+0),A Set the new type.
49545 CP 76 Return unless the type is 76.
49547 RET NZ
49548 LD (IX+9),24 Set the depth of the object to 24 (type 76 only).
49552 RET Return.
Turn the ball into a creature of the nearest monster's kind.
UpdateBall_Creature 49553 CALL FindNearestMonster Find the nearest living monster.
49556 ADD A,A Multiply its number by four to get its kind.
49557 ADD A,A
49558 OR %01110000 Make it a creature (112 to 127).
49560 LD (IX+0),A Set the new type.
49563 RET Return.
Prev: 49490 Up: Map Next: 49564