Prev: 39174 Up: Map Next: 39316
39228: Handler: Bouncing Wheel
Steer the Bouncing Wheel toward the scroll position and bounce it at the play-area edges.
Input
IX Actor slot
Handler_BouncingWheel 39228 LD H,(IX+3) Fetch the high byte of the world X.
39231 LD L,(IX+2) Fetch the low byte of the world X.
39234 LD DE,(24698) Fetch Jetman_Position.
39238 AND A Subtract the scroll position.
39239 SBC HL,DE
39241 LD C,0 C=0.
Leave the speed unchanged if the wheel is on this screen or just off its left edge.
39243 LD A,H Fetch the high byte of the gap.
39244 AND %00011111 Keep only bits 0-4.
39246 JR Z,Handler_BouncingWheel_AddY Jump to Handler_BouncingWheel_AddY if the alien is on this screen.
39248 OR %11100000 Set bits 5-7.
39250 CPL Flip the bits.
39251 AND A Jump to Handler_BouncingWheel_AddY if the result is zero.
39252 JR Z,Handler_BouncingWheel_AddY
39254 BIT 4,H Test bit 4 of the gap.
48 is a signed +48 rightward speed; 208 is signed -48 leftward.
39256 LD A,48 A=48.
39258 JR NZ,Handler_BouncingWheel_WriteSpeed Jump to Handler_BouncingWheel_WriteSpeed if the alien is left of the scroll.
39260 LD A,208 A=208.
Handler_BouncingWheel_WriteSpeed 39262 LD (IX+5),A Write the speed to *IX+5.
Move the wheel vertically, bouncing it off the play-area edges.
Handler_BouncingWheel_AddY 39265 LD A,(IX+4) Fetch the alien's Y position.
39268 ADD A,(IX+6) Add the vertical thrust.
39271 CP 56 Jump to Handler_BouncingWheel_ThrustDown if the alien is above the play area.
39273 JR C,Handler_BouncingWheel_ThrustDown
39275 CP 176 Jump to Handler_BouncingWheel_ThrustUp if the alien has hit the ground line.
39277 JR NC,Handler_BouncingWheel_ThrustUp
39279 LD (IX+4),A Write the Y position back.
Step the animation timer and pick the animation frame.
Handler_BouncingWheel_TickAnimation 39282 INC (IX+17) Increase the animation timer.
39285 LD A,(IX+17) Fetch the animation timer.
39288 CP 6 Jump to Handler_BouncingWheel_WriteFrame if it is still below 6.
39290 JR C,Handler_BouncingWheel_WriteFrame
39292 XOR A Write 0 to the animation timer.
39293 LD (IX+17),A
Sprite IDs begin at 168 ("Bouncing Wheel: Frame 1").
Handler_BouncingWheel_WriteFrame 39296 ADD A,168 Add 168 for these frames.
39298 LD (IX+0),A Write it to the actor type.
39301 JP PlaceSpawnedAlien_Age Jump to PlaceSpawnedAlien_Age.
Bounce off the top by thrusting down, or off the ground by thrusting up.
Handler_BouncingWheel_ThrustDown 39304 LD (IX+6),3 Write 3 to the vertical thrust.
39308 JR Handler_BouncingWheel_TickAnimation Jump to Handler_BouncingWheel_TickAnimation.
Handler_BouncingWheel_ThrustUp 39310 LD (IX+6),253 Write 253 to the vertical thrust.
39314 JR Handler_BouncingWheel_TickAnimation Jump to Handler_BouncingWheel_TickAnimation.
Prev: 39174 Up: Map Next: 39316