Prev: 39228 Up: Map Next: 39471
39316: Handler: Spinner
Wobble the Spinner's X and Y speed offsets, steer it toward the scroll position and bounce it at the play-area edges.
Input
IX Actor slot
Handler_Spinner 39316 LD A,(IX+18) Jump to Handler_Spinner_WobbleX if *IX+18 is positive.
39319 AND A
39320 JP P,Handler_Spinner_WobbleX
39323 LD A,2 A=2.
39325 JR Handler_Spinner_AddWobbleX Jump to Handler_Spinner_AddWobbleX.
Handler_Spinner_WobbleX 39327 LD A,254 A=254.
Handler_Spinner_AddWobbleX 39329 ADD A,(IX+19) Add it to *IX+19.
39332 LD (IX+19),A Write the new value back.
39335 ADD A,(IX+18) Add it to *IX+18.
39338 LD (IX+18),A Write the new value back.
Wobble the vertical speed offsets in the same way.
39341 LD A,(IX+20) Jump to Handler_Spinner_WobbleY if *IX+20 is positive.
39344 AND A
39345 JP P,Handler_Spinner_WobbleY
39348 LD A,2 A=2.
39350 JR Handler_Spinner_AddWobbleY Jump to Handler_Spinner_AddWobbleY.
Handler_Spinner_WobbleY 39352 LD A,254 A=254.
Handler_Spinner_AddWobbleY 39354 ADD A,(IX+21) Add it to *IX+21.
39357 LD (IX+21),A Write the new value back.
39360 ADD A,(IX+20) Add it to *IX+20.
39363 LD (IX+20),A Write the new value back.
Move the spinner vertically, bouncing it off the play-area edges.
39366 ADD A,(IX+6) Add the vertical thrust.
39369 SRA A Divide the result by 16.
39371 SRA A
39373 SRA A
39375 SRA A
39377 ADD A,(IX+4) Add it to the alien's Y position.
39380 CP 58 Jump to Handler_Spinner_ThrustDown if the alien is above the play area.
39382 JR C,Handler_Spinner_ThrustDown
39384 CP 176 Jump to Handler_Spinner_ThrustUp if the alien has hit the ground line.
39386 JR NC,Handler_Spinner_ThrustUp
39388 LD (IX+4),A Write the Y position back.
Work out the extra horizontal speed from the scroll position.
Handler_Spinner_CompareScroll 39391 LD H,(IX+3) Fetch the high byte of the world X.
39394 LD L,(IX+2) Fetch the low byte of the world X.
39397 LD DE,(24698) Fetch Jetman_Position.
39401 AND A Subtract the scroll position.
39402 SBC HL,DE
39404 LD C,0 C=0.
Leave the extra speed unchanged if the spinner is on this screen or just off its left edge.
39406 LD A,H Fetch the high byte of the gap.
39407 AND %00011111 Keep only bits 0-4.
39409 JR Z,Handler_Spinner_MergeExtraSpeed Jump to Handler_Spinner_MergeExtraSpeed if the alien is on this screen.
39411 OR %11100000 Set bits 5-7.
39413 CPL Flip the bits.
39414 AND A Jump to Handler_Spinner_MergeExtraSpeed if the result is zero.
39415 JR Z,Handler_Spinner_MergeExtraSpeed
39417 BIT 4,H Test bit 4 of the gap.
32 is a signed +32 rightward extra speed; 224 is signed -32 leftward.
39419 LD A,32 A=32.
39421 JR NZ,Handler_Spinner_WriteExtraX Jump to Handler_Spinner_WriteExtraX if the alien is left of the scroll.
39423 LD A,224 A=224.
Handler_Spinner_WriteExtraX 39425 LD (IX+22),A Write it to *IX+22.
Handler_Spinner_MergeExtraSpeed 39428 LD A,(IX+22) Fetch *IX+22.
39431 ADD A,(IX+18) Add *IX+18.
39434 LD (IX+5),A Write the result to the horizontal speed.
Step the animation timer and pick the animation frame.
39437 INC (IX+17) Increase the animation timer.
39440 LD A,(IX+17) Fetch the animation timer.
39443 CP 6 Jump to Handler_Spinner_WriteFrame if it is still below 6.
39445 JR C,Handler_Spinner_WriteFrame
39447 XOR A Write 0 to the animation timer.
39448 LD (IX+17),A
Sprite IDs begin at 176 ("Spinner: Frame 1").
Handler_Spinner_WriteFrame 39451 ADD A,176 Add 176 for these frames.
39453 LD (IX+0),A Write it to the actor type.
39456 JP PlaceSpawnedAlien_Age Jump to PlaceSpawnedAlien_Age.
32 is a signed +32 downward thrust. 224 is signed -32 upward.
Handler_Spinner_ThrustDown 39459 LD (IX+6),32 Write 32 to the vertical thrust.
39463 JR Handler_Spinner_CompareScroll Jump to Handler_Spinner_CompareScroll.
Handler_Spinner_ThrustUp 39465 LD (IX+6),224 Write 224 to the vertical thrust.
39469 JR Handler_Spinner_CompareScroll Jump to Handler_Spinner_CompareScroll.
Prev: 39228 Up: Map Next: 39471