Prev: 34859 Up: Map Next: 35124
35085: Set Random Speed
Used by the routines at FireShot, SetFallingSpeed and ReverseVerticalSpeed.
Gives an object a random speed. The object is removed if it ends up with no speed at all.
Input
IY Address of the object
SetRandomSpeed 35085 LD A,(39884) Fetch the second byte of the random seed.
35088 LD B,A Copy it into B.
35089 AND %00000110 Keep two bits.
35091 NEG Negate them.
35093 LD C,A Copy the result into C.
35094 LD (IY+9),A Set the vertical speed of the object.
35097 LD A,B Fetch the random value again.
35098 RLCA Rotate bits 5 to 3 into the bottom three bits.
35099 RLCA
35100 RLCA
35101 AND %00000111 Keep them.
35103 CP 7 Jump to SetRandomSpeed_Remove if the value is 7.
35105 JP Z,SetRandomSpeed_Remove
35108 SUB 3 Subtract three...
35110 ADD A,A ...and double it to get a horizontal speed.
35111 LD B,A
35112 LD (IY+7),A Set the horizontal speed of the object.
35115 OR C Combine the speeds.
35116 JR NZ,FireShot_Sound Jump to FireShot_Sound if the object has any speed.
This entry point is used by the routine at SetFallingSpeed.
SetRandomSpeed_Remove 35118 LD (IY+0),255 Free the slot of the object.
35122 JR FireShot_Sound Jump to FireShot_Sound.
Prev: 34859 Up: Map Next: 35124