Prev: 993C Up: Map Next: 9A2F
9994: 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 9994 LD A,(IX+$12) Jump to Handler_Spinner_WobbleX if *IX+12 is positive.
9997 AND A
9998 JP P,Handler_Spinner_WobbleX
999B LD A,$02 A=02.
999D JR Handler_Spinner_AddWobbleX Jump to Handler_Spinner_AddWobbleX.
Handler_Spinner_WobbleX 999F LD A,$FE A=FE.
Handler_Spinner_AddWobbleX 99A1 ADD A,(IX+$13) Add it to *IX+13.
99A4 LD (IX+$13),A Write the new value back.
99A7 ADD A,(IX+$12) Add it to *IX+12.
99AA LD (IX+$12),A Write the new value back.
Wobble the vertical speed offsets in the same way.
99AD LD A,(IX+$14) Jump to Handler_Spinner_WobbleY if *IX+14 is positive.
99B0 AND A
99B1 JP P,Handler_Spinner_WobbleY
99B4 LD A,$02 A=02.
99B6 JR Handler_Spinner_AddWobbleY Jump to Handler_Spinner_AddWobbleY.
Handler_Spinner_WobbleY 99B8 LD A,$FE A=FE.
Handler_Spinner_AddWobbleY 99BA ADD A,(IX+$15) Add it to *IX+15.
99BD LD (IX+$15),A Write the new value back.
99C0 ADD A,(IX+$14) Add it to *IX+14.
99C3 LD (IX+$14),A Write the new value back.
Move the spinner vertically, bouncing it off the play-area edges.
99C6 ADD A,(IX+$06) Add the vertical thrust.
99C9 SRA A Divide the result by 10.
99CB SRA A
99CD SRA A
99CF SRA A
99D1 ADD A,(IX+$04) Add it to the alien's Y position.
99D4 CP $3A Jump to Handler_Spinner_ThrustDown if the alien is above the play area.
99D6 JR C,Handler_Spinner_ThrustDown
99D8 CP $B0 Jump to Handler_Spinner_ThrustUp if the alien has hit the ground line.
99DA JR NC,Handler_Spinner_ThrustUp
99DC LD (IX+$04),A Write the Y position back.
Work out the extra horizontal speed from the scroll position.
Handler_Spinner_CompareScroll 99DF LD H,(IX+$03) Fetch the high byte of the world X.
99E2 LD L,(IX+$02) Fetch the low byte of the world X.
99E5 LD DE,($607A) Fetch Jetman_Position.
99E9 AND A Subtract the scroll position.
99EA SBC HL,DE
99EC LD C,$00 C=00.
Leave the extra speed unchanged if the spinner is on this screen or just off its left edge.
99EE LD A,H Fetch the high byte of the gap.
99EF AND %00011111 Keep only bits 0-4.
99F1 JR Z,Handler_Spinner_MergeExtraSpeed Jump to Handler_Spinner_MergeExtraSpeed if the alien is on this screen.
99F3 OR %11100000 Set bits 5-7.
99F5 CPL Flip the bits.
99F6 AND A Jump to Handler_Spinner_MergeExtraSpeed if the result is zero.
99F7 JR Z,Handler_Spinner_MergeExtraSpeed
99F9 BIT 4,H Test bit 4 of the gap.
20 is a signed +20 rightward extra speed; E0 is signed -20 leftward.
99FB LD A,$20 A=20.
99FD JR NZ,Handler_Spinner_WriteExtraX Jump to Handler_Spinner_WriteExtraX if the alien is left of the scroll.
99FF LD A,$E0 A=E0.
Handler_Spinner_WriteExtraX 9A01 LD (IX+$16),A Write it to *IX+16.
Handler_Spinner_MergeExtraSpeed 9A04 LD A,(IX+$16) Fetch *IX+16.
9A07 ADD A,(IX+$12) Add *IX+12.
9A0A LD (IX+$05),A Write the result to the horizontal speed.
Step the animation timer and pick the animation frame.
9A0D INC (IX+$11) Increase the animation timer.
9A10 LD A,(IX+$11) Fetch the animation timer.
9A13 CP $06 Jump to Handler_Spinner_WriteFrame if it is still below 06.
9A15 JR C,Handler_Spinner_WriteFrame
9A17 XOR A Write 00 to the animation timer.
9A18 LD (IX+$11),A
Sprite IDs begin at B0 ("Spinner: Frame 1").
Handler_Spinner_WriteFrame 9A1B ADD A,$B0 Add B0 for these frames.
9A1D LD (IX+$00),A Write it to the actor type.
9A20 JP PlaceSpawnedAlien_Age Jump to PlaceSpawnedAlien_Age.
20 is a signed +20 downward thrust. E0 is signed -20 upward.
Handler_Spinner_ThrustDown 9A23 LD (IX+$06),$20 Write 20 to the vertical thrust.
9A27 JR Handler_Spinner_CompareScroll Jump to Handler_Spinner_CompareScroll.
Handler_Spinner_ThrustUp 9A29 LD (IX+$06),$E0 Write E0 to the vertical thrust.
9A2D JR Handler_Spinner_CompareScroll Jump to Handler_Spinner_CompareScroll.
Prev: 993C Up: Map Next: 9A2F